<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Sdaniel8</id>
	<title>Expertiza_Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Sdaniel8"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Sdaniel8"/>
	<updated>2026-05-08T14:14:18Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=160617</id>
		<title>CSC/ECE 517 Fall 2024 - E2451. Reimplement feedback response map.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=160617"/>
		<updated>2024-12-04T04:07:31Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2451: Reimplement feedback response map'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions, among other tasks. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
=== Project Overview ===&lt;br /&gt;
&lt;br /&gt;
The goal of this project is to refactor the feedback_response_map.rb file from the Expertiza repository and integrate it into the reimplementation-back-end repository. Within Expertiza, when a user submits a review, an instance of the Response class is created, associated with a ResponseMap. Each ResponseMap links a reviewer (reviewer_id), reviewee (reviewee_id), and the reviewed item (reviewed_object_id). FeedbackResponseMap, a subclass of ResponseMap, represents the feedback provided by a reviewee on the feedback received for their submission.&lt;br /&gt;
&lt;br /&gt;
This class has significant room for improvement, especially with respect to object-oriented principles. Refactoring feedback_response_map.rb will streamline functionality, enhance maintainability, and improve adherence to coding standards.&lt;br /&gt;
&lt;br /&gt;
=== Current Implementation ===&lt;br /&gt;
&lt;br /&gt;
The current feedback_response_map.rb in the Expertiza repository has several issues. It includes the following problems:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Poor adherence to SOLID and DRY principles&amp;lt;/b&amp;gt;: The current code structure introduces unnecessary repetition and complexity.&lt;br /&gt;
* &amp;lt;b&amp;gt;feedback_response_report Method Issues&amp;lt;/b&amp;gt;: This critical method is highly complex, relying on custom data structures and separate containers for each review round, resulting in a DRY violation.&lt;br /&gt;
* &amp;lt;b&amp;gt;Improper Responsibility Assignment&amp;lt;/b&amp;gt;: The email method does not belong within this class and would benefit from refactoring out into a separate class using the Visitor pattern. This pattern is suggested to streamline functionality, though alternative design patterns may be considered if more suitable.&lt;br /&gt;
* &amp;lt;b&amp;gt;Memory Inefficiencies&amp;lt;/b&amp;gt;: The method currently creates unnecessary memory through inefficient structures, including multiple separate arrays for different rounds of review, which could be simplified into a 2D array structure.&lt;br /&gt;
* &amp;lt;b&amp;gt;Code Smells&amp;lt;/b&amp;gt;: The code has redundant methods, unclear variable names, inefficient loops, and overly long method names.&lt;br /&gt;
&lt;br /&gt;
=== Objectives &amp;amp; Requirements ===&lt;br /&gt;
1. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Address the DRY violation by consolidating the containers for review rounds.&lt;br /&gt;
* Generalize the code to handle both cases—when rubrics vary by round and when they do not—without duplicating code.&lt;br /&gt;
* Introduce efficient data structures, like a 2D array, to replace multiple arrays and reduce memory usage.&lt;br /&gt;
&lt;br /&gt;
2. Separate Responsibilities Using Visitor Pattern (&amp;lt;i&amp;gt;stretch goal&amp;lt;/i&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
* Extract the email method using the Visitor pattern to modularize email functionality. Alternatively, select a design pattern better suited to organizing this method if available. Note that the email method is not properly used in its current location and is better suited to the Response class rather than ResponseMap.&lt;br /&gt;
&lt;br /&gt;
3. Eliminate Redundant Methods&lt;br /&gt;
&lt;br /&gt;
* Remove methods that do not serve a clear purpose and improve method naming for clarity.&lt;br /&gt;
* Aim to address any redundant meta-review functionality, as indicated by the professor's preference to remove these from response_map.rb.&lt;br /&gt;
&lt;br /&gt;
4. Refactor for Code Clarity and Efficiency&lt;br /&gt;
&lt;br /&gt;
* Improve variable names, reduce unnecessary loops, and replace long method names with concise, intuitive alternatives.&lt;br /&gt;
* Ensure that each method has a single, clearly defined purpose, improving code readability.&lt;br /&gt;
&lt;br /&gt;
5. Testing and Documentation&lt;br /&gt;
&lt;br /&gt;
* Write comprehensive tests for all newly implemented and modified methods to ensure reliability.&lt;br /&gt;
* Add detailed comments to facilitate code maintenance and understanding for future developers.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Design Principles ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Single Responsibility Principle (SRP)&amp;lt;/b&amp;gt;: Each method and class should have a single, well-defined purpose.&lt;br /&gt;
* &amp;lt;b&amp;gt;Don’t Repeat Yourself (DRY)&amp;lt;/b&amp;gt;: Eliminate redundancy by creating general solutions that handle multiple scenarios.&lt;br /&gt;
* &amp;lt;b&amp;gt;Ruby Readability Guidelines (Week 9 Notes)&amp;lt;/b&amp;gt;:&lt;br /&gt;
** Guideline: Variable names should be neither too short nor too long.&lt;br /&gt;
** Guideline: Names should not be redundant.&lt;br /&gt;
** Guideline: &amp;lt;b&amp;gt;A method should do only one thing and do it well.&amp;lt;/b&amp;gt;&lt;br /&gt;
* &amp;lt;b&amp;gt;Visitor Pattern&amp;lt;/b&amp;gt;: Utilize this pattern to separate emailing functionalities from the main class.&lt;br /&gt;
&lt;br /&gt;
=== Implementation Plan ===&lt;br /&gt;
&lt;br /&gt;
The refactoring will proceed as follows:&lt;br /&gt;
&lt;br /&gt;
1. Analyze and Refactor Current Code Structure&lt;br /&gt;
&lt;br /&gt;
* Review and understand the existing structure and dependencies within feedback_response_map.rb.&lt;br /&gt;
* Identify areas of redundancy, complexity, and inefficiency, particularly in feedback_response_report, to create a clear plan for refactoring.&lt;br /&gt;
* Try to reduce character count and improve readability with aliasing (this way we do not break any code that relies on being able to call specific methods).&lt;br /&gt;
&lt;br /&gt;
2. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Consolidate containers for each review round to address DRY violations. By using a single structure to store review data, we will eliminate hard-coded repetition.&lt;br /&gt;
* Generalize logic to accommodate both scenarios where rubrics vary by round and where they do not, without duplicating code paths.&lt;br /&gt;
* Replace inefficient structures, such as multiple arrays, with more flexible and memory-efficient options, like a 2D array or a hash, to reduce memory usage and improve scalability.&lt;br /&gt;
&lt;br /&gt;
3. Introduce Helper Methods for Reusable Logic (for feedback_response_report)&lt;br /&gt;
&lt;br /&gt;
* Extract frequently used or complex code blocks into helper methods, reducing the size of primary methods and enhancing reusability.&lt;br /&gt;
* Use helper methods for specific actions, like handling rounds or retrieving assignment data, to make the code cleaner and better organized.&lt;br /&gt;
* Emphasis on adhering to the guideline: A method should do only one thing and do it well.&lt;br /&gt;
&lt;br /&gt;
4. Research Future Refactoring for email Method&lt;br /&gt;
&lt;br /&gt;
* The email method is convoluted and the functionality should be refactored into a different class in the future.&lt;br /&gt;
* This is because this visitor pattern violation is present in many classes, and is beyond the scope of a one-class re-implementation.&lt;br /&gt;
&lt;br /&gt;
5. Improve Variable Naming and Structure&lt;br /&gt;
&lt;br /&gt;
* Replace ambiguous variable names with clearer alternatives that convey purpose, such as renaming @temp_review_responses and @temp_response_map_ids to more meaningful names.&lt;br /&gt;
* Simplify long method names to make the code more readable and approachable for new contributors.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Analyze and Refactor Current Code Structure&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before refactoring, the FeedbackResponseMap class contains 6 methods, with the majority of the code in self.feedback_response_report:&lt;br /&gt;
&lt;br /&gt;
[[File:FeedbackResponseMap_before.png |250px]]&lt;br /&gt;
&lt;br /&gt;
We aim to change that by splitting up this method into three helper methods, as seen in the following:&lt;br /&gt;
&lt;br /&gt;
[[File:FeedbackResponseMap_after.png |350px]]&lt;br /&gt;
&lt;br /&gt;
To go into more detail, here is the code for the feedback_response_report method, and how we intend to split it up:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_after_code1.png |600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_after_code2.png |600px]]&lt;br /&gt;
&lt;br /&gt;
The red section of code will be self.get_feedback_authors, yellow will be self.varying_rubrics_report, and green will be self.static_rubrics_report. Each separated group will be its own method, and self.varying_rubrics_report and self.static_rubrics_report (the yellow and green methods) will be returned at the end of the new feedback_response_report.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Refactor the feedback_response_report Method&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following are the original arrays used to statically represent the review rounds.&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-OriginalArrayRounds.png]]&lt;br /&gt;
&lt;br /&gt;
We can take these multiple arrays, and use dictionaries instead, where each round is called by its key value (integer value). &lt;br /&gt;
&lt;br /&gt;
[[File:E2451-UpdatedArraysMain.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
The code found in the feedback_response_report method that use the arrays were moved to the two helper methods, seen as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-UpdatedArrays1.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-UpdatedArrays2.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
Additionally, Rubocop was used to analyze the code and adhere to proper Ruby Guidelines. The command below was used to search for any code smells that we missed.&lt;br /&gt;
&lt;br /&gt;
   rubocop app/models/feedback_response_map.rb&lt;br /&gt;
&lt;br /&gt;
Originally, there were only three offenses, but this largely grew as we continued to refactor the code. All of the offenses can be seen below:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-Rubocop1.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-Rubocop2.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-Rubocop3.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-Rubocop4.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
All of these offenses were fixed. The following three offenses were the original ones. For the first and third offenses, the colon after the method headers were simply removed. For the second offense, the “return” keyword caused errors, thus, it was removed, because a ruby method will return  its last statement. The two other private methods containing “return” also had that keyword removed. &lt;br /&gt;
&lt;br /&gt;
[[File:E2451-RubocopOriginal.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
Lastly, commenting was added throughout the files, to improve readability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Introduce Helper Methods for Reusable Logic (for feedback_response_report)&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As planned in step 1, the feedback_response_report method was split up into 3 private helper methods: get_feedback_authors(id), varying_rubrics_report(review_responses, response_map_ids), and static_rubrics_report(review_responses, response_map_ids). One change we made that was different from the UML diagram was the addition of an id parameter in the get_feedback_authors method, in order to access id, since it was a parameter given to feedback_response_report. Each helper method was planned in order to stick to the guideline of “A method should do only one thing and do it well.”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Final UML for FeedbackResponseMap&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_FeedbackResponseMap_final.drawio.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Authors&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This image contains comments showing what the implementation looked like before:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_authors_before_1.png]]&lt;br /&gt;
&lt;br /&gt;
This image shows the construction of the private method we implemented to replace it, reducing complexity and improving readability in the process:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_authors_after_1.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Report&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This image contains comments showing what the implementation looked like before (this image is out of date, the return functionality for the varying rubric report rounds has since been generalized, please see the repo for the updated version) (The updated version does not include the old version comments, which is why this screenshot is used):&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_reports_before_1.png]]&lt;br /&gt;
&lt;br /&gt;
These images show the construction of the private methods we implemented to replace it, reducing complexity and improving readability in the process:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_reports_varying_1.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_report_static_1.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Notice that in both the original self.feedback_response_report method and the private methods, comments are included to explain each non-obvious step of the process.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Complexity changes&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Previously, Rubocop reported the following failures on behalf of the self.feedback_response_report method:&lt;br /&gt;
&lt;br /&gt;
  Metrics/PerceivedComplexity: Perceived complexity for feedback_response_report is too high. [14/8]&lt;br /&gt;
  Metrics/CyclomaticComplexity: Cyclomatic complexity for feedback_response_report is too high. [12/7]&lt;br /&gt;
  Metrics/AbcSize: Assignment Branch Condition size for feedback_response_report is too high. [&amp;lt;14, 46, 16&amp;gt; 50.68/20]&lt;br /&gt;
&lt;br /&gt;
Now, neither self.feedback_response_report nor any of its associated private methods trigger any of these Metric violations!&lt;br /&gt;
(Note that the email method does trigger a AbcSize violation when the protective comments are removed, but adjusting that method is beyond the scope of this project for reasons listed in the Implementation Plan)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Research Future Refactoring for email Method&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As discussed in the implementation plan, the email method was left as is. Any changes would require the addition of a new class and/or major refactoring for the functionality.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. Improve Variable Naming and Structure&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The two sets of variables discussed in the plan, @temp_response_map_ids and @temp_review_responses were modified as needed. First, the @temp_response_map_ids was moved to the helper methods varying_rubrics_report and static_rubrics_report, to be initialized, and changed to response_map_ids.&lt;br /&gt;
&lt;br /&gt;
Secondly, @temp_review_responses was changed to review_responses in the helper methods that call it: varying_rubrics_report and static_rubrics_report&lt;br /&gt;
&lt;br /&gt;
=== Testing ===&lt;br /&gt;
&lt;br /&gt;
1. Adapt Existing Tests for Refactored Methods&lt;br /&gt;
&lt;br /&gt;
* Any new helper methods will be private, and so by the &amp;quot;Magic Tricks of Testing&amp;quot; guide, should not be tested (both query and command messages sent to self are ignored in the test plan).&lt;br /&gt;
* Use mocks to isolate components during testing, especially for external dependencies like Mailer, to ensure that email functionality works as expected without direct integration.&lt;br /&gt;
&lt;br /&gt;
2. Document Code for Clarity&lt;br /&gt;
&lt;br /&gt;
* Write detailed comments explaining the purpose of each method, input and output, and any critical logic that might be complex for future developers to understand.&lt;br /&gt;
* Create or update documentation and diagrams to illustrate the newly designed structure, making it easier for new developers to contribute or modify functionality.&lt;br /&gt;
&lt;br /&gt;
=== Documentation ===&lt;br /&gt;
&lt;br /&gt;
Ensure all code is well-documented, with comments explaining purpose, inputs, outputs, and any complex logic. Maintain updated documentation for all modified and newly added classes and methods, allowing for ease of understanding and maintenance.&lt;br /&gt;
&lt;br /&gt;
=== Files ===&lt;br /&gt;
&lt;br /&gt;
The files that were added or modified to our repository are shown below.&lt;br /&gt;
&lt;br /&gt;
==== Models ====&lt;br /&gt;
&lt;br /&gt;
The following files were copied from the expertiza/expertiza repository:&lt;br /&gt;
* analytic/assignment_team_analytic.rb&lt;br /&gt;
* assignment_team.rb&lt;br /&gt;
* feedback_response_map.rb&lt;br /&gt;
&lt;br /&gt;
Added assignment_team.rb and assignment_team_analytic.rb as the existing spec tests depended on those 2 files. No changes were made to these files other than commenting out include Scoring in assignment_team.rb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;feedback_response_map.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Many comments were placed throughout the document in order to make code more readable.&lt;br /&gt;
&lt;br /&gt;
The main changes were taking feedback_response_report method and scanning it, to find different functionalities that could be taken out of it and turned into the following private helper methods: get_feedback_authors, varying_rubrics_report, static_rubrics_report.&lt;br /&gt;
&lt;br /&gt;
Additionally, the variable @temp_response_map_ids was changed into response_map_ids both inside and outside the helper methods that used this variable. The variable @temp_review_responses was not changed except for being called review_responses in the helper methods.&lt;br /&gt;
&lt;br /&gt;
==== Database ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;migrate/20241203083135_add_missing_reponse_map_fields.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One class is added, called AddMissingResponseMapFields, with a change of adding columns to response_maps and type and calibrate_to.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The only things changed in this file were a version change, as well as the addition of a t.string of &amp;quot;type&amp;quot; and a t.integer of &amp;quot;calibrate_to&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== Spec ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;factories.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file was modified to use single quotation marks instead of double quotation marks to adhere to RuboCop. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;factories/factories.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We populated the factory with necessary factories such as response, course, institution, and role, as well as fixing the factory formatting to function properly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;feedback_response_map.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The code was updated to adhere to RuboCop guidelines. Secondly, tests and parts of tests were commented out if they were reliant on functionality that was not yet implemented in reimplementation-back-end.&lt;br /&gt;
&lt;br /&gt;
=== Video ===&lt;br /&gt;
&lt;br /&gt;
https://youtu.be/SbmDoJNm4Q4&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
&lt;br /&gt;
By refactoring feedback_response_map.rb, this project enhances Expertiza’s backend maintainability and readability, ensuring a modular, efficient, and more secure implementation.&lt;br /&gt;
&lt;br /&gt;
== Team Information ==&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
* Chaitanya Srusti (crsrusti@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
=== Members ===&lt;br /&gt;
&lt;br /&gt;
* Sarah Daniel (sdaniel8@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* William Grochocinski (wagrocho@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Tipton Middleton (tgmiddl2@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* ChatGPT (Honorary Member)&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=160605</id>
		<title>CSC/ECE 517 Fall 2024 - E2451. Reimplement feedback response map.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=160605"/>
		<updated>2024-12-04T03:58:23Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2451: Reimplement feedback response map'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions, among other tasks. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
=== Project Overview ===&lt;br /&gt;
&lt;br /&gt;
The goal of this project is to refactor the feedback_response_map.rb file from the Expertiza repository and integrate it into the reimplementation-back-end repository. Within Expertiza, when a user submits a review, an instance of the Response class is created, associated with a ResponseMap. Each ResponseMap links a reviewer (reviewer_id), reviewee (reviewee_id), and the reviewed item (reviewed_object_id). FeedbackResponseMap, a subclass of ResponseMap, represents the feedback provided by a reviewee on the feedback received for their submission.&lt;br /&gt;
&lt;br /&gt;
This class has significant room for improvement, especially with respect to object-oriented principles. Refactoring feedback_response_map.rb will streamline functionality, enhance maintainability, and improve adherence to coding standards.&lt;br /&gt;
&lt;br /&gt;
=== Current Implementation ===&lt;br /&gt;
&lt;br /&gt;
The current feedback_response_map.rb in the Expertiza repository has several issues. It includes the following problems:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Poor adherence to SOLID and DRY principles&amp;lt;/b&amp;gt;: The current code structure introduces unnecessary repetition and complexity.&lt;br /&gt;
* &amp;lt;b&amp;gt;feedback_response_report Method Issues&amp;lt;/b&amp;gt;: This critical method is highly complex, relying on custom data structures and separate containers for each review round, resulting in a DRY violation.&lt;br /&gt;
* &amp;lt;b&amp;gt;Improper Responsibility Assignment&amp;lt;/b&amp;gt;: The email method does not belong within this class and would benefit from refactoring out into a separate class using the Visitor pattern. This pattern is suggested to streamline functionality, though alternative design patterns may be considered if more suitable.&lt;br /&gt;
* &amp;lt;b&amp;gt;Memory Inefficiencies&amp;lt;/b&amp;gt;: The method currently creates unnecessary memory through inefficient structures, including multiple separate arrays for different rounds of review, which could be simplified into a 2D array structure.&lt;br /&gt;
* &amp;lt;b&amp;gt;Code Smells&amp;lt;/b&amp;gt;: The code has redundant methods, unclear variable names, inefficient loops, and overly long method names.&lt;br /&gt;
&lt;br /&gt;
=== Objectives &amp;amp; Requirements ===&lt;br /&gt;
1. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Address the DRY violation by consolidating the containers for review rounds.&lt;br /&gt;
* Generalize the code to handle both cases—when rubrics vary by round and when they do not—without duplicating code.&lt;br /&gt;
* Introduce efficient data structures, like a 2D array, to replace multiple arrays and reduce memory usage.&lt;br /&gt;
&lt;br /&gt;
2. Separate Responsibilities Using Visitor Pattern (&amp;lt;i&amp;gt;stretch goal&amp;lt;/i&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
* Extract the email method using the Visitor pattern to modularize email functionality. Alternatively, select a design pattern better suited to organizing this method if available. Note that the email method is not properly used in its current location and is better suited to the Response class rather than ResponseMap.&lt;br /&gt;
&lt;br /&gt;
3. Eliminate Redundant Methods&lt;br /&gt;
&lt;br /&gt;
* Remove methods that do not serve a clear purpose and improve method naming for clarity.&lt;br /&gt;
* Aim to address any redundant meta-review functionality, as indicated by the professor's preference to remove these from response_map.rb.&lt;br /&gt;
&lt;br /&gt;
4. Refactor for Code Clarity and Efficiency&lt;br /&gt;
&lt;br /&gt;
* Improve variable names, reduce unnecessary loops, and replace long method names with concise, intuitive alternatives.&lt;br /&gt;
* Ensure that each method has a single, clearly defined purpose, improving code readability.&lt;br /&gt;
&lt;br /&gt;
5. Testing and Documentation&lt;br /&gt;
&lt;br /&gt;
* Write comprehensive tests for all newly implemented and modified methods to ensure reliability.&lt;br /&gt;
* Add detailed comments to facilitate code maintenance and understanding for future developers.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Design Principles ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Single Responsibility Principle (SRP)&amp;lt;/b&amp;gt;: Each method and class should have a single, well-defined purpose.&lt;br /&gt;
* &amp;lt;b&amp;gt;Don’t Repeat Yourself (DRY)&amp;lt;/b&amp;gt;: Eliminate redundancy by creating general solutions that handle multiple scenarios.&lt;br /&gt;
* &amp;lt;b&amp;gt;Ruby Readability Guidelines (Week 9 Notes)&amp;lt;/b&amp;gt;:&lt;br /&gt;
** Guideline: Variable names should be neither too short nor too long.&lt;br /&gt;
** Guideline: Names should not be redundant.&lt;br /&gt;
** Guideline: &amp;lt;b&amp;gt;A method should do only one thing and do it well.&amp;lt;/b&amp;gt;&lt;br /&gt;
* &amp;lt;b&amp;gt;Visitor Pattern&amp;lt;/b&amp;gt;: Utilize this pattern to separate emailing functionalities from the main class.&lt;br /&gt;
&lt;br /&gt;
=== Implementation Plan ===&lt;br /&gt;
&lt;br /&gt;
The refactoring will proceed as follows:&lt;br /&gt;
&lt;br /&gt;
1. Analyze and Refactor Current Code Structure&lt;br /&gt;
&lt;br /&gt;
* Review and understand the existing structure and dependencies within feedback_response_map.rb.&lt;br /&gt;
* Identify areas of redundancy, complexity, and inefficiency, particularly in feedback_response_report, to create a clear plan for refactoring.&lt;br /&gt;
* Try to reduce character count and improve readability with aliasing (this way we do not break any code that relies on being able to call specific methods).&lt;br /&gt;
&lt;br /&gt;
2. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Consolidate containers for each review round to address DRY violations. By using a single structure to store review data, we will eliminate hard-coded repetition.&lt;br /&gt;
* Generalize logic to accommodate both scenarios where rubrics vary by round and where they do not, without duplicating code paths.&lt;br /&gt;
* Replace inefficient structures, such as multiple arrays, with more flexible and memory-efficient options, like a 2D array or a hash, to reduce memory usage and improve scalability.&lt;br /&gt;
&lt;br /&gt;
3. Introduce Helper Methods for Reusable Logic (for feedback_response_report)&lt;br /&gt;
&lt;br /&gt;
* Extract frequently used or complex code blocks into helper methods, reducing the size of primary methods and enhancing reusability.&lt;br /&gt;
* Use helper methods for specific actions, like handling rounds or retrieving assignment data, to make the code cleaner and better organized.&lt;br /&gt;
* Emphasis on adhering to the guideline: A method should do only one thing and do it well.&lt;br /&gt;
&lt;br /&gt;
4. Research Future Refactoring for email Method&lt;br /&gt;
&lt;br /&gt;
* The email method is convoluted and the functionality should be refactored into a different class in the future.&lt;br /&gt;
* This is because this visitor pattern violation is present in many classes, and is beyond the scope of a one-class re-implementation.&lt;br /&gt;
&lt;br /&gt;
5. Improve Variable Naming and Structure&lt;br /&gt;
&lt;br /&gt;
* Replace ambiguous variable names with clearer alternatives that convey purpose, such as renaming @temp_review_responses and @temp_response_map_ids to more meaningful names.&lt;br /&gt;
* Simplify long method names to make the code more readable and approachable for new contributors.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Analyze and Refactor Current Code Structure&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before refactoring, the FeedbackResponseMap class contains 6 methods, with the majority of the code in self.feedback_response_report:&lt;br /&gt;
&lt;br /&gt;
[[File:FeedbackResponseMap_before.png |250px]]&lt;br /&gt;
&lt;br /&gt;
We aim to change that by splitting up this method into three helper methods, as seen in the following:&lt;br /&gt;
&lt;br /&gt;
[[File:FeedbackResponseMap_after.png |350px]]&lt;br /&gt;
&lt;br /&gt;
To go into more detail, here is the code for the feedback_response_report method, and how we intend to split it up:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_after_code1.png |600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_after_code2.png |600px]]&lt;br /&gt;
&lt;br /&gt;
The red section of code will be self.get_feedback_authors, yellow will be self.varying_rubrics_report, and green will be self.static_rubrics_report. Each separated group will be its own method, and self.varying_rubrics_report and self.static_rubrics_report (the yellow and green methods) will be returned at the end of the new feedback_response_report.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Refactor the feedback_response_report Method&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following are the original arrays used to statically represent the review rounds.&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-OriginalArrayRounds.png]]&lt;br /&gt;
&lt;br /&gt;
We can take these multiple arrays, and use dictionaries instead, where each round is called by its key value (integer value). &lt;br /&gt;
&lt;br /&gt;
[[File:E2451-UpdatedArraysMain.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
The code found in the feedback_response_report method that use the arrays were moved to the two helper methods, seen as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-UpdatedArrays1.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-UpdatedArrays2.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
Additionally, Rubocop was used to analyze the code and adhere to proper Ruby Guidelines. The command below was used to search for any code smells that we missed.&lt;br /&gt;
&lt;br /&gt;
   rubocop app/models/feedback_response_map.rb&lt;br /&gt;
&lt;br /&gt;
Originally, there were only three offenses, but this largely grew as we continued to refactor the code. All of the offenses can be seen below:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-Rubocop1.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-Rubocop2.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-Rubocop3.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-Rubocop4.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
All of these offenses were fixed. The following three offenses were the original ones. For the first and third offenses, the colon after the method headers were simply removed. For the second offense, the “return” keyword caused errors, thus, it was removed, because a ruby method will return  its last statement. The two other private methods containing “return” also had that keyword removed. &lt;br /&gt;
&lt;br /&gt;
[[File:E2451-RubocopOriginal.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
Lastly, commenting was added throughout the files, to improve readability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Introduce Helper Methods for Reusable Logic (for feedback_response_report)&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As planned in step 1, the feedback_response_report method was split up into 3 private helper methods: get_feedback_authors(id), varying_rubrics_report(review_responses, response_map_ids), and static_rubrics_report(review_responses, response_map_ids). One change we made that was different from the UML diagram was the addition of an id parameter in the get_feedback_authors method, in order to access id, since it was a parameter given to feedback_response_report. Each helper method was planned in order to stick to the guideline of “A method should do only one thing and do it well.”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Final UML for FeedbackResponseMap&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_FeedbackResponseMap_final.drawio.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Authors&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This image contains comments showing what the implementation looked like before:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_authors_before_1.png]]&lt;br /&gt;
&lt;br /&gt;
This image shows the construction of the private method we implemented to replace it, reducing complexity and improving readability in the process:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_authors_after_1.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Report&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This image contains comments showing what the implementation looked like before (this image is out of date, the return functionality for the varying rubric report rounds has since been generalized, please see the repo for the updated version) (The updated version does not include the old version comments, which is why this screenshot is used):&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_reports_before_1.png]]&lt;br /&gt;
&lt;br /&gt;
These images show the construction of the private methods we implemented to replace it, reducing complexity and improving readability in the process:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_reports_varying_1.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_report_static_1.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Notice that in both the original self.feedback_response_report method and the private methods, comments are included to explain each non-obvious step of the process.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Complexity changes&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Previously, Rubocop reported the following failures on behalf of the self.feedback_response_report method:&lt;br /&gt;
&lt;br /&gt;
  Metrics/PerceivedComplexity: Perceived complexity for feedback_response_report is too high. [14/8]&lt;br /&gt;
  Metrics/CyclomaticComplexity: Cyclomatic complexity for feedback_response_report is too high. [12/7]&lt;br /&gt;
  Metrics/AbcSize: Assignment Branch Condition size for feedback_response_report is too high. [&amp;lt;14, 46, 16&amp;gt; 50.68/20]&lt;br /&gt;
&lt;br /&gt;
Now, neither self.feedback_response_report nor any of its associated private methods trigger any of these Metric violations!&lt;br /&gt;
(Note that the email method does trigger a AbcSize violation when the protective comments are removed, but adjusting that method is beyond the scope of this project for reasons listed in the Implementation Plan)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Research Future Refactoring for email Method&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As discussed in the implementation plan, the email method was left as is. Any changes would require the addition of a new class and/or major refactoring for the functionality.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. Improve Variable Naming and Structure&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The two sets of variables discussed in the plan, @temp_response_map_ids and @temp_review_responses were modified as needed. First, the @temp_response_map_ids was moved to the helper methods varying_rubrics_report and static_rubrics_report, to be initialized, and changed to response_map_ids.&lt;br /&gt;
&lt;br /&gt;
Secondly, @temp_review_responses was changed to review_responses in the helper methods that call it: varying_rubrics_report and static_rubrics_report&lt;br /&gt;
&lt;br /&gt;
=== Testing ===&lt;br /&gt;
&lt;br /&gt;
1. Adapt Existing Tests for Refactored Methods&lt;br /&gt;
&lt;br /&gt;
* Any new helper methods will be private, and so by the &amp;quot;Magic Tricks of Testing&amp;quot; guide, should not be tested (both query and command messages sent to self are ignored in the test plan).&lt;br /&gt;
* Use mocks to isolate components during testing, especially for external dependencies like Mailer, to ensure that email functionality works as expected without direct integration.&lt;br /&gt;
&lt;br /&gt;
2. Document Code for Clarity&lt;br /&gt;
&lt;br /&gt;
* Write detailed comments explaining the purpose of each method, input and output, and any critical logic that might be complex for future developers to understand.&lt;br /&gt;
* Create or update documentation and diagrams to illustrate the newly designed structure, making it easier for new developers to contribute or modify functionality.&lt;br /&gt;
&lt;br /&gt;
=== Documentation ===&lt;br /&gt;
&lt;br /&gt;
Ensure all code is well-documented, with comments explaining purpose, inputs, outputs, and any complex logic. Maintain updated documentation for all modified and newly added classes and methods, allowing for ease of understanding and maintenance.&lt;br /&gt;
&lt;br /&gt;
=== Files ===&lt;br /&gt;
&lt;br /&gt;
The files that were added or modified to our repository are shown below.&lt;br /&gt;
&lt;br /&gt;
==== Models ====&lt;br /&gt;
&lt;br /&gt;
The following files were copied from the expertiza/expertiza repository:&lt;br /&gt;
* analytic/assignment_team_analytic.rb&lt;br /&gt;
* assignment_team.rb&lt;br /&gt;
* feedback_response_map.rb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;feedback_response_map.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Many comments were placed throughout the document in order to make code more readable.&lt;br /&gt;
&lt;br /&gt;
The main changes were taking feedback_response_report method and scanning it, to find different functionalities that could be taken out of it and turned into the following private helper methods: get_feedback_authors, varying_rubrics_report, static_rubrics_report.&lt;br /&gt;
&lt;br /&gt;
Additionally, the variable @temp_response_map_ids was changed into response_map_ids both inside and outside the helper methods that used this variable. The variable @temp_review_responses was not changed except for being called review_responses in the helper methods.&lt;br /&gt;
&lt;br /&gt;
==== Database ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;migrate/20241203083135_add_missing_reponse_map_fields.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One class is added, called AddMissingResponseMapFields, with a change of adding columns to response_maps and type and calibrate_to.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The only things changed in this file were a version change, as well as the addition of a t.string of &amp;quot;type&amp;quot; and a t.integer of &amp;quot;calibrate_to&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== Spec ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;factories.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file was modified to use single quotation marks instead of double quotation marks to adhere to RuboCop. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;factories/factories.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We populated the factory with necessary factories to run our tests.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;feedback_response_map.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The code was updated to adhere to RuboCop guidelines. Secondly, tests and parts of tests were commented out if they were reliant on functionality that was not yet implemented in reimplementation-back-end.&lt;br /&gt;
&lt;br /&gt;
=== Video ===&lt;br /&gt;
&lt;br /&gt;
https://youtu.be/SbmDoJNm4Q4&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
&lt;br /&gt;
By refactoring feedback_response_map.rb, this project enhances Expertiza’s backend maintainability and readability, ensuring a modular, efficient, and more secure implementation.&lt;br /&gt;
&lt;br /&gt;
== Team Information ==&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
* Chaitanya Srusti (crsrusti@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
=== Members ===&lt;br /&gt;
&lt;br /&gt;
* Sarah Daniel (sdaniel8@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* William Grochocinski (wagrocho@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Tipton Middleton (tgmiddl2@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* ChatGPT (Honorary Member)&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=160601</id>
		<title>CSC/ECE 517 Fall 2024 - E2451. Reimplement feedback response map.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=160601"/>
		<updated>2024-12-04T03:53:05Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2451: Reimplement feedback response map'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions, among other tasks. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
=== Project Overview ===&lt;br /&gt;
&lt;br /&gt;
The goal of this project is to refactor the feedback_response_map.rb file from the Expertiza repository and integrate it into the reimplementation-back-end repository. Within Expertiza, when a user submits a review, an instance of the Response class is created, associated with a ResponseMap. Each ResponseMap links a reviewer (reviewer_id), reviewee (reviewee_id), and the reviewed item (reviewed_object_id). FeedbackResponseMap, a subclass of ResponseMap, represents the feedback provided by a reviewee on the feedback received for their submission.&lt;br /&gt;
&lt;br /&gt;
This class has significant room for improvement, especially with respect to object-oriented principles. Refactoring feedback_response_map.rb will streamline functionality, enhance maintainability, and improve adherence to coding standards.&lt;br /&gt;
&lt;br /&gt;
=== Current Implementation ===&lt;br /&gt;
&lt;br /&gt;
The current feedback_response_map.rb in the Expertiza repository has several issues. It includes the following problems:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Poor adherence to SOLID and DRY principles&amp;lt;/b&amp;gt;: The current code structure introduces unnecessary repetition and complexity.&lt;br /&gt;
* &amp;lt;b&amp;gt;feedback_response_report Method Issues&amp;lt;/b&amp;gt;: This critical method is highly complex, relying on custom data structures and separate containers for each review round, resulting in a DRY violation.&lt;br /&gt;
* &amp;lt;b&amp;gt;Improper Responsibility Assignment&amp;lt;/b&amp;gt;: The email method does not belong within this class and would benefit from refactoring out into a separate class using the Visitor pattern. This pattern is suggested to streamline functionality, though alternative design patterns may be considered if more suitable.&lt;br /&gt;
* &amp;lt;b&amp;gt;Memory Inefficiencies&amp;lt;/b&amp;gt;: The method currently creates unnecessary memory through inefficient structures, including multiple separate arrays for different rounds of review, which could be simplified into a 2D array structure.&lt;br /&gt;
* &amp;lt;b&amp;gt;Code Smells&amp;lt;/b&amp;gt;: The code has redundant methods, unclear variable names, inefficient loops, and overly long method names.&lt;br /&gt;
&lt;br /&gt;
=== Objectives &amp;amp; Requirements ===&lt;br /&gt;
1. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Address the DRY violation by consolidating the containers for review rounds.&lt;br /&gt;
* Generalize the code to handle both cases—when rubrics vary by round and when they do not—without duplicating code.&lt;br /&gt;
* Introduce efficient data structures, like a 2D array, to replace multiple arrays and reduce memory usage.&lt;br /&gt;
&lt;br /&gt;
2. Separate Responsibilities Using Visitor Pattern (&amp;lt;i&amp;gt;stretch goal&amp;lt;/i&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
* Extract the email method using the Visitor pattern to modularize email functionality. Alternatively, select a design pattern better suited to organizing this method if available. Note that the email method is not properly used in its current location and is better suited to the Response class rather than ResponseMap.&lt;br /&gt;
&lt;br /&gt;
3. Eliminate Redundant Methods&lt;br /&gt;
&lt;br /&gt;
* Remove methods that do not serve a clear purpose and improve method naming for clarity.&lt;br /&gt;
* Aim to address any redundant meta-review functionality, as indicated by the professor's preference to remove these from response_map.rb.&lt;br /&gt;
&lt;br /&gt;
4. Refactor for Code Clarity and Efficiency&lt;br /&gt;
&lt;br /&gt;
* Improve variable names, reduce unnecessary loops, and replace long method names with concise, intuitive alternatives.&lt;br /&gt;
* Ensure that each method has a single, clearly defined purpose, improving code readability.&lt;br /&gt;
&lt;br /&gt;
5. Testing and Documentation&lt;br /&gt;
&lt;br /&gt;
* Write comprehensive tests for all newly implemented and modified methods to ensure reliability.&lt;br /&gt;
* Add detailed comments to facilitate code maintenance and understanding for future developers.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Design Principles ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Single Responsibility Principle (SRP)&amp;lt;/b&amp;gt;: Each method and class should have a single, well-defined purpose.&lt;br /&gt;
* &amp;lt;b&amp;gt;Don’t Repeat Yourself (DRY)&amp;lt;/b&amp;gt;: Eliminate redundancy by creating general solutions that handle multiple scenarios.&lt;br /&gt;
* &amp;lt;b&amp;gt;Ruby Readability Guidelines (Week 9 Notes)&amp;lt;/b&amp;gt;:&lt;br /&gt;
** Guideline: Variable names should be neither too short nor too long.&lt;br /&gt;
** Guideline: Names should not be redundant.&lt;br /&gt;
** Guideline: &amp;lt;b&amp;gt;A method should do only one thing and do it well.&amp;lt;/b&amp;gt;&lt;br /&gt;
* &amp;lt;b&amp;gt;Visitor Pattern&amp;lt;/b&amp;gt;: Utilize this pattern to separate emailing functionalities from the main class.&lt;br /&gt;
&lt;br /&gt;
=== Implementation Plan ===&lt;br /&gt;
&lt;br /&gt;
The refactoring will proceed as follows:&lt;br /&gt;
&lt;br /&gt;
1. Analyze and Refactor Current Code Structure&lt;br /&gt;
&lt;br /&gt;
* Review and understand the existing structure and dependencies within feedback_response_map.rb.&lt;br /&gt;
* Identify areas of redundancy, complexity, and inefficiency, particularly in feedback_response_report, to create a clear plan for refactoring.&lt;br /&gt;
* Try to reduce character count and improve readability with aliasing (this way we do not break any code that relies on being able to call specific methods).&lt;br /&gt;
&lt;br /&gt;
2. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Consolidate containers for each review round to address DRY violations. By using a single structure to store review data, we will eliminate hard-coded repetition.&lt;br /&gt;
* Generalize logic to accommodate both scenarios where rubrics vary by round and where they do not, without duplicating code paths.&lt;br /&gt;
* Replace inefficient structures, such as multiple arrays, with more flexible and memory-efficient options, like a 2D array or a hash, to reduce memory usage and improve scalability.&lt;br /&gt;
&lt;br /&gt;
3. Introduce Helper Methods for Reusable Logic (for feedback_response_report)&lt;br /&gt;
&lt;br /&gt;
* Extract frequently used or complex code blocks into helper methods, reducing the size of primary methods and enhancing reusability.&lt;br /&gt;
* Use helper methods for specific actions, like handling rounds or retrieving assignment data, to make the code cleaner and better organized.&lt;br /&gt;
* Emphasis on adhering to the guideline: A method should do only one thing and do it well.&lt;br /&gt;
&lt;br /&gt;
4. Research Future Refactoring for email Method&lt;br /&gt;
&lt;br /&gt;
* The email method is convoluted and the functionality should be refactored into a different class in the future.&lt;br /&gt;
* This is because this visitor pattern violation is present in many classes, and is beyond the scope of a one-class re-implementation.&lt;br /&gt;
&lt;br /&gt;
5. Improve Variable Naming and Structure&lt;br /&gt;
&lt;br /&gt;
* Replace ambiguous variable names with clearer alternatives that convey purpose, such as renaming @temp_review_responses and @temp_response_map_ids to more meaningful names.&lt;br /&gt;
* Simplify long method names to make the code more readable and approachable for new contributors.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Analyze and Refactor Current Code Structure&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before refactoring, the FeedbackResponseMap class contains 6 methods, with the majority of the code in self.feedback_response_report:&lt;br /&gt;
&lt;br /&gt;
[[File:FeedbackResponseMap_before.png |250px]]&lt;br /&gt;
&lt;br /&gt;
We aim to change that by splitting up this method into three helper methods, as seen in the following:&lt;br /&gt;
&lt;br /&gt;
[[File:FeedbackResponseMap_after.png |350px]]&lt;br /&gt;
&lt;br /&gt;
To go into more detail, here is the code for the feedback_response_report method, and how we intend to split it up:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_after_code1.png |600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_after_code2.png |600px]]&lt;br /&gt;
&lt;br /&gt;
The red section of code will be self.get_feedback_authors, yellow will be self.varying_rubrics_report, and green will be self.static_rubrics_report. Each separated group will be its own method, and self.varying_rubrics_report and self.static_rubrics_report (the yellow and green methods) will be returned at the end of the new feedback_response_report.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Refactor the feedback_response_report Method&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following are the original arrays used to statically represent the review rounds.&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-OriginalArrayRounds.png]]&lt;br /&gt;
&lt;br /&gt;
We can take these multiple arrays, and use dictionaries instead, where each round is called by its key value (integer value). &lt;br /&gt;
&lt;br /&gt;
[[File:E2451-UpdatedArraysMain.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
The code found in the feedback_response_report method that use the arrays were moved to the two helper methods, seen as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-UpdatedArrays1.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-UpdatedArrays2.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
Additionally, Rubocop was used to analyze the code and adhere to proper Ruby Guidelines. The command below was used to search for any code smells that we missed.&lt;br /&gt;
&lt;br /&gt;
   rubocop app/models/feedback_response_map.rb&lt;br /&gt;
&lt;br /&gt;
Originally, there were only three offenses, but this largely grew as we continued to refactor the code. All of the offenses can be seen below:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-Rubocop1.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-Rubocop2.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-Rubocop3.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-Rubocop4.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
All of these offenses were fixed. The following three offenses were the original ones. For the first and third offenses, the colon after the method headers were simply removed. For the second offense, the “return” keyword caused errors, thus, it was removed, because a ruby method will return  its last statement. The two other private methods containing “return” also had that keyword removed. &lt;br /&gt;
&lt;br /&gt;
[[File:E2451-RubocopOriginal.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
Lastly, commenting was added throughout the files, to improve readability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Introduce Helper Methods for Reusable Logic (for feedback_response_report)&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As planned in step 1, the feedback_response_report method was split up into 3 private helper methods: get_feedback_authors(id), varying_rubrics_report(review_responses, response_map_ids), and static_rubrics_report(review_responses, response_map_ids). One change we made that was different from the UML diagram was the addition of an id parameter in the get_feedback_authors method, in order to access id, since it was a parameter given to feedback_response_report. Each helper method was planned in order to stick to the guideline of “A method should do only one thing and do it well.”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Final UML for FeedbackResponseMap&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_FeedbackResponseMap_final.drawio.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Authors&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This image contains comments showing what the implementation looked like before:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_authors_before_1.png]]&lt;br /&gt;
&lt;br /&gt;
This image shows the construction of the private method we implemented to replace it, reducing complexity and improving readability in the process:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_authors_after_1.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Report&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This image contains comments showing what the implementation looked like before (this image is out of date, the return functionality for the varying rubric report rounds has since been generalized, please see the repo for the updated version) (The updated version does not include the old version comments, which is why this screenshot is used):&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_reports_before_1.png]]&lt;br /&gt;
&lt;br /&gt;
These images show the construction of the private methods we implemented to replace it, reducing complexity and improving readability in the process:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_reports_varying_1.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_report_static_1.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Notice that in both the original self.feedback_response_report method and the private methods, comments are included to explain each non-obvious step of the process.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Complexity changes&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Previously, Rubocop reported the following failures on behalf of the self.feedback_response_report method:&lt;br /&gt;
&lt;br /&gt;
  Metrics/PerceivedComplexity: Perceived complexity for feedback_response_report is too high. [14/8]&lt;br /&gt;
  Metrics/CyclomaticComplexity: Cyclomatic complexity for feedback_response_report is too high. [12/7]&lt;br /&gt;
  Metrics/AbcSize: Assignment Branch Condition size for feedback_response_report is too high. [&amp;lt;14, 46, 16&amp;gt; 50.68/20]&lt;br /&gt;
&lt;br /&gt;
Now, neither self.feedback_response_report nor any of its associated private methods trigger any of these Metric violations!&lt;br /&gt;
(Note that the email method does trigger a AbcSize violation when the protective comments are removed, but adjusting that method is beyond the scope of this project for reasons listed in the Implementation Plan)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Research Future Refactoring for email Method&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As discussed in the implementation plan, the email method was left as is. Any changes would require the addition of a new class and/or major refactoring for the functionality.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. Improve Variable Naming and Structure&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The two sets of variables discussed in the plan, @temp_response_map_ids and @temp_review_responses were modified as needed. First, the @temp_response_map_ids was moved to the helper methods varying_rubrics_report and static_rubrics_report, to be initialized, and changed to response_map_ids.&lt;br /&gt;
&lt;br /&gt;
Secondly, @temp_review_responses was changed to review_responses in the helper methods that call it: varying_rubrics_report and static_rubrics_report&lt;br /&gt;
&lt;br /&gt;
=== Testing ===&lt;br /&gt;
&lt;br /&gt;
1. Adapt Existing Tests for Refactored Methods&lt;br /&gt;
&lt;br /&gt;
* Any new helper methods will be private, and so by the &amp;quot;Magic Tricks of Testing&amp;quot; guide, should not be tested (both query and command messages sent to self are ignored in the test plan).&lt;br /&gt;
* Use mocks to isolate components during testing, especially for external dependencies like Mailer, to ensure that email functionality works as expected without direct integration.&lt;br /&gt;
&lt;br /&gt;
2. Document Code for Clarity&lt;br /&gt;
&lt;br /&gt;
* Write detailed comments explaining the purpose of each method, input and output, and any critical logic that might be complex for future developers to understand.&lt;br /&gt;
* Create or update documentation and diagrams to illustrate the newly designed structure, making it easier for new developers to contribute or modify functionality.&lt;br /&gt;
&lt;br /&gt;
=== Documentation ===&lt;br /&gt;
&lt;br /&gt;
Ensure all code is well-documented, with comments explaining purpose, inputs, outputs, and any complex logic. Maintain updated documentation for all modified and newly added classes and methods, allowing for ease of understanding and maintenance.&lt;br /&gt;
&lt;br /&gt;
=== Files ===&lt;br /&gt;
&lt;br /&gt;
The files that were added or modified to our repository are shown below.&lt;br /&gt;
&lt;br /&gt;
==== Models ====&lt;br /&gt;
&lt;br /&gt;
The following files were copied from the expertiza/expertiza repository:&lt;br /&gt;
* analytic/assignment_team_analytic.rb&lt;br /&gt;
* assignment_team.rb&lt;br /&gt;
* feedback_response_map.rb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;feedback_response_map.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Many comments were placed throughout the document in order to make code more readable.&lt;br /&gt;
&lt;br /&gt;
The main changes were taking feedback_response_report method and scanning it, to find different functionalities that could be taken out of it and turned into the following private helper methods: get_feedback_authors, varying_rubrics_report, static_rubrics_report.&lt;br /&gt;
&lt;br /&gt;
Additionally, the variable @temp_response_map_ids was changed into response_map_ids both inside and outside the helper methods that used this variable. The variable @temp_review_responses was not changed except for being called review_responses in the helper methods.&lt;br /&gt;
&lt;br /&gt;
==== Database ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;migrate/20241203083135_add_missing_reponse_map_fields.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One class is added, called AddMissingResponseMapFields, with a change of adding columns to response_maps and type and calibrate_to.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The only things changed in this file were a version change, as well as the addition of a t.string of &amp;quot;type&amp;quot; and a t.integer of &amp;quot;calibrate_to&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== Spec ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;factories.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file was modified to use single quotation marks instead of double quotation marks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;factories/factories.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We populated the factory with necessary factories to run our tests.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;feedback_response_map.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Video ===&lt;br /&gt;
&lt;br /&gt;
https://youtu.be/SbmDoJNm4Q4&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
&lt;br /&gt;
By refactoring feedback_response_map.rb, this project enhances Expertiza’s backend maintainability and readability, ensuring a modular, efficient, and more secure implementation.&lt;br /&gt;
&lt;br /&gt;
== Team Information ==&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
* Chaitanya Srusti (crsrusti@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
=== Members ===&lt;br /&gt;
&lt;br /&gt;
* Sarah Daniel (sdaniel8@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* William Grochocinski (wagrocho@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Tipton Middleton (tgmiddl2@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* ChatGPT (Honorary Member)&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=160547</id>
		<title>CSC/ECE 517 Fall 2024 - E2451. Reimplement feedback response map.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=160547"/>
		<updated>2024-12-04T03:31:53Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2451: Reimplement feedback response map'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions, among other tasks. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
=== Project Overview ===&lt;br /&gt;
&lt;br /&gt;
The goal of this project is to refactor the feedback_response_map.rb file from the Expertiza repository and integrate it into the reimplementation-back-end repository. Within Expertiza, when a user submits a review, an instance of the Response class is created, associated with a ResponseMap. Each ResponseMap links a reviewer (reviewer_id), reviewee (reviewee_id), and the reviewed item (reviewed_object_id). FeedbackResponseMap, a subclass of ResponseMap, represents the feedback provided by a reviewee on the feedback received for their submission.&lt;br /&gt;
&lt;br /&gt;
This class has significant room for improvement, especially with respect to object-oriented principles. Refactoring feedback_response_map.rb will streamline functionality, enhance maintainability, and improve adherence to coding standards.&lt;br /&gt;
&lt;br /&gt;
=== Current Implementation ===&lt;br /&gt;
&lt;br /&gt;
The current feedback_response_map.rb in the Expertiza repository has several issues. It includes the following problems:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Poor adherence to SOLID and DRY principles&amp;lt;/b&amp;gt;: The current code structure introduces unnecessary repetition and complexity.&lt;br /&gt;
* &amp;lt;b&amp;gt;feedback_response_report Method Issues&amp;lt;/b&amp;gt;: This critical method is highly complex, relying on custom data structures and separate containers for each review round, resulting in a DRY violation.&lt;br /&gt;
* &amp;lt;b&amp;gt;Improper Responsibility Assignment&amp;lt;/b&amp;gt;: The email method does not belong within this class and would benefit from refactoring out into a separate class using the Visitor pattern. This pattern is suggested to streamline functionality, though alternative design patterns may be considered if more suitable.&lt;br /&gt;
* &amp;lt;b&amp;gt;Memory Inefficiencies&amp;lt;/b&amp;gt;: The method currently creates unnecessary memory through inefficient structures, including multiple separate arrays for different rounds of review, which could be simplified into a 2D array structure.&lt;br /&gt;
* &amp;lt;b&amp;gt;Code Smells&amp;lt;/b&amp;gt;: The code has redundant methods, unclear variable names, inefficient loops, and overly long method names.&lt;br /&gt;
&lt;br /&gt;
=== Objectives &amp;amp; Requirements ===&lt;br /&gt;
1. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Address the DRY violation by consolidating the containers for review rounds.&lt;br /&gt;
* Generalize the code to handle both cases—when rubrics vary by round and when they do not—without duplicating code.&lt;br /&gt;
* Introduce efficient data structures, like a 2D array, to replace multiple arrays and reduce memory usage.&lt;br /&gt;
&lt;br /&gt;
2. Separate Responsibilities Using Visitor Pattern (&amp;lt;i&amp;gt;stretch goal&amp;lt;/i&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
* Extract the email method using the Visitor pattern to modularize email functionality. Alternatively, select a design pattern better suited to organizing this method if available. Note that the email method is not properly used in its current location and is better suited to the Response class rather than ResponseMap.&lt;br /&gt;
&lt;br /&gt;
3. Eliminate Redundant Methods&lt;br /&gt;
&lt;br /&gt;
* Remove methods that do not serve a clear purpose and improve method naming for clarity.&lt;br /&gt;
* Aim to address any redundant meta-review functionality, as indicated by the professor's preference to remove these from response_map.rb.&lt;br /&gt;
&lt;br /&gt;
4. Refactor for Code Clarity and Efficiency&lt;br /&gt;
&lt;br /&gt;
* Improve variable names, reduce unnecessary loops, and replace long method names with concise, intuitive alternatives.&lt;br /&gt;
* Ensure that each method has a single, clearly defined purpose, improving code readability.&lt;br /&gt;
&lt;br /&gt;
5. Testing and Documentation&lt;br /&gt;
&lt;br /&gt;
* Write comprehensive tests for all newly implemented and modified methods to ensure reliability.&lt;br /&gt;
* Add detailed comments to facilitate code maintenance and understanding for future developers.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Design Principles ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Single Responsibility Principle (SRP)&amp;lt;/b&amp;gt;: Each method and class should have a single, well-defined purpose.&lt;br /&gt;
* &amp;lt;b&amp;gt;Don’t Repeat Yourself (DRY)&amp;lt;/b&amp;gt;: Eliminate redundancy by creating general solutions that handle multiple scenarios.&lt;br /&gt;
* &amp;lt;b&amp;gt;Ruby Readability Guidelines (Week 9 Notes)&amp;lt;/b&amp;gt;:&lt;br /&gt;
** Guideline: Variable names should be neither too short nor too long.&lt;br /&gt;
** Guideline: Names should not be redundant.&lt;br /&gt;
** Guideline: &amp;lt;b&amp;gt;A method should do only one thing and do it well.&amp;lt;/b&amp;gt;&lt;br /&gt;
* &amp;lt;b&amp;gt;Visitor Pattern&amp;lt;/b&amp;gt;: Utilize this pattern to separate emailing functionalities from the main class.&lt;br /&gt;
&lt;br /&gt;
=== Implementation Plan ===&lt;br /&gt;
&lt;br /&gt;
The refactoring will proceed as follows:&lt;br /&gt;
&lt;br /&gt;
1. Analyze and Refactor Current Code Structure&lt;br /&gt;
&lt;br /&gt;
* Review and understand the existing structure and dependencies within feedback_response_map.rb.&lt;br /&gt;
* Identify areas of redundancy, complexity, and inefficiency, particularly in feedback_response_report, to create a clear plan for refactoring.&lt;br /&gt;
* Try to reduce character count and improve readability with aliasing (this way we do not break any code that relies on being able to call specific methods).&lt;br /&gt;
&lt;br /&gt;
2. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Consolidate containers for each review round to address DRY violations. By using a single structure to store review data, we will eliminate hard-coded repetition.&lt;br /&gt;
* Generalize logic to accommodate both scenarios where rubrics vary by round and where they do not, without duplicating code paths.&lt;br /&gt;
* Replace inefficient structures, such as multiple arrays, with more flexible and memory-efficient options, like a 2D array or a hash, to reduce memory usage and improve scalability.&lt;br /&gt;
&lt;br /&gt;
3. Introduce Helper Methods for Reusable Logic (for feedback_response_report)&lt;br /&gt;
&lt;br /&gt;
* Extract frequently used or complex code blocks into helper methods, reducing the size of primary methods and enhancing reusability.&lt;br /&gt;
* Use helper methods for specific actions, like handling rounds or retrieving assignment data, to make the code cleaner and better organized.&lt;br /&gt;
* Emphasis on adhering to the guideline: A method should do only one thing and do it well.&lt;br /&gt;
&lt;br /&gt;
4. Research Future Refactoring for email Method&lt;br /&gt;
&lt;br /&gt;
* The email method is convoluted and the functionality should be refactored into a different class in the future.&lt;br /&gt;
* This is because this visitor pattern violation is present in many classes, and is beyond the scope of a one-class re-implementation.&lt;br /&gt;
&lt;br /&gt;
5. Improve Variable Naming and Structure&lt;br /&gt;
&lt;br /&gt;
* Replace ambiguous variable names with clearer alternatives that convey purpose, such as renaming @temp_review_responses and @temp_response_map_ids to more meaningful names.&lt;br /&gt;
* Simplify long method names to make the code more readable and approachable for new contributors.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Analyze and Refactor Current Code Structure&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before refactoring, the FeedbackResponseMap class contains 6 methods, with the majority of the code in self.feedback_response_report:&lt;br /&gt;
&lt;br /&gt;
[[File:FeedbackResponseMap_before.png |250px]]&lt;br /&gt;
&lt;br /&gt;
We aim to change that by splitting up this method into three helper methods, as seen in the following:&lt;br /&gt;
&lt;br /&gt;
[[File:FeedbackResponseMap_after.png |350px]]&lt;br /&gt;
&lt;br /&gt;
To go into more detail, here is the code for the feedback_response_report method, and how we intend to split it up:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_after_code1.png |600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_after_code2.png |600px]]&lt;br /&gt;
&lt;br /&gt;
The red section of code will be self.get_feedback_authors, yellow will be self.varying_rubrics_report, and green will be self.static_rubrics_report. Each separated group will be its own method, and self.varying_rubrics_report and self.static_rubrics_report (the yellow and green methods) will be returned at the end of the new feedback_response_report.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Refactor the feedback_response_report Method&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following are the original arrays used to statically represent the review rounds.&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-OriginalArrayRounds.png]]&lt;br /&gt;
&lt;br /&gt;
We can take these multiple arrays, and use dictionaries instead, where each round is called by its key value (integer value). &lt;br /&gt;
&lt;br /&gt;
[[File:E2451-UpdatedArraysMain.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
The code found in the feedback_response_report method that use the arrays were moved to the two helper methods, seen as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-UpdatedArrays1.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-UpdatedArrays2.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
Additionally, Rubocop was used to analyze the code and adhere to proper Ruby Guidelines. The command below was used to search for any code smells that we missed.&lt;br /&gt;
&lt;br /&gt;
   rubocop app/models/feedback_response_map.rb&lt;br /&gt;
&lt;br /&gt;
Originally, there were only three offenses, but this largely grew as we continued to refactor the code. All of the offenses can be seen below:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-Rubocop1.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-Rubocop2.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-Rubocop3.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-Rubocop4.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
All of these offenses were fixed. The following three offenses were the original ones. For the first and third offenses, the colon after the method headers were simply removed. For the second offense, the “return” keyword caused errors, thus, it was removed, because a ruby method will return  its last statement. The two other private methods containing “return” also had that keyword removed. &lt;br /&gt;
&lt;br /&gt;
[[File:E2451-RubocopOriginal.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
Lastly, commenting was added throughout the files, to improve readability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Introduce Helper Methods for Reusable Logic (for feedback_response_report)&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As planned in step 1, the feedback_response_report method was split up into 3 private helper methods: get_feedback_authors(id), varying_rubrics_report(review_responses, response_map_ids), and static_rubrics_report(review_responses, response_map_ids). One change we made that was different from the UML diagram was the addition of an id parameter in the get_feedback_authors method, in order to access id, since it was a parameter given to feedback_response_report. Each helper method was planned in order to stick to the guideline of “A method should do only one thing and do it well.”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Final UML for FeedbackResponseMap&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_FeedbackResponseMap_final.drawio.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Authors&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This image contains comments showing what the implementation looked like before:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_authors_before_1.png]]&lt;br /&gt;
&lt;br /&gt;
This image shows the construction of the private method we implemented to replace it, reducing complexity and improving readability in the process:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_authors_after_1.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Report&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This image contains comments showing what the implementation looked like before (this image is out of date, the return functionality for the varying rubric report rounds has since been generalized, please see the repo for the updated version) (The updated version does not include the old version comments, which is why this screenshot is used):&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_reports_before_1.png]]&lt;br /&gt;
&lt;br /&gt;
These images show the construction of the private methods we implemented to replace it, reducing complexity and improving readability in the process:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_reports_varying_1.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_report_static_1.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Notice that in both the original self.feedback_response_report method and the private methods, comments are included to explain each non-obvious step of the process.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Complexity changes&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Previously, Rubocop reported the following failures on behalf of the self.feedback_response_report method:&lt;br /&gt;
&lt;br /&gt;
  Metrics/PerceivedComplexity: Perceived complexity for feedback_response_report is too high. [14/8]&lt;br /&gt;
  Metrics/CyclomaticComplexity: Cyclomatic complexity for feedback_response_report is too high. [12/7]&lt;br /&gt;
  Metrics/AbcSize: Assignment Branch Condition size for feedback_response_report is too high. [&amp;lt;14, 46, 16&amp;gt; 50.68/20]&lt;br /&gt;
&lt;br /&gt;
Now, neither self.feedback_response_report nor any of its associated private methods trigger any of these Metric violations!&lt;br /&gt;
(Note that the email method does trigger a AbcSize violation when the protective comments are removed, but adjusting that method is beyond the scope of this project for reasons listed in the Implementation Plan)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Research Future Refactoring for email Method&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As discussed in the implementation plan, the email method was left as is. Any changes would require the addition of a new class and/or major refactoring for the functionality.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. Improve Variable Naming and Structure&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The two sets of variables discussed in the plan, @temp_response_map_ids and @temp_review_responses were modified as needed. First, the @temp_response_map_ids was moved to the helper methods varying_rubrics_report and static_rubrics_report, to be initialized, and changed to response_map_ids.&lt;br /&gt;
&lt;br /&gt;
Secondly, @temp_review_responses was changed to review_responses in the helper methods that call it: varying_rubrics_report and static_rubrics_report&lt;br /&gt;
&lt;br /&gt;
=== Testing ===&lt;br /&gt;
&lt;br /&gt;
1. Adapt Existing Tests for Refactored Methods&lt;br /&gt;
&lt;br /&gt;
* Any new helper methods will be private, and so by the &amp;quot;Magic Tricks of Testing&amp;quot; guide, should not be tested (both query and command messages sent to self are ignored in the test plan).&lt;br /&gt;
* Use mocks to isolate components during testing, especially for external dependencies like Mailer, to ensure that email functionality works as expected without direct integration.&lt;br /&gt;
&lt;br /&gt;
2. Document Code for Clarity&lt;br /&gt;
&lt;br /&gt;
* Write detailed comments explaining the purpose of each method, input and output, and any critical logic that might be complex for future developers to understand.&lt;br /&gt;
* Create or update documentation and diagrams to illustrate the newly designed structure, making it easier for new developers to contribute or modify functionality.&lt;br /&gt;
&lt;br /&gt;
=== Documentation ===&lt;br /&gt;
&lt;br /&gt;
Ensure all code is well-documented, with comments explaining purpose, inputs, outputs, and any complex logic. Maintain updated documentation for all modified and newly added classes and methods, allowing for ease of understanding and maintenance.&lt;br /&gt;
&lt;br /&gt;
=== Files ===&lt;br /&gt;
&lt;br /&gt;
==== Models ====&lt;br /&gt;
&lt;br /&gt;
The following files were copied from the expertiza/expertiza repository:&lt;br /&gt;
* analytic/assignment_team_analytic.rb&lt;br /&gt;
* assignment_team.rb&lt;br /&gt;
* feedback_response_map.rb&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;feedback_response_map.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
fds&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Database ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;migrate/20241203083135_add_missing_reponse_map_fields.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Spec ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;factories.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;factories/factories.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;feedback_response_map.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Video ===&lt;br /&gt;
&lt;br /&gt;
https://youtu.be/SbmDoJNm4Q4&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
&lt;br /&gt;
By refactoring feedback_response_map.rb, this project enhances Expertiza’s backend maintainability and readability, ensuring a modular, efficient, and more secure implementation.&lt;br /&gt;
&lt;br /&gt;
== Team Information ==&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
* Chaitanya Srusti (crsrusti@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
=== Members ===&lt;br /&gt;
&lt;br /&gt;
* Sarah Daniel (sdaniel8@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* William Grochocinski (wagrocho@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Tipton Middleton (tgmiddl2@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* ChatGPT (Honorary Member)&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2451-UpdatedArraysMain.png&amp;diff=160479</id>
		<title>File:E2451-UpdatedArraysMain.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2451-UpdatedArraysMain.png&amp;diff=160479"/>
		<updated>2024-12-04T02:32:14Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: Sdaniel8 uploaded a new version of File:E2451-UpdatedArraysMain.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2451-UpdatedArraysMain.png&amp;diff=160478</id>
		<title>File:E2451-UpdatedArraysMain.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2451-UpdatedArraysMain.png&amp;diff=160478"/>
		<updated>2024-12-04T02:30:16Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: Sdaniel8 uploaded a new version of File:E2451-UpdatedArraysMain.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=160428</id>
		<title>CSC/ECE 517 Fall 2024 - E2451. Reimplement feedback response map.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=160428"/>
		<updated>2024-12-04T01:51:54Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2451: Reimplement feedback response map'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions, among other tasks. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
=== Project Overview ===&lt;br /&gt;
&lt;br /&gt;
The goal of this project is to refactor the feedback_response_map.rb file from the Expertiza repository and integrate it into the reimplementation-back-end repository. Within Expertiza, when a user submits a review, an instance of the Response class is created, associated with a ResponseMap. Each ResponseMap links a reviewer (reviewer_id), reviewee (reviewee_id), and the reviewed item (reviewed_object_id). FeedbackResponseMap, a subclass of ResponseMap, represents the feedback provided by a reviewee on the feedback received for their submission.&lt;br /&gt;
&lt;br /&gt;
This class has significant room for improvement, especially with respect to object-oriented principles. Refactoring feedback_response_map.rb will streamline functionality, enhance maintainability, and improve adherence to coding standards.&lt;br /&gt;
&lt;br /&gt;
=== Current Implementation ===&lt;br /&gt;
&lt;br /&gt;
The current feedback_response_map.rb in the Expertiza repository has several issues. It includes the following problems:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Poor adherence to SOLID and DRY principles&amp;lt;/b&amp;gt;: The current code structure introduces unnecessary repetition and complexity.&lt;br /&gt;
* &amp;lt;b&amp;gt;feedback_response_report Method Issues&amp;lt;/b&amp;gt;: This critical method is highly complex, relying on custom data structures and separate containers for each review round, resulting in a DRY violation.&lt;br /&gt;
* &amp;lt;b&amp;gt;Improper Responsibility Assignment&amp;lt;/b&amp;gt;: The email method does not belong within this class and would benefit from refactoring out into a separate class using the Visitor pattern. This pattern is suggested to streamline functionality, though alternative design patterns may be considered if more suitable.&lt;br /&gt;
* &amp;lt;b&amp;gt;Memory Inefficiencies&amp;lt;/b&amp;gt;: The method currently creates unnecessary memory through inefficient structures, including multiple separate arrays for different rounds of review, which could be simplified into a 2D array structure.&lt;br /&gt;
* &amp;lt;b&amp;gt;Code Smells&amp;lt;/b&amp;gt;: The code has redundant methods, unclear variable names, inefficient loops, and overly long method names.&lt;br /&gt;
&lt;br /&gt;
=== Objectives &amp;amp; Requirements ===&lt;br /&gt;
1. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Address the DRY violation by consolidating the containers for review rounds.&lt;br /&gt;
* Generalize the code to handle both cases—when rubrics vary by round and when they do not—without duplicating code.&lt;br /&gt;
* Introduce efficient data structures, like a 2D array, to replace multiple arrays and reduce memory usage.&lt;br /&gt;
&lt;br /&gt;
2. Separate Responsibilities Using Visitor Pattern (&amp;lt;i&amp;gt;stretch goal&amp;lt;/i&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
* Extract the email method using the Visitor pattern to modularize email functionality. Alternatively, select a design pattern better suited to organizing this method if available. Note that the email method is not properly used in its current location and is better suited to the Response class rather than ResponseMap.&lt;br /&gt;
&lt;br /&gt;
3. Eliminate Redundant Methods&lt;br /&gt;
&lt;br /&gt;
* Remove methods that do not serve a clear purpose and improve method naming for clarity.&lt;br /&gt;
* Aim to address any redundant meta-review functionality, as indicated by the professor's preference to remove these from response_map.rb.&lt;br /&gt;
&lt;br /&gt;
4. Refactor for Code Clarity and Efficiency&lt;br /&gt;
&lt;br /&gt;
* Improve variable names, reduce unnecessary loops, and replace long method names with concise, intuitive alternatives.&lt;br /&gt;
* Ensure that each method has a single, clearly defined purpose, improving code readability.&lt;br /&gt;
&lt;br /&gt;
5. Testing and Documentation&lt;br /&gt;
&lt;br /&gt;
* Write comprehensive tests for all newly implemented and modified methods to ensure reliability.&lt;br /&gt;
* Add detailed comments to facilitate code maintenance and understanding for future developers.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Design Principles ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Single Responsibility Principle (SRP)&amp;lt;/b&amp;gt;: Each method and class should have a single, well-defined purpose.&lt;br /&gt;
* &amp;lt;b&amp;gt;Don’t Repeat Yourself (DRY)&amp;lt;/b&amp;gt;: Eliminate redundancy by creating general solutions that handle multiple scenarios.&lt;br /&gt;
* &amp;lt;b&amp;gt;Ruby Readability Guidelines (Week 9 Notes)&amp;lt;/b&amp;gt;:&lt;br /&gt;
** Guideline: Variable names should be neither too short nor too long.&lt;br /&gt;
** Guideline: Names should not be redundant.&lt;br /&gt;
** Guideline: &amp;lt;b&amp;gt;A method should do only one thing and do it well.&amp;lt;/b&amp;gt;&lt;br /&gt;
* &amp;lt;b&amp;gt;Visitor Pattern&amp;lt;/b&amp;gt;: Utilize this pattern to separate emailing functionalities from the main class.&lt;br /&gt;
&lt;br /&gt;
=== Implementation Plan ===&lt;br /&gt;
&lt;br /&gt;
The refactoring will proceed as follows:&lt;br /&gt;
&lt;br /&gt;
1. Analyze and Refactor Current Code Structure&lt;br /&gt;
&lt;br /&gt;
* Review and understand the existing structure and dependencies within feedback_response_map.rb.&lt;br /&gt;
* Identify areas of redundancy, complexity, and inefficiency, particularly in feedback_response_report, to create a clear plan for refactoring.&lt;br /&gt;
* Try to reduce character count and improve readability with aliasing (this way we do not break any code that relies on being able to call specific methods).&lt;br /&gt;
&lt;br /&gt;
2. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Consolidate containers for each review round to address DRY violations. By using a single structure to store review data, we will eliminate hard-coded repetition.&lt;br /&gt;
* Generalize logic to accommodate both scenarios where rubrics vary by round and where they do not, without duplicating code paths.&lt;br /&gt;
* Replace inefficient structures, such as multiple arrays, with more flexible and memory-efficient options, like a 2D array or a hash, to reduce memory usage and improve scalability.&lt;br /&gt;
&lt;br /&gt;
3. Introduce Helper Methods for Reusable Logic (for feedback_response_report)&lt;br /&gt;
&lt;br /&gt;
* Extract frequently used or complex code blocks into helper methods, reducing the size of primary methods and enhancing reusability.&lt;br /&gt;
* Use helper methods for specific actions, like handling rounds or retrieving assignment data, to make the code cleaner and better organized.&lt;br /&gt;
* Emphasis on adhering to the guideline: A method should do only one thing and do it well.&lt;br /&gt;
&lt;br /&gt;
4. Research Future Refactoring for email Method&lt;br /&gt;
&lt;br /&gt;
* The email method is convoluted and the functionality should be refactored into a different class in the future.&lt;br /&gt;
* This is because this visitor pattern violation is present in many classes, and is beyond the scope of a one-class re-implementation.&lt;br /&gt;
&lt;br /&gt;
5. Improve Variable Naming and Structure&lt;br /&gt;
&lt;br /&gt;
* Replace ambiguous variable names with clearer alternatives that convey purpose, such as renaming @temp_review_responses and @temp_response_map_ids to more meaningful names.&lt;br /&gt;
* Simplify long method names to make the code more readable and approachable for new contributors.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Analyze and Refactor Current Code Structure&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before refactoring, the FeedbackResponseMap class contains 6 methods, with the majority of the code in self.feedback_response_report:&lt;br /&gt;
&lt;br /&gt;
[[File:FeedbackResponseMap_before.png |250px]]&lt;br /&gt;
&lt;br /&gt;
We aim to change that by splitting up this method into three helper methods, as seen in the following:&lt;br /&gt;
&lt;br /&gt;
[[File:FeedbackResponseMap_after.png |350px]]&lt;br /&gt;
&lt;br /&gt;
To go into more detail, here is the code for the feedback_response_report method, and how we intend to split it up:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_after_code1.png |600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_after_code2.png |600px]]&lt;br /&gt;
&lt;br /&gt;
The red section of code will be self.get_feedback_authors, yellow will be self.varying_rubrics_report, and green will be self.static_rubrics_report. Each separated group will be its own method, and self.varying_rubrics_report and self.static_rubrics_report (the yellow and green methods) will be returned at the end of the new feedback_response_report.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Refactor the feedback_response_report Method&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following are the original arrays used to statically represent the review rounds.&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-OriginalArrayRounds.png]]&lt;br /&gt;
&lt;br /&gt;
We can take these multiple arrays, and use dictionaries instead, where each round is called by its key value (integer value). &lt;br /&gt;
&lt;br /&gt;
[[File:E2451-UpdatedArraysMain.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
The code found in the feedback_response_report method that use the arrays were moved to the two helper methods, seen as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-UpdatedArrays1.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-UpdatedArrays2.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
Additionally, Rubocop was used to analyze the code and adhere to proper Ruby Guidelines. The command below was used to search for any code smells that we missed.&lt;br /&gt;
&lt;br /&gt;
   rubocop app/models/feedback_response_map.rb&lt;br /&gt;
&lt;br /&gt;
Originally, there were only three offenses, but this largely grew as we continued to refactor the code. All of the offenses can be seen below:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-Rubocop1.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-Rubocop2.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-Rubocop3.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-Rubocop4.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
All of these offenses were fixed. The following three offenses were the original ones. For the first and third offenses, the colon after the method headers were simply removed. For the second offense, the “return” keyword caused errors, thus, it was removed, because a ruby method will return  its last statement. The two other private methods containing “return” also had that keyword removed. &lt;br /&gt;
&lt;br /&gt;
[[File:E2451-RubocopOriginal.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
Lastly, commenting was added throughout the files, to improve readability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Introduce Helper Methods for Reusable Logic (for feedback_response_report)&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As planned in step 1, the feedback_response_report method was split up into 3 private helper methods: get_feedback_authors(id), varying_rubrics_report(review_responses, response_map_ids), and static_rubrics_report(review_responses, response_map_ids). One change we made that was different from the UML diagram was the addition of an id parameter in the get_feedback_authors method, in order to access id, since it was a parameter given to feedback_response_report. Each helper method was planned in order to stick to the guideline of “A method should do only one thing and do it well.”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Final UML for FeedbackResponseMap&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_FeedbackResponseMap_final.drawio.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Authors&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This image contains comments showing what the implementation looked like before:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_authors_before_1.png]]&lt;br /&gt;
&lt;br /&gt;
This image shows the construction of the private method we implemented to replace it, reducing complexity and improving readability in the process:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_authors_after_1.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Report&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This image contains comments showing what the implementation looked like before:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_reports_before_1.png]]&lt;br /&gt;
&lt;br /&gt;
These images show the construction of the private methods we implemented to replace it, reducing complexity and improving readability in the process:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_reports_varying_1.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_report_static_1.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Notice that in both the original self.feedback_response_report method and the private methods, comments are included to explain each non-obvious step of the process.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Complexity changes&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Previously, Rubocop reported the following failures on behalf of the self.feedback_response_report method:&lt;br /&gt;
&lt;br /&gt;
  Metrics/PerceivedComplexity: Perceived complexity for feedback_response_report is too high. [14/8]&lt;br /&gt;
  Metrics/CyclomaticComplexity: Cyclomatic complexity for feedback_response_report is too high. [12/7]&lt;br /&gt;
  Metrics/AbcSize: Assignment Branch Condition size for feedback_response_report is too high. [&amp;lt;14, 46, 16&amp;gt; 50.68/20]&lt;br /&gt;
&lt;br /&gt;
Now, neither self.feedback_response_report nor any of its associated private methods trigger any of these Metric violations!&lt;br /&gt;
(Note that the email method does trigger a AbcSize violation when the protective comments are removed, but adjusting that method is beyond the scope of this project for reasons listed in the Implementation Plan)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Research Future Refactoring for email Method&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As discussed in the implementation plan, the email method was left as is. Any changes would require the addition of a new class and/or major refactoring for the functionality.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. Improve Variable Naming and Structure&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The two sets of variables discussed in the plan, @temp_response_map_ids and @temp_review_responses were modified as needed. First, the @temp_response_map_ids was moved to the helper methods varying_rubrics_report and static_rubrics_report, to be initialized, and changed to response_map_ids.&lt;br /&gt;
&lt;br /&gt;
Secondly, @temp_review_responses was changed to review_responses in the helper methods that call it: varying_rubrics_report and static_rubrics_report&lt;br /&gt;
&lt;br /&gt;
=== Testing ===&lt;br /&gt;
&lt;br /&gt;
1. Adapt Existing Tests for Refactored Methods&lt;br /&gt;
&lt;br /&gt;
* Any new helper methods will be private, and so by the &amp;quot;Magic Tricks of Testing&amp;quot; guide, should not be tested (both query and command messages sent to self are ignored in the test plan).&lt;br /&gt;
* Use mocks to isolate components during testing, especially for external dependencies like Mailer, to ensure that email functionality works as expected without direct integration.&lt;br /&gt;
&lt;br /&gt;
2. Document Code for Clarity&lt;br /&gt;
&lt;br /&gt;
* Write detailed comments explaining the purpose of each method, input and output, and any critical logic that might be complex for future developers to understand.&lt;br /&gt;
* Create or update documentation and diagrams to illustrate the newly designed structure, making it easier for new developers to contribute or modify functionality.&lt;br /&gt;
&lt;br /&gt;
=== Documentation ===&lt;br /&gt;
&lt;br /&gt;
Ensure all code is well-documented, with comments explaining purpose, inputs, outputs, and any complex logic. Maintain updated documentation for all modified and newly added classes and methods, allowing for ease of understanding and maintenance.&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
&lt;br /&gt;
By refactoring feedback_response_map.rb, this project will enhance Expertiza’s backend maintainability and readability, ensuring a modular, efficient, and more secure implementation.&lt;br /&gt;
&lt;br /&gt;
== Team Information ==&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
* Chaitanya Srusti (crsrusti@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
=== Members ===&lt;br /&gt;
&lt;br /&gt;
* Sarah Daniel (sdaniel8@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* William Grochocinski (wagrocho@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Tipton Middleton (tgmiddl2@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* ChatGPT (Honorary Member)&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=160400</id>
		<title>CSC/ECE 517 Fall 2024 - E2451. Reimplement feedback response map.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=160400"/>
		<updated>2024-12-04T01:29:19Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2451: Reimplement feedback response map'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions, among other tasks. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
=== Project Overview ===&lt;br /&gt;
&lt;br /&gt;
The goal of this project is to refactor the feedback_response_map.rb file from the Expertiza repository and integrate it into the reimplementation-back-end repository. Within Expertiza, when a user submits a review, an instance of the Response class is created, associated with a ResponseMap. Each ResponseMap links a reviewer (reviewer_id), reviewee (reviewee_id), and the reviewed item (reviewed_object_id). FeedbackResponseMap, a subclass of ResponseMap, represents the feedback provided by a reviewee on the feedback received for their submission.&lt;br /&gt;
&lt;br /&gt;
This class has significant room for improvement, especially with respect to object-oriented principles. Refactoring feedback_response_map.rb will streamline functionality, enhance maintainability, and improve adherence to coding standards.&lt;br /&gt;
&lt;br /&gt;
=== Current Implementation ===&lt;br /&gt;
&lt;br /&gt;
The current feedback_response_map.rb in the Expertiza repository has several issues. It includes the following problems:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Poor adherence to SOLID and DRY principles&amp;lt;/b&amp;gt;: The current code structure introduces unnecessary repetition and complexity.&lt;br /&gt;
* &amp;lt;b&amp;gt;feedback_response_report Method Issues&amp;lt;/b&amp;gt;: This critical method is highly complex, relying on custom data structures and separate containers for each review round, resulting in a DRY violation.&lt;br /&gt;
* &amp;lt;b&amp;gt;Improper Responsibility Assignment&amp;lt;/b&amp;gt;: The email method does not belong within this class and would benefit from refactoring out into a separate class using the Visitor pattern. This pattern is suggested to streamline functionality, though alternative design patterns may be considered if more suitable.&lt;br /&gt;
* &amp;lt;b&amp;gt;Memory Inefficiencies&amp;lt;/b&amp;gt;: The method currently creates unnecessary memory through inefficient structures, including multiple separate arrays for different rounds of review, which could be simplified into a 2D array structure.&lt;br /&gt;
* &amp;lt;b&amp;gt;Code Smells&amp;lt;/b&amp;gt;: The code has redundant methods, unclear variable names, inefficient loops, and overly long method names.&lt;br /&gt;
&lt;br /&gt;
=== Objectives &amp;amp; Requirements ===&lt;br /&gt;
1. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Address the DRY violation by consolidating the containers for review rounds.&lt;br /&gt;
* Generalize the code to handle both cases—when rubrics vary by round and when they do not—without duplicating code.&lt;br /&gt;
* Introduce efficient data structures, like a 2D array, to replace multiple arrays and reduce memory usage.&lt;br /&gt;
&lt;br /&gt;
2. Separate Responsibilities Using Visitor Pattern (&amp;lt;i&amp;gt;stretch goal&amp;lt;/i&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
* Extract the email method using the Visitor pattern to modularize email functionality. Alternatively, select a design pattern better suited to organizing this method if available. Note that the email method is not properly used in its current location and is better suited to the Response class rather than ResponseMap.&lt;br /&gt;
&lt;br /&gt;
3. Eliminate Redundant Methods&lt;br /&gt;
&lt;br /&gt;
* Remove methods that do not serve a clear purpose and improve method naming for clarity.&lt;br /&gt;
* Aim to address any redundant meta-review functionality, as indicated by the professor's preference to remove these from response_map.rb.&lt;br /&gt;
&lt;br /&gt;
4. Refactor for Code Clarity and Efficiency&lt;br /&gt;
&lt;br /&gt;
* Improve variable names, reduce unnecessary loops, and replace long method names with concise, intuitive alternatives.&lt;br /&gt;
* Ensure that each method has a single, clearly defined purpose, improving code readability.&lt;br /&gt;
&lt;br /&gt;
5. Testing and Documentation&lt;br /&gt;
&lt;br /&gt;
* Write comprehensive tests for all newly implemented and modified methods to ensure reliability.&lt;br /&gt;
* Add detailed comments to facilitate code maintenance and understanding for future developers.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Design Principles ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Single Responsibility Principle (SRP)&amp;lt;/b&amp;gt;: Each method and class should have a single, well-defined purpose.&lt;br /&gt;
* &amp;lt;b&amp;gt;Don’t Repeat Yourself (DRY)&amp;lt;/b&amp;gt;: Eliminate redundancy by creating general solutions that handle multiple scenarios.&lt;br /&gt;
* &amp;lt;b&amp;gt;Ruby Readability Guidelines (Week 9 Notes)&amp;lt;/b&amp;gt;:&lt;br /&gt;
** Guideline: Variable names should be neither too short nor too long.&lt;br /&gt;
** Guideline: Names should not be redundant.&lt;br /&gt;
** Guideline: &amp;lt;b&amp;gt;A method should do only one thing and do it well.&amp;lt;/b&amp;gt;&lt;br /&gt;
* &amp;lt;b&amp;gt;Visitor Pattern&amp;lt;/b&amp;gt;: Utilize this pattern to separate emailing functionalities from the main class.&lt;br /&gt;
&lt;br /&gt;
=== Implementation Plan ===&lt;br /&gt;
&lt;br /&gt;
The refactoring will proceed as follows:&lt;br /&gt;
&lt;br /&gt;
1. Analyze and Refactor Current Code Structure&lt;br /&gt;
&lt;br /&gt;
* Review and understand the existing structure and dependencies within feedback_response_map.rb.&lt;br /&gt;
* Identify areas of redundancy, complexity, and inefficiency, particularly in feedback_response_report, to create a clear plan for refactoring.&lt;br /&gt;
* Try to reduce character count and improve readability with aliasing (this way we do not break any code that relies on being able to call specific methods).&lt;br /&gt;
&lt;br /&gt;
2. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Consolidate containers for each review round to address DRY violations. By using a single structure to store review data, we will eliminate hard-coded repetition.&lt;br /&gt;
* Generalize logic to accommodate both scenarios where rubrics vary by round and where they do not, without duplicating code paths.&lt;br /&gt;
* Replace inefficient structures, such as multiple arrays, with more flexible and memory-efficient options, like a 2D array or a hash, to reduce memory usage and improve scalability.&lt;br /&gt;
&lt;br /&gt;
3. Introduce Helper Methods for Reusable Logic (for feedback_response_report)&lt;br /&gt;
&lt;br /&gt;
* Extract frequently used or complex code blocks into helper methods, reducing the size of primary methods and enhancing reusability.&lt;br /&gt;
* Use helper methods for specific actions, like handling rounds or retrieving assignment data, to make the code cleaner and better organized.&lt;br /&gt;
* Emphasis on adhering to the guideline: A method should do only one thing and do it well.&lt;br /&gt;
&lt;br /&gt;
4. Research Future Refactoring for email Method&lt;br /&gt;
&lt;br /&gt;
* The email method is convoluted and the functionality should be refactored into a different class in the future.&lt;br /&gt;
* This is because this visitor pattern violation is present in many classes, and is beyond the scope of a one-class re-implementation.&lt;br /&gt;
&lt;br /&gt;
5. Improve Variable Naming and Structure&lt;br /&gt;
&lt;br /&gt;
* Replace ambiguous variable names with clearer alternatives that convey purpose, such as renaming @temp_review_responses and @temp_response_map_ids to more meaningful names.&lt;br /&gt;
* Simplify long method names to make the code more readable and approachable for new contributors.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Analyze and Refactor Current Code Structure&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before refactoring, the FeedbackResponseMap class contains 6 methods, with the majority of the code in self.feedback_response_report:&lt;br /&gt;
&lt;br /&gt;
[[File:FeedbackResponseMap_before.png |250px]]&lt;br /&gt;
&lt;br /&gt;
We aim to change that by splitting up this method into three helper methods, as seen in the following:&lt;br /&gt;
&lt;br /&gt;
[[File:FeedbackResponseMap_after.png |350px]]&lt;br /&gt;
&lt;br /&gt;
To go into more detail, here is the code for the feedback_response_report method, and how we intend to split it up:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_after_code1.png |600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_after_code2.png |600px]]&lt;br /&gt;
&lt;br /&gt;
The red section of code will be self.get_feedback_authors, yellow will be self.varying_rubrics_report, and green will be self.static_rubrics_report. Each separated group will be its own method, and self.varying_rubrics_report and self.static_rubrics_report (the yellow and green methods) will be returned at the end of the new feedback_response_report.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Refactor the feedback_response_report Method&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following are the original arrays used to statically represent the review rounds.&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-OriginalArrayRounds.png]]&lt;br /&gt;
&lt;br /&gt;
We can take these multiple arrays, and use dictionaries instead, where each round is called by its key value (integer value). &lt;br /&gt;
&lt;br /&gt;
[[File:E2451-UpdatedArraysMain.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
The code found in the feedback_response_report method that use the arrays were moved to the two helper methods, seen as follows:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-UpdatedArrays1.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-UpdatedArrays2.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
Additionally, Rubocop was used to analyze the code and adhere to proper Ruby Guidelines. The command below was used to search for any code smells that we missed.&lt;br /&gt;
&lt;br /&gt;
   rubocop app/models/feedback_response_map.rb&lt;br /&gt;
&lt;br /&gt;
Originally, there were only three offenses, but this largely grew as we continued to refactor the code. All of the offenses can be seen below:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-Rubocop1.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-Rubocop2.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-Rubocop3.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-Rubocop4.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
All of these offenses were fixed. The following three offenses were the original ones. For the first and third offenses, the colon after the method headers were simply removed. For the second offense, the “return” keyword caused errors, thus, it was removed, because a ruby method will return  its last statement. The two other private methods containing “return” also had that keyword removed. &lt;br /&gt;
&lt;br /&gt;
[[File:E2451-RubocopOriginal.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
Lastly, commenting was added throughout the files, to improve readability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Introduce Helper Methods for Reusable Logic (for feedback_response_report)&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As planned in step 1, the feedback_response_report method was split up into 3 private helper methods: get_feedback_authors(id), varying_rubrics_report(review_responses, response_map_ids), and static_rubrics_report(review_responses, response_map_ids). One change we made that was different from the UML diagram was the addition of an id parameter in the get_feedback_authors method, in order to ____. Each helper method was planned in order to stick to the guideline of “A method should do only one thing and do it well.”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Final UML for FeedbackResponseMap&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_FeedbackResponseMap_final.drawio.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Authors&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This image contains comments showing what the implementation looked like before:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_authors_before_1.png]]&lt;br /&gt;
&lt;br /&gt;
This image shows the construction of the private method we implemented to replace it, reducing complexity and improving readability in the process:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_authors_after_1.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Report&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This image contains comments showing what the implementation looked like before:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_reports_before_1.png]]&lt;br /&gt;
&lt;br /&gt;
These images show the construction of the private methods we implemented to replace it, reducing complexity and improving readability in the process:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_reports_varying_1.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_report_static_1.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Notice that in both the original self.feedback_response_report method and the private methods, comments are included to explain each non-obvious step of the process.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Complexity changes&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Previously, Rubocop reported the following failures on behalf of the self.feedback_response_report method:&lt;br /&gt;
&lt;br /&gt;
  Metrics/PerceivedComplexity: Perceived complexity for feedback_response_report is too high. [14/8]&lt;br /&gt;
  Metrics/CyclomaticComplexity: Cyclomatic complexity for feedback_response_report is too high. [12/7]&lt;br /&gt;
  Metrics/AbcSize: Assignment Branch Condition size for feedback_response_report is too high. [&amp;lt;14, 46, 16&amp;gt; 50.68/20]&lt;br /&gt;
&lt;br /&gt;
Now, neither self.feedback_response_report nor any of its associated private methods trigger any of these Metric violations!&lt;br /&gt;
(Note that the email method does trigger a AbcSize violation when the protective comments are removed, but adjusting that method is beyond the scope of this project for reasons listed in the Implementation Plan)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Research Future Refactoring for email Method&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As discussed in the implementation plan, the email method was left as is. Any changes would require the addition of a new class and/or major refactoring for the functionality.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. Improve Variable Naming and Structure&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The two sets of variables discussed in the plan, @temp_response_map_ids and @temp_review_responses were modified as needed. First, the @temp_response_map_ids was moved to the helper methods varying_rubrics_report and static_rubrics_report, to be initialized, and changed to response_map_ids.&lt;br /&gt;
&lt;br /&gt;
Secondly, @temp_review_responses was changed to review_responses in the helper methods that call it: varying_rubrics_report and static_rubrics_report&lt;br /&gt;
&lt;br /&gt;
=== Testing ===&lt;br /&gt;
&lt;br /&gt;
1. Adapt Existing Tests for Refactored Methods&lt;br /&gt;
&lt;br /&gt;
* Any new helper methods will be private, and so by the &amp;quot;Magic Tricks of Testing&amp;quot; guide, should not be tested (both query and command messages sent to self are ignored in the test plan).&lt;br /&gt;
* Use mocks to isolate components during testing, especially for external dependencies like Mailer, to ensure that email functionality works as expected without direct integration.&lt;br /&gt;
&lt;br /&gt;
2. Document Code for Clarity&lt;br /&gt;
&lt;br /&gt;
* Write detailed comments explaining the purpose of each method, input and output, and any critical logic that might be complex for future developers to understand.&lt;br /&gt;
* Create or update documentation and diagrams to illustrate the newly designed structure, making it easier for new developers to contribute or modify functionality.&lt;br /&gt;
&lt;br /&gt;
=== Documentation ===&lt;br /&gt;
&lt;br /&gt;
Ensure all code is well-documented, with comments explaining purpose, inputs, outputs, and any complex logic. Maintain updated documentation for all modified and newly added classes and methods, allowing for ease of understanding and maintenance.&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
&lt;br /&gt;
By refactoring feedback_response_map.rb, this project will enhance Expertiza’s backend maintainability and readability, ensuring a modular, efficient, and more secure implementation.&lt;br /&gt;
&lt;br /&gt;
== Team Information ==&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
* Chaitanya Srusti (crsrusti@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
=== Members ===&lt;br /&gt;
&lt;br /&gt;
* Sarah Daniel (sdaniel8@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* William Grochocinski (wagrocho@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Tipton Middleton (tgmiddl2@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* ChatGPT (Honorary Member)&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2451-UpdatedArrays2.png&amp;diff=160399</id>
		<title>File:E2451-UpdatedArrays2.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2451-UpdatedArrays2.png&amp;diff=160399"/>
		<updated>2024-12-04T01:27:48Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2451-UpdatedArrays1.png&amp;diff=160398</id>
		<title>File:E2451-UpdatedArrays1.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2451-UpdatedArrays1.png&amp;diff=160398"/>
		<updated>2024-12-04T01:27:14Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2451-UpdatedArraysMain.png&amp;diff=160397</id>
		<title>File:E2451-UpdatedArraysMain.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2451-UpdatedArraysMain.png&amp;diff=160397"/>
		<updated>2024-12-04T01:26:43Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2451-OriginalArrayRounds.png&amp;diff=160387</id>
		<title>File:E2451-OriginalArrayRounds.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2451-OriginalArrayRounds.png&amp;diff=160387"/>
		<updated>2024-12-04T00:52:02Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=160305</id>
		<title>CSC/ECE 517 Fall 2024 - E2451. Reimplement feedback response map.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=160305"/>
		<updated>2024-12-03T23:47:22Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2451: Reimplement feedback response map'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions, among other tasks. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
=== Project Overview ===&lt;br /&gt;
&lt;br /&gt;
The goal of this project is to refactor the feedback_response_map.rb file from the Expertiza repository and integrate it into the reimplementation-back-end repository. Within Expertiza, when a user submits a review, an instance of the Response class is created, associated with a ResponseMap. Each ResponseMap links a reviewer (reviewer_id), reviewee (reviewee_id), and the reviewed item (reviewed_object_id). FeedbackResponseMap, a subclass of ResponseMap, represents the feedback provided by a reviewee on the feedback received for their submission.&lt;br /&gt;
&lt;br /&gt;
This class has significant room for improvement, especially with respect to object-oriented principles. Refactoring feedback_response_map.rb will streamline functionality, enhance maintainability, and improve adherence to coding standards.&lt;br /&gt;
&lt;br /&gt;
=== Current Implementation ===&lt;br /&gt;
&lt;br /&gt;
The current feedback_response_map.rb in the Expertiza repository has several issues. It includes the following problems:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Poor adherence to SOLID and DRY principles&amp;lt;/b&amp;gt;: The current code structure introduces unnecessary repetition and complexity.&lt;br /&gt;
* &amp;lt;b&amp;gt;feedback_response_report Method Issues&amp;lt;/b&amp;gt;: This critical method is highly complex, relying on custom data structures and separate containers for each review round, resulting in a DRY violation.&lt;br /&gt;
* &amp;lt;b&amp;gt;Improper Responsibility Assignment&amp;lt;/b&amp;gt;: The email method does not belong within this class and would benefit from refactoring out into a separate class using the Visitor pattern. This pattern is suggested to streamline functionality, though alternative design patterns may be considered if more suitable.&lt;br /&gt;
* &amp;lt;b&amp;gt;Memory Inefficiencies&amp;lt;/b&amp;gt;: The method currently creates unnecessary memory through inefficient structures, including multiple separate arrays for different rounds of review, which could be simplified into a 2D array structure.&lt;br /&gt;
* &amp;lt;b&amp;gt;Code Smells&amp;lt;/b&amp;gt;: The code has redundant methods, unclear variable names, inefficient loops, and overly long method names.&lt;br /&gt;
&lt;br /&gt;
=== Objectives &amp;amp; Requirements ===&lt;br /&gt;
1. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Address the DRY violation by consolidating the containers for review rounds.&lt;br /&gt;
* Generalize the code to handle both cases—when rubrics vary by round and when they do not—without duplicating code.&lt;br /&gt;
* Introduce efficient data structures, like a 2D array, to replace multiple arrays and reduce memory usage.&lt;br /&gt;
&lt;br /&gt;
2. Separate Responsibilities Using Visitor Pattern (&amp;lt;i&amp;gt;stretch goal&amp;lt;/i&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
* Extract the email method using the Visitor pattern to modularize email functionality. Alternatively, select a design pattern better suited to organizing this method if available. Note that the email method is not properly used in its current location and is better suited to the Response class rather than ResponseMap.&lt;br /&gt;
&lt;br /&gt;
3. Eliminate Redundant Methods&lt;br /&gt;
&lt;br /&gt;
* Remove methods that do not serve a clear purpose and improve method naming for clarity.&lt;br /&gt;
* Aim to address any redundant meta-review functionality, as indicated by the professor's preference to remove these from response_map.rb.&lt;br /&gt;
&lt;br /&gt;
4. Refactor for Code Clarity and Efficiency&lt;br /&gt;
&lt;br /&gt;
* Improve variable names, reduce unnecessary loops, and replace long method names with concise, intuitive alternatives.&lt;br /&gt;
* Ensure that each method has a single, clearly defined purpose, improving code readability.&lt;br /&gt;
&lt;br /&gt;
5. Testing and Documentation&lt;br /&gt;
&lt;br /&gt;
* Write comprehensive tests for all newly implemented and modified methods to ensure reliability.&lt;br /&gt;
* Add detailed comments to facilitate code maintenance and understanding for future developers.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Design Principles ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Single Responsibility Principle (SRP)&amp;lt;/b&amp;gt;: Each method and class should have a single, well-defined purpose.&lt;br /&gt;
* &amp;lt;b&amp;gt;Don’t Repeat Yourself (DRY)&amp;lt;/b&amp;gt;: Eliminate redundancy by creating general solutions that handle multiple scenarios.&lt;br /&gt;
* &amp;lt;b&amp;gt;Ruby Readability Guidelines (Week 9 Notes)&amp;lt;/b&amp;gt;:&lt;br /&gt;
** Guideline: Variable names should be neither too short nor too long.&lt;br /&gt;
** Guideline: Names should not be redundant.&lt;br /&gt;
** Guideline: &amp;lt;b&amp;gt;A method should do only one thing and do it well.&amp;lt;/b&amp;gt;&lt;br /&gt;
* &amp;lt;b&amp;gt;Visitor Pattern&amp;lt;/b&amp;gt;: Utilize this pattern to separate emailing functionalities from the main class.&lt;br /&gt;
&lt;br /&gt;
=== Implementation Plan ===&lt;br /&gt;
&lt;br /&gt;
The refactoring will proceed as follows:&lt;br /&gt;
&lt;br /&gt;
1. Analyze and Refactor Current Code Structure&lt;br /&gt;
&lt;br /&gt;
* Review and understand the existing structure and dependencies within feedback_response_map.rb.&lt;br /&gt;
* Identify areas of redundancy, complexity, and inefficiency, particularly in feedback_response_report, to create a clear plan for refactoring.&lt;br /&gt;
* Try to reduce character count and improve readability with aliasing (this way we do not break any code that relies on being able to call specific methods).&lt;br /&gt;
&lt;br /&gt;
2. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Consolidate containers for each review round to address DRY violations. By using a single structure to store review data, we will eliminate hard-coded repetition.&lt;br /&gt;
* Generalize logic to accommodate both scenarios where rubrics vary by round and where they do not, without duplicating code paths.&lt;br /&gt;
* Replace inefficient structures, such as multiple arrays, with more flexible and memory-efficient options, like a 2D array or a hash, to reduce memory usage and improve scalability.&lt;br /&gt;
&lt;br /&gt;
3. Introduce Helper Methods for Reusable Logic (for feedback_response_report)&lt;br /&gt;
&lt;br /&gt;
* Extract frequently used or complex code blocks into helper methods, reducing the size of primary methods and enhancing reusability.&lt;br /&gt;
* Use helper methods for specific actions, like handling rounds or retrieving assignment data, to make the code cleaner and better organized.&lt;br /&gt;
* Emphasis on adhering to the guideline: A method should do only one thing and do it well.&lt;br /&gt;
&lt;br /&gt;
4. Research Future Refactoring for email Method&lt;br /&gt;
&lt;br /&gt;
* The email method is convoluted and the functionality should be refactored into a different class in the future.&lt;br /&gt;
* This is because this visitor pattern violation is present in many classes, and is beyond the scope of a one-class re-implementation.&lt;br /&gt;
&lt;br /&gt;
5. Improve Variable Naming and Structure&lt;br /&gt;
&lt;br /&gt;
* Replace ambiguous variable names with clearer alternatives that convey purpose, such as renaming @temp_review_responses and @temp_response_map_ids to more meaningful names.&lt;br /&gt;
* Simplify long method names to make the code more readable and approachable for new contributors.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Analyze and Refactor Current Code Structure&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before refactoring, the FeedbackResponseMap class contains 6 methods, with the majority of the code in self.feedback_response_report:&lt;br /&gt;
&lt;br /&gt;
[[File:FeedbackResponseMap_before.png |250px]]&lt;br /&gt;
&lt;br /&gt;
We aim to change that by splitting up this method into three helper methods, as seen in the following:&lt;br /&gt;
&lt;br /&gt;
[[File:FeedbackResponseMap_after.png |350px]]&lt;br /&gt;
&lt;br /&gt;
To go into more detail, here is the code for the feedback_response_report method, and how we intend to split it up:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_after_code1.png |600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_after_code2.png |600px]]&lt;br /&gt;
&lt;br /&gt;
The red section of code will be self.get_feedback_authors, yellow will be self.varying_rubrics_report, and green will be self.static_rubrics_report. Each separated group will be its own method, and self.varying_rubrics_report and self.static_rubrics_report (the yellow and green methods) will be returned at the end of the new feedback_response_report.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Refactor the feedback_response_report Method&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can take the multiple arrays found to represent rounds, and use dictionaries instead, where each round is called by its key value (integer value). &lt;br /&gt;
&lt;br /&gt;
INSERT PIC OF BEFORE AND AFTER OF ARRAYS/DICTS HERE&lt;br /&gt;
&lt;br /&gt;
Additionally, Rubocop was used to analyze the code and adhere to proper Ruby Guidelines. The command below was used to search for any code smells that we missed.&lt;br /&gt;
&lt;br /&gt;
   rubocop app/models/feedback_response_map.rb&lt;br /&gt;
&lt;br /&gt;
Originally, there were only three offenses, but this largely grew as we continued to refactor the code. All of the offenses can be seen below:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-Rubocop1.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-Rubocop2.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-Rubocop3.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451-Rubocop4.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
All of these offenses were fixed. The following three offenses were the original ones. For the first and third offenses, the colon after the method headers were simply removed. For the second offense, the “return” keyword caused errors, thus, it was removed, because a ruby method will return  its last statement. The two other private methods containing “return” also had that keyword removed. &lt;br /&gt;
&lt;br /&gt;
[[File:E2451-RubocopOriginal.png | 600px]]&lt;br /&gt;
&lt;br /&gt;
Lastly, commenting was added throughout the files, to improve readability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Introduce Helper Methods for Reusable Logic (for feedback_response_report)&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As planned in step 1, the feedback_response_report method was split up into 3 private helper methods: get_feedback_authors(id), varying_rubrics_report(review_responses, response_map_ids), and static_rubrics_report(review_responses, response_map_ids). One change we made that was different from the UML diagram was the addition of an id parameter in the get_feedback_authors method, in order to ____. Each helper method was planned in order to stick to the guideline of “A method should do only one thing and do it well.”&lt;br /&gt;
&lt;br /&gt;
INSERT UPDATED UML DIAGRAM AND NEW IMAGES OF THE FILES&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Research future refactoring for email method&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. Improve variable naming and structure&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Authors====&lt;br /&gt;
&lt;br /&gt;
This image contains comments showing what the implementation looked like before:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_authors_before.png]]&lt;br /&gt;
&lt;br /&gt;
This image shows the construction of the private method we implemented to replace it, reducing complexity and improving readability in the process:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_authors_after.png]]&lt;br /&gt;
&lt;br /&gt;
====Report====&lt;br /&gt;
&lt;br /&gt;
This image contains comments showing what the implementation looked like before:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_reports_before.png]]&lt;br /&gt;
&lt;br /&gt;
These images show the construction of the private methods we implemented to replace it, reducing complexity and improving readability in the process:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_reports_varying.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_report_static.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Notice that in both the original self.feedback_response_report method and the private methods, comments are included to explain each non-obvious step of the process.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[MAYBE ADD COMPLEXITY METRICS BEFORE AND AFTER HERE?]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. Research Future Refactoring for email Method&lt;br /&gt;
&lt;br /&gt;
As discussed in the implementation plan, the email method was left as is. Any changes would require the addition of a new class and/or major refactoring for the functionality.&lt;br /&gt;
&lt;br /&gt;
5. Improve Variable Naming and Structure&lt;br /&gt;
&lt;br /&gt;
The two sets of variables discussed in the plan, @temp_response_map_ids and @temp_review_responses were modified as needed. First, the @temp_response_map_ids was moved to the helper methods varying_rubrics_report and static_rubrics_report, to be initialized, and changed to response_map_ids.&lt;br /&gt;
&lt;br /&gt;
Secondly, @temp_review_responses was changed to review_responses in the helper methods that call it: varying_rubrics_report and static_rubrics_report&lt;br /&gt;
&lt;br /&gt;
=== Testing ===&lt;br /&gt;
&lt;br /&gt;
1. Adapt Existing Tests for Refactored Methods&lt;br /&gt;
&lt;br /&gt;
* Any new helper methods will be private, and so by the &amp;quot;Magic Tricks of Testing&amp;quot; guide, should not be tested (both query and command messages sent to self are ignored in the test plan).&lt;br /&gt;
* Use mocks to isolate components during testing, especially for external dependencies like Mailer, to ensure that email functionality works as expected without direct integration.&lt;br /&gt;
&lt;br /&gt;
2. Document Code for Clarity&lt;br /&gt;
&lt;br /&gt;
* Write detailed comments explaining the purpose of each method, input and output, and any critical logic that might be complex for future developers to understand.&lt;br /&gt;
* Create or update documentation and diagrams to illustrate the newly designed structure, making it easier for new developers to contribute or modify functionality.&lt;br /&gt;
&lt;br /&gt;
=== Documentation ===&lt;br /&gt;
&lt;br /&gt;
Ensure all code is well-documented, with comments explaining purpose, inputs, outputs, and any complex logic. Maintain updated documentation for all modified and newly added classes and methods, allowing for ease of understanding and maintenance.&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
&lt;br /&gt;
By refactoring feedback_response_map.rb, this project will enhance Expertiza’s backend maintainability and readability, ensuring a modular, efficient, and more secure implementation.&lt;br /&gt;
&lt;br /&gt;
== Team Information ==&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
* Chaitanya Srusti (crsrusti@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
=== Members ===&lt;br /&gt;
&lt;br /&gt;
* Sarah Daniel (sdaniel8@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* William Grochocinski (wagrocho@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Tipton Middleton (tgmiddl2@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* ChatGPT (Honorary Member)&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2451-RubocopOriginal.png&amp;diff=160304</id>
		<title>File:E2451-RubocopOriginal.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2451-RubocopOriginal.png&amp;diff=160304"/>
		<updated>2024-12-03T23:47:17Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2451-Rubocop4.png&amp;diff=160300</id>
		<title>File:E2451-Rubocop4.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2451-Rubocop4.png&amp;diff=160300"/>
		<updated>2024-12-03T23:42:05Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2451-Rubocop3.png&amp;diff=160299</id>
		<title>File:E2451-Rubocop3.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2451-Rubocop3.png&amp;diff=160299"/>
		<updated>2024-12-03T23:41:43Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2451-Rubocop2.png&amp;diff=160297</id>
		<title>File:E2451-Rubocop2.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2451-Rubocop2.png&amp;diff=160297"/>
		<updated>2024-12-03T23:41:00Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2451-Rubocop1.png&amp;diff=160287</id>
		<title>File:E2451-Rubocop1.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2451-Rubocop1.png&amp;diff=160287"/>
		<updated>2024-12-03T23:38:06Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=160216</id>
		<title>CSC/ECE 517 Fall 2024 - E2451. Reimplement feedback response map.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=160216"/>
		<updated>2024-12-03T21:26:48Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2451: Reimplement feedback response map'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions, among other tasks. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
=== Project Overview ===&lt;br /&gt;
&lt;br /&gt;
The goal of this project is to refactor the feedback_response_map.rb file from the Expertiza repository and integrate it into the reimplementation-back-end repository. Within Expertiza, when a user submits a review, an instance of the Response class is created, associated with a ResponseMap. Each ResponseMap links a reviewer (reviewer_id), reviewee (reviewee_id), and the reviewed item (reviewed_object_id). FeedbackResponseMap, a subclass of ResponseMap, represents the feedback provided by a reviewee on the feedback received for their submission.&lt;br /&gt;
&lt;br /&gt;
This class has significant room for improvement, especially with respect to object-oriented principles. Refactoring feedback_response_map.rb will streamline functionality, enhance maintainability, and improve adherence to coding standards.&lt;br /&gt;
&lt;br /&gt;
=== Current Implementation ===&lt;br /&gt;
&lt;br /&gt;
The current feedback_response_map.rb in the Expertiza repository has several issues. It includes the following problems:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Poor adherence to SOLID and DRY principles&amp;lt;/b&amp;gt;: The current code structure introduces unnecessary repetition and complexity.&lt;br /&gt;
* &amp;lt;b&amp;gt;feedback_response_report Method Issues&amp;lt;/b&amp;gt;: This critical method is highly complex, relying on custom data structures and separate containers for each review round, resulting in a DRY violation.&lt;br /&gt;
* &amp;lt;b&amp;gt;Improper Responsibility Assignment&amp;lt;/b&amp;gt;: The email method does not belong within this class and would benefit from refactoring out into a separate class using the Visitor pattern. This pattern is suggested to streamline functionality, though alternative design patterns may be considered if more suitable.&lt;br /&gt;
* &amp;lt;b&amp;gt;Memory Inefficiencies&amp;lt;/b&amp;gt;: The method currently creates unnecessary memory through inefficient structures, including multiple separate arrays for different rounds of review, which could be simplified into a 2D array structure.&lt;br /&gt;
* &amp;lt;b&amp;gt;Code Smells&amp;lt;/b&amp;gt;: The code has redundant methods, unclear variable names, inefficient loops, and overly long method names.&lt;br /&gt;
&lt;br /&gt;
=== Objectives &amp;amp; Requirements ===&lt;br /&gt;
1. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Address the DRY violation by consolidating the containers for review rounds.&lt;br /&gt;
* Generalize the code to handle both cases—when rubrics vary by round and when they do not—without duplicating code.&lt;br /&gt;
* Introduce efficient data structures, like a 2D array, to replace multiple arrays and reduce memory usage.&lt;br /&gt;
&lt;br /&gt;
2. Separate Responsibilities Using Visitor Pattern (&amp;lt;i&amp;gt;stretch goal&amp;lt;/i&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
* Extract the email method using the Visitor pattern to modularize email functionality. Alternatively, select a design pattern better suited to organizing this method if available. Note that the email method is not properly used in its current location and is better suited to the Response class rather than ResponseMap.&lt;br /&gt;
&lt;br /&gt;
3. Eliminate Redundant Methods&lt;br /&gt;
&lt;br /&gt;
* Remove methods that do not serve a clear purpose and improve method naming for clarity.&lt;br /&gt;
* Aim to address any redundant meta-review functionality, as indicated by the professor's preference to remove these from response_map.rb.&lt;br /&gt;
&lt;br /&gt;
4. Refactor for Code Clarity and Efficiency&lt;br /&gt;
&lt;br /&gt;
* Improve variable names, reduce unnecessary loops, and replace long method names with concise, intuitive alternatives.&lt;br /&gt;
* Ensure that each method has a single, clearly defined purpose, improving code readability.&lt;br /&gt;
&lt;br /&gt;
5. Testing and Documentation&lt;br /&gt;
&lt;br /&gt;
* Write comprehensive tests for all newly implemented and modified methods to ensure reliability.&lt;br /&gt;
* Add detailed comments to facilitate code maintenance and understanding for future developers.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Design Principles ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Single Responsibility Principle (SRP)&amp;lt;/b&amp;gt;: Each method and class should have a single, well-defined purpose.&lt;br /&gt;
* &amp;lt;b&amp;gt;Don’t Repeat Yourself (DRY)&amp;lt;/b&amp;gt;: Eliminate redundancy by creating general solutions that handle multiple scenarios.&lt;br /&gt;
* &amp;lt;b&amp;gt;Ruby Readability Guidelines (Week 9 Notes)&amp;lt;/b&amp;gt;:&lt;br /&gt;
** Guideline: Variable names should be neither too short nor too long.&lt;br /&gt;
** Guideline: Names should not be redundant.&lt;br /&gt;
** Guideline: &amp;lt;b&amp;gt;A method should do only one thing and do it well.&amp;lt;/b&amp;gt;&lt;br /&gt;
* &amp;lt;b&amp;gt;Visitor Pattern&amp;lt;/b&amp;gt;: Utilize this pattern to separate emailing functionalities from the main class.&lt;br /&gt;
&lt;br /&gt;
=== Implementation Plan ===&lt;br /&gt;
&lt;br /&gt;
The refactoring will proceed as follows:&lt;br /&gt;
&lt;br /&gt;
1. Analyze and Refactor Current Code Structure&lt;br /&gt;
&lt;br /&gt;
* Review and understand the existing structure and dependencies within feedback_response_map.rb.&lt;br /&gt;
* Identify areas of redundancy, complexity, and inefficiency, particularly in feedback_response_report, to create a clear plan for refactoring.&lt;br /&gt;
* Try to reduce character count and improve readability with aliasing (this way we do not break any code that relies on being able to call specific methods).&lt;br /&gt;
&lt;br /&gt;
2. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Consolidate containers for each review round to address DRY violations. By using a single structure to store review data, we will eliminate hard-coded repetition.&lt;br /&gt;
* Generalize logic to accommodate both scenarios where rubrics vary by round and where they do not, without duplicating code paths.&lt;br /&gt;
* Replace inefficient structures, such as multiple arrays, with more flexible and memory-efficient options, like a 2D array or a hash, to reduce memory usage and improve scalability.&lt;br /&gt;
&lt;br /&gt;
3. Introduce Helper Methods for Reusable Logic (for feedback_response_report)&lt;br /&gt;
&lt;br /&gt;
* Extract frequently used or complex code blocks into helper methods, reducing the size of primary methods and enhancing reusability.&lt;br /&gt;
* Use helper methods for specific actions, like handling rounds or retrieving assignment data, to make the code cleaner and better organized.&lt;br /&gt;
* Emphasis on adhering to the guideline: A method should do only one thing and do it well.&lt;br /&gt;
&lt;br /&gt;
4. Research Future Refactoring for email Method&lt;br /&gt;
&lt;br /&gt;
* The email method is convoluted and the functionality should be refactored into a different class in the future.&lt;br /&gt;
* This is because this visitor pattern violation is present in many classes, and is beyond the scope of a one-class re-implementation.&lt;br /&gt;
&lt;br /&gt;
5. Improve Variable Naming and Structure&lt;br /&gt;
&lt;br /&gt;
* Replace ambiguous variable names with clearer alternatives that convey purpose, such as renaming @temp_review_responses and @temp_response_map_ids to more meaningful names.&lt;br /&gt;
* Simplify long method names to make the code more readable and approachable for new contributors.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Analyze and Refactor Current Code Structure&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before refactoring, the FeedbackResponseMap class contains 6 methods, with the majority of the code in self.feedback_response_report:&lt;br /&gt;
&lt;br /&gt;
[[File:FeedbackResponseMap_before.png |250px]]&lt;br /&gt;
&lt;br /&gt;
We aim to change that by splitting up this method into three helper methods, as seen in the following:&lt;br /&gt;
&lt;br /&gt;
[[File:FeedbackResponseMap_after.png |350px]]&lt;br /&gt;
&lt;br /&gt;
To go into more detail, here is the code for the feedback_response_report method, and how we intend to split it up:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_after_code1.png |600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_after_code2.png |600px]]&lt;br /&gt;
&lt;br /&gt;
The red section of code will be self.get_feedback_authors, yellow will be self.varying_rubrics_report, and green will be self.static_rubrics_report. Each separated group will be its own method, and self.varying_rubrics_report and self.static_rubrics_report (the yellow and green methods) will be returned at the end of the new feedback_response_report.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Refactor the feedback_response_report Method&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can take the multiple arrays found to represent rounds, and use dictionaries instead, where each round is called by its key value (integer value). &lt;br /&gt;
&lt;br /&gt;
INSERT PIC OF BEFORE AND AFTER OF ARRAYS/DICTS HERE&lt;br /&gt;
&lt;br /&gt;
Additionally, Rubocop was used to analyze the code and adhere to proper Ruby Guidelines. The command below was used to search for any code smells that we missed.&lt;br /&gt;
&lt;br /&gt;
   rubocop app/models/feedback_response_map.rb&lt;br /&gt;
&lt;br /&gt;
Originally, there were only three offenses, but this largely grew as we continued to clean up the code. All of the offenses can be seen below:&lt;br /&gt;
&lt;br /&gt;
INSERT PICS OF RUBOCOP&lt;br /&gt;
&lt;br /&gt;
Lastly, commenting was added throughout the files, to increase readability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Introduce Helper Methods for Reusable Logic (for feedback_response_report)&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As planned in step 1, the feedback_response_report method was split up into 3 private helper methods: get_feedback_authors(id), varying_rubrics_report(review_responses, response_map_ids), and static_rubrics_report(review_responses, response_map_ids). One change we made that was different from the UML diagram was the addition of an id parameter in the get_feedback_authors method, in order to ____. Each helper method was planned in order to stick to the guideline of “A method should do only one thing and do it well.”&lt;br /&gt;
&lt;br /&gt;
INSERT UPDATED UML DIAGRAM AND NEW IMAGES OF THE FILES&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Research future refactoring for email method&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;5. Improve variable naming and structure&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Authors====&lt;br /&gt;
&lt;br /&gt;
This image contains comments showing what the implementation looked like before:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_authors_before.png]]&lt;br /&gt;
&lt;br /&gt;
This image shows the construction of the private method we implemented to replace it, reducing complexity and improving readability in the process:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_authors_after.png]]&lt;br /&gt;
&lt;br /&gt;
====Report====&lt;br /&gt;
&lt;br /&gt;
This image contains comments showing what the implementation looked like before:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_reports_before.png]]&lt;br /&gt;
&lt;br /&gt;
These images show the construction of the private methods we implemented to replace it, reducing complexity and improving readability in the process:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_reports_varying.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_report_static.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Notice that in both the original self.feedback_response_report method and the private methods, comments are included to explain each non-obvious step of the process.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[MAYBE ADD COMPLEXITY METRICS BEFORE AND AFTER HERE?]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. Research Future Refactoring for email Method&lt;br /&gt;
&lt;br /&gt;
As discussed in the implementation plan, the email method was left as is. Any changes would require the addition of a new class and/or major refactoring for the functionality.&lt;br /&gt;
&lt;br /&gt;
5. Improve Variable Naming and Structure&lt;br /&gt;
&lt;br /&gt;
The two sets of variables discussed in the plan, @temp_response_map_ids and @temp_review_responses were modified as needed. First, the @temp_response_map_ids was moved to the helper methods varying_rubrics_report and static_rubrics_report, to be initialized, and changed to response_map_ids.&lt;br /&gt;
&lt;br /&gt;
Secondly, @temp_review_responses was changed to review_responses in the helper methods that call it: varying_rubrics_report and static_rubrics_report&lt;br /&gt;
&lt;br /&gt;
=== Testing ===&lt;br /&gt;
&lt;br /&gt;
1. Adapt Existing Tests for Refactored Methods&lt;br /&gt;
&lt;br /&gt;
* Any new helper methods will be private, and so by the &amp;quot;Magic Tricks of Testing&amp;quot; guide, should not be tested (both query and command messages sent to self are ignored in the test plan).&lt;br /&gt;
* Use mocks to isolate components during testing, especially for external dependencies like Mailer, to ensure that email functionality works as expected without direct integration.&lt;br /&gt;
&lt;br /&gt;
2. Document Code for Clarity&lt;br /&gt;
&lt;br /&gt;
* Write detailed comments explaining the purpose of each method, input and output, and any critical logic that might be complex for future developers to understand.&lt;br /&gt;
* Create or update documentation and diagrams to illustrate the newly designed structure, making it easier for new developers to contribute or modify functionality.&lt;br /&gt;
&lt;br /&gt;
=== Documentation ===&lt;br /&gt;
&lt;br /&gt;
Ensure all code is well-documented, with comments explaining purpose, inputs, outputs, and any complex logic. Maintain updated documentation for all modified and newly added classes and methods, allowing for ease of understanding and maintenance.&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
&lt;br /&gt;
By refactoring feedback_response_map.rb, this project will enhance Expertiza’s backend maintainability and readability, ensuring a modular, efficient, and more secure implementation.&lt;br /&gt;
&lt;br /&gt;
== Team Information ==&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
* Chaitanya Srusti (crsrusti@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
=== Members ===&lt;br /&gt;
&lt;br /&gt;
* Sarah Daniel (sdaniel8@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* William Grochocinski (wagrocho@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Tipton Middleton (tgmiddl2@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* ChatGPT (Honorary Member)&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=159793</id>
		<title>CSC/ECE 517 Fall 2024 - E2451. Reimplement feedback response map.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=159793"/>
		<updated>2024-11-29T18:52:19Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2451: Reimplement feedback response map'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions, among other tasks. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
=== Project Overview ===&lt;br /&gt;
&lt;br /&gt;
The goal of this project is to refactor the feedback_response_map.rb file from the Expertiza repository and integrate it into the reimplementation-back-end repository. Within Expertiza, when a user submits a review, an instance of the Response class is created, associated with a ResponseMap. Each ResponseMap links a reviewer (reviewer_id), reviewee (reviewee_id), and the reviewed item (reviewed_object_id). FeedbackResponseMap, a subclass of ResponseMap, represents the feedback provided by a reviewee on the feedback received for their submission.&lt;br /&gt;
&lt;br /&gt;
This class has significant room for improvement, especially with respect to object-oriented principles. Refactoring feedback_response_map.rb will streamline functionality, enhance maintainability, and improve adherence to coding standards.&lt;br /&gt;
&lt;br /&gt;
=== Current Implementation ===&lt;br /&gt;
&lt;br /&gt;
The current feedback_response_map.rb in the Expertiza repository has several issues. It includes the following problems:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Poor adherence to SOLID and DRY principles&amp;lt;/b&amp;gt;: The current code structure introduces unnecessary repetition and complexity.&lt;br /&gt;
* &amp;lt;b&amp;gt;feedback_response_report Method Issues&amp;lt;/b&amp;gt;: This critical method is highly complex, relying on custom data structures and separate containers for each review round, resulting in a DRY violation.&lt;br /&gt;
* &amp;lt;b&amp;gt;Improper Responsibility Assignment&amp;lt;/b&amp;gt;: The email method does not belong within this class and would benefit from refactoring out into a separate class using the Visitor pattern. This pattern is suggested to streamline functionality, though alternative design patterns may be considered if more suitable.&lt;br /&gt;
* &amp;lt;b&amp;gt;Memory Inefficiencies&amp;lt;/b&amp;gt;: The method currently creates unnecessary memory through inefficient structures, including multiple separate arrays for different rounds of review, which could be simplified into a 2D array structure.&lt;br /&gt;
* &amp;lt;b&amp;gt;Code Smells&amp;lt;/b&amp;gt;: The code has redundant methods, unclear variable names, inefficient loops, and overly long method names.&lt;br /&gt;
&lt;br /&gt;
=== Objectives &amp;amp; Requirements ===&lt;br /&gt;
1. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Address the DRY violation by consolidating the containers for review rounds.&lt;br /&gt;
* Generalize the code to handle both cases—when rubrics vary by round and when they do not—without duplicating code.&lt;br /&gt;
* Introduce efficient data structures, like a 2D array, to replace multiple arrays and reduce memory usage.&lt;br /&gt;
&lt;br /&gt;
2. Separate Responsibilities Using Visitor Pattern (&amp;lt;i&amp;gt;stretch goal&amp;lt;/i&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
* Extract the email method using the Visitor pattern to modularize email functionality. Alternatively, select a design pattern better suited to organizing this method if available. Note that the email method is not properly used in its current location and is better suited to the Response class rather than ResponseMap.&lt;br /&gt;
&lt;br /&gt;
3. Eliminate Redundant Methods&lt;br /&gt;
&lt;br /&gt;
* Remove methods that do not serve a clear purpose and improve method naming for clarity.&lt;br /&gt;
* Aim to address any redundant meta-review functionality, as indicated by the professor's preference to remove these from response_map.rb.&lt;br /&gt;
&lt;br /&gt;
4. Refactor for Code Clarity and Efficiency&lt;br /&gt;
&lt;br /&gt;
* Improve variable names, reduce unnecessary loops, and replace long method names with concise, intuitive alternatives.&lt;br /&gt;
* Ensure that each method has a single, clearly defined purpose, improving code readability.&lt;br /&gt;
&lt;br /&gt;
5. Testing and Documentation&lt;br /&gt;
&lt;br /&gt;
* Write comprehensive tests for all newly implemented and modified methods to ensure reliability.&lt;br /&gt;
* Add detailed comments to facilitate code maintenance and understanding for future developers.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Design Principles ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Single Responsibility Principle (SRP)&amp;lt;/b&amp;gt;: Each method and class should have a single, well-defined purpose.&lt;br /&gt;
* &amp;lt;b&amp;gt;Don’t Repeat Yourself (DRY)&amp;lt;/b&amp;gt;: Eliminate redundancy by creating general solutions that handle multiple scenarios.&lt;br /&gt;
* &amp;lt;b&amp;gt;Ruby Readability Guidelines (Week 9 Notes)&amp;lt;/b&amp;gt;:&lt;br /&gt;
** Guideline: Variable names should be neither too short nor too long.&lt;br /&gt;
** Guideline: Names should not be redundant.&lt;br /&gt;
** Guideline: &amp;lt;b&amp;gt;A method should do only one thing and do it well.&amp;lt;/b&amp;gt;&lt;br /&gt;
* &amp;lt;b&amp;gt;Visitor Pattern&amp;lt;/b&amp;gt;: Utilize this pattern to separate emailing functionalities from the main class.&lt;br /&gt;
&lt;br /&gt;
=== Implementation Plan ===&lt;br /&gt;
&lt;br /&gt;
The refactoring will proceed as follows:&lt;br /&gt;
&lt;br /&gt;
1. Analyze and Refactor Current Code Structure&lt;br /&gt;
&lt;br /&gt;
* Review and understand the existing structure and dependencies within feedback_response_map.rb.&lt;br /&gt;
* Identify areas of redundancy, complexity, and inefficiency, particularly in feedback_response_report, to create a clear plan for refactoring.&lt;br /&gt;
* Try to reduce character count and improve readability with aliasing (this way we do not break any code that relies on being able to call specific methods).&lt;br /&gt;
&lt;br /&gt;
2. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Consolidate containers for each review round to address DRY violations. By using a single structure to store review data, we will eliminate hard-coded repetition.&lt;br /&gt;
* Generalize logic to accommodate both scenarios where rubrics vary by round and where they do not, without duplicating code paths.&lt;br /&gt;
* Replace inefficient structures, such as multiple arrays, with more flexible and memory-efficient options, like a 2D array or a hash, to reduce memory usage and improve scalability.&lt;br /&gt;
&lt;br /&gt;
3. Introduce Helper Methods for Reusable Logic (for feedback_response_report)&lt;br /&gt;
&lt;br /&gt;
* Extract frequently used or complex code blocks into helper methods, reducing the size of primary methods and enhancing reusability.&lt;br /&gt;
* Use helper methods for specific actions, like handling rounds or retrieving assignment data, to make the code cleaner and better organized.&lt;br /&gt;
* Emphasis on adhering to the guideline: A method should do only one thing and do it well.&lt;br /&gt;
&lt;br /&gt;
4. Research Future Refactoring for email Method&lt;br /&gt;
&lt;br /&gt;
* The email method is convoluted and the functionality should be refactored into a different class in the future.&lt;br /&gt;
* This is because this visitor pattern violation is present in many classes, and is beyond the scope of a one-class re-implementation.&lt;br /&gt;
&lt;br /&gt;
5. Improve Variable Naming and Structure&lt;br /&gt;
&lt;br /&gt;
* Replace ambiguous variable names with clearer alternatives that convey purpose, such as renaming @temp_review_responses and @temp_response_map_ids to more meaningful names.&lt;br /&gt;
* Simplify long method names to make the code more readable and approachable for new contributors.&lt;br /&gt;
&lt;br /&gt;
Because the main focus will be on feedback_response_map.rb, we can take a closer look on what we will do to implement these (point #3 above). Before refactoring, the FeedbackResponseMap class contains 6 methods, with the majority of the code in self.feedback_response_report:&lt;br /&gt;
&lt;br /&gt;
[[File:FeedbackResponseMap_before.png |250px]]&lt;br /&gt;
&lt;br /&gt;
We aim to change that by splitting up this method into multiple helper methods, as seen in the following:&lt;br /&gt;
&lt;br /&gt;
[[File:FeedbackResponseMap_after.png |350px]]&lt;br /&gt;
&lt;br /&gt;
To go into more detail, here is the code for the feedback_response_report method, and how we intend to split it up:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_after_code1.png |600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_after_code2.png |600px]]&lt;br /&gt;
&lt;br /&gt;
The red section of code will be self.get_feedback_authors, yellow will be self.varying_rubrics_report, and green will be self.static_rubrics_report. Each separated group will be its own method, and self.varying_rubrics_report and self.static_rubrics_report (the yellow and green methods) will be returned at the end of the new feedback_response_report.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
&lt;br /&gt;
1. Analyze and Refactor Current Code Structure&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Introduce Helper Methods for Reusable Logic (for feedback_response_report)&lt;br /&gt;
&lt;br /&gt;
As planned from before, the feedback_response_report method was split up into 3 private helper methods: get_feedback_authors(id), varying_rubrics_report(review_responses, response_map_ids), and static_rubrics_report(review_responses, response_map_ids). The main difference between the plan and the actual implementation are the added arguments when creating these private methods.&lt;br /&gt;
&lt;br /&gt;
[ADD PICTURES HERE]&lt;br /&gt;
&lt;br /&gt;
4. Research Future Refactoring for email Method&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. Improve Variable Naming and Structure&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Testing ===&lt;br /&gt;
&lt;br /&gt;
1. Adapt Existing Tests for Refactored Methods&lt;br /&gt;
&lt;br /&gt;
* Any new helper methods will be private, and so by the &amp;quot;Magic Tricks of Testing&amp;quot; guide, should not be tested (both query and command messages sent to self are ignored in the test plan).&lt;br /&gt;
* Use mocks to isolate components during testing, especially for external dependencies like Mailer, to ensure that email functionality works as expected without direct integration.&lt;br /&gt;
&lt;br /&gt;
2. Document Code for Clarity&lt;br /&gt;
&lt;br /&gt;
* Write detailed comments explaining the purpose of each method, input and output, and any critical logic that might be complex for future developers to understand.&lt;br /&gt;
* Create or update documentation and diagrams to illustrate the newly designed structure, making it easier for new developers to contribute or modify functionality.&lt;br /&gt;
&lt;br /&gt;
=== Documentation ===&lt;br /&gt;
&lt;br /&gt;
Ensure all code is well-documented, with comments explaining purpose, inputs, outputs, and any complex logic. Maintain updated documentation for all modified and newly added classes and methods, allowing for ease of understanding and maintenance.&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
&lt;br /&gt;
By refactoring feedback_response_map.rb, this project will enhance Expertiza’s backend maintainability and readability, ensuring a modular, efficient, and more secure implementation.&lt;br /&gt;
&lt;br /&gt;
== Team Information ==&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
* Chaitanya Srusti (crsrusti@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
=== Members ===&lt;br /&gt;
&lt;br /&gt;
* Sarah Daniel (sdaniel8@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* William Grochocinski (wagrocho@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Tipton Middleton (tgmiddl2@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* ChatGPT (Honorary Member)&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=159791</id>
		<title>CSC/ECE 517 Fall 2024 - E2451. Reimplement feedback response map.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=159791"/>
		<updated>2024-11-29T18:43:01Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2451: Reimplement feedback response map'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions, among other tasks. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
=== Project Overview ===&lt;br /&gt;
&lt;br /&gt;
The goal of this project is to refactor the feedback_response_map.rb file from the Expertiza repository and integrate it into the reimplementation-back-end repository. Within Expertiza, when a user submits a review, an instance of the Response class is created, associated with a ResponseMap. Each ResponseMap links a reviewer (reviewer_id), reviewee (reviewee_id), and the reviewed item (reviewed_object_id). FeedbackResponseMap, a subclass of ResponseMap, represents the feedback provided by a reviewee on the feedback received for their submission.&lt;br /&gt;
&lt;br /&gt;
This class has significant room for improvement, especially with respect to object-oriented principles. Refactoring feedback_response_map.rb will streamline functionality, enhance maintainability, and improve adherence to coding standards.&lt;br /&gt;
&lt;br /&gt;
=== Current Implementation ===&lt;br /&gt;
&lt;br /&gt;
The current feedback_response_map.rb in the Expertiza repository has several issues. It includes the following problems:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Poor adherence to SOLID and DRY principles&amp;lt;/b&amp;gt;: The current code structure introduces unnecessary repetition and complexity.&lt;br /&gt;
* &amp;lt;b&amp;gt;feedback_response_report Method Issues&amp;lt;/b&amp;gt;: This critical method is highly complex, relying on custom data structures and separate containers for each review round, resulting in a DRY violation.&lt;br /&gt;
* &amp;lt;b&amp;gt;Improper Responsibility Assignment&amp;lt;/b&amp;gt;: The email method does not belong within this class and would benefit from refactoring out into a separate class using the Visitor pattern. This pattern is suggested to streamline functionality, though alternative design patterns may be considered if more suitable.&lt;br /&gt;
* &amp;lt;b&amp;gt;Memory Inefficiencies&amp;lt;/b&amp;gt;: The method currently creates unnecessary memory through inefficient structures, including multiple separate arrays for different rounds of review, which could be simplified into a 2D array structure.&lt;br /&gt;
* &amp;lt;b&amp;gt;Code Smells&amp;lt;/b&amp;gt;: The code has redundant methods, unclear variable names, inefficient loops, and overly long method names.&lt;br /&gt;
&lt;br /&gt;
=== Objectives &amp;amp; Requirements ===&lt;br /&gt;
1. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Address the DRY violation by consolidating the containers for review rounds.&lt;br /&gt;
* Generalize the code to handle both cases—when rubrics vary by round and when they do not—without duplicating code.&lt;br /&gt;
* Introduce efficient data structures, like a 2D array, to replace multiple arrays and reduce memory usage.&lt;br /&gt;
&lt;br /&gt;
2. Separate Responsibilities Using Visitor Pattern (&amp;lt;i&amp;gt;stretch goal&amp;lt;/i&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
* Extract the email method using the Visitor pattern to modularize email functionality. Alternatively, select a design pattern better suited to organizing this method if available. Note that the email method is not properly used in its current location and is better suited to the Response class rather than ResponseMap.&lt;br /&gt;
&lt;br /&gt;
3. Eliminate Redundant Methods&lt;br /&gt;
&lt;br /&gt;
* Remove methods that do not serve a clear purpose and improve method naming for clarity.&lt;br /&gt;
* Aim to address any redundant meta-review functionality, as indicated by the professor's preference to remove these from response_map.rb.&lt;br /&gt;
&lt;br /&gt;
4. Refactor for Code Clarity and Efficiency&lt;br /&gt;
&lt;br /&gt;
* Improve variable names, reduce unnecessary loops, and replace long method names with concise, intuitive alternatives.&lt;br /&gt;
* Ensure that each method has a single, clearly defined purpose, improving code readability.&lt;br /&gt;
&lt;br /&gt;
5. Testing and Documentation&lt;br /&gt;
&lt;br /&gt;
* Write comprehensive tests for all newly implemented and modified methods to ensure reliability.&lt;br /&gt;
* Add detailed comments to facilitate code maintenance and understanding for future developers.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Design Principles ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Single Responsibility Principle (SRP)&amp;lt;/b&amp;gt;: Each method and class should have a single, well-defined purpose.&lt;br /&gt;
* &amp;lt;b&amp;gt;Don’t Repeat Yourself (DRY)&amp;lt;/b&amp;gt;: Eliminate redundancy by creating general solutions that handle multiple scenarios.&lt;br /&gt;
* &amp;lt;b&amp;gt;Ruby Readability Guidelines (Week 9 Notes)&amp;lt;/b&amp;gt;:&lt;br /&gt;
** Guideline: Variable names should be neither too short nor too long.&lt;br /&gt;
** Guideline: Names should not be redundant.&lt;br /&gt;
** Guideline: &amp;lt;b&amp;gt;A method should do only one thing and do it well.&amp;lt;/b&amp;gt;&lt;br /&gt;
* &amp;lt;b&amp;gt;Visitor Pattern&amp;lt;/b&amp;gt;: Utilize this pattern to separate emailing functionalities from the main class.&lt;br /&gt;
&lt;br /&gt;
=== Implementation Plan ===&lt;br /&gt;
&lt;br /&gt;
The refactoring will proceed as follows:&lt;br /&gt;
&lt;br /&gt;
1. Analyze and Refactor Current Code Structure&lt;br /&gt;
&lt;br /&gt;
* Review and understand the existing structure and dependencies within feedback_response_map.rb.&lt;br /&gt;
* Identify areas of redundancy, complexity, and inefficiency, particularly in feedback_response_report, to create a clear plan for refactoring.&lt;br /&gt;
* Try to reduce character count and improve readability with aliasing (this way we do not break any code that relies on being able to call specific methods).&lt;br /&gt;
&lt;br /&gt;
2. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Consolidate containers for each review round to address DRY violations. By using a single structure to store review data, we will eliminate hard-coded repetition.&lt;br /&gt;
* Generalize logic to accommodate both scenarios where rubrics vary by round and where they do not, without duplicating code paths.&lt;br /&gt;
* Replace inefficient structures, such as multiple arrays, with more flexible and memory-efficient options, like a 2D array or a hash, to reduce memory usage and improve scalability.&lt;br /&gt;
&lt;br /&gt;
3. Introduce Helper Methods for Reusable Logic (for feedback_response_report)&lt;br /&gt;
&lt;br /&gt;
* Extract frequently used or complex code blocks into helper methods, reducing the size of primary methods and enhancing reusability.&lt;br /&gt;
* Use helper methods for specific actions, like handling rounds or retrieving assignment data, to make the code cleaner and better organized.&lt;br /&gt;
* Emphasis on adhering to the guideline: A method should do only one thing and do it well.&lt;br /&gt;
&lt;br /&gt;
4. Research Future Refactoring for email Method&lt;br /&gt;
&lt;br /&gt;
* The email method is convoluted and the functionality should be refactored into a different class in the future.&lt;br /&gt;
* This is because this visitor pattern violation is present in many classes, and is beyond the scope of a one-class re-implementation.&lt;br /&gt;
&lt;br /&gt;
5. Improve Variable Naming and Structure&lt;br /&gt;
&lt;br /&gt;
* Replace ambiguous variable names with clearer alternatives that convey purpose, such as renaming @temp_review_responses and @temp_response_map_ids to more meaningful names.&lt;br /&gt;
* Simplify long method names to make the code more readable and approachable for new contributors.&lt;br /&gt;
&lt;br /&gt;
Because the main focus will be on feedback_response_map.rb, we can take a closer look on what we will do to implement these (point #3 above). Before refactoring, the FeedbackResponseMap class contains 6 methods, with the majority of the code in self.feedback_response_report:&lt;br /&gt;
&lt;br /&gt;
[[File:FeedbackResponseMap_before.png |250px]]&lt;br /&gt;
&lt;br /&gt;
We aim to change that by splitting up this method into multiple helper methods, as seen in the following:&lt;br /&gt;
&lt;br /&gt;
[[File:FeedbackResponseMap_after.png |350px]]&lt;br /&gt;
&lt;br /&gt;
To go into more detail, here is the code for the feedback_response_report method, and how we intend to split it up:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_after_code1.png |600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_after_code2.png |600px]]&lt;br /&gt;
&lt;br /&gt;
The red section of code will be self.get_feedback_authors, yellow will be self.varying_rubrics_report, and green will be self.static_rubrics_report. Each separated group will be its own method, and self.varying_rubrics_report and self.static_rubrics_report (the yellow and green methods) will be returned at the end of the new feedback_response_report.&lt;br /&gt;
&lt;br /&gt;
=== Implementation ===&lt;br /&gt;
&lt;br /&gt;
1. Analyze and Refactor Current Code Structure&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Introduce Helper Methods for Reusable Logic (for feedback_response_report)&lt;br /&gt;
&lt;br /&gt;
As planned from before, the feedback_response_report method was split up into 3 private helper methods: get_feedback_authors(id), varying_rubrics_report(review_responses, response_map_ids), and static_rubrics_report(review_responses, response_map_ids). The main difference between the plan and the actual implementation are the added arguments when creating these private methods.&lt;br /&gt;
&lt;br /&gt;
4. Research Future Refactoring for email Method&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. Improve Variable Naming and Structure&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Testing ===&lt;br /&gt;
&lt;br /&gt;
1. Adapt Existing Tests for Refactored Methods&lt;br /&gt;
&lt;br /&gt;
* Any new helper methods will be private, and so by the &amp;quot;Magic Tricks of Testing&amp;quot; guide, should not be tested (both query and command messages sent to self are ignored in the test plan).&lt;br /&gt;
* Use mocks to isolate components during testing, especially for external dependencies like Mailer, to ensure that email functionality works as expected without direct integration.&lt;br /&gt;
&lt;br /&gt;
2. Document Code for Clarity&lt;br /&gt;
&lt;br /&gt;
* Write detailed comments explaining the purpose of each method, input and output, and any critical logic that might be complex for future developers to understand.&lt;br /&gt;
* Create or update documentation and diagrams to illustrate the newly designed structure, making it easier for new developers to contribute or modify functionality.&lt;br /&gt;
&lt;br /&gt;
=== Documentation ===&lt;br /&gt;
&lt;br /&gt;
Ensure all code is well-documented, with comments explaining purpose, inputs, outputs, and any complex logic. Maintain updated documentation for all modified and newly added classes and methods, allowing for ease of understanding and maintenance.&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
&lt;br /&gt;
By refactoring feedback_response_map.rb, this project will enhance Expertiza’s backend maintainability and readability, ensuring a modular, efficient, and more secure implementation.&lt;br /&gt;
&lt;br /&gt;
== Team Information ==&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
* Chaitanya Srusti (crsrusti@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
=== Members ===&lt;br /&gt;
&lt;br /&gt;
* Sarah Daniel (sdaniel8@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* William Grochocinski (wagrocho@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Tipton Middleton (tgmiddl2@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* ChatGPT (Honorary Member)&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=159718</id>
		<title>CSC/ECE 517 Fall 2024 - E2451. Reimplement feedback response map.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=159718"/>
		<updated>2024-11-18T04:20:29Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2451: Reimplement feedback response map'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions, among other tasks. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
=== Project Overview ===&lt;br /&gt;
&lt;br /&gt;
The goal of this project is to refactor the feedback_response_map.rb file from the Expertiza repository and integrate it into the reimplementation-back-end repository. Within Expertiza, when a user submits a review, an instance of the Response class is created, associated with a ResponseMap. Each ResponseMap links a reviewer (reviewer_id), reviewee (reviewee_id), and the reviewed item (reviewed_object_id). FeedbackResponseMap, a subclass of ResponseMap, represents the feedback provided by a reviewee on the feedback received for their submission.&lt;br /&gt;
&lt;br /&gt;
This class has significant room for improvement, especially with respect to object-oriented principles. Refactoring feedback_response_map.rb will streamline functionality, enhance maintainability, and improve adherence to coding standards.&lt;br /&gt;
&lt;br /&gt;
=== Current Implementation ===&lt;br /&gt;
&lt;br /&gt;
The current feedback_response_map.rb in the Expertiza repository has several issues. It includes the following problems:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Poor adherence to SOLID and DRY principles&amp;lt;/b&amp;gt;: The current code structure introduces unnecessary repetition and complexity.&lt;br /&gt;
* &amp;lt;b&amp;gt;feedback_response_report Method Issues&amp;lt;/b&amp;gt;: This critical method is highly complex, relying on custom data structures and separate containers for each review round, resulting in a DRY violation.&lt;br /&gt;
* &amp;lt;b&amp;gt;Improper Responsibility Assignment&amp;lt;/b&amp;gt;: The email method does not belong within this class and would benefit from refactoring out into a separate class using the Visitor pattern. This pattern is suggested to streamline functionality, though alternative design patterns may be considered if more suitable.&lt;br /&gt;
* &amp;lt;b&amp;gt;Memory Inefficiencies&amp;lt;/b&amp;gt;: The method currently creates unnecessary memory through inefficient structures, including multiple separate arrays for different rounds of review, which could be simplified into a 2D array structure.&lt;br /&gt;
* &amp;lt;b&amp;gt;Code Smells&amp;lt;/b&amp;gt;: The code has redundant methods, unclear variable names, inefficient loops, and overly long method names.&lt;br /&gt;
&lt;br /&gt;
=== Objectives &amp;amp; Requirements ===&lt;br /&gt;
1. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Address the DRY violation by consolidating the containers for review rounds.&lt;br /&gt;
* Generalize the code to handle both cases—when rubrics vary by round and when they do not—without duplicating code.&lt;br /&gt;
* Introduce efficient data structures, like a 2D array, to replace multiple arrays and reduce memory usage.&lt;br /&gt;
&lt;br /&gt;
2. Separate Responsibilities Using Visitor Pattern (&amp;lt;i&amp;gt;stretch goal&amp;lt;/i&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
* Extract the email method using the Visitor pattern to modularize email functionality. Alternatively, select a design pattern better suited to organizing this method if available. Note that the email method is not properly used in its current location and is better suited to the Response class rather than ResponseMap.&lt;br /&gt;
&lt;br /&gt;
3. Eliminate Redundant Methods&lt;br /&gt;
&lt;br /&gt;
* Remove methods that do not serve a clear purpose and improve method naming for clarity.&lt;br /&gt;
* Aim to address any redundant meta-review functionality, as indicated by the professor's preference to remove these from response_map.rb.&lt;br /&gt;
&lt;br /&gt;
4. Refactor for Code Clarity and Efficiency&lt;br /&gt;
&lt;br /&gt;
* Improve variable names, reduce unnecessary loops, and replace long method names with concise, intuitive alternatives.&lt;br /&gt;
* Ensure that each method has a single, clearly defined purpose, improving code readability.&lt;br /&gt;
&lt;br /&gt;
5. Testing and Documentation&lt;br /&gt;
&lt;br /&gt;
* Write comprehensive tests for all newly implemented and modified methods to ensure reliability.&lt;br /&gt;
* Add detailed comments to facilitate code maintenance and understanding for future developers.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Design Principles ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Single Responsibility Principle (SRP)&amp;lt;/b&amp;gt;: Each method and class should have a single, well-defined purpose.&lt;br /&gt;
* &amp;lt;b&amp;gt;Don’t Repeat Yourself (DRY)&amp;lt;/b&amp;gt;: Eliminate redundancy by creating general solutions that handle multiple scenarios.&lt;br /&gt;
* &amp;lt;b&amp;gt;Ruby Readability Guidelines (Week 9 Notes)&amp;lt;/b&amp;gt;:&lt;br /&gt;
** Guideline: Variable names should be neither too short nor too long.&lt;br /&gt;
** Guideline: Names should not be redundant.&lt;br /&gt;
** Guideline: &amp;lt;b&amp;gt;A method should do only one thing and do it well.&amp;lt;/b&amp;gt;&lt;br /&gt;
* &amp;lt;b&amp;gt;Visitor Pattern&amp;lt;/b&amp;gt;: Utilize this pattern to separate emailing functionalities from the main class.&lt;br /&gt;
&lt;br /&gt;
=== Implementation Plan ===&lt;br /&gt;
&lt;br /&gt;
The refactoring will proceed as follows:&lt;br /&gt;
&lt;br /&gt;
1. Analyze and Refactor Current Code Structure&lt;br /&gt;
&lt;br /&gt;
* Review and understand the existing structure and dependencies within feedback_response_map.rb.&lt;br /&gt;
* Identify areas of redundancy, complexity, and inefficiency, particularly in feedback_response_report, to create a clear plan for refactoring.&lt;br /&gt;
* Try to reduce character count and improve readability with aliasing (this way we do not break any code that relies on being able to call specific methods).&lt;br /&gt;
&lt;br /&gt;
2. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Consolidate containers for each review round to address DRY violations. By using a single structure to store review data, we will eliminate hard-coded repetition.&lt;br /&gt;
* Generalize logic to accommodate both scenarios where rubrics vary by round and where they do not, without duplicating code paths.&lt;br /&gt;
* Replace inefficient structures, such as multiple arrays, with more flexible and memory-efficient options, like a 2D array or a hash, to reduce memory usage and improve scalability.&lt;br /&gt;
&lt;br /&gt;
3. Introduce Helper Methods for Reusable Logic (for feedback_response_report)&lt;br /&gt;
&lt;br /&gt;
* Extract frequently used or complex code blocks into helper methods, reducing the size of primary methods and enhancing reusability.&lt;br /&gt;
* Use helper methods for specific actions, like handling rounds or retrieving assignment data, to make the code cleaner and better organized.&lt;br /&gt;
* Emphasis on adhering to the guideline: A method should do only one thing and do it well.&lt;br /&gt;
&lt;br /&gt;
4. Research Future Refactoring for email Method&lt;br /&gt;
&lt;br /&gt;
* The email method is convoluted and the functionality should be refactored into a different class in the future.&lt;br /&gt;
* This is because this visitor pattern violation is present in many classes, and is beyond the scope of a one-class re-implementation.&lt;br /&gt;
&lt;br /&gt;
5. Improve Variable Naming and Structure&lt;br /&gt;
&lt;br /&gt;
* Replace ambiguous variable names with clearer alternatives that convey purpose, such as renaming @temp_review_responses and @temp_response_map_ids to more meaningful names.&lt;br /&gt;
* Simplify long method names to make the code more readable and approachable for new contributors.&lt;br /&gt;
&lt;br /&gt;
Because the main focus will be on feedback_response_map.rb, we can take a closer look on what we will do to implement these (point #3 above). Before refactoring, the FeedbackResponseMap class contains 6 methods, with the majority of the code in self.feedback_response_report:&lt;br /&gt;
&lt;br /&gt;
[[File:FeedbackResponseMap_before.png |250px]]&lt;br /&gt;
&lt;br /&gt;
We aim to change that by splitting up this method into multiple helper methods, as seen in the following:&lt;br /&gt;
&lt;br /&gt;
[[File:FeedbackResponseMap_after.png |350px]]&lt;br /&gt;
&lt;br /&gt;
To go into more detail, here is the code for the feedback_response_report method, and how we intend to split it up:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_after_code1.png |600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_after_code2.png |600px]]&lt;br /&gt;
&lt;br /&gt;
The red section of code will be self.get_feedback_authors, yellow will be self.varying_rubrics_report, and green will be self.static_rubrics_report. Each separated group will be its own method, and self.varying_rubrics_report and self.static_rubrics_report (the yellow and green methods) will be returned at the end of the new feedback_response_report.&lt;br /&gt;
&lt;br /&gt;
=== Testing ===&lt;br /&gt;
&lt;br /&gt;
1. Adapt Existing Tests for Refactored Methods&lt;br /&gt;
&lt;br /&gt;
* Any new helper methods will be private, and so by the &amp;quot;Magic Tricks of Testing&amp;quot; guide, should not be tested (both query and command messages sent to self are ignored in the test plan).&lt;br /&gt;
* Use mocks to isolate components during testing, especially for external dependencies like Mailer, to ensure that email functionality works as expected without direct integration.&lt;br /&gt;
&lt;br /&gt;
2. Document Code for Clarity&lt;br /&gt;
&lt;br /&gt;
* Write detailed comments explaining the purpose of each method, input and output, and any critical logic that might be complex for future developers to understand.&lt;br /&gt;
* Create or update documentation and diagrams to illustrate the newly designed structure, making it easier for new developers to contribute or modify functionality.&lt;br /&gt;
&lt;br /&gt;
=== Documentation ===&lt;br /&gt;
&lt;br /&gt;
Ensure all code is well-documented, with comments explaining purpose, inputs, outputs, and any complex logic. Maintain updated documentation for all modified and newly added classes and methods, allowing for ease of understanding and maintenance.&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
&lt;br /&gt;
By refactoring feedback_response_map.rb, this project will enhance Expertiza’s backend maintainability and readability, ensuring a modular, efficient, and more secure implementation.&lt;br /&gt;
&lt;br /&gt;
== Team Information ==&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
* Chaitanya Srusti (crsrusti@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
=== Members ===&lt;br /&gt;
&lt;br /&gt;
* Sarah Daniel (sdaniel8@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* William Grochocinski (wagrocho@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Tipton Middleton (tgmiddl2@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* ChatGPT (Honorary Member)&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=159716</id>
		<title>CSC/ECE 517 Fall 2024 - E2451. Reimplement feedback response map.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=159716"/>
		<updated>2024-11-18T04:19:47Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2451: Reimplement feedback response map'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions, among other tasks. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
=== Project Overview ===&lt;br /&gt;
&lt;br /&gt;
The goal of this project is to refactor the feedback_response_map.rb file from the Expertiza repository and integrate it into the reimplementation-back-end repository. Within Expertiza, when a user submits a review, an instance of the Response class is created, associated with a ResponseMap. Each ResponseMap links a reviewer (reviewer_id), reviewee (reviewee_id), and the reviewed item (reviewed_object_id). FeedbackResponseMap, a subclass of ResponseMap, represents the feedback provided by a reviewee on the feedback received for their submission.&lt;br /&gt;
&lt;br /&gt;
This class has significant room for improvement, especially with respect to object-oriented principles. Refactoring feedback_response_map.rb will streamline functionality, enhance maintainability, and improve adherence to coding standards.&lt;br /&gt;
&lt;br /&gt;
=== Current Implementation ===&lt;br /&gt;
&lt;br /&gt;
The current feedback_response_map.rb in the Expertiza repository has several issues. It includes the following problems:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Poor adherence to SOLID and DRY principles&amp;lt;/b&amp;gt;: The current code structure introduces unnecessary repetition and complexity.&lt;br /&gt;
* &amp;lt;b&amp;gt;feedback_response_report Method Issues&amp;lt;/b&amp;gt;: This critical method is highly complex, relying on custom data structures and separate containers for each review round, resulting in a DRY violation.&lt;br /&gt;
* &amp;lt;b&amp;gt;Improper Responsibility Assignment&amp;lt;/b&amp;gt;: The email method does not belong within this class and would benefit from refactoring out into a separate class using the Visitor pattern. This pattern is suggested to streamline functionality, though alternative design patterns may be considered if more suitable.&lt;br /&gt;
* &amp;lt;b&amp;gt;Memory Inefficiencies&amp;lt;/b&amp;gt;: The method currently creates unnecessary memory through inefficient structures, including multiple separate arrays for different rounds of review, which could be simplified into a 2D array structure.&lt;br /&gt;
* &amp;lt;b&amp;gt;Code Smells&amp;lt;/b&amp;gt;: The code has redundant methods, unclear variable names, inefficient loops, and overly long method names.&lt;br /&gt;
&lt;br /&gt;
=== Objectives &amp;amp; Requirements ===&lt;br /&gt;
1. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Address the DRY violation by consolidating the containers for review rounds.&lt;br /&gt;
* Generalize the code to handle both cases—when rubrics vary by round and when they do not—without duplicating code.&lt;br /&gt;
* Introduce efficient data structures, like a 2D array, to replace multiple arrays and reduce memory usage.&lt;br /&gt;
&lt;br /&gt;
2. Separate Responsibilities Using Visitor Pattern (&amp;lt;i&amp;gt;stretch goal&amp;lt;/i&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
* Extract the email method using the Visitor pattern to modularize email functionality. Alternatively, select a design pattern better suited to organizing this method if available. Note that the email method is not properly used in its current location and is better suited to the Response class rather than ResponseMap.&lt;br /&gt;
&lt;br /&gt;
3. Eliminate Redundant Methods&lt;br /&gt;
&lt;br /&gt;
* Remove methods that do not serve a clear purpose and improve method naming for clarity.&lt;br /&gt;
* Aim to address any redundant meta-review functionality, as indicated by the professor's preference to remove these from response_map.rb.&lt;br /&gt;
&lt;br /&gt;
4. Refactor for Code Clarity and Efficiency&lt;br /&gt;
&lt;br /&gt;
* Improve variable names, reduce unnecessary loops, and replace long method names with concise, intuitive alternatives.&lt;br /&gt;
* Ensure that each method has a single, clearly defined purpose, improving code readability.&lt;br /&gt;
&lt;br /&gt;
5. Testing and Documentation&lt;br /&gt;
&lt;br /&gt;
* Write comprehensive tests for all newly implemented and modified methods to ensure reliability.&lt;br /&gt;
* Add detailed comments to facilitate code maintenance and understanding for future developers.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Design Principles ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Single Responsibility Principle (SRP)&amp;lt;/b&amp;gt;: Each method and class should have a single, well-defined purpose.&lt;br /&gt;
* &amp;lt;b&amp;gt;Don’t Repeat Yourself (DRY)&amp;lt;/b&amp;gt;: Eliminate redundancy by creating general solutions that handle multiple scenarios.&lt;br /&gt;
* &amp;lt;b&amp;gt;Ruby Readability Guidelines (Week 9 Notes)&amp;lt;/b&amp;gt;:&lt;br /&gt;
** Guideline: Variable names should be neither too short nor too long.&lt;br /&gt;
** Guideline: Names should not be redundant.&lt;br /&gt;
** Guideline: &amp;lt;b&amp;gt;A method should do only one thing and do it well.&amp;lt;/b&amp;gt;&lt;br /&gt;
* &amp;lt;b&amp;gt;Visitor Pattern&amp;lt;/b&amp;gt;: Utilize this pattern to separate emailing functionalities from the main class.&lt;br /&gt;
&lt;br /&gt;
=== Implementation Plan ===&lt;br /&gt;
&lt;br /&gt;
The refactoring will proceed as follows:&lt;br /&gt;
&lt;br /&gt;
1. Analyze and Refactor Current Code Structure&lt;br /&gt;
&lt;br /&gt;
* Review and understand the existing structure and dependencies within feedback_response_map.rb.&lt;br /&gt;
* Identify areas of redundancy, complexity, and inefficiency, particularly in feedback_response_report, to create a clear plan for refactoring.&lt;br /&gt;
* Try to reduce character count and improve readability with aliasing (this way we do not break any code that relies on being able to call specific methods).&lt;br /&gt;
&lt;br /&gt;
2. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Consolidate containers for each review round to address DRY violations. By using a single structure to store review data, we will eliminate hard-coded repetition.&lt;br /&gt;
* Generalize logic to accommodate both scenarios where rubrics vary by round and where they do not, without duplicating code paths.&lt;br /&gt;
* Replace inefficient structures, such as multiple arrays, with more flexible and memory-efficient options, like a 2D array or a hash, to reduce memory usage and improve scalability.&lt;br /&gt;
&lt;br /&gt;
3. Introduce Helper Methods for Reusable Logic (for feedback_response_report)&lt;br /&gt;
&lt;br /&gt;
* Extract frequently used or complex code blocks into helper methods, reducing the size of primary methods and enhancing reusability.&lt;br /&gt;
* Use helper methods for specific actions, like handling rounds or retrieving assignment data, to make the code cleaner and better organized.&lt;br /&gt;
* Emphasis on adhering to the guideline: A method should do only one thing and do it well.&lt;br /&gt;
&lt;br /&gt;
4. Research Future Refactoring for email Method&lt;br /&gt;
&lt;br /&gt;
* The email method is convoluted and the functionality should be refactored into a different class in the future.&lt;br /&gt;
* This is because this visitor pattern violation is present in many classes, and is beyond the scope of a one-class re-implementation.&lt;br /&gt;
&lt;br /&gt;
5. Improve Variable Naming and Structure&lt;br /&gt;
&lt;br /&gt;
* Replace ambiguous variable names with clearer alternatives that convey purpose, such as renaming @temp_review_responses and @temp_response_map_ids to more meaningful names.&lt;br /&gt;
* Simplify long method names to make the code more readable and approachable for new contributors.&lt;br /&gt;
&lt;br /&gt;
Because the main focus will be on feedback_response_map.rb, we can take a closer look on what we will do to implement these (point #3 above). Before refactoring, the FeedbackResponseMap class contains 6 methods, with the majority of the code in self.feedback_response_report:&lt;br /&gt;
&lt;br /&gt;
[[File:FeedbackResponseMap_before.png |250px]]&lt;br /&gt;
&lt;br /&gt;
We aim to change that by splitting up this method into multiple helper methods, as seen in the following:&lt;br /&gt;
&lt;br /&gt;
[[File:FeedbackResponseMap_after.png |350px]]&lt;br /&gt;
&lt;br /&gt;
To go into more detail, here is the code for the feedback_response_report method, and how we intend to split it up:&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_after_code1.png |600px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2451_after_code2.png |600px]]&lt;br /&gt;
&lt;br /&gt;
The red section of code will be self.get_feedback_authors, yellow will be self.varying_rubrics_report, and green will be self.static_rubrics_report.&lt;br /&gt;
&lt;br /&gt;
Each separated group will be its own method, and self.varying_rubrics_report and self.static_rubrics_report (the yellow and green methods) will be returned at the end of the new feedback_response_report.&lt;br /&gt;
&lt;br /&gt;
=== Testing ===&lt;br /&gt;
&lt;br /&gt;
1. Adapt Existing Tests for Refactored Methods&lt;br /&gt;
&lt;br /&gt;
* Any new helper methods will be private, and so by the &amp;quot;Magic Tricks of Testing&amp;quot; guide, should not be tested (both query and command messages sent to self are ignored in the test plan).&lt;br /&gt;
* Use mocks to isolate components during testing, especially for external dependencies like Mailer, to ensure that email functionality works as expected without direct integration.&lt;br /&gt;
&lt;br /&gt;
2. Document Code for Clarity&lt;br /&gt;
&lt;br /&gt;
* Write detailed comments explaining the purpose of each method, input and output, and any critical logic that might be complex for future developers to understand.&lt;br /&gt;
* Create or update documentation and diagrams to illustrate the newly designed structure, making it easier for new developers to contribute or modify functionality.&lt;br /&gt;
&lt;br /&gt;
=== Documentation ===&lt;br /&gt;
&lt;br /&gt;
Ensure all code is well-documented, with comments explaining purpose, inputs, outputs, and any complex logic. Maintain updated documentation for all modified and newly added classes and methods, allowing for ease of understanding and maintenance.&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
&lt;br /&gt;
By refactoring feedback_response_map.rb, this project will enhance Expertiza’s backend maintainability and readability, ensuring a modular, efficient, and more secure implementation.&lt;br /&gt;
&lt;br /&gt;
== Team Information ==&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
* Chaitanya Srusti (crsrusti@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
=== Members ===&lt;br /&gt;
&lt;br /&gt;
* Sarah Daniel (sdaniel8@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* William Grochocinski (wagrocho@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Tipton Middleton (tgmiddl2@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* ChatGPT (Honorary Member)&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=159715</id>
		<title>CSC/ECE 517 Fall 2024 - E2451. Reimplement feedback response map.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=159715"/>
		<updated>2024-11-18T04:17:42Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2451: Reimplement feedback response map'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions, among other tasks. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
=== Project Overview ===&lt;br /&gt;
&lt;br /&gt;
The goal of this project is to refactor the feedback_response_map.rb file from the Expertiza repository and integrate it into the reimplementation-back-end repository. Within Expertiza, when a user submits a review, an instance of the Response class is created, associated with a ResponseMap. Each ResponseMap links a reviewer (reviewer_id), reviewee (reviewee_id), and the reviewed item (reviewed_object_id). FeedbackResponseMap, a subclass of ResponseMap, represents the feedback provided by a reviewee on the feedback received for their submission.&lt;br /&gt;
&lt;br /&gt;
This class has significant room for improvement, especially with respect to object-oriented principles. Refactoring feedback_response_map.rb will streamline functionality, enhance maintainability, and improve adherence to coding standards.&lt;br /&gt;
&lt;br /&gt;
=== Current Implementation ===&lt;br /&gt;
&lt;br /&gt;
The current feedback_response_map.rb in the Expertiza repository has several issues. It includes the following problems:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Poor adherence to SOLID and DRY principles&amp;lt;/b&amp;gt;: The current code structure introduces unnecessary repetition and complexity.&lt;br /&gt;
* &amp;lt;b&amp;gt;feedback_response_report Method Issues&amp;lt;/b&amp;gt;: This critical method is highly complex, relying on custom data structures and separate containers for each review round, resulting in a DRY violation.&lt;br /&gt;
* &amp;lt;b&amp;gt;Improper Responsibility Assignment&amp;lt;/b&amp;gt;: The email method does not belong within this class and would benefit from refactoring out into a separate class using the Visitor pattern. This pattern is suggested to streamline functionality, though alternative design patterns may be considered if more suitable.&lt;br /&gt;
* &amp;lt;b&amp;gt;Memory Inefficiencies&amp;lt;/b&amp;gt;: The method currently creates unnecessary memory through inefficient structures, including multiple separate arrays for different rounds of review, which could be simplified into a 2D array structure.&lt;br /&gt;
* &amp;lt;b&amp;gt;Code Smells&amp;lt;/b&amp;gt;: The code has redundant methods, unclear variable names, inefficient loops, and overly long method names.&lt;br /&gt;
&lt;br /&gt;
=== Objectives &amp;amp; Requirements ===&lt;br /&gt;
1. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Address the DRY violation by consolidating the containers for review rounds.&lt;br /&gt;
* Generalize the code to handle both cases—when rubrics vary by round and when they do not—without duplicating code.&lt;br /&gt;
* Introduce efficient data structures, like a 2D array, to replace multiple arrays and reduce memory usage.&lt;br /&gt;
&lt;br /&gt;
2. Separate Responsibilities Using Visitor Pattern (&amp;lt;i&amp;gt;stretch goal&amp;lt;/i&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
* Extract the email method using the Visitor pattern to modularize email functionality. Alternatively, select a design pattern better suited to organizing this method if available. Note that the email method is not properly used in its current location and is better suited to the Response class rather than ResponseMap.&lt;br /&gt;
&lt;br /&gt;
3. Eliminate Redundant Methods&lt;br /&gt;
&lt;br /&gt;
* Remove methods that do not serve a clear purpose and improve method naming for clarity.&lt;br /&gt;
* Aim to address any redundant meta-review functionality, as indicated by the professor's preference to remove these from response_map.rb.&lt;br /&gt;
&lt;br /&gt;
4. Refactor for Code Clarity and Efficiency&lt;br /&gt;
&lt;br /&gt;
* Improve variable names, reduce unnecessary loops, and replace long method names with concise, intuitive alternatives.&lt;br /&gt;
* Ensure that each method has a single, clearly defined purpose, improving code readability.&lt;br /&gt;
&lt;br /&gt;
5. Testing and Documentation&lt;br /&gt;
&lt;br /&gt;
* Write comprehensive tests for all newly implemented and modified methods to ensure reliability.&lt;br /&gt;
* Add detailed comments to facilitate code maintenance and understanding for future developers.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Design Principles ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Single Responsibility Principle (SRP)&amp;lt;/b&amp;gt;: Each method and class should have a single, well-defined purpose.&lt;br /&gt;
* &amp;lt;b&amp;gt;Don’t Repeat Yourself (DRY)&amp;lt;/b&amp;gt;: Eliminate redundancy by creating general solutions that handle multiple scenarios.&lt;br /&gt;
* &amp;lt;b&amp;gt;Ruby Readability Guidelines (Week 9 Notes)&amp;lt;/b&amp;gt;:&lt;br /&gt;
** Guideline: Variable names should be neither too short nor too long.&lt;br /&gt;
** Guideline: Names should not be redundant.&lt;br /&gt;
** Guideline: &amp;lt;b&amp;gt;A method should do only one thing and do it well.&amp;lt;/b&amp;gt;&lt;br /&gt;
* &amp;lt;b&amp;gt;Visitor Pattern&amp;lt;/b&amp;gt;: Utilize this pattern to separate emailing functionalities from the main class.&lt;br /&gt;
&lt;br /&gt;
=== Implementation Plan ===&lt;br /&gt;
&lt;br /&gt;
The refactoring will proceed as follows:&lt;br /&gt;
&lt;br /&gt;
1. Analyze and Refactor Current Code Structure&lt;br /&gt;
&lt;br /&gt;
* Review and understand the existing structure and dependencies within feedback_response_map.rb.&lt;br /&gt;
* Identify areas of redundancy, complexity, and inefficiency, particularly in feedback_response_report, to create a clear plan for refactoring.&lt;br /&gt;
* Try to reduce character count and improve readability with aliasing (this way we do not break any code that relies on being able to call specific methods).&lt;br /&gt;
&lt;br /&gt;
2. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Consolidate containers for each review round to address DRY violations. By using a single structure to store review data, we will eliminate hard-coded repetition.&lt;br /&gt;
* Generalize logic to accommodate both scenarios where rubrics vary by round and where they do not, without duplicating code paths.&lt;br /&gt;
* Replace inefficient structures, such as multiple arrays, with more flexible and memory-efficient options, like a 2D array or a hash, to reduce memory usage and improve scalability.&lt;br /&gt;
&lt;br /&gt;
3. Introduce Helper Methods for Reusable Logic (for feedback_response_report)&lt;br /&gt;
&lt;br /&gt;
* Extract frequently used or complex code blocks into helper methods, reducing the size of primary methods and enhancing reusability.&lt;br /&gt;
* Use helper methods for specific actions, like handling rounds or retrieving assignment data, to make the code cleaner and better organized.&lt;br /&gt;
* Emphasis on adhering to the guideline: A method should do only one thing and do it well.&lt;br /&gt;
&lt;br /&gt;
4. Research Future Refactoring for email Method&lt;br /&gt;
&lt;br /&gt;
* The email method is convoluted and the functionality should be refactored into a different class in the future.&lt;br /&gt;
* This is because this visitor pattern violation is present in many classes, and is beyond the scope of a one-class re-implementation.&lt;br /&gt;
&lt;br /&gt;
5. Improve Variable Naming and Structure&lt;br /&gt;
&lt;br /&gt;
* Replace ambiguous variable names with clearer alternatives that convey purpose, such as renaming @temp_review_responses and @temp_response_map_ids to more meaningful names.&lt;br /&gt;
* Simplify long method names to make the code more readable and approachable for new contributors.&lt;br /&gt;
&lt;br /&gt;
Because the main focus will be on feedback_response_map.rb, we can take a closer look on what we will do to implement these (point #3 above). Before refactoring, the FeedbackResponseMap class contains 6 methods, with the majority of the code in self.feedback_response_report:&lt;br /&gt;
&lt;br /&gt;
[[File:FeedbackResponseMap_before.png |300px]]&lt;br /&gt;
&lt;br /&gt;
We aim to change that by splitting up this method into multiple helper methods, as seen in the following:&lt;br /&gt;
&lt;br /&gt;
[[File:FeedbackResponseMap_after.png |300px]]&lt;br /&gt;
&lt;br /&gt;
To go into more detail, here is the code for the feedback_response_report method, and how we intend to split it up:&lt;br /&gt;
&lt;br /&gt;
[[E2451_after_code1.png |400px]]&lt;br /&gt;
&lt;br /&gt;
[[E2451_after_code2.png |400px]]&lt;br /&gt;
&lt;br /&gt;
The red section of code will be self.get_feedback_authors, yellow will be self.varying_rubrics_report, and green will be self.static_rubrics_report.&lt;br /&gt;
&lt;br /&gt;
Each separated group will be its own method, and self.varying_rubrics_report and self.static_rubrics_report (the yellow and green methods) will be returned at the end of the new feedback_response_report.&lt;br /&gt;
&lt;br /&gt;
=== Testing ===&lt;br /&gt;
&lt;br /&gt;
1. Adapt Existing Tests for Refactored Methods&lt;br /&gt;
&lt;br /&gt;
* Any new helper methods will be private, and so by the &amp;quot;Magic Tricks of Testing&amp;quot; guide, should not be tested (both query and command messages sent to self are ignored in the test plan).&lt;br /&gt;
* Use mocks to isolate components during testing, especially for external dependencies like Mailer, to ensure that email functionality works as expected without direct integration.&lt;br /&gt;
&lt;br /&gt;
2. Document Code for Clarity&lt;br /&gt;
&lt;br /&gt;
* Write detailed comments explaining the purpose of each method, input and output, and any critical logic that might be complex for future developers to understand.&lt;br /&gt;
* Create or update documentation and diagrams to illustrate the newly designed structure, making it easier for new developers to contribute or modify functionality.&lt;br /&gt;
&lt;br /&gt;
=== Documentation ===&lt;br /&gt;
&lt;br /&gt;
Ensure all code is well-documented, with comments explaining purpose, inputs, outputs, and any complex logic. Maintain updated documentation for all modified and newly added classes and methods, allowing for ease of understanding and maintenance.&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
&lt;br /&gt;
By refactoring feedback_response_map.rb, this project will enhance Expertiza’s backend maintainability and readability, ensuring a modular, efficient, and more secure implementation.&lt;br /&gt;
&lt;br /&gt;
== Team Information ==&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
* Chaitanya Srusti (crsrusti@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
=== Members ===&lt;br /&gt;
&lt;br /&gt;
* Sarah Daniel (sdaniel8@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* William Grochocinski (wagrocho@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Tipton Middleton (tgmiddl2@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* ChatGPT (Honorary Member)&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2451_after_code2.png&amp;diff=159714</id>
		<title>File:E2451 after code2.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2451_after_code2.png&amp;diff=159714"/>
		<updated>2024-11-18T04:14:48Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2451_after_code1.png&amp;diff=159713</id>
		<title>File:E2451 after code1.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2451_after_code1.png&amp;diff=159713"/>
		<updated>2024-11-18T04:14:01Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:FeedbackResponseMap_after.png&amp;diff=159711</id>
		<title>File:FeedbackResponseMap after.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:FeedbackResponseMap_after.png&amp;diff=159711"/>
		<updated>2024-11-18T04:11:15Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=159707</id>
		<title>CSC/ECE 517 Fall 2024 - E2451. Reimplement feedback response map.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=159707"/>
		<updated>2024-11-18T04:05:26Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2451: Reimplement feedback response map'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions, among other tasks. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
=== Project Overview ===&lt;br /&gt;
&lt;br /&gt;
The goal of this project is to refactor the feedback_response_map.rb file from the Expertiza repository and integrate it into the reimplementation-back-end repository. Within Expertiza, when a user submits a review, an instance of the Response class is created, associated with a ResponseMap. Each ResponseMap links a reviewer (reviewer_id), reviewee (reviewee_id), and the reviewed item (reviewed_object_id). FeedbackResponseMap, a subclass of ResponseMap, represents the feedback provided by a reviewee on the feedback received for their submission.&lt;br /&gt;
&lt;br /&gt;
This class has significant room for improvement, especially with respect to object-oriented principles. Refactoring feedback_response_map.rb will streamline functionality, enhance maintainability, and improve adherence to coding standards.&lt;br /&gt;
&lt;br /&gt;
=== Current Implementation ===&lt;br /&gt;
&lt;br /&gt;
The current feedback_response_map.rb in the Expertiza repository has several issues. It includes the following problems:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Poor adherence to SOLID and DRY principles&amp;lt;/b&amp;gt;: The current code structure introduces unnecessary repetition and complexity.&lt;br /&gt;
* &amp;lt;b&amp;gt;feedback_response_report Method Issues&amp;lt;/b&amp;gt;: This critical method is highly complex, relying on custom data structures and separate containers for each review round, resulting in a DRY violation.&lt;br /&gt;
* &amp;lt;b&amp;gt;Improper Responsibility Assignment&amp;lt;/b&amp;gt;: The email method does not belong within this class and would benefit from refactoring out into a separate class using the Visitor pattern. This pattern is suggested to streamline functionality, though alternative design patterns may be considered if more suitable.&lt;br /&gt;
* &amp;lt;b&amp;gt;Memory Inefficiencies&amp;lt;/b&amp;gt;: The method currently creates unnecessary memory through inefficient structures, including multiple separate arrays for different rounds of review, which could be simplified into a 2D array structure.&lt;br /&gt;
* &amp;lt;b&amp;gt;Code Smells&amp;lt;/b&amp;gt;: The code has redundant methods, unclear variable names, inefficient loops, and overly long method names.&lt;br /&gt;
&lt;br /&gt;
=== Objectives &amp;amp; Requirements ===&lt;br /&gt;
1. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Address the DRY violation by consolidating the containers for review rounds.&lt;br /&gt;
* Generalize the code to handle both cases—when rubrics vary by round and when they do not—without duplicating code.&lt;br /&gt;
* Introduce efficient data structures, like a 2D array, to replace multiple arrays and reduce memory usage.&lt;br /&gt;
&lt;br /&gt;
2. Separate Responsibilities Using Visitor Pattern (&amp;lt;i&amp;gt;stretch goal&amp;lt;/i&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
* Extract the email method using the Visitor pattern to modularize email functionality. Alternatively, select a design pattern better suited to organizing this method if available. Note that the email method is not properly used in its current location and is better suited to the Response class rather than ResponseMap.&lt;br /&gt;
&lt;br /&gt;
3. Eliminate Redundant Methods&lt;br /&gt;
&lt;br /&gt;
* Remove methods that do not serve a clear purpose and improve method naming for clarity.&lt;br /&gt;
* Aim to address any redundant meta-review functionality, as indicated by the professor's preference to remove these from response_map.rb.&lt;br /&gt;
&lt;br /&gt;
4. Refactor for Code Clarity and Efficiency&lt;br /&gt;
&lt;br /&gt;
* Improve variable names, reduce unnecessary loops, and replace long method names with concise, intuitive alternatives.&lt;br /&gt;
* Ensure that each method has a single, clearly defined purpose, improving code readability.&lt;br /&gt;
&lt;br /&gt;
5. Testing and Documentation&lt;br /&gt;
&lt;br /&gt;
* Write comprehensive tests for all newly implemented and modified methods to ensure reliability.&lt;br /&gt;
* Add detailed comments to facilitate code maintenance and understanding for future developers.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Design Principles ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Single Responsibility Principle (SRP)&amp;lt;/b&amp;gt;: Each method and class should have a single, well-defined purpose.&lt;br /&gt;
* &amp;lt;b&amp;gt;Don’t Repeat Yourself (DRY)&amp;lt;/b&amp;gt;: Eliminate redundancy by creating general solutions that handle multiple scenarios.&lt;br /&gt;
* &amp;lt;b&amp;gt;Ruby Readability Guidelines (Week 9 Notes)&amp;lt;/b&amp;gt;:&lt;br /&gt;
** Guideline: Variable names should be neither too short nor too long.&lt;br /&gt;
** Guideline: Names should not be redundant.&lt;br /&gt;
** Guideline: &amp;lt;b&amp;gt;A method should do only one thing and do it well.&amp;lt;/b&amp;gt;&lt;br /&gt;
* &amp;lt;b&amp;gt;Visitor Pattern&amp;lt;/b&amp;gt;: Utilize this pattern to separate emailing functionalities from the main class.&lt;br /&gt;
&lt;br /&gt;
=== Implementation Plan ===&lt;br /&gt;
Before refactoring, the FeedbackResponseMap class contained 6 methods, with the majority of the code in self.feedback_response_report as seen below:&lt;br /&gt;
&lt;br /&gt;
[[File:FeedbackResponseMap_before.png |300px]]&lt;br /&gt;
&lt;br /&gt;
We aim to change that by splitting up this method into multiple helper methods.&lt;br /&gt;
&lt;br /&gt;
The refactoring will proceed as follows:&lt;br /&gt;
&lt;br /&gt;
1. Analyze and Refactor Current Code Structure&lt;br /&gt;
&lt;br /&gt;
* Review and understand the existing structure and dependencies within feedback_response_map.rb.&lt;br /&gt;
* Identify areas of redundancy, complexity, and inefficiency, particularly in feedback_response_report, to create a clear plan for refactoring.&lt;br /&gt;
* Try to reduce character count and improve readability with aliasing (this way we do not break any code that relies on being able to call specific methods).&lt;br /&gt;
&lt;br /&gt;
2. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Consolidate containers for each review round to address DRY violations. By using a single structure to store review data, we will eliminate hard-coded repetition.&lt;br /&gt;
* Generalize logic to accommodate both scenarios where rubrics vary by round and where they do not, without duplicating code paths.&lt;br /&gt;
* Replace inefficient structures, such as multiple arrays, with more flexible and memory-efficient options, like a 2D array or a hash, to reduce memory usage and improve scalability.&lt;br /&gt;
&lt;br /&gt;
3. Introduce Helper Methods for Reusable Logic (for feedback_response_report)&lt;br /&gt;
&lt;br /&gt;
* Extract frequently used or complex code blocks into helper methods, reducing the size of primary methods and enhancing reusability.&lt;br /&gt;
* Use helper methods for specific actions, like handling rounds or retrieving assignment data, to make the code cleaner and better organized.&lt;br /&gt;
* Emphasis on adhering to the guideline: A method should do only one thing and do it well.&lt;br /&gt;
&lt;br /&gt;
4. Research Future Refactoring for email Method&lt;br /&gt;
&lt;br /&gt;
* The email method is convoluted and the functionality should be refactored into a different class in the future.&lt;br /&gt;
* This is because this visitor pattern violation is present in many classes, and is beyond the scope of a one-class re-implementation.&lt;br /&gt;
&lt;br /&gt;
5. Improve Variable Naming and Structure&lt;br /&gt;
&lt;br /&gt;
* Replace ambiguous variable names with clearer alternatives that convey purpose, such as renaming @temp_review_responses and @temp_response_map_ids to more meaningful names.&lt;br /&gt;
* Simplify long method names to make the code more readable and approachable for new contributors.&lt;br /&gt;
&lt;br /&gt;
=== Testing ===&lt;br /&gt;
&lt;br /&gt;
1. Adapt Existing Tests for Refactored Methods&lt;br /&gt;
&lt;br /&gt;
* Any new helper methods will be private, and so by the &amp;quot;Magic Tricks of Testing&amp;quot; guide, should not be tested (both query and command messages sent to self are ignored in the test plan).&lt;br /&gt;
* Use mocks to isolate components during testing, especially for external dependencies like Mailer, to ensure that email functionality works as expected without direct integration.&lt;br /&gt;
&lt;br /&gt;
2. Document Code for Clarity&lt;br /&gt;
&lt;br /&gt;
* Write detailed comments explaining the purpose of each method, input and output, and any critical logic that might be complex for future developers to understand.&lt;br /&gt;
* Create or update documentation and diagrams to illustrate the newly designed structure, making it easier for new developers to contribute or modify functionality.&lt;br /&gt;
&lt;br /&gt;
=== Documentation ===&lt;br /&gt;
&lt;br /&gt;
Ensure all code is well-documented, with comments explaining purpose, inputs, outputs, and any complex logic. Maintain updated documentation for all modified and newly added classes and methods, allowing for ease of understanding and maintenance.&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
&lt;br /&gt;
By refactoring feedback_response_map.rb, this project will enhance Expertiza’s backend maintainability and readability, ensuring a modular, efficient, and more secure implementation.&lt;br /&gt;
&lt;br /&gt;
== Team Information ==&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
* Chaitanya Srusti (crsrusti@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
=== Members ===&lt;br /&gt;
&lt;br /&gt;
* Sarah Daniel (sdaniel8@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* William Grochocinski (wagrocho@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Tipton Middleton (tgmiddl2@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* ChatGPT (Honorary Member)&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=159706</id>
		<title>CSC/ECE 517 Fall 2024 - E2451. Reimplement feedback response map.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=159706"/>
		<updated>2024-11-18T04:05:08Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2451: Reimplement feedback response map'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions, among other tasks. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
=== Project Overview ===&lt;br /&gt;
&lt;br /&gt;
The goal of this project is to refactor the feedback_response_map.rb file from the Expertiza repository and integrate it into the reimplementation-back-end repository. Within Expertiza, when a user submits a review, an instance of the Response class is created, associated with a ResponseMap. Each ResponseMap links a reviewer (reviewer_id), reviewee (reviewee_id), and the reviewed item (reviewed_object_id). FeedbackResponseMap, a subclass of ResponseMap, represents the feedback provided by a reviewee on the feedback received for their submission.&lt;br /&gt;
&lt;br /&gt;
This class has significant room for improvement, especially with respect to object-oriented principles. Refactoring feedback_response_map.rb will streamline functionality, enhance maintainability, and improve adherence to coding standards.&lt;br /&gt;
&lt;br /&gt;
=== Current Implementation ===&lt;br /&gt;
&lt;br /&gt;
The current feedback_response_map.rb in the Expertiza repository has several issues. It includes the following problems:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Poor adherence to SOLID and DRY principles&amp;lt;/b&amp;gt;: The current code structure introduces unnecessary repetition and complexity.&lt;br /&gt;
* &amp;lt;b&amp;gt;feedback_response_report Method Issues&amp;lt;/b&amp;gt;: This critical method is highly complex, relying on custom data structures and separate containers for each review round, resulting in a DRY violation.&lt;br /&gt;
* &amp;lt;b&amp;gt;Improper Responsibility Assignment&amp;lt;/b&amp;gt;: The email method does not belong within this class and would benefit from refactoring out into a separate class using the Visitor pattern. This pattern is suggested to streamline functionality, though alternative design patterns may be considered if more suitable.&lt;br /&gt;
* &amp;lt;b&amp;gt;Memory Inefficiencies&amp;lt;/b&amp;gt;: The method currently creates unnecessary memory through inefficient structures, including multiple separate arrays for different rounds of review, which could be simplified into a 2D array structure.&lt;br /&gt;
* &amp;lt;b&amp;gt;Code Smells&amp;lt;/b&amp;gt;: The code has redundant methods, unclear variable names, inefficient loops, and overly long method names.&lt;br /&gt;
&lt;br /&gt;
=== Objectives &amp;amp; Requirements ===&lt;br /&gt;
1. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Address the DRY violation by consolidating the containers for review rounds.&lt;br /&gt;
* Generalize the code to handle both cases—when rubrics vary by round and when they do not—without duplicating code.&lt;br /&gt;
* Introduce efficient data structures, like a 2D array, to replace multiple arrays and reduce memory usage.&lt;br /&gt;
&lt;br /&gt;
2. Separate Responsibilities Using Visitor Pattern (&amp;lt;i&amp;gt;stretch goal&amp;lt;/i&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
* Extract the email method using the Visitor pattern to modularize email functionality. Alternatively, select a design pattern better suited to organizing this method if available. Note that the email method is not properly used in its current location and is better suited to the Response class rather than ResponseMap.&lt;br /&gt;
&lt;br /&gt;
3. Eliminate Redundant Methods&lt;br /&gt;
&lt;br /&gt;
* Remove methods that do not serve a clear purpose and improve method naming for clarity.&lt;br /&gt;
* Aim to address any redundant meta-review functionality, as indicated by the professor's preference to remove these from response_map.rb.&lt;br /&gt;
&lt;br /&gt;
4. Refactor for Code Clarity and Efficiency&lt;br /&gt;
&lt;br /&gt;
* Improve variable names, reduce unnecessary loops, and replace long method names with concise, intuitive alternatives.&lt;br /&gt;
* Ensure that each method has a single, clearly defined purpose, improving code readability.&lt;br /&gt;
&lt;br /&gt;
5. Testing and Documentation&lt;br /&gt;
&lt;br /&gt;
* Write comprehensive tests for all newly implemented and modified methods to ensure reliability.&lt;br /&gt;
* Add detailed comments to facilitate code maintenance and understanding for future developers.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Design Principles ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Single Responsibility Principle (SRP)&amp;lt;/b&amp;gt;: Each method and class should have a single, well-defined purpose.&lt;br /&gt;
* &amp;lt;b&amp;gt;Don’t Repeat Yourself (DRY)&amp;lt;/b&amp;gt;: Eliminate redundancy by creating general solutions that handle multiple scenarios.&lt;br /&gt;
* &amp;lt;b&amp;gt;Ruby Readability Guidelines (Week 9 Notes)&amp;lt;/b&amp;gt;:&lt;br /&gt;
** Guideline: Variable names should be neither too short nor too long.&lt;br /&gt;
** Guideline: Names should not be redundant.&lt;br /&gt;
** Guideline: &amp;lt;b&amp;gt;A method should do only one thing and do it well.&amp;lt;/b&amp;gt;&lt;br /&gt;
* &amp;lt;b&amp;gt;Visitor Pattern&amp;lt;/b&amp;gt;: Utilize this pattern to separate emailing functionalities from the main class.&lt;br /&gt;
&lt;br /&gt;
=== Implementation Plan ===&lt;br /&gt;
Before refactoring, the FeedbackResponseMap class contained 6 methods, with the majority of the code in self.feedback_response_report as seen below:&lt;br /&gt;
&lt;br /&gt;
[[File:FeedbackResponseMap_before.png |200px]]&lt;br /&gt;
&lt;br /&gt;
We aim to change that by splitting up this method into multiple helper methods.&lt;br /&gt;
&lt;br /&gt;
The refactoring will proceed as follows:&lt;br /&gt;
&lt;br /&gt;
1. Analyze and Refactor Current Code Structure&lt;br /&gt;
&lt;br /&gt;
* Review and understand the existing structure and dependencies within feedback_response_map.rb.&lt;br /&gt;
* Identify areas of redundancy, complexity, and inefficiency, particularly in feedback_response_report, to create a clear plan for refactoring.&lt;br /&gt;
* Try to reduce character count and improve readability with aliasing (this way we do not break any code that relies on being able to call specific methods).&lt;br /&gt;
&lt;br /&gt;
2. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Consolidate containers for each review round to address DRY violations. By using a single structure to store review data, we will eliminate hard-coded repetition.&lt;br /&gt;
* Generalize logic to accommodate both scenarios where rubrics vary by round and where they do not, without duplicating code paths.&lt;br /&gt;
* Replace inefficient structures, such as multiple arrays, with more flexible and memory-efficient options, like a 2D array or a hash, to reduce memory usage and improve scalability.&lt;br /&gt;
&lt;br /&gt;
3. Introduce Helper Methods for Reusable Logic (for feedback_response_report)&lt;br /&gt;
&lt;br /&gt;
* Extract frequently used or complex code blocks into helper methods, reducing the size of primary methods and enhancing reusability.&lt;br /&gt;
* Use helper methods for specific actions, like handling rounds or retrieving assignment data, to make the code cleaner and better organized.&lt;br /&gt;
* Emphasis on adhering to the guideline: A method should do only one thing and do it well.&lt;br /&gt;
&lt;br /&gt;
4. Research Future Refactoring for email Method&lt;br /&gt;
&lt;br /&gt;
* The email method is convoluted and the functionality should be refactored into a different class in the future.&lt;br /&gt;
* This is because this visitor pattern violation is present in many classes, and is beyond the scope of a one-class re-implementation.&lt;br /&gt;
&lt;br /&gt;
5. Improve Variable Naming and Structure&lt;br /&gt;
&lt;br /&gt;
* Replace ambiguous variable names with clearer alternatives that convey purpose, such as renaming @temp_review_responses and @temp_response_map_ids to more meaningful names.&lt;br /&gt;
* Simplify long method names to make the code more readable and approachable for new contributors.&lt;br /&gt;
&lt;br /&gt;
=== Testing ===&lt;br /&gt;
&lt;br /&gt;
1. Adapt Existing Tests for Refactored Methods&lt;br /&gt;
&lt;br /&gt;
* Any new helper methods will be private, and so by the &amp;quot;Magic Tricks of Testing&amp;quot; guide, should not be tested (both query and command messages sent to self are ignored in the test plan).&lt;br /&gt;
* Use mocks to isolate components during testing, especially for external dependencies like Mailer, to ensure that email functionality works as expected without direct integration.&lt;br /&gt;
&lt;br /&gt;
2. Document Code for Clarity&lt;br /&gt;
&lt;br /&gt;
* Write detailed comments explaining the purpose of each method, input and output, and any critical logic that might be complex for future developers to understand.&lt;br /&gt;
* Create or update documentation and diagrams to illustrate the newly designed structure, making it easier for new developers to contribute or modify functionality.&lt;br /&gt;
&lt;br /&gt;
=== Documentation ===&lt;br /&gt;
&lt;br /&gt;
Ensure all code is well-documented, with comments explaining purpose, inputs, outputs, and any complex logic. Maintain updated documentation for all modified and newly added classes and methods, allowing for ease of understanding and maintenance.&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
&lt;br /&gt;
By refactoring feedback_response_map.rb, this project will enhance Expertiza’s backend maintainability and readability, ensuring a modular, efficient, and more secure implementation.&lt;br /&gt;
&lt;br /&gt;
== Team Information ==&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
* Chaitanya Srusti (crsrusti@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
=== Members ===&lt;br /&gt;
&lt;br /&gt;
* Sarah Daniel (sdaniel8@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* William Grochocinski (wagrocho@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Tipton Middleton (tgmiddl2@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* ChatGPT (Honorary Member)&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=159705</id>
		<title>CSC/ECE 517 Fall 2024 - E2451. Reimplement feedback response map.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=159705"/>
		<updated>2024-11-18T04:04:42Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2451: Reimplement feedback response map'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions, among other tasks. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
=== Project Overview ===&lt;br /&gt;
&lt;br /&gt;
The goal of this project is to refactor the feedback_response_map.rb file from the Expertiza repository and integrate it into the reimplementation-back-end repository. Within Expertiza, when a user submits a review, an instance of the Response class is created, associated with a ResponseMap. Each ResponseMap links a reviewer (reviewer_id), reviewee (reviewee_id), and the reviewed item (reviewed_object_id). FeedbackResponseMap, a subclass of ResponseMap, represents the feedback provided by a reviewee on the feedback received for their submission.&lt;br /&gt;
&lt;br /&gt;
This class has significant room for improvement, especially with respect to object-oriented principles. Refactoring feedback_response_map.rb will streamline functionality, enhance maintainability, and improve adherence to coding standards.&lt;br /&gt;
&lt;br /&gt;
=== Current Implementation ===&lt;br /&gt;
&lt;br /&gt;
The current feedback_response_map.rb in the Expertiza repository has several issues. It includes the following problems:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Poor adherence to SOLID and DRY principles&amp;lt;/b&amp;gt;: The current code structure introduces unnecessary repetition and complexity.&lt;br /&gt;
* &amp;lt;b&amp;gt;feedback_response_report Method Issues&amp;lt;/b&amp;gt;: This critical method is highly complex, relying on custom data structures and separate containers for each review round, resulting in a DRY violation.&lt;br /&gt;
* &amp;lt;b&amp;gt;Improper Responsibility Assignment&amp;lt;/b&amp;gt;: The email method does not belong within this class and would benefit from refactoring out into a separate class using the Visitor pattern. This pattern is suggested to streamline functionality, though alternative design patterns may be considered if more suitable.&lt;br /&gt;
* &amp;lt;b&amp;gt;Memory Inefficiencies&amp;lt;/b&amp;gt;: The method currently creates unnecessary memory through inefficient structures, including multiple separate arrays for different rounds of review, which could be simplified into a 2D array structure.&lt;br /&gt;
* &amp;lt;b&amp;gt;Code Smells&amp;lt;/b&amp;gt;: The code has redundant methods, unclear variable names, inefficient loops, and overly long method names.&lt;br /&gt;
&lt;br /&gt;
=== Objectives &amp;amp; Requirements ===&lt;br /&gt;
1. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Address the DRY violation by consolidating the containers for review rounds.&lt;br /&gt;
* Generalize the code to handle both cases—when rubrics vary by round and when they do not—without duplicating code.&lt;br /&gt;
* Introduce efficient data structures, like a 2D array, to replace multiple arrays and reduce memory usage.&lt;br /&gt;
&lt;br /&gt;
2. Separate Responsibilities Using Visitor Pattern (&amp;lt;i&amp;gt;stretch goal&amp;lt;/i&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
* Extract the email method using the Visitor pattern to modularize email functionality. Alternatively, select a design pattern better suited to organizing this method if available. Note that the email method is not properly used in its current location and is better suited to the Response class rather than ResponseMap.&lt;br /&gt;
&lt;br /&gt;
3. Eliminate Redundant Methods&lt;br /&gt;
&lt;br /&gt;
* Remove methods that do not serve a clear purpose and improve method naming for clarity.&lt;br /&gt;
* Aim to address any redundant meta-review functionality, as indicated by the professor's preference to remove these from response_map.rb.&lt;br /&gt;
&lt;br /&gt;
4. Refactor for Code Clarity and Efficiency&lt;br /&gt;
&lt;br /&gt;
* Improve variable names, reduce unnecessary loops, and replace long method names with concise, intuitive alternatives.&lt;br /&gt;
* Ensure that each method has a single, clearly defined purpose, improving code readability.&lt;br /&gt;
&lt;br /&gt;
5. Testing and Documentation&lt;br /&gt;
&lt;br /&gt;
* Write comprehensive tests for all newly implemented and modified methods to ensure reliability.&lt;br /&gt;
* Add detailed comments to facilitate code maintenance and understanding for future developers.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Design Principles ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Single Responsibility Principle (SRP)&amp;lt;/b&amp;gt;: Each method and class should have a single, well-defined purpose.&lt;br /&gt;
* &amp;lt;b&amp;gt;Don’t Repeat Yourself (DRY)&amp;lt;/b&amp;gt;: Eliminate redundancy by creating general solutions that handle multiple scenarios.&lt;br /&gt;
* &amp;lt;b&amp;gt;Ruby Readability Guidelines (Week 9 Notes)&amp;lt;/b&amp;gt;:&lt;br /&gt;
** Guideline: Variable names should be neither too short nor too long.&lt;br /&gt;
** Guideline: Names should not be redundant.&lt;br /&gt;
** Guideline: &amp;lt;b&amp;gt;A method should do only one thing and do it well.&amp;lt;/b&amp;gt;&lt;br /&gt;
* &amp;lt;b&amp;gt;Visitor Pattern&amp;lt;/b&amp;gt;: Utilize this pattern to separate emailing functionalities from the main class.&lt;br /&gt;
&lt;br /&gt;
=== Implementation Plan ===&lt;br /&gt;
Before refactoring, the FeedbackResponseMap class contained 6 methods, with the majority of the code in self.feedback_response_report as seen below:&lt;br /&gt;
&lt;br /&gt;
[[File:FeedbackResponseMap_before.png |300px]]&lt;br /&gt;
&lt;br /&gt;
We aim to change that by splitting up this method into multiple helper methods.&lt;br /&gt;
&lt;br /&gt;
The refactoring will proceed as follows:&lt;br /&gt;
&lt;br /&gt;
1. Analyze and Refactor Current Code Structure&lt;br /&gt;
&lt;br /&gt;
* Review and understand the existing structure and dependencies within feedback_response_map.rb.&lt;br /&gt;
* Identify areas of redundancy, complexity, and inefficiency, particularly in feedback_response_report, to create a clear plan for refactoring.&lt;br /&gt;
* Try to reduce character count and improve readability with aliasing (this way we do not break any code that relies on being able to call specific methods).&lt;br /&gt;
&lt;br /&gt;
2. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Consolidate containers for each review round to address DRY violations. By using a single structure to store review data, we will eliminate hard-coded repetition.&lt;br /&gt;
* Generalize logic to accommodate both scenarios where rubrics vary by round and where they do not, without duplicating code paths.&lt;br /&gt;
* Replace inefficient structures, such as multiple arrays, with more flexible and memory-efficient options, like a 2D array or a hash, to reduce memory usage and improve scalability.&lt;br /&gt;
&lt;br /&gt;
3. Introduce Helper Methods for Reusable Logic (for feedback_response_report)&lt;br /&gt;
&lt;br /&gt;
* Extract frequently used or complex code blocks into helper methods, reducing the size of primary methods and enhancing reusability.&lt;br /&gt;
* Use helper methods for specific actions, like handling rounds or retrieving assignment data, to make the code cleaner and better organized.&lt;br /&gt;
* Emphasis on adhering to the guideline: A method should do only one thing and do it well.&lt;br /&gt;
&lt;br /&gt;
4. Research Future Refactoring for email Method&lt;br /&gt;
&lt;br /&gt;
* The email method is convoluted and the functionality should be refactored into a different class in the future.&lt;br /&gt;
* This is because this visitor pattern violation is present in many classes, and is beyond the scope of a one-class re-implementation.&lt;br /&gt;
&lt;br /&gt;
5. Improve Variable Naming and Structure&lt;br /&gt;
&lt;br /&gt;
* Replace ambiguous variable names with clearer alternatives that convey purpose, such as renaming @temp_review_responses and @temp_response_map_ids to more meaningful names.&lt;br /&gt;
* Simplify long method names to make the code more readable and approachable for new contributors.&lt;br /&gt;
&lt;br /&gt;
=== Testing ===&lt;br /&gt;
&lt;br /&gt;
1. Adapt Existing Tests for Refactored Methods&lt;br /&gt;
&lt;br /&gt;
* Any new helper methods will be private, and so by the &amp;quot;Magic Tricks of Testing&amp;quot; guide, should not be tested (both query and command messages sent to self are ignored in the test plan).&lt;br /&gt;
* Use mocks to isolate components during testing, especially for external dependencies like Mailer, to ensure that email functionality works as expected without direct integration.&lt;br /&gt;
&lt;br /&gt;
2. Document Code for Clarity&lt;br /&gt;
&lt;br /&gt;
* Write detailed comments explaining the purpose of each method, input and output, and any critical logic that might be complex for future developers to understand.&lt;br /&gt;
* Create or update documentation and diagrams to illustrate the newly designed structure, making it easier for new developers to contribute or modify functionality.&lt;br /&gt;
&lt;br /&gt;
=== Documentation ===&lt;br /&gt;
&lt;br /&gt;
Ensure all code is well-documented, with comments explaining purpose, inputs, outputs, and any complex logic. Maintain updated documentation for all modified and newly added classes and methods, allowing for ease of understanding and maintenance.&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
&lt;br /&gt;
By refactoring feedback_response_map.rb, this project will enhance Expertiza’s backend maintainability and readability, ensuring a modular, efficient, and more secure implementation.&lt;br /&gt;
&lt;br /&gt;
== Team Information ==&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
* Chaitanya Srusti (crsrusti@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
=== Members ===&lt;br /&gt;
&lt;br /&gt;
* Sarah Daniel (sdaniel8@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* William Grochocinski (wagrocho@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Tipton Middleton (tgmiddl2@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* ChatGPT (Honorary Member)&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:FeedbackResponseMap_before.png&amp;diff=159702</id>
		<title>File:FeedbackResponseMap before.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:FeedbackResponseMap_before.png&amp;diff=159702"/>
		<updated>2024-11-18T04:00:38Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=159037</id>
		<title>CSC/ECE 517 Fall 2024 - E2451. Reimplement feedback response map.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=159037"/>
		<updated>2024-11-12T03:39:11Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2451: Reimplement feedback response map'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions, among other tasks. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
=== Project Overview ===&lt;br /&gt;
&lt;br /&gt;
The goal of this project is to refactor the feedback_response_map.rb file from the Expertiza repository and integrate it into the reimplementation-back-end repository. Within Expertiza, when a user submits a review, an instance of the Response class is created, associated with a ResponseMap. Each ResponseMap links a reviewer (reviewer_id), reviewee (reviewee_id), and the reviewed item (reviewed_object_id). FeedbackResponseMap, a subclass of ResponseMap, represents the feedback provided by a reviewee on the feedback received for their submission.&lt;br /&gt;
&lt;br /&gt;
This class has significant room for improvement, especially with respect to object-oriented principles. Refactoring feedback_response_map.rb will streamline functionality, enhance maintainability, and improve adherence to coding standards.&lt;br /&gt;
&lt;br /&gt;
=== Current Implementation ===&lt;br /&gt;
&lt;br /&gt;
The current feedback_response_map.rb in the Expertiza repository has several issues. It includes the following problems:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Poor adherence to SOLID and DRY principles&amp;lt;/b&amp;gt;: The current code structure introduces unnecessary repetition and complexity.&lt;br /&gt;
* &amp;lt;b&amp;gt;feedback_response_report Method Issues&amp;lt;/b&amp;gt;: This critical method is highly complex, relying on custom data structures and separate containers for each review round, resulting in a DRY violation.&lt;br /&gt;
* &amp;lt;b&amp;gt;Improper Responsibility Assignment&amp;lt;/b&amp;gt;: The email method does not belong within this class and would benefit from refactoring out into a separate class using the Visitor pattern. This pattern is suggested to streamline functionality, though alternative design patterns may be considered if more suitable.&lt;br /&gt;
* &amp;lt;b&amp;gt;Memory Inefficiencies&amp;lt;/b&amp;gt;: The method currently creates unnecessary memory through inefficient structures, including multiple separate arrays for different rounds of review, which could be simplified into a 2D array structure.&lt;br /&gt;
* &amp;lt;b&amp;gt;Code Smells&amp;lt;/b&amp;gt;: The code has redundant methods, unclear variable names, inefficient loops, and overly long method names.&lt;br /&gt;
&lt;br /&gt;
=== Objectives &amp;amp; Requirements ===&lt;br /&gt;
1. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Address the DRY violation by consolidating the containers for review rounds.&lt;br /&gt;
* Generalize the code to handle both cases—when rubrics vary by round and when they do not—without duplicating code.&lt;br /&gt;
* Introduce efficient data structures, like a 2D array, to replace multiple arrays and reduce memory usage.&lt;br /&gt;
&lt;br /&gt;
2. Separate Responsibilities Using Visitor Pattern (&amp;lt;i&amp;gt;stretch goal&amp;lt;/i&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
* Extract the email method using the Visitor pattern to modularize email functionality. Alternatively, select a design pattern better suited to organizing this method if available. Note that the email method is not properly used in its current location and is better suited to the Response class rather than ResponseMap.&lt;br /&gt;
&lt;br /&gt;
3. Eliminate Redundant Methods&lt;br /&gt;
&lt;br /&gt;
* Remove methods that do not serve a clear purpose and improve method naming for clarity.&lt;br /&gt;
* Aim to address any redundant meta-review functionality, as indicated by the professor's preference to remove these from response_map.rb.&lt;br /&gt;
&lt;br /&gt;
4. Refactor for Code Clarity and Efficiency&lt;br /&gt;
&lt;br /&gt;
* Improve variable names, reduce unnecessary loops, and replace long method names with concise, intuitive alternatives.&lt;br /&gt;
* Ensure that each method has a single, clearly defined purpose, improving code readability.&lt;br /&gt;
&lt;br /&gt;
5. Testing and Documentation&lt;br /&gt;
&lt;br /&gt;
* Write comprehensive tests for all newly implemented and modified methods to ensure reliability.&lt;br /&gt;
* Add detailed comments to facilitate code maintenance and understanding for future developers.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Design Principles ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Single Responsibility Principle (SRP)&amp;lt;/b&amp;gt;: Each method and class should have a single, well-defined purpose.&lt;br /&gt;
* &amp;lt;b&amp;gt;Don’t Repeat Yourself (DRY)&amp;lt;/b&amp;gt;: Eliminate redundancy by creating general solutions that handle multiple scenarios.&lt;br /&gt;
* &amp;lt;b&amp;gt;Ruby Readability Guidelines (Week 9 Notes)&amp;lt;/b&amp;gt;:&lt;br /&gt;
** Guideline: Variable names should be neither too short nor too long.&lt;br /&gt;
** Guideline: Names should not be redundant.&lt;br /&gt;
** Guideline: &amp;lt;b&amp;gt;A method should do only one thing and do it well.&amp;lt;/b&amp;gt;&lt;br /&gt;
* &amp;lt;b&amp;gt;Visitor Pattern&amp;lt;/b&amp;gt;: Utilize this pattern to separate emailing functionalities from the main class.&lt;br /&gt;
&lt;br /&gt;
=== Implementation Plan ===&lt;br /&gt;
The refactoring will proceed as follows:&lt;br /&gt;
&lt;br /&gt;
1. Analyze and Refactor Current Code Structure&lt;br /&gt;
&lt;br /&gt;
* Review and understand the existing structure and dependencies within feedback_response_map.rb.&lt;br /&gt;
* Identify areas of redundancy, complexity, and inefficiency, particularly in feedback_response_report, to create a clear plan for refactoring.&lt;br /&gt;
* Try to reduce character count and improve readability with aliasing (this way we do not break any code that relies on being able to call specific methods).&lt;br /&gt;
&lt;br /&gt;
2. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Consolidate containers for each review round to address DRY violations. By using a single structure to store review data, we will eliminate hard-coded repetition.&lt;br /&gt;
* Generalize logic to accommodate both scenarios where rubrics vary by round and where they do not, without duplicating code paths.&lt;br /&gt;
* Replace inefficient structures, such as multiple arrays, with more flexible and memory-efficient options, like a 2D array or a hash, to reduce memory usage and improve scalability.&lt;br /&gt;
&lt;br /&gt;
3. Introduce Helper Methods for Reusable Logic (for feedback_response_report)&lt;br /&gt;
&lt;br /&gt;
* Extract frequently used or complex code blocks into helper methods, reducing the size of primary methods and enhancing reusability.&lt;br /&gt;
* Use helper methods for specific actions, like handling rounds or retrieving assignment data, to make the code cleaner and better organized.&lt;br /&gt;
* Emphasis on adhering to the guideline: A method should do only one thing and do it well.&lt;br /&gt;
&lt;br /&gt;
4. Research Future Refactoring for email Method&lt;br /&gt;
&lt;br /&gt;
* The email method is convoluted and the functionality should be refactored into a different class in the future.&lt;br /&gt;
* This is because this visitor pattern violation is present in many classes, and is beyond the scope of a one-class re-implementation.&lt;br /&gt;
&lt;br /&gt;
5. Improve Variable Naming and Structure&lt;br /&gt;
&lt;br /&gt;
* Replace ambiguous variable names with clearer alternatives that convey purpose, such as renaming @temp_review_responses and @temp_response_map_ids to more meaningful names.&lt;br /&gt;
* Simplify long method names to make the code more readable and approachable for new contributors.&lt;br /&gt;
&lt;br /&gt;
=== Testing ===&lt;br /&gt;
&lt;br /&gt;
1. Adapt Existing Tests for Refactored Methods&lt;br /&gt;
&lt;br /&gt;
* Any new helper methods will be private, and so by the &amp;quot;Magic Tricks of Testing&amp;quot; guide, should not be tested (both query and command messages sent to self are ignored in the test plan).&lt;br /&gt;
* Use mocks to isolate components during testing, especially for external dependencies like Mailer, to ensure that email functionality works as expected without direct integration.&lt;br /&gt;
&lt;br /&gt;
2. Document Code for Clarity&lt;br /&gt;
&lt;br /&gt;
* Write detailed comments explaining the purpose of each method, input and output, and any critical logic that might be complex for future developers to understand.&lt;br /&gt;
* Create or update documentation and diagrams to illustrate the newly designed structure, making it easier for new developers to contribute or modify functionality.&lt;br /&gt;
&lt;br /&gt;
=== Documentation ===&lt;br /&gt;
&lt;br /&gt;
Ensure all code is well-documented, with comments explaining purpose, inputs, outputs, and any complex logic. Maintain updated documentation for all modified and newly added classes and methods, allowing for ease of understanding and maintenance.&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
&lt;br /&gt;
By refactoring feedback_response_map.rb, this project will enhance Expertiza’s backend maintainability and readability, ensuring a modular, efficient, and more secure implementation.&lt;br /&gt;
&lt;br /&gt;
== Team Information ==&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
* Chaitanya Srusti (crsrusti@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
=== Members ===&lt;br /&gt;
&lt;br /&gt;
* Sarah Daniel (sdaniel8@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* William Grochocinski (wagrocho@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Tipton Middleton (tgmiddl2@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* ChatGPT (Honorary Member)&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=159027</id>
		<title>CSC/ECE 517 Fall 2024 - E2451. Reimplement feedback response map.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2451._Reimplement_feedback_response_map.rb&amp;diff=159027"/>
		<updated>2024-11-12T03:28:37Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2451: Reimplement feedback response map'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
=== Project Overview ===&lt;br /&gt;
&lt;br /&gt;
The goal of this project is to refactor the feedback_response_map.rb file from the Expertiza repository and integrate it into the reimplementation-back-end repository. Within Expertiza, when a user submits a review, an instance of the Response class is created, associated with a ResponseMap. Each ResponseMap links a reviewer (reviewer_id), reviewee (reviewee_id), and the reviewed item (reviewed_object_id). FeedbackResponseMap, a subclass of ResponseMap, represents the feedback provided by a reviewee on the feedback received for their submission.&lt;br /&gt;
&lt;br /&gt;
This class has significant room for improvement, especially with respect to object-oriented principles. Refactoring feedback_response_map.rb will streamline functionality, enhance maintainability, and improve adherence to coding standards.&lt;br /&gt;
&lt;br /&gt;
=== Current Implementation ===&lt;br /&gt;
&lt;br /&gt;
The current feedback_response_map.rb in the Expertiza repository has several issues. It includes the following problems:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Poor adherence to SOLID and DRY principles&amp;lt;/b&amp;gt;: The current code structure introduces unnecessary repetition and complexity.&lt;br /&gt;
* &amp;lt;b&amp;gt;feedback_response_report Method Issues&amp;lt;/b&amp;gt;: This critical method is highly complex, relying on custom data structures and separate containers for each review round, resulting in a DRY violation.&lt;br /&gt;
* &amp;lt;b&amp;gt;Improper Responsibility Assignment&amp;lt;/b&amp;gt;: The email method does not belong within this class and would benefit from refactoring out into a separate class using the Visitor pattern. This pattern is suggested to streamline functionality, though alternative design patterns may be considered if more suitable.&lt;br /&gt;
* &amp;lt;b&amp;gt;Memory Inefficiencies&amp;lt;/b&amp;gt;: The method currently creates unnecessary memory through inefficient structures, including multiple separate arrays for different rounds of review, which could be simplified into a 2D array structure.&lt;br /&gt;
* &amp;lt;b&amp;gt;Code Smells&amp;lt;/b&amp;gt;: The code has redundant methods, unclear variable names, inefficient loops, and overly long method names.&lt;br /&gt;
&lt;br /&gt;
=== Objectives &amp;amp; Requirements ===&lt;br /&gt;
1. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Address the DRY violation by consolidating the containers for review rounds.&lt;br /&gt;
* Generalize the code to handle both cases—when rubrics vary by round and when they do not—without duplicating code.&lt;br /&gt;
* Introduce efficient data structures, like a 2D array, to replace multiple arrays and reduce memory usage.&lt;br /&gt;
&lt;br /&gt;
2. Separate Responsibilities Using Visitor Pattern&lt;br /&gt;
&lt;br /&gt;
* Extract the email method using the Visitor pattern to modularize email functionality. Alternatively, select a design pattern better suited to organizing this method if available. Note that the email method is not properly used in its current location and is better suited to the Response class rather than ResponseMap.&lt;br /&gt;
&lt;br /&gt;
3. Eliminate Redundant Methods&lt;br /&gt;
&lt;br /&gt;
* Remove methods that do not serve a clear purpose and improve method naming for clarity.&lt;br /&gt;
* Aim to address any redundant meta-review functionality, as indicated by the professor's preference to remove these from response_map.rb.&lt;br /&gt;
&lt;br /&gt;
4. Refactor for Code Clarity and Efficiency&lt;br /&gt;
&lt;br /&gt;
* Improve variable names, reduce unnecessary loops, and replace long method names with concise, intuitive alternatives.&lt;br /&gt;
* Ensure that each method has a single, clearly defined purpose, improving code readability.&lt;br /&gt;
&lt;br /&gt;
5. Testing and Documentation&lt;br /&gt;
&lt;br /&gt;
* Write comprehensive tests for all newly implemented and modified methods to ensure reliability.&lt;br /&gt;
* Add detailed comments to facilitate code maintenance and understanding for future developers.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Design Principles ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Single Responsibility Principle (SRP)&amp;lt;/b&amp;gt;: Each method and class should have a single, well-defined purpose.&lt;br /&gt;
* &amp;lt;b&amp;gt;Don’t Repeat Yourself (DRY)&amp;lt;/b&amp;gt;: Eliminate redundancy by creating general solutions that handle multiple scenarios.&lt;br /&gt;
* &amp;lt;b&amp;gt;Ruby Readability Guidelines (Week 9 Notes)&amp;lt;/b&amp;gt;:&lt;br /&gt;
** Guideline: Variable names should be neither too short nor too long.&lt;br /&gt;
** Guideline: Names should not be redundant.&lt;br /&gt;
** Guideline: &amp;lt;b&amp;gt;A method should do only one thing and do it well.&amp;lt;/b&amp;gt;&lt;br /&gt;
* &amp;lt;b&amp;gt;Visitor Pattern&amp;lt;/b&amp;gt;: Utilize this pattern to separate emailing functionalities from the main class.&lt;br /&gt;
&lt;br /&gt;
=== Implementation Plan ===&lt;br /&gt;
The refactoring will proceed as follows:&lt;br /&gt;
&lt;br /&gt;
1. Analyze and Refactor Current Code Structure&lt;br /&gt;
&lt;br /&gt;
* Review and understand the existing structure and dependencies within feedback_response_map.rb.&lt;br /&gt;
* Identify areas of redundancy, complexity, and inefficiency, particularly in feedback_response_report, to create a clear plan for refactoring.&lt;br /&gt;
&lt;br /&gt;
2. Refactor the feedback_response_report Method&lt;br /&gt;
&lt;br /&gt;
* Consolidate containers for each review round to address DRY violations. By using a single structure to store review data, we will eliminate hard-coded repetition.&lt;br /&gt;
* Generalize logic to accommodate both scenarios where rubrics vary by round and where they do not, without duplicating code paths.&lt;br /&gt;
* Replace inefficient structures, such as multiple arrays, with more flexible and memory-efficient options, like a 2D array or a hash, to reduce memory usage and improve scalability.&lt;br /&gt;
&lt;br /&gt;
3. Separate and Modularize the email Method&lt;br /&gt;
&lt;br /&gt;
* Move the email method out of FeedbackResponseMap and into a separate service class. This separation will follow the Visitor pattern or a more suitable pattern identified during implementation, to better manage email-related functionality.&lt;br /&gt;
* Assign responsibility for sending feedback-related emails to a dedicated service class (e.g., FeedbackEmailService), ensuring that the core functionality of FeedbackResponseMap is isolated from email concerns.&lt;br /&gt;
* Update any dependencies to use the newly created email service.&lt;br /&gt;
&lt;br /&gt;
4. Improve Variable Naming and Structure&lt;br /&gt;
&lt;br /&gt;
* Replace ambiguous variable names with clearer alternatives that convey purpose, such as renaming @temp_review_responses and @temp_response_map_ids to more meaningful names.&lt;br /&gt;
* Simplify long method names to make the code more readable and approachable for new contributors.&lt;br /&gt;
&lt;br /&gt;
5. Introduce Helper Methods for Reusable Logic&lt;br /&gt;
&lt;br /&gt;
* Extract frequently used or complex code blocks into helper methods, reducing the size of primary methods and enhancing reusability.&lt;br /&gt;
* Use helper methods for specific actions, like handling rounds or retrieving assignment data, to make the code cleaner and better organized.&lt;br /&gt;
&lt;br /&gt;
=== Testing ===&lt;br /&gt;
&lt;br /&gt;
1. Develop Tests for Refactored and New Methods&lt;br /&gt;
&lt;br /&gt;
* Create unit tests for each refactored and newly created method, particularly focusing on feedback_response_report and any extracted functionalities.&lt;br /&gt;
* Use mocks to isolate components during testing, especially for external dependencies like Mailer, to ensure that email functionality works as expected without direct integration.&lt;br /&gt;
&lt;br /&gt;
2. Document Code for Clarity&lt;br /&gt;
&lt;br /&gt;
* Write detailed comments explaining the purpose of each method, input and output, and any critical logic that might be complex for future developers to understand.&lt;br /&gt;
* Create or update documentation and diagrams to illustrate the newly designed structure, making it easier for new developers to contribute or modify functionality.&lt;br /&gt;
&lt;br /&gt;
=== Documentation ===&lt;br /&gt;
&lt;br /&gt;
Ensure all code is well-documented, with comments explaining purpose, inputs, outputs, and any complex logic. Maintain updated documentation for all modified and newly added classes and methods, allowing for ease of understanding and maintenance.&lt;br /&gt;
&lt;br /&gt;
=== Conclusion ===&lt;br /&gt;
&lt;br /&gt;
By refactoring feedback_response_map.rb, this project will enhance Expertiza’s backend maintainability and readability, ensuring a modular, efficient, and more secure implementation.&lt;br /&gt;
&lt;br /&gt;
== Team Information ==&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
* Chaitanya Srusti (crsrusti@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
=== Members ===&lt;br /&gt;
&lt;br /&gt;
* Sarah Daniel (sdaniel8@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* William Grochocinski (wagrocho@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Tipton Middleton (tgmiddl2@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* ChatGPT (Honorary Member)&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158676</id>
		<title>CSC/ECE 517 Fall 2024 - E2480. Implement testing for new Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158676"/>
		<updated>2024-11-01T02:45:58Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2480: Implement testing for new Bookmarks Controller'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
A bookmark is a resource that a student can post for a certain topic, that other students may find useful if working on that topic. Students working on the topic have the ability to rate the bookmark based on usefulness, and using a rubric. The average of all ratings will be computed to get an average score.&lt;br /&gt;
&lt;br /&gt;
As discussed in E2480's background, the BookmarksController is implemented with CRUD operations, as well as the ability to rate bookmarks, calculate average ratings, and check for proper authorization when accessing a Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== Prior Work and Related Projects === &lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller#Problem_Statement E2424 Reimplement the Bookmarks Controller]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1786_OSS_Project_Juniper:_Bookmark_enhancements E1786 Bookmark enhancements]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=E1915_Authorization_Utilities E1915 Authorization Utilities]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Requirements === &lt;br /&gt;
&lt;br /&gt;
There are four main requirements assigned for the project, seen as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Add Tests and Generate API Documentation&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Develop comprehensive test cases for the BookmarksController to ensure the correctness of CRUD operations, bookmark ratings, and score calculations.&lt;br /&gt;
* The test coverage should aim to cover at least 90% of the code, ensuring thorough validation of edge cases and error handling.&lt;br /&gt;
* Utilize Swagger UI to generate API documentation for the controller and verify that routes are correctly defined.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Code Quality and Refactoring &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use tools like Rubocop and Code Climate to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods).&lt;br /&gt;
* Any unused or unclear functionality should be removed to improve maintainability.&lt;br /&gt;
* Rename methods with ambiguous names to improve clarity and ensure code follows the clean code principles.&lt;br /&gt;
* Review and optimize performance, particularly in areas where loops or methods can be refactored for better efficiency, such as handling the deletion of associated data (e.g., deleting all questions related to a questionnaire).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Authorization and Error Handling &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure proper enforcement of authorization rules and handle edge cases with informative error messages&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Final Deliverables &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure that all tests pass and API documentation is fully generated using Swagger UI.&lt;br /&gt;
* Confirm that code coverage exceeds 90%, and there are no significant code smells or performance issues flagged by Rubocop and Code Climate.&lt;br /&gt;
&lt;br /&gt;
==== Tasks ====&lt;br /&gt;
&lt;br /&gt;
We can simplify the above requirements down to the following tasks:&lt;br /&gt;
&lt;br /&gt;
* Create tests with at least 90% test coverage for BookmarksController&lt;br /&gt;
* Use Swagger UI to generate API documentation for the BookmarksController&lt;br /&gt;
* Fix and remove code smells, and refactor where necessary to optimize performance&lt;br /&gt;
* Implement authorization rules and handle edge cases using error messages that indicate what the error is&lt;br /&gt;
&lt;br /&gt;
There are two more tasks (see details in ''Process --&amp;gt; Findings'' below) that were given, which can be summed up as the following:&lt;br /&gt;
* Create an action_allowed? method to see if a User has access to a Course, and if a Student has access to a Bookmark&lt;br /&gt;
&lt;br /&gt;
== Process ==&lt;br /&gt;
&lt;br /&gt;
=== Findings ===&lt;br /&gt;
&lt;br /&gt;
Please note, the project repository was forked from reimplementation-back-end repository for Expertiza.&lt;br /&gt;
&lt;br /&gt;
After searching through the repository, we noticed a few issues with the reimplementation-back-end that were not discussed in the OSS project details. After discussing with Dr. Gehringer and the TA, we decided on specific tasks to focus on during this project. One such issue was checking for if a user such as a TA, Instructor, or Admin has access to the bookmark, which is determined by if the user has access to the course that contains the assignment, which contains a topic, which then contains the bookmark. &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Access&amp;quot; for different user types (Students are omitted, as they are only allowed to modify/delete bookmarks they created) is defined as follows: TAs have access if there exists a TaMapping between them and the course the bookmark is under. Intructors have access if they are the instructor for the course the bookmark is under. Admins have access if they are the parent of (created) the instructor of the course the bookmark is under. Super Admins always have access.&lt;br /&gt;
&lt;br /&gt;
Thus, the following additional tasks are expected in an action_allowed? method:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a User has access to a Course:&amp;lt;/b&amp;gt; The access a User (TA, Instructor, Admin) has to a Course is determined by the connection of Course to a Bookmark. A Course contains an Assignment, which contains a Topic, which then contains the Bookmark. Thus, if the user has access to a Course, they can access the Bookmark. &lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a Student has access to a Bookmark:&amp;lt;/b&amp;gt; This can be determined by checking to see if the Student had created the Bookmark. If so, then the Student can choose to edit or destroy the Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== New Changes ===&lt;br /&gt;
&lt;br /&gt;
==== Models &amp;amp; Controllers ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the bookmark.rb file, the only change is to uncomment the line related to :topic. This way, we can identify which Users can identify Bookmarks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/controllers/api/v1/bookmarks_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added action_allowed? functionality&lt;br /&gt;
|Code was added to include the AuthorizationHelper, as well as run the action_allowed? method before the other methods run, so the User type can be identified.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/3 Pull Request 3]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added 'index' to a When case for Students&lt;br /&gt;
|Identified Students by additionally looking for an'index' parameter, and using just this and the 'list' parameters to determine if the User is a student.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added 'show' and 'get_bookmark_rating_score' to a When case for Students&lt;br /&gt;
|Identified Students by looking for list, index, show, and get_bookmark_rating_score parameters. If the User is a Student, then the Student can view the bookmarks list.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/5 Pull Request 5]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Added check_action_allowed method&lt;br /&gt;
|Making the before action as the new method check_action_allowed, which will pull up an Unauthorized access json file if action_allowed is false.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Changing the methods, and added a check_action_allowed&lt;br /&gt;
|Adding searching for a bookmark by id functionality, and if the bookmark is not found, a json page will be returned for the show, destroy, update, get_bookmark_rating_score, save_bookmark_rating_score. The check_allowed_action method will show a page if the user is allowed to perform the action. Code cleanup was also done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Changing a couple of method calls, and adding conditions, as well as checking to see if a TaMapping exists&lt;br /&gt;
|Instead of a create method to create a bookmark rating, we call the new method with the same parameters, and call the save method. Also added a few conditionals to the 'when' blocks. Lastly, when the User is a TA, we can check to see if a TaMapping exists for the TA and a Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/helpers/authorization_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file was imported from the main Expertiza/Expertiza repo and functionality was added to integrate with the action_allowed? method to determine if users had valid privileges when trying to perform certain actions. However, the functionality in this file depends on session[:user], something that is not implemented in Expertiza/reimplementation-back-end. Due to this, this file was not used in this implementation, but the file and added functionality was kept for future use.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark_rating.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a validates statement&lt;br /&gt;
|The new validates statement will check to see if a bookmark's rating is present for a BookmarkRating.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Improving validates statement&lt;br /&gt;
|The validates statement now allows for only integers that are between 0 and 5.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Tests &amp;amp; Helpers ====&lt;br /&gt;
&lt;br /&gt;
===== Spec Files =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/requests/api/v1/bookmarks_controller_spec.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added and cleaned up happy and sad tests for getting bookmarks&lt;br /&gt;
|Cleaned up tests, and added expected functionality for the tests. Some tests were incorrectly named, so that was fixed as well. Added happy and sad tests such as not letting someone without a token access list of bookmarks, and letting the user access the list of bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding User type by role_id and creating headers for signing in, and adding tests.&lt;br /&gt;
|Added new tests to check for specific users such as TA, Instructor, and Student. Also, added headers that will be used as tokens in order to authorize User login.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Creating test cases for each User type, and removes the header authentication in this file.&lt;br /&gt;
|Added better tests to check for all types of Users, and removed the original getting a student and also moved the headers functionality from the file. Header authentication is now done within each test.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Add specific test cases for Students, TAs, Admin, and Super Admin&lt;br /&gt;
|Added better tests to check for all types of Users, such as letting a specific User type access lists of bookmarks, allowing a specific User type to query existing and non-existing bookmarks and seeing the results. Also, Users who are not signed in cannot access the list of bookmarks, or query bookmarks. Lastly, adds a create_bookmark method to make a bookmark while finding or creating a corresponding User, Course, Assignment, and SignUpTopic. The method will also decide that if the bookmark does not exist based on these values, then create it.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Adding specific test cases for BookmarkRatings&lt;br /&gt;
|Making test cases even more specific by adding test cases for all kinds of Users that may access BookmarkRatings. Also tests to see if BookmarkRatings can be accessed when a User is not logged in. Lastly, makes a make_bookmark_rating method that will create a bookmark if it doesn't exist, along with assigning a user to it (and creating a Student type if the user is nil).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Adding tests for adding, updating, deleting a bookmark, as well as other tests.&lt;br /&gt;
|Tests were created for seeing the path of how a Bookmark is created, updated, and deleted. Tests were also created in querying Bookmark Ratings for all kinds of Users (as well as signed out users), to make sure non-existent bookmarks will not be shown. There was also additions of sad tests to make sure that Users that are not Students cannot make, or update bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|Adding tests for adding, updating, and deleting a bookmark rating, as well as updating/deleting bookmarks for other Users.&lt;br /&gt;
|This PR adds happy and sad tests for functionality of adding, updating, and deleting bookmark ratings as a Student. Tests for adding, updating, and deleting Bookmarks by TA, Instructor, Admin, and SuperAdmin are also added. Lastly, functionality to look for a TA by role, and checking to see if a user is a TA is also added (and if a TA, then add the TA to the course).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Helpers =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/rails_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Load files in /spec/support/&lt;br /&gt;
|Files in /spec/support/ and its subfolders need to be loaded in for certain functionality to work. In particular, factory_bot.rb and authentication_helper.rb are found in this folder.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Seed the database if it isn't already seeded&lt;br /&gt;
|After running into issues with the database not being seeded when it should be, rails_helper was modified to check if seeding has occurred and to seed it if that had not already been done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/spec_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added SimpleCov configuration&lt;br /&gt;
|SimpleCov needs configuration files in spec_helper in order to load and be configured properly. Since SimpleCov was required for this project, this configuration information needed to be added to spec_helper.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/support/authentication_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial creation&lt;br /&gt;
|This helper file was created to facilitate the automatic login process. When called with a username and password, the system would try to login as that user and return the configuration header that needed to be send with each future CRUD request. If the password field is not provided, the helper attempts to use the default password. If the user is also left blank, an administrator login will be returned.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Removal of Admin Login&lt;br /&gt;
|After fully implementing the five separate users, we could not think of a use-case where we would want to log-in as an administrator by default since any user seeded in the DB could easily be loaded and logged in with. Due to this, we removed the internal login_admin functionality, thus requiring all calls to AuthenticationHelper to specify a user.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Factories =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Assignment from factories&lt;br /&gt;
|Create Assignment data using factories. Then get an existing Instructor from the database or create a new one to add to each Assignment.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmark_ratings.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create Factory Bookmark Ratings&lt;br /&gt;
|Making data for bookmark ratings using Factory. Will make the bookmark and user null values (nil), and set a rating of 0).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmarks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create Factory Bookmarks&lt;br /&gt;
|Create Bookmark data using factories. We can add random strings to the title and description, as well as search the database for an existing Student to assign the Bookmark to.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/course.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Factory Course&lt;br /&gt;
|Create Course data using factories. Then get an Instructor from the database or create a new one. Then, use an existing institution or make a new Institution for each Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/institution.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/join_team_requests.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/roles.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/sign_up_topics.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Factory Topic&lt;br /&gt;
|Create Topics using factories, and assign an assignment id to each Topic.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/student_tasks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/users.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Database files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|All usages of ta mappings throughout the reimplementation-back-end repository use ta_id, whereas the schema refers to it as user_id. This created problems when trying to use ta mappings, especially in tests. To fix this, instead of refactoring all instances of ta mappings to have their field referred to as user_id, we changed the schema to reflect the existing usage of ta_id, while still having it understand that the foreign key refers to users. We created a migration (seen below) that accomplishes this task.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing users to TAs&lt;br /&gt;
|Instead of &amp;quot;user_id&amp;quot;, changed the value to ta_id. Also removing a foreign_key of mapping TA's to Users.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/seeds.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a role for the database&lt;br /&gt;
|Cleaned up the code, added useful comments, and added a role column for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding and Creating a User by email&lt;br /&gt;
|Based on the email type, Users will be created as seeds for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Remove all Code except Admin find and creation&lt;br /&gt;
|Only admin values will be found or created (for testing purposes). All other users will not be created using seed. From now on, User's will be created by factories instead of seeded into the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/migrate/20241030195109_update_ta_mappings_table_structure.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|Facilitates the changes made to the schema&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Deleted Files ====&lt;br /&gt;
&lt;br /&gt;
Two files regarding factories were deleted in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4]:&lt;br /&gt;
&lt;br /&gt;
* spec/factories.rb - the factories in this file were split into their own factory files in spec/factories/&lt;br /&gt;
* spec/factories/factories.rb - this was an empty file, deleted to clean up the repo&lt;br /&gt;
&lt;br /&gt;
=== Rubocop ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Why Rubocop ====&lt;br /&gt;
&lt;br /&gt;
Rubocop was one of the tools listed in the project instructions, and so we used it &amp;quot;to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods)&amp;quot;. We chose it in part because it was easy to apply to our system (simple CLI), and easy to make changes based on the feedback (provided line numbers and violation types).&lt;br /&gt;
&lt;br /&gt;
==== How it was applied ====&lt;br /&gt;
&lt;br /&gt;
We applied rubocop using simple one line commands based on what we wanted it to do. The general template we followed was:&lt;br /&gt;
  rubocop [-A] ./spec/requests/api/v1/bookmarks_controller_spec.rb [--out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt]&lt;br /&gt;
Where we would include&lt;br /&gt;
  -A&lt;br /&gt;
If we wanted it to auto-correct any automatically correctable violations, and&lt;br /&gt;
  --out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt&lt;br /&gt;
If we wanted output to be delivered to a file for improved readability&lt;br /&gt;
&lt;br /&gt;
==== What Changed ====&lt;br /&gt;
&lt;br /&gt;
Lots of small violations like trailing whitespace, unnecessary blank lines, using &amp;quot; == nil&amp;quot; instead of &amp;quot;.nil?&amp;quot;, and using double instead of single quotes were corrected automatically.&lt;br /&gt;
&lt;br /&gt;
Some bigger violations like brace indent alignment and inner field indentation were also able to be fixed automatically, although many of those came about after manual fixes to other violations, like:&lt;br /&gt;
&lt;br /&gt;
Line length violations were plentiful, most of them being caused by the long API commands. When we broke those down into their chunks, often times the `params:` argument would have its contents spread across multiple lines for readability (which caused some of the indent-related violations mentioned above). Other line length violations were on test descriptor lines (`it '&amp;lt;...&amp;gt;'`). The descriptors that triggered them covered complex tests, and so were intentionally detailed to inform future developers of what the test does, so shortening them was not ideal. These violations were resolved by splitting the descriptor across multiple lines.&lt;br /&gt;
&lt;br /&gt;
Overall, the readability of the test file improved substantially!&lt;br /&gt;
&lt;br /&gt;
==== What did not change, and why? ====&lt;br /&gt;
&lt;br /&gt;
There were some violations that were intentionally not corrected to preserve readability and consistency:&lt;br /&gt;
* Block length violations were dismissed because adhering to them would undermine the structure of our test file. Our test file is laid out in segments defined by the `describe` blocks. At the uppermost level there is a describe block encapsulating all of the tests in the file. From there tests are divided by user type, this reduces redundancy in data preparation, improving test efficiency by having separate `before(:each)` blocks for each user. Within users, tests are further divided by API call type. This way it is easy to determine the location of a failing test, improving the speed of debugging. Because our structure relies on nested `describe` blocks, those at the uppermost levels are prone to triggering block length violations. With this in mind, we made the conscious decision to disable rubocop block length metrics with the following comments at the start and end of our test file respectively:&lt;br /&gt;
  # rubocop:disable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
  # rubocop:enable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
== Tests == &lt;br /&gt;
&lt;br /&gt;
Originally, tests were run using RSpec, but these created 13/13 Bookmarks controller tests failed. These tests were removed, and remade.&lt;br /&gt;
&lt;br /&gt;
Swagger UI is a set of tools that is used by the Expertiza developers to run RSpec tests through an interface instead of the command line. Swagger was originally needed in order to view and run tests, because the RSpec tests for this project need to be fixed. However, since RSpec tests have been recreated, the use of Swagger will not be required to run tests, but only check for code smells and coverage.&lt;br /&gt;
&lt;br /&gt;
=== Running RSpec tests via Swagger ===&lt;br /&gt;
&lt;br /&gt;
Steps&lt;br /&gt;
* Build the containers&lt;br /&gt;
* Go to http://localhost:3002/api-docs&lt;br /&gt;
* Login via the Authentication block at the bottom (U: &amp;quot;admin&amp;quot;, P: &amp;quot;password123&amp;quot;)&lt;br /&gt;
* Copy the token in the response&lt;br /&gt;
* Scroll up to the top and click &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* In the popup, paste in the token and hit &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* Navigate to the test you want to run, edit the parameters, and run it&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
Tests for both Bookmark_Controller.rb and Bookmark.rb both have 100% coverage! Previously, tests were not comprehensive, and tests would not run at all. We recreated all of the tests and made sure coverage was at least above 90% (as expected in the Requirements). &lt;br /&gt;
&lt;br /&gt;
View the code for &amp;lt;b&amp;gt;Bookmark_Controller.rb&amp;lt;/b&amp;gt; below, as well as number of times each line was executed:&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController1To33Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController34To63Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController64To98Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController99To130Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController130To154Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
As we can see, many of the lines were executed 10 times or more. Also, many lines in the beginning were executed only once. However, substantial code is executed at least more than once.&lt;br /&gt;
&lt;br /&gt;
See the summary of coverage for both files below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarkCoverageE2480.png |1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;BookmarksController.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksControllerCoverageE2480.png |1000px]]&lt;br /&gt;
&lt;br /&gt;
As mentioned before, both files have 100% coverage, with an average of 20 hits (executions) per line for BookmarksController.rb.&lt;br /&gt;
&lt;br /&gt;
== Recommended next steps ==&lt;br /&gt;
&lt;br /&gt;
* There are methods in the authorization_helper.rb that check to see if a TA or Instructor can access an assignment, that have some code smells such as bad method names.&lt;br /&gt;
* The questionnaire (which is used to rate the bookmark) needs the functionality of identifying a user type. Possibly create a mixin to implement this.&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158675</id>
		<title>CSC/ECE 517 Fall 2024 - E2480. Implement testing for new Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158675"/>
		<updated>2024-11-01T02:44:43Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2480: Implement testing for new Bookmarks Controller'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
A bookmark is a resource that a student can post for a certain topic, that other students may find useful if working on that topic. Students working on the topic have the ability to rate the bookmark based on usefulness, and using a rubric. The average of all ratings will be computed to get an average score.&lt;br /&gt;
&lt;br /&gt;
As discussed in E2480's background, the BookmarksController is implemented with CRUD operations, as well as the ability to rate bookmarks, calculate average ratings, and check for proper authorization when accessing a Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== Prior Work and Related Projects === &lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller#Problem_Statement E2424 Reimplement the Bookmarks Controller]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1786_OSS_Project_Juniper:_Bookmark_enhancements E1786 Bookmark enhancements]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=E1915_Authorization_Utilities E1915 Authorization Utilities]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Requirements === &lt;br /&gt;
&lt;br /&gt;
There are four main requirements assigned for the project, seen as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Add Tests and Generate API Documentation&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Develop comprehensive test cases for the BookmarksController to ensure the correctness of CRUD operations, bookmark ratings, and score calculations.&lt;br /&gt;
* The test coverage should aim to cover at least 90% of the code, ensuring thorough validation of edge cases and error handling.&lt;br /&gt;
* Utilize Swagger UI to generate API documentation for the controller and verify that routes are correctly defined.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Code Quality and Refactoring &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use tools like Rubocop and Code Climate to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods).&lt;br /&gt;
* Any unused or unclear functionality should be removed to improve maintainability.&lt;br /&gt;
* Rename methods with ambiguous names to improve clarity and ensure code follows the clean code principles.&lt;br /&gt;
* Review and optimize performance, particularly in areas where loops or methods can be refactored for better efficiency, such as handling the deletion of associated data (e.g., deleting all questions related to a questionnaire).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Authorization and Error Handling &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure proper enforcement of authorization rules and handle edge cases with informative error messages&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Final Deliverables &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure that all tests pass and API documentation is fully generated using Swagger UI.&lt;br /&gt;
* Confirm that code coverage exceeds 90%, and there are no significant code smells or performance issues flagged by Rubocop and Code Climate.&lt;br /&gt;
&lt;br /&gt;
==== Tasks ====&lt;br /&gt;
&lt;br /&gt;
We can simplify the above requirements down to the following tasks:&lt;br /&gt;
&lt;br /&gt;
* Create tests with at least 90% test coverage for BookmarksController&lt;br /&gt;
* Use Swagger UI to generate API documentation for the BookmarksController&lt;br /&gt;
* Fix and remove code smells, and refactor where necessary to optimize performance&lt;br /&gt;
* Implement authorization rules and handle edge cases using error messages that indicate what the error is&lt;br /&gt;
&lt;br /&gt;
There are two more tasks (see details in ''Process --&amp;gt; Findings'' below) that were given, which can be summed up as the following:&lt;br /&gt;
* Create an action_allowed? method to see if a User has access to a Course, and if a Student has access to a Bookmark&lt;br /&gt;
&lt;br /&gt;
== Process ==&lt;br /&gt;
&lt;br /&gt;
=== Findings ===&lt;br /&gt;
&lt;br /&gt;
Please note, the project repository was forked from reimplementation-back-end repository for Expertiza.&lt;br /&gt;
&lt;br /&gt;
After searching through the repository, we noticed a few issues with the reimplementation-back-end that were not discussed in the OSS project details. After discussing with Dr. Gehringer and the TA, we decided on specific tasks to focus on during this project. One such issue was checking for if a user such as a TA, Instructor, or Admin has access to the bookmark, which is determined by if the user has access to the course that contains the assignment, which contains a topic, which then contains the bookmark. &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Access&amp;quot; for different user types (Students are omitted, as they are only allowed to modify/delete bookmarks they created) is defined as follows: TAs have access if there exists a TaMapping between them and the course the bookmark is under. Intructors have access if they are the instructor for the course the bookmark is under. Admins have access if they are the parent of (created) the instructor of the course the bookmark is under. Super Admins always have access.&lt;br /&gt;
&lt;br /&gt;
Thus, the following additional tasks are expected in an action_allowed? method:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a User has access to a Course:&amp;lt;/b&amp;gt; The access a User (TA, Instructor, Admin) has to a Course is determined by the connection of Course to a Bookmark. A Course contains an Assignment, which contains a Topic, which then contains the Bookmark. Thus, if the user has access to a Course, they can access the Bookmark. &lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a Student has access to a Bookmark:&amp;lt;/b&amp;gt; This can be determined by checking to see if the Student had created the Bookmark. If so, then the Student can choose to edit or destroy the Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== New Changes ===&lt;br /&gt;
&lt;br /&gt;
==== Models &amp;amp; Controllers ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the bookmark.rb file, the only change is to uncomment the line related to :topic. This way, we can identify which Users can identify Bookmarks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/controllers/api/v1/bookmarks_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added action_allowed? functionality&lt;br /&gt;
|Code was added to include the AuthorizationHelper, as well as run the action_allowed? method before the other methods run, so the User type can be identified.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/3 Pull Request 3]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added 'index' to a When case for Students&lt;br /&gt;
|Identified Students by additionally looking for an'index' parameter, and using just this and the 'list' parameters to determine if the User is a student.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added 'show' and 'get_bookmark_rating_score' to a When case for Students&lt;br /&gt;
|Identified Students by looking for list, index, show, and get_bookmark_rating_score parameters. If the User is a Student, then the Student can view the bookmarks list.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/5 Pull Request 5]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Added check_action_allowed method&lt;br /&gt;
|Making the before action as the new method check_action_allowed, which will pull up an Unauthorized access json file if action_allowed is false.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Changing the methods, and added a check_action_allowed&lt;br /&gt;
|Adding searching for a bookmark by id functionality, and if the bookmark is not found, a json page will be returned for the show, destroy, update, get_bookmark_rating_score, save_bookmark_rating_score. The check_allowed_action method will show a page if the user is allowed to perform the action. Code cleanup was also done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Changing a couple of method calls, and adding conditions, as well as checking to see if a TaMapping exists&lt;br /&gt;
|Instead of a create method to create a bookmark rating, we call the new method with the same parameters, and call the save method. Also added a few conditionals to the 'when' blocks. Lastly, when the User is a TA, we can check to see if a TaMapping exists for the TA and a Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/helpers/authorization_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file was imported from the main Expertiza/Expertiza repo and functionality was added to integrate with the action_allowed? method to determine if users had valid privileges when trying to perform certain actions. However, the functionality in this file depends on session[:user], something that is not implemented in Expertiza/reimplementation-back-end. Due to this, this file was not used in this implementation, but the file and added functionality was kept for future use.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark_rating.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a validates statement&lt;br /&gt;
|The new validates statement will check to see if a bookmark's rating is present for a BookmarkRating.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Improving validates statement&lt;br /&gt;
|The validates statement now allows for only integers that are between 0 and 5.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Tests &amp;amp; Helpers ====&lt;br /&gt;
&lt;br /&gt;
===== Spec Files =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/requests/api/v1/bookmarks_controller_spec.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added and cleaned up happy and sad tests for getting bookmarks&lt;br /&gt;
|Cleaned up tests, and added expected functionality for the tests. Some tests were incorrectly named, so that was fixed as well. Added happy and sad tests such as not letting someone without a token access list of bookmarks, and letting the user access the list of bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding User type by role_id and creating headers for signing in, and adding tests.&lt;br /&gt;
|Added new tests to check for specific users such as TA, Instructor, and Student. Also, added headers that will be used as tokens in order to authorize User login.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Creating test cases for each User type, and removes the header authentication in this file.&lt;br /&gt;
|Added better tests to check for all types of Users, and removed the original getting a student and also moved the headers functionality from the file. Header authentication is now done within each test.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Add specific test cases for Students, TAs, Admin, and Super Admin&lt;br /&gt;
|Added better tests to check for all types of Users, such as letting a specific User type access lists of bookmarks, allowing a specific User type to query existing and non-existing bookmarks and seeing the results. Also, Users who are not signed in cannot access the list of bookmarks, or query bookmarks. Lastly, adds a create_bookmark method to make a bookmark while finding or creating a corresponding User, Course, Assignment, and SignUpTopic. The method will also decide that if the bookmark does not exist based on these values, then create it.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Adding specific test cases for BookmarkRatings&lt;br /&gt;
|Making test cases even more specific by adding test cases for all kinds of Users that may access BookmarkRatings. Also tests to see if BookmarkRatings can be accessed when a User is not logged in. Lastly, makes a make_bookmark_rating method that will create a bookmark if it doesn't exist, along with assigning a user to it (and creating a Student type if the user is nil).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Adding tests for adding, updating, deleting a bookmark, as well as other tests.&lt;br /&gt;
|Tests were created for seeing the path of how a Bookmark is created, updated, and deleted. Tests were also created in querying Bookmark Ratings for all kinds of Users (as well as signed out users), to make sure non-existent bookmarks will not be shown. There was also additions of sad tests to make sure that Users that are not Students cannot make, or update bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|Adding tests for adding, updating, and deleting a bookmark rating, as well as updating/deleting bookmarks for other Users.&lt;br /&gt;
|This PR adds happy and sad tests for functionality of adding, updating, and deleting bookmark ratings as a Student. Tests for adding, updating, and deleting Bookmarks by TA, Instructor, Admin, and SuperAdmin are also added. Lastly, functionality to look for a TA by role, and checking to see if a user is a TA is also added (and if a TA, then add the TA to the course).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Helpers =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/rails_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Load files in /spec/support/&lt;br /&gt;
|Files in /spec/support/ and its subfolders need to be loaded in for certain functionality to work. In particular, factory_bot.rb and authentication_helper.rb are found in this folder.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Seed the database if it isn't already seeded&lt;br /&gt;
|After running into issues with the database not being seeded when it should be, rails_helper was modified to check if seeding has occurred and to seed it if that had not already been done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/spec_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added SimpleCov configuration&lt;br /&gt;
|SimpleCov needs configuration files in spec_helper in order to load and be configured properly. Since SimpleCov was required for this project, this configuration information needed to be added to spec_helper.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/support/authentication_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Initial creation&lt;br /&gt;
|This helper file was created to facilitate the automatic login process. When called with a username and password, the system would try to login as that user and return the configuration header that needed to be send with each future CRUD request. If the password field is not provided, the helper attempts to use the default password. If the user is also left blank, an administrator login will be returned.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Removal of Admin Login&lt;br /&gt;
|After fully implementing the five separate users, we could not think of a use-case where we would want to log-in as an administrator by default since any user seeded in the DB could easily be loaded and logged in with. Due to this, we removed the internal login_admin functionality, thus requiring all calls to AuthenticationHelper to specify a user.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Factories =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Assignment from factories&lt;br /&gt;
|Create Assignment data using factories. Then get an existing Instructor from the database or create a new one to add to each Assignment.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmark_ratings.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create Factory Bookmark Ratings&lt;br /&gt;
|Making data for bookmark ratings using Factory. Will make the bookmark and user null values (nil), and set a rating of 0).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmarks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create Factory Bookmarks&lt;br /&gt;
|Create Bookmark data using factories. We can add random strings to the title and description, as well as search the database for an existing Student to assign the Bookmark to.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/course.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Factory Course&lt;br /&gt;
|Create Course data using factories. Then get an Instructor from the database or create a new one. Then, use an existing institution or make a new Institution for each Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/institution.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/join_team_requests.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/roles.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/sign_up_topics.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Factory Topic&lt;br /&gt;
|Create Topics using factories, and assign an assignment id to each Topic.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/student_tasks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/users.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Database files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|All usages of ta mappings throughout the reimplementation-back-end repository use ta_id, whereas the schema refers to it as user_id. This created problems when trying to use ta mappings, especially in tests. To fix this, instead of refactoring all instances of ta mappings to have their field referred to as user_id, we changed the schema to reflect the existing usage of ta_id, while still having it understand that the foreign key refers to users. We created a migration (seen below) that accomplishes this task.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing users to TAs&lt;br /&gt;
|Instead of &amp;quot;user_id&amp;quot;, changed the value to ta_id. Also removing a foreign_key of mapping TA's to Users.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/seeds.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a role for the database&lt;br /&gt;
|Cleaned up the code, added useful comments, and added a role column for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding and Creating a User by email&lt;br /&gt;
|Based on the email type, Users will be created as seeds for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Remove all Code except Admin find and creation&lt;br /&gt;
|Only admin values will be found or created (for testing purposes). All other users will not be created using seed. From now on, User's will be created by factories instead of seeded into the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/migrate/20241030195109_update_ta_mappings_table_structure.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|Facilitates the changes made to the schema&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Deleted Files ====&lt;br /&gt;
&lt;br /&gt;
Two files regarding factories were deleted in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4]:&lt;br /&gt;
&lt;br /&gt;
* spec/factories.rb - the factories in this file were split into their own factory files in spec/factories/&lt;br /&gt;
* spec/factories/factories.rb - this was an empty file, deleted to clean up the repo&lt;br /&gt;
&lt;br /&gt;
=== Rubocop ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Why Rubocop ====&lt;br /&gt;
&lt;br /&gt;
Rubocop was one of the tools listed in the project instructions, and so we used it &amp;quot;to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods)&amp;quot;. We chose it in part because it was easy to apply to our system (simple CLI), and easy to make changes based on the feedback (provided line numbers and violation types).&lt;br /&gt;
&lt;br /&gt;
==== How it was applied ====&lt;br /&gt;
&lt;br /&gt;
We applied rubocop using simple one line commands based on what we wanted it to do. The general template we followed was:&lt;br /&gt;
  rubocop [-A] ./spec/requests/api/v1/bookmarks_controller_spec.rb [--out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt]&lt;br /&gt;
Where we would include&lt;br /&gt;
  -A&lt;br /&gt;
If we wanted it to auto-correct any automatically correctable violations, and&lt;br /&gt;
  --out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt&lt;br /&gt;
If we wanted output to be delivered to a file for improved readability&lt;br /&gt;
&lt;br /&gt;
==== What Changed ====&lt;br /&gt;
&lt;br /&gt;
Lots of small violations like trailing whitespace, unnecessary blank lines, using &amp;quot; == nil&amp;quot; instead of &amp;quot;.nil?&amp;quot;, and using double instead of single quotes were corrected automatically.&lt;br /&gt;
&lt;br /&gt;
Some bigger violations like brace indent alignment and inner field indentation were also able to be fixed automatically, although many of those came about after manual fixes to other violations, like:&lt;br /&gt;
&lt;br /&gt;
Line length violations were plentiful, most of them being caused by the long API commands. When we broke those down into their chunks, often times the `params:` argument would have its contents spread across multiple lines for readability (which caused some of the indent-related violations mentioned above). Other line length violations were on test descriptor lines (`it '&amp;lt;...&amp;gt;'`). The descriptors that triggered them covered complex tests, and so were intentionally detailed to inform future developers of what the test does, so shortening them was not ideal. These violations were resolved by splitting the descriptor across multiple lines.&lt;br /&gt;
&lt;br /&gt;
Overall, the readability of the test file improved substantially!&lt;br /&gt;
&lt;br /&gt;
==== What did not change, and why? ====&lt;br /&gt;
&lt;br /&gt;
There were some violations that were intentionally not corrected to preserve readability and consistency:&lt;br /&gt;
* Block length violations were dismissed because adhering to them would undermine the structure of our test file. Our test file is laid out in segments defined by the `describe` blocks. At the uppermost level there is a describe block encapsulating all of the tests in the file. From there tests are divided by user type, this reduces redundancy in data preparation, improving test efficiency by having separate `before(:each)` blocks for each user. Within users, tests are further divided by API call type. This way it is easy to determine the location of a failing test, improving the speed of debugging. Because our structure relies on nested `describe` blocks, those at the uppermost levels are prone to triggering block length violations. With this in mind, we made the conscious decision to disable rubocop block length metrics with the following comments at the start and end of our test file respectively:&lt;br /&gt;
  # rubocop:disable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
  # rubocop:enable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
== Tests == &lt;br /&gt;
&lt;br /&gt;
Originally, tests were run using RSpec, but these created 13/13 Bookmarks controller tests failed. These tests were removed, and remade.&lt;br /&gt;
&lt;br /&gt;
Swagger UI is a set of tools that is used by the Expertiza developers to run RSpec tests through an interface instead of the command line. Swagger was originally needed in order to view and run tests, because the RSpec tests for this project need to be fixed. However, since RSpec tests have been recreated, the use of Swagger will not be required to run tests, but only check for code smells and coverage.&lt;br /&gt;
&lt;br /&gt;
=== Running RSpec tests via Swagger ===&lt;br /&gt;
&lt;br /&gt;
Steps&lt;br /&gt;
* Build the containers&lt;br /&gt;
* Go to http://localhost:3002/api-docs&lt;br /&gt;
* Login via the Authentication block at the bottom (U: &amp;quot;admin&amp;quot;, P: &amp;quot;password123&amp;quot;)&lt;br /&gt;
* Copy the token in the response&lt;br /&gt;
* Scroll up to the top and click &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* In the popup, paste in the token and hit &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* Navigate to the test you want to run, edit the parameters, and run it&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
Tests for both Bookmark_Controller.rb and Bookmark.rb both have 100% coverage! Previously, tests were not comprehensive, and tests would not run at all. We recreated all of the tests and made sure coverage was at least above 90% (as expected in the Requirements). &lt;br /&gt;
&lt;br /&gt;
View the code for &amp;lt;b&amp;gt;Bookmark_Controller.rb&amp;lt;/b&amp;gt; below, as well as number of times each line was executed:&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController1To33Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController34To63Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController64To98Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController99To130Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController130To154Coverage.PNG |1000px]]&lt;br /&gt;
&lt;br /&gt;
As we can see, many of the lines were executed 10 times or more. Also, many lines in the beginning were executed only once. However, substantial code is executed at least more than once.&lt;br /&gt;
&lt;br /&gt;
See the summary of coverage for both files below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarkCoverageE2480.png |1000px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;BookmarksController.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksControllerCoverageE2480.png |1000px]]&lt;br /&gt;
&lt;br /&gt;
As mentioned before, both files have 100% coverage, with around 20 average hits per line for BookmarksController.rb.&lt;br /&gt;
&lt;br /&gt;
== Recommended next steps ==&lt;br /&gt;
&lt;br /&gt;
* There are methods in the authorization_helper.rb that check to see if a TA or Instructor can access an assignment, that have some code smells such as bad method names.&lt;br /&gt;
* The questionnaire (which is used to rate the bookmark) needs the functionality of identifying a user type. Possibly create a mixin to implement this.&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:BookmarksController130To154Coverage.PNG&amp;diff=158673</id>
		<title>File:BookmarksController130To154Coverage.PNG</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:BookmarksController130To154Coverage.PNG&amp;diff=158673"/>
		<updated>2024-11-01T02:37:59Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:BookmarksController99To130Coverage.PNG&amp;diff=158672</id>
		<title>File:BookmarksController99To130Coverage.PNG</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:BookmarksController99To130Coverage.PNG&amp;diff=158672"/>
		<updated>2024-11-01T02:37:38Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:BookmarksController64To98Coverage.PNG&amp;diff=158671</id>
		<title>File:BookmarksController64To98Coverage.PNG</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:BookmarksController64To98Coverage.PNG&amp;diff=158671"/>
		<updated>2024-11-01T02:37:17Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:BookmarksController34To63Coverage.PNG&amp;diff=158670</id>
		<title>File:BookmarksController34To63Coverage.PNG</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:BookmarksController34To63Coverage.PNG&amp;diff=158670"/>
		<updated>2024-11-01T02:36:56Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:BookmarksController1To33Coverage.PNG&amp;diff=158669</id>
		<title>File:BookmarksController1To33Coverage.PNG</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:BookmarksController1To33Coverage.PNG&amp;diff=158669"/>
		<updated>2024-11-01T02:36:33Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158668</id>
		<title>CSC/ECE 517 Fall 2024 - E2480. Implement testing for new Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158668"/>
		<updated>2024-11-01T02:36:10Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2480: Implement testing for new Bookmarks Controller'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
A bookmark is a resource that a student can post for a certain topic, that other students may find useful if working on that topic. Students working on the topic have the ability to rate the bookmark based on usefulness, and using a rubric. The average of all ratings will be computed to get an average score.&lt;br /&gt;
&lt;br /&gt;
As discussed in E2480's background, the BookmarksController is implemented with CRUD operations, as well as the ability to rate bookmarks, calculate average ratings, and check for proper authorization when accessing a Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== Prior Work and Related Projects === &lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller#Problem_Statement E2424 Reimplement the Bookmarks Controller]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1786_OSS_Project_Juniper:_Bookmark_enhancements E1786 Bookmark enhancements]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=E1915_Authorization_Utilities E1915 Authorization Utilities]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Requirements === &lt;br /&gt;
&lt;br /&gt;
There are four main requirements assigned for the project, seen as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Add Tests and Generate API Documentation&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Develop comprehensive test cases for the BookmarksController to ensure the correctness of CRUD operations, bookmark ratings, and score calculations.&lt;br /&gt;
* The test coverage should aim to cover at least 90% of the code, ensuring thorough validation of edge cases and error handling.&lt;br /&gt;
* Utilize Swagger UI to generate API documentation for the controller and verify that routes are correctly defined.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Code Quality and Refactoring &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use tools like Rubocop and Code Climate to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods).&lt;br /&gt;
* Any unused or unclear functionality should be removed to improve maintainability.&lt;br /&gt;
* Rename methods with ambiguous names to improve clarity and ensure code follows the clean code principles.&lt;br /&gt;
* Review and optimize performance, particularly in areas where loops or methods can be refactored for better efficiency, such as handling the deletion of associated data (e.g., deleting all questions related to a questionnaire).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Authorization and Error Handling &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure proper enforcement of authorization rules and handle edge cases with informative error messages&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Final Deliverables &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure that all tests pass and API documentation is fully generated using Swagger UI.&lt;br /&gt;
* Confirm that code coverage exceeds 90%, and there are no significant code smells or performance issues flagged by Rubocop and Code Climate.&lt;br /&gt;
&lt;br /&gt;
==== Tasks ====&lt;br /&gt;
&lt;br /&gt;
We can simplify the above requirements down to the following tasks:&lt;br /&gt;
&lt;br /&gt;
* Create tests with at least 90% test coverage for BookmarksController&lt;br /&gt;
* Use Swagger UI to generate API documentation for the BookmarksController&lt;br /&gt;
* Fix and remove code smells, and refactor where necessary to optimize performance&lt;br /&gt;
* Implement authorization rules and handle edge cases using error messages that indicate what the error is&lt;br /&gt;
&lt;br /&gt;
There are two more tasks (see details in ''Process --&amp;gt; Findings'' below) that were given, which can be summed up as the following:&lt;br /&gt;
* Create an action_allowed? method to see if a User has access to a Course, and if a Student has access to a Bookmark&lt;br /&gt;
&lt;br /&gt;
== Process ==&lt;br /&gt;
&lt;br /&gt;
=== Findings ===&lt;br /&gt;
&lt;br /&gt;
Please note, the project repository was forked from reimplementation-back-end repository for Expertiza.&lt;br /&gt;
&lt;br /&gt;
After searching through the repository, we noticed a few issues with the reimplementation-back-end that were not discussed in the OSS project details. After discussing with Dr. Gehringer and the TA, we decided on specific tasks to focus on during this project. One such issue was checking for if a user such as a TA, Instructor, or Admin has access to the bookmark, which is determined by if the user has access to the course that contains the assignment, which contains a topic, which then contains the bookmark. &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Access&amp;quot; for different user types (Students are omitted, as they are only allowed to modify/delete bookmarks they created) is defined as follows: TAs have access if there exists a TaMapping between them and the course the bookmark is under. Intructors have access if they are the instructor for the course the bookmark is under. Admins have access if they are the parent of (created) the instructor of the course the bookmark is under. Super Admins always have access.&lt;br /&gt;
&lt;br /&gt;
Thus, the following additional tasks are expected in an action_allowed? method:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a User has access to a Course:&amp;lt;/b&amp;gt; The access a User (TA, Instructor, Admin) has to a Course is determined by the connection of Course to a Bookmark. A Course contains an Assignment, which contains a Topic, which then contains the Bookmark. Thus, if the user has access to a Course, they can access the Bookmark. &lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a Student has access to a Bookmark:&amp;lt;/b&amp;gt; This can be determined by checking to see if the Student had created the Bookmark. If so, then the Student can choose to edit or destroy the Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== New Changes ===&lt;br /&gt;
&lt;br /&gt;
==== Models &amp;amp; Controllers ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the bookmark.rb file, the only change is to uncomment the line related to :topic. This way, we can identify which Users can identify Bookmarks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/controllers/api/v1/bookmarks_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added action_allowed? functionality&lt;br /&gt;
|Code was added to include the AuthorizationHelper, as well as run the action_allowed? method before the other methods run, so the User type can be identified.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/3 Pull Request 3]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added 'index' to a When case for Students&lt;br /&gt;
|Identified Students by additionally looking for an'index' parameter, and using just this and the 'list' parameters to determine if the User is a student.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added 'show' and 'get_bookmark_rating_score' to a When case for Students&lt;br /&gt;
|Identified Students by looking for list, index, show, and get_bookmark_rating_score parameters. If the User is a Student, then the Student can view the bookmarks list.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/5 Pull Request 5]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Added check_action_allowed method&lt;br /&gt;
|Making the before action as the new method check_action_allowed, which will pull up an Unauthorized access json file if action_allowed is false.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Changing the methods, and added a check_action_allowed&lt;br /&gt;
|Adding searching for a bookmark by id functionality, and if the bookmark is not found, a json page will be returned for the show, destroy, update, get_bookmark_rating_score, save_bookmark_rating_score. The check_allowed_action method will show a page if the user is allowed to perform the action. Code cleanup was also done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Changing a couple of method calls, and adding conditions, as well as checking to see if a TaMapping exists&lt;br /&gt;
|Instead of a create method to create a bookmark rating, we call the new method with the same parameters, and call the save method. Also added a few conditionals to the 'when' blocks. Lastly, when the User is a TA, we can check to see if a TaMapping exists for the TA and a Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/helpers/authorization_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file was imported from the main Expertiza/Expertiza repo and functionality was added to integrate with the action_allowed? method to determine if users had valid privileges when trying to perform certain actions. However, the functionality in this file depends on session[:user], something that is not implemented in Expertiza/reimplementation-back-end. Due to this, this file was not used in this implementation, but the file and added functionality was kept for future use.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark_rating.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a validates statement&lt;br /&gt;
|The new validates statement will check to see if a bookmark's rating is present for a BookmarkRating.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Improving validates statement&lt;br /&gt;
|The validates statement now allows for only integers that are between 0 and 5.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Tests &amp;amp; Helpers ====&lt;br /&gt;
&lt;br /&gt;
===== Spec Files =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/requests/api/v1/bookmarks_controller_spec.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added and cleaned up happy and sad tests for getting bookmarks&lt;br /&gt;
|Cleaned up tests, and added expected functionality for the tests. Some tests were incorrectly named, so that was fixed as well. Added happy and sad tests such as not letting someone without a token access list of bookmarks, and letting the user access the list of bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding User type by role_id and creating headers for signing in, and adding tests.&lt;br /&gt;
|Added new tests to check for specific users such as TA, Instructor, and Student. Also, added headers that will be used as tokens in order to authorize User login.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Creating test cases for each User type, and removes the header authentication in this file.&lt;br /&gt;
|Added better tests to check for all types of Users, and removed the original getting a student and also moved the headers functionality from the file. Header authentication is now done within each test.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Add specific test cases for Students, TAs, Admin, and Super Admin&lt;br /&gt;
|Added better tests to check for all types of Users, such as letting a specific User type access lists of bookmarks, allowing a specific User type to query existing and non-existing bookmarks and seeing the results. Also, Users who are not signed in cannot access the list of bookmarks, or query bookmarks. Lastly, adds a create_bookmark method to make a bookmark while finding or creating a corresponding User, Course, Assignment, and SignUpTopic. The method will also decide that if the bookmark does not exist based on these values, then create it.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Adding specific test cases for BookmarkRatings&lt;br /&gt;
|Making test cases even more specific by adding test cases for all kinds of Users that may access BookmarkRatings. Also tests to see if BookmarkRatings can be accessed when a User is not logged in. Lastly, makes a make_bookmark_rating method that will create a bookmark if it doesn't exist, along with assigning a user to it (and creating a Student type if the user is nil).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Adding tests for adding, updating, deleting a bookmark, as well as other tests.&lt;br /&gt;
|Tests were created for seeing the path of how a Bookmark is created, updated, and deleted. Tests were also created in querying Bookmark Ratings for all kinds of Users (as well as signed out users), to make sure non-existent bookmarks will not be shown. There was also additions of sad tests to make sure that Users that are not Students cannot make, or update bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|Adding tests for adding, updating, and deleting a bookmark rating, as well as updating/deleting bookmarks for other Users.&lt;br /&gt;
|This PR adds happy and sad tests for functionality of adding, updating, and deleting bookmark ratings as a Student. Tests for adding, updating, and deleting Bookmarks by TA, Instructor, Admin, and SuperAdmin are also added. Lastly, functionality to look for a TA by role, and checking to see if a user is a TA is also added (and if a TA, then add the TA to the course).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Helpers =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/rails_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Load files in /spec/support/&lt;br /&gt;
|Files in /spec/support/ and its subfolders need to be loaded in for certain functionality to work. In particular, factory_bot.rb and authentication_helper.rb are found in this folder.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Seed the database if it isn't already seeded&lt;br /&gt;
|After running into issues with the database not being seeded when it should be, rails_helper was modified to check if seeding has occurred and to seed it if that had not already been done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/spec_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added SimpleCov configuration&lt;br /&gt;
|SimpleCov needs configuration files in spec_helper in order to load and be configured properly. Since SimpleCov was required for this project, this configuration information needed to be added to spec_helper.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/support/authentication_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Factories =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Assignment from factories&lt;br /&gt;
|Create Assignment data using factories. Then get an existing Instructor from the database or create a new one to add to each Assignment.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmark_ratings.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create Factory Bookmark Ratings&lt;br /&gt;
|Making data for bookmark ratings using Factory. Will make the bookmark and user null values (nil), and set a rating of 0).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmarks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create Factory Bookmarks&lt;br /&gt;
|Create Bookmark data using factories. We can add random strings to the title and description, as well as search the database for an existing Student to assign the Bookmark to.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/course.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Factory Course&lt;br /&gt;
|Create Course data using factories. Then get an Instructor from the database or create a new one. Then, use an existing institution or make a new Institution for each Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/institution.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/join_team_requests.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/roles.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/sign_up_topics.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Factory Topic&lt;br /&gt;
|Create Topics using factories, and assign an assignment id to each Topic.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/student_tasks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/users.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Database files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|All usages of ta mappings throughout the reimplementation-back-end repository use ta_id, whereas the schema refers to it as user_id. This created problems when trying to use ta mappings, especially in tests. To fix this, instead of refactoring all instances of ta mappings to have their field referred to as user_id, we changed the schema to reflect the existing usage of ta_id, while still having it understand that the foreign key refers to users. We created a migration (seen below) that accomplishes this task.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing users to TAs&lt;br /&gt;
|Instead of &amp;quot;user_id&amp;quot;, changed the value to ta_id. Also removing a foreign_key of mapping TA's to Users.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/seeds.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a role for the database&lt;br /&gt;
|Cleaned up the code, added useful comments, and added a role column for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding and Creating a User by email&lt;br /&gt;
|Based on the email type, Users will be created as seeds for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Remove all Code except Admin find and creation&lt;br /&gt;
|Only admin values will be found or created (for testing purposes). All other users will not be created using seed. From now on, User's will be created by factories instead of seeded into the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/migrate/20241030195109_update_ta_mappings_table_structure.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|Facilitates the changes made to the schema&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Deleted Files ====&lt;br /&gt;
&lt;br /&gt;
Two files regarding factories were deleted in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4]:&lt;br /&gt;
&lt;br /&gt;
* spec/factories.rb - the factories in this file were split into their own factory files in spec/factories/&lt;br /&gt;
* spec/factories/factories.rb - this was an empty file, deleted to clean up the repo&lt;br /&gt;
&lt;br /&gt;
=== Rubocop ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Why Rubocop ====&lt;br /&gt;
&lt;br /&gt;
Rubocop was one of the tools listed in the project instructions, and so we used it &amp;quot;to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods)&amp;quot;. We chose it in part because it was easy to apply to our system (simple CLI), and easy to make changes based on the feedback (provided line numbers and violation types).&lt;br /&gt;
&lt;br /&gt;
==== How it was applied ====&lt;br /&gt;
&lt;br /&gt;
We applied rubocop using simple one line commands based on what we wanted it to do. The general template we followed was:&lt;br /&gt;
  rubocop [-A] ./spec/requests/api/v1/bookmarks_controller_spec.rb [--out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt]&lt;br /&gt;
Where we would include&lt;br /&gt;
  -A&lt;br /&gt;
If we wanted it to auto-correct any automatically correctable violations, and&lt;br /&gt;
  --out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt&lt;br /&gt;
If we wanted output to be delivered to a file for improved readability&lt;br /&gt;
&lt;br /&gt;
==== What Changed ====&lt;br /&gt;
&lt;br /&gt;
Lots of small violations like trailing whitespace, unnecessary blank lines, using &amp;quot; == nil&amp;quot; instead of &amp;quot;.nil?&amp;quot;, and using double instead of single quotes were corrected automatically.&lt;br /&gt;
&lt;br /&gt;
Some bigger violations like brace indent alignment and inner field indentation were also able to be fixed automatically, although many of those came about after manual fixes to other violations, like:&lt;br /&gt;
&lt;br /&gt;
Line length violations were plentiful, most of them being caused by the long API commands. When we broke those down into their chunks, often times the `params:` argument would have its contents spread across multiple lines for readability (which caused some of the indent-related violations mentioned above). Other line length violations were on test descriptor lines (`it '&amp;lt;...&amp;gt;'`). The descriptors that triggered them covered complex tests, and so were intentionally detailed to inform future developers of what the test does, so shortening them was not ideal. These violations were resolved by splitting the descriptor across multiple lines.&lt;br /&gt;
&lt;br /&gt;
Overall, the readability of the test file improved substantially!&lt;br /&gt;
&lt;br /&gt;
==== What did not change, and why? ====&lt;br /&gt;
&lt;br /&gt;
There were some violations that were intentionally not corrected to preserve readability and consistency:&lt;br /&gt;
* Block length violations were dismissed because adhering to them would undermine the structure of our test file. Our test file is laid out in segments defined by the `describe` blocks. At the uppermost level there is a describe block encapsulating all of the tests in the file. From there tests are divided by user type, this reduces redundancy in data preparation, improving test efficiency by having separate `before(:each)` blocks for each user. Within users, tests are further divided by API call type. This way it is easy to determine the location of a failing test, improving the speed of debugging. Because our structure relies on nested `describe` blocks, those at the uppermost levels are prone to triggering block length violations. With this in mind, we made the conscious decision to disable rubocop block length metrics with the following comments at the start and end of our test file respectively:&lt;br /&gt;
  # rubocop:disable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
  # rubocop:enable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
== Tests == &lt;br /&gt;
&lt;br /&gt;
Originally, tests were run using RSpec, but these created 13/13 Bookmarks controller tests failed. These tests were removed, and remade.&lt;br /&gt;
&lt;br /&gt;
Swagger UI is a set of tools that is used by the Expertiza developers to run RSpec tests through an interface instead of the command line. Swagger was originally needed in order to view and run tests, because the RSpec tests for this project need to be fixed. However, since RSpec tests have been recreated, the use of Swagger will not be required to run tests, but only check for code smells and coverage.&lt;br /&gt;
&lt;br /&gt;
=== Running RSpec tests via Swagger ===&lt;br /&gt;
&lt;br /&gt;
Steps&lt;br /&gt;
* Build the containers&lt;br /&gt;
* Go to http://localhost:3002/api-docs&lt;br /&gt;
* Login via the Authentication block at the bottom (U: &amp;quot;admin&amp;quot;, P: &amp;quot;password123&amp;quot;)&lt;br /&gt;
* Copy the token in the response&lt;br /&gt;
* Scroll up to the top and click &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* In the popup, paste in the token and hit &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* Navigate to the test you want to run, edit the parameters, and run it&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
Tests for both Bookmark_Controller.rb and Bookmark.rb both have 100% coverage! Previously, tests were not comprehensive, and tests would not run at all. We recreated all of the tests and made sure coverage was at least above 90% (as expected in the Requirements). &lt;br /&gt;
&lt;br /&gt;
View the code for Bookmark_Controller.rb below, as well as number of times each line was executed:&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController1To33Coverage.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController34To63Coverage.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController64To98Coverage.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController99To130Coverage.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksController130To154Coverage.png]]&lt;br /&gt;
&lt;br /&gt;
See the coverage for both files below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarkCoverageE2480.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;BookmarksController.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksControllerCoverageE2480.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Recommended next steps ==&lt;br /&gt;
&lt;br /&gt;
* There are methods in the authorization_helper.rb that check to see if a TA or Instructor can access an assignment, that have some code smells such as bad method names.&lt;br /&gt;
* The questionnaire (which is used to rate the bookmark) needs the functionality of identifying a user type. Possibly create a mixin to implement this.&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158665</id>
		<title>CSC/ECE 517 Fall 2024 - E2480. Implement testing for new Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158665"/>
		<updated>2024-11-01T02:28:23Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2480: Implement testing for new Bookmarks Controller'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
A bookmark is a resource that a student can post for a certain topic, that other students may find useful if working on that topic. Students working on the topic have the ability to rate the bookmark based on usefulness, and using a rubric. The average of all ratings will be computed to get an average score.&lt;br /&gt;
&lt;br /&gt;
As discussed in E2480's background, the BookmarksController is implemented with CRUD operations, as well as the ability to rate bookmarks, calculate average ratings, and check for proper authorization when accessing a Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== Prior Work and Related Projects === &lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller#Problem_Statement E2424 Reimplement the Bookmarks Controller]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1786_OSS_Project_Juniper:_Bookmark_enhancements E1786 Bookmark enhancements]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=E1915_Authorization_Utilities E1915 Authorization Utilities]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Requirements === &lt;br /&gt;
&lt;br /&gt;
There are four main requirements assigned for the project, seen as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Add Tests and Generate API Documentation&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Develop comprehensive test cases for the BookmarksController to ensure the correctness of CRUD operations, bookmark ratings, and score calculations.&lt;br /&gt;
* The test coverage should aim to cover at least 90% of the code, ensuring thorough validation of edge cases and error handling.&lt;br /&gt;
* Utilize Swagger UI to generate API documentation for the controller and verify that routes are correctly defined.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Code Quality and Refactoring &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use tools like Rubocop and Code Climate to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods).&lt;br /&gt;
* Any unused or unclear functionality should be removed to improve maintainability.&lt;br /&gt;
* Rename methods with ambiguous names to improve clarity and ensure code follows the clean code principles.&lt;br /&gt;
* Review and optimize performance, particularly in areas where loops or methods can be refactored for better efficiency, such as handling the deletion of associated data (e.g., deleting all questions related to a questionnaire).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Authorization and Error Handling &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure proper enforcement of authorization rules and handle edge cases with informative error messages&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Final Deliverables &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure that all tests pass and API documentation is fully generated using Swagger UI.&lt;br /&gt;
* Confirm that code coverage exceeds 90%, and there are no significant code smells or performance issues flagged by Rubocop and Code Climate.&lt;br /&gt;
&lt;br /&gt;
==== Tasks ====&lt;br /&gt;
&lt;br /&gt;
We can simplify the above requirements down to the following tasks:&lt;br /&gt;
&lt;br /&gt;
* Create tests with at least 90% test coverage for BookmarksController&lt;br /&gt;
* Use Swagger UI to generate API documentation for the BookmarksController&lt;br /&gt;
* Fix and remove code smells, and refactor where necessary to optimize performance&lt;br /&gt;
* Implement authorization rules and handle edge cases using error messages that indicate what the error is&lt;br /&gt;
&lt;br /&gt;
There are two more tasks (see details in ''Process --&amp;gt; Findings'' below) that were given, which can be summed up as the following:&lt;br /&gt;
* Create an action_allowed? method to see if a User has access to a Course, and if a Student has access to a Bookmark&lt;br /&gt;
&lt;br /&gt;
== Process ==&lt;br /&gt;
&lt;br /&gt;
=== Findings ===&lt;br /&gt;
&lt;br /&gt;
Please note, the project repository was forked from reimplementation-back-end repository for Expertiza.&lt;br /&gt;
&lt;br /&gt;
After searching through the repository, we noticed a few issues with the reimplementation-back-end that were not discussed in the OSS project details. After discussing with Dr. Gehringer and the TA, we decided on specific tasks to focus on during this project. One such issue was checking for if a user such as a TA, Instructor, or Admin has access to the bookmark, which is determined by if the user has access to the course that contains the assignment, which contains a topic, which then contains the bookmark. &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Access&amp;quot; for different user types (Students are omitted, as they are only allowed to modify/delete bookmarks they created) is defined as follows: TAs have access if there exists a TaMapping between them and the course the bookmark is under. Intructors have access if they are the instructor for the course the bookmark is under. Admins have access if they are the parent of (created) the instructor of the course the bookmark is under. Super Admins always have access.&lt;br /&gt;
&lt;br /&gt;
Thus, the following additional tasks are expected in an action_allowed? method:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a User has access to a Course:&amp;lt;/b&amp;gt; The access a User (TA, Instructor, Admin) has to a Course is determined by the connection of Course to a Bookmark. A Course contains an Assignment, which contains a Topic, which then contains the Bookmark. Thus, if the user has access to a Course, they can access the Bookmark. &lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a Student has access to a Bookmark:&amp;lt;/b&amp;gt; This can be determined by checking to see if the Student had created the Bookmark. If so, then the Student can choose to edit or destroy the Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== New Changes ===&lt;br /&gt;
&lt;br /&gt;
==== Models &amp;amp; Controllers ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the bookmark.rb file, the only change is to uncomment the line related to :topic. This way, we can identify which Users can identify Bookmarks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/controllers/api/v1/bookmarks_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added action_allowed? functionality&lt;br /&gt;
|Code was added to include the AuthorizationHelper, as well as run the action_allowed? method before the other methods run, so the User type can be identified.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/3 Pull Request 3]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added 'index' to a When case for Students&lt;br /&gt;
|Identified Students by additionally looking for an'index' parameter, and using just this and the 'list' parameters to determine if the User is a student.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added 'show' and 'get_bookmark_rating_score' to a When case for Students&lt;br /&gt;
|Identified Students by looking for list, index, show, and get_bookmark_rating_score parameters. If the User is a Student, then the Student can view the bookmarks list.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/5 Pull Request 5]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Added check_action_allowed method&lt;br /&gt;
|Making the before action as the new method check_action_allowed, which will pull up an Unauthorized access json file if action_allowed is false.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Changing the methods, and added a check_action_allowed&lt;br /&gt;
|Adding searching for a bookmark by id functionality, and if the bookmark is not found, a json page will be returned for the show, destroy, update, get_bookmark_rating_score, save_bookmark_rating_score. The check_allowed_action method will show a page if the user is allowed to perform the action. Code cleanup was also done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Changing a couple of method calls, and adding conditions, as well as checking to see if a TaMapping exists&lt;br /&gt;
|Instead of a create method to create a bookmark rating, we call the new method with the same parameters, and call the save method. Also added a few conditionals to the 'when' blocks. Lastly, when the User is a TA, we can check to see if a TaMapping exists for the TA and a Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/helpers/authorization_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file was imported from the main Expertiza/Expertiza repo and functionality was added to integrate with the action_allowed? method to determine if users had valid privileges when trying to perform certain actions. However, the functionality in this file depends on session[:user], something that is not implemented in Expertiza/reimplementation-back-end. Due to this, this file was not used in this implementation, but the file and added functionality was kept for future use.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark_rating.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a validates statement&lt;br /&gt;
|The new validates statement will check to see if a bookmark's rating is present for a BookmarkRating.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Improving validates statement&lt;br /&gt;
|The validates statement now allows for only integers that are between 0 and 5.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Tests &amp;amp; Helpers ====&lt;br /&gt;
&lt;br /&gt;
===== Spec Files =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/requests/api/v1/bookmarks_controller_spec.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added and cleaned up happy and sad tests for getting bookmarks&lt;br /&gt;
|Cleaned up tests, and added expected functionality for the tests. Some tests were incorrectly named, so that was fixed as well. Added happy and sad tests such as not letting someone without a token access list of bookmarks, and letting the user access the list of bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding User type by role_id and creating headers for signing in, and adding tests.&lt;br /&gt;
|Added new tests to check for specific users such as TA, Instructor, and Student. Also, added headers that will be used as tokens in order to authorize User login.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Creating test cases for each User type, and removes the header authentication in this file.&lt;br /&gt;
|Added better tests to check for all types of Users, and removed the original getting a student and also moved the headers functionality from the file. Header authentication is now done within each test.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Add specific test cases for Students, TAs, Admin, and Super Admin&lt;br /&gt;
|Added better tests to check for all types of Users, such as letting a specific User type access lists of bookmarks, allowing a specific User type to query existing and non-existing bookmarks and seeing the results. Also, Users who are not signed in cannot access the list of bookmarks, or query bookmarks. Lastly, adds a create_bookmark method to make a bookmark while finding or creating a corresponding User, Course, Assignment, and SignUpTopic. The method will also decide that if the bookmark does not exist based on these values, then create it.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Adding specific test cases for BookmarkRatings&lt;br /&gt;
|Making test cases even more specific by adding test cases for all kinds of Users that may access BookmarkRatings. Also tests to see if BookmarkRatings can be accessed when a User is not logged in. Lastly, makes a make_bookmark_rating method that will create a bookmark if it doesn't exist, along with assigning a user to it (and creating a Student type if the user is nil).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Adding tests for adding, updating, deleting a bookmark, as well as other tests.&lt;br /&gt;
|Tests were created for seeing the path of how a Bookmark is created, updated, and deleted. Tests were also created in querying Bookmark Ratings for all kinds of Users (as well as signed out users), to make sure non-existent bookmarks will not be shown. There was also additions of sad tests to make sure that Users that are not Students cannot make, or update bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|Adding tests for adding, updating, and deleting a bookmark rating, as well as updating/deleting bookmarks for other Users.&lt;br /&gt;
|This PR adds happy and sad tests for functionality of adding, updating, and deleting bookmark ratings as a Student. Tests for adding, updating, and deleting Bookmarks by TA, Instructor, Admin, and SuperAdmin are also added. Lastly, functionality to look for a TA by role, and checking to see if a user is a TA is also added (and if a TA, then add the TA to the course).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Helpers =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/rails_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Seed the database&lt;br /&gt;
|If there are no Users in the database, then add functionality to seed the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/spec_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding SimpleCov functionality to specific files&lt;br /&gt;
|Making certain files (such as bookmarks_controller.rb and bookmark.rb) run to check coverage of the files.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/support/authentication_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Factories =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Assignment from factories&lt;br /&gt;
|Create Assignment data using factories. Then get an existing Instructor from the database or create a new one to add to each Assignment.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmark_ratings.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create Factory Bookmark Ratings&lt;br /&gt;
|Making data for bookmark ratings using Factory. Will make the bookmark and user null values (nil), and set a rating of 0).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmarks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create Factory Bookmarks&lt;br /&gt;
|Create Bookmark data using factories. We can add random strings to the title and description, as well as search the database for an existing Student to assign the Bookmark to.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/course.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Factory Course&lt;br /&gt;
|Create Course data using factories. Then get an Instructor from the database or create a new one. Then, use an existing institution or make a new Institution for each Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/institution.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/join_team_requests.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/roles.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/sign_up_topics.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Factory Topic&lt;br /&gt;
|Create Topics using factories, and assign an assignment id to each Topic.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/student_tasks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/users.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Database files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|All usages of ta mappings throughout the reimplementation-back-end repository use ta_id, whereas the schema refers to it as user_id. This created problems when trying to use ta mappings, especially in tests. To fix this, instead of refactoring all instances of ta mappings to have their field referred to as user_id, we changed the schema to reflect the existing usage of ta_id, while still having it understand that the foreign key refers to users. We created a migration (seen below) that accomplishes this task.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing users to TAs&lt;br /&gt;
|Instead of &amp;quot;user_id&amp;quot;, changed the value to ta_id. Also removing a foreign_key of mapping TA's to Users.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/seeds.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a role for the database&lt;br /&gt;
|Cleaned up the code, added useful comments, and added a role column for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding and Creating a User by email&lt;br /&gt;
|Based on the email type, Users will be created as seeds for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Remove all Code except Admin find and creation&lt;br /&gt;
|Only admin values will be found or created (for testing purposes). All other users will not be created using seed. From now on, User's will be created by factories instead of seeded into the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/migrate/20241030195109_update_ta_mappings_table_structure.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|Facilitates the changes made to the schema&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Deleted Files ====&lt;br /&gt;
&lt;br /&gt;
Two files regarding factories were deleted in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4]:&lt;br /&gt;
&lt;br /&gt;
* spec/factories.rb - the factories in this file were split into their own factory files in spec/factories/&lt;br /&gt;
* spec/factories/factories.rb - this was an empty file, deleted to clean up the repo&lt;br /&gt;
&lt;br /&gt;
=== Rubocop ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Why Rubocop ====&lt;br /&gt;
&lt;br /&gt;
Rubocop was one of the tools listed in the project instructions, and so we used it &amp;quot;to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods)&amp;quot;. We chose it in part because it was easy to apply to our system (simple CLI), and easy to make changes based on the feedback (provided line numbers and violation types).&lt;br /&gt;
&lt;br /&gt;
==== How it was applied ====&lt;br /&gt;
&lt;br /&gt;
We applied rubocop using simple one line commands based on what we wanted it to do. The general template we followed was:&lt;br /&gt;
  rubocop [-A] ./spec/requests/api/v1/bookmarks_controller_spec.rb [--out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt]&lt;br /&gt;
Where we would include&lt;br /&gt;
  -A&lt;br /&gt;
If we wanted it to auto-correct any automatically correctable violations, and&lt;br /&gt;
  --out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt&lt;br /&gt;
If we wanted output to be delivered to a file for improved readability&lt;br /&gt;
&lt;br /&gt;
==== What Changed ====&lt;br /&gt;
&lt;br /&gt;
Lots of small violations like trailing whitespace, unnecessary blank lines, using &amp;quot; == nil&amp;quot; instead of &amp;quot;.nil?&amp;quot;, and using double instead of single quotes were corrected automatically.&lt;br /&gt;
&lt;br /&gt;
Some bigger violations like brace indent alignment and inner field indentation were also able to be fixed automatically, although many of those came about after manual fixes to other violations, like:&lt;br /&gt;
&lt;br /&gt;
Line length violations were plentiful, most of them being caused by the long API commands. When we broke those down into their chunks, often times the `params:` argument would have its contents spread across multiple lines for readability (which caused some of the indent-related violations mentioned above). Other line length violations were on test descriptor lines (`it '&amp;lt;...&amp;gt;'`). The descriptors that triggered them covered complex tests, and so were intentionally detailed to inform future developers of what the test does, so shortening them was not ideal. These violations were resolved by splitting the descriptor across multiple lines.&lt;br /&gt;
&lt;br /&gt;
Overall, the readability of the test file improved substantially!&lt;br /&gt;
&lt;br /&gt;
==== What did not change, and why? ====&lt;br /&gt;
&lt;br /&gt;
There were some violations that were intentionally not corrected to preserve readability and consistency:&lt;br /&gt;
* Block length violations were dismissed because adhering to them would undermine the structure of our test file. Our test file is laid out in segments defined by the `describe` blocks. At the uppermost level there is a describe block encapsulating all of the tests in the file. From there tests are divided by user type, this reduces redundancy in data preparation, improving test efficiency by having separate `before(:each)` blocks for each user. Within users, tests are further divided by API call type. This way it is easy to determine the location of a failing test, improving the speed of debugging. Because our structure relies on nested `describe` blocks, those at the uppermost levels are prone to triggering block length violations. With this in mind, we made the conscious decision to disable rubocop block length metrics with the following comments at the start and end of our test file respectively:&lt;br /&gt;
  # rubocop:disable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
  # rubocop:enable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
== Tests == &lt;br /&gt;
&lt;br /&gt;
Originally, tests were run using RSpec, but these created 13/13 Bookmarks controller tests failed. These tests were removed, and remade.&lt;br /&gt;
&lt;br /&gt;
Swagger UI is a set of tools that is used by the Expertiza developers to run RSpec tests through an interface instead of the command line. Swagger was originally needed in order to view and run tests, because the RSpec tests for this project need to be fixed. However, since RSpec tests have been recreated, the use of Swagger will not be required to run tests, but only check for code smells and coverage.&lt;br /&gt;
&lt;br /&gt;
=== Running RSpec tests via Swagger ===&lt;br /&gt;
&lt;br /&gt;
Steps&lt;br /&gt;
* Build the containers&lt;br /&gt;
* Go to http://localhost:3002/api-docs&lt;br /&gt;
* Login via the Authentication block at the bottom (U: &amp;quot;admin&amp;quot;, P: &amp;quot;password123&amp;quot;)&lt;br /&gt;
* Copy the token in the response&lt;br /&gt;
* Scroll up to the top and click &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* In the popup, paste in the token and hit &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* Navigate to the test you want to run, edit the parameters, and run it&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
Tests for both Bookmark_Controller.rb and Bookmark.rb both have 100% coverage! Previously, tests were not comprehensive, and tests would not run at all. We recreated all of the tests and made sure coverage was at least above 90% (as expected in the Requirements). &lt;br /&gt;
&lt;br /&gt;
View the code for Bookmark_Controller.rb below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
See the coverage for both files below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarkCoverageE2480.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;BookmarksController.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:BookmarksControllerCoverageE2480.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Failing Tests ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Recommended next steps ==&lt;br /&gt;
&lt;br /&gt;
* There are methods in the authorization_helper.rb that check to see if a TA or Instructor can access an assignment, that have some code smells such as bad method names.&lt;br /&gt;
* The questionnaire (which is used to rate the bookmark) needs the functionality of identifying a user type. Possibly create a mixin to implement this.&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:BookmarksControllerCoverageE2480.png&amp;diff=158663</id>
		<title>File:BookmarksControllerCoverageE2480.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:BookmarksControllerCoverageE2480.png&amp;diff=158663"/>
		<updated>2024-11-01T02:26:01Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158661</id>
		<title>CSC/ECE 517 Fall 2024 - E2480. Implement testing for new Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158661"/>
		<updated>2024-11-01T02:25:37Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2480: Implement testing for new Bookmarks Controller'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
A bookmark is a resource that a student can post for a certain topic, that other students may find useful if working on that topic. Students working on the topic have the ability to rate the bookmark based on usefulness, and using a rubric. The average of all ratings will be computed to get an average score.&lt;br /&gt;
&lt;br /&gt;
As discussed in E2480's background, the BookmarksController is implemented with CRUD operations, as well as the ability to rate bookmarks, calculate average ratings, and check for proper authorization when accessing a Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== Prior Work and Related Projects === &lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller#Problem_Statement E2424 Reimplement the Bookmarks Controller]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1786_OSS_Project_Juniper:_Bookmark_enhancements E1786 Bookmark enhancements]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=E1915_Authorization_Utilities E1915 Authorization Utilities]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Requirements === &lt;br /&gt;
&lt;br /&gt;
There are four main requirements assigned for the project, seen as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Add Tests and Generate API Documentation&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Develop comprehensive test cases for the BookmarksController to ensure the correctness of CRUD operations, bookmark ratings, and score calculations.&lt;br /&gt;
* The test coverage should aim to cover at least 90% of the code, ensuring thorough validation of edge cases and error handling.&lt;br /&gt;
* Utilize Swagger UI to generate API documentation for the controller and verify that routes are correctly defined.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Code Quality and Refactoring &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use tools like Rubocop and Code Climate to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods).&lt;br /&gt;
* Any unused or unclear functionality should be removed to improve maintainability.&lt;br /&gt;
* Rename methods with ambiguous names to improve clarity and ensure code follows the clean code principles.&lt;br /&gt;
* Review and optimize performance, particularly in areas where loops or methods can be refactored for better efficiency, such as handling the deletion of associated data (e.g., deleting all questions related to a questionnaire).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Authorization and Error Handling &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure proper enforcement of authorization rules and handle edge cases with informative error messages&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Final Deliverables &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure that all tests pass and API documentation is fully generated using Swagger UI.&lt;br /&gt;
* Confirm that code coverage exceeds 90%, and there are no significant code smells or performance issues flagged by Rubocop and Code Climate.&lt;br /&gt;
&lt;br /&gt;
==== Tasks ====&lt;br /&gt;
&lt;br /&gt;
We can simplify the above requirements down to the following tasks:&lt;br /&gt;
&lt;br /&gt;
* Create tests with at least 90% test coverage for BookmarksController&lt;br /&gt;
* Use Swagger UI to generate API documentation for the BookmarksController&lt;br /&gt;
* Fix and remove code smells, and refactor where necessary to optimize performance&lt;br /&gt;
* Implement authorization rules and handle edge cases using error messages that indicate what the error is&lt;br /&gt;
&lt;br /&gt;
There are two more tasks (see details in ''Process --&amp;gt; Findings'' below) that were given, which can be summed up as the following:&lt;br /&gt;
* Create an action_allowed? method to see if a User has access to a Course, and if a Student has access to a Bookmark&lt;br /&gt;
&lt;br /&gt;
== Process ==&lt;br /&gt;
&lt;br /&gt;
=== Findings ===&lt;br /&gt;
&lt;br /&gt;
Please note, the project repository was forked from reimplementation-back-end repository for Expertiza.&lt;br /&gt;
&lt;br /&gt;
After searching through the repository, we noticed a few issues with the reimplementation-back-end that were not discussed in the OSS project details. After discussing with Dr. Gehringer and the TA, we decided on specific tasks to focus on during this project. One such issue was checking for if a user such as a TA, Instructor, or Admin has access to the bookmark, which is determined by if the user has access to the course that contains the assignment, which contains a topic, which then contains the bookmark. &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Access&amp;quot; for different user types (Students are omitted, as they are only allowed to modify/delete bookmarks they created) is defined as follows: TAs have access if there exists a TaMapping between them and the course the bookmark is under. Intructors have access if they are the instructor for the course the bookmark is under. Admins have access if they are the parent of (created) the instructor of the course the bookmark is under. Super Admins always have access.&lt;br /&gt;
&lt;br /&gt;
Thus, the following additional tasks are expected in an action_allowed? method:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a User has access to a Course:&amp;lt;/b&amp;gt; The access a User (TA, Instructor, Admin) has to a Course is determined by the connection of Course to a Bookmark. A Course contains an Assignment, which contains a Topic, which then contains the Bookmark. Thus, if the user has access to a Course, they can access the Bookmark. &lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a Student has access to a Bookmark:&amp;lt;/b&amp;gt; This can be determined by checking to see if the Student had created the Bookmark. If so, then the Student can choose to edit or destroy the Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== New Changes ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the bookmark.rb file, the only change is to uncomment the line related to :topic. This way, we can identify which Users can identify Bookmarks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/controllers/api/v1/bookmarks_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added action_allowed? functionality&lt;br /&gt;
|Code was added to include the AuthorizationHelper, as well as run the action_allowed? method before the other methods run, so the User type can be identified.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/3 Pull Request 3]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added 'index' to a When case for Students&lt;br /&gt;
|Identified Students by additionally looking for an'index' parameter, and using just this and the 'list' parameters to determine if the User is a student.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added 'show' and 'get_bookmark_rating_score' to a When case for Students&lt;br /&gt;
|Identified Students by looking for list, index, show, and get_bookmark_rating_score parameters. If the User is a Student, then the Student can view the bookmarks list.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/5 Pull Request 5]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Added check_action_allowed method&lt;br /&gt;
|Making the before action as the new method check_action_allowed, which will pull up an Unauthorized access json file if action_allowed is false.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Changing the methods, and added a check_action_allowed&lt;br /&gt;
|Adding searching for a bookmark by id functionality, and if the bookmark is not found, a json page will be returned for the show, destroy, update, get_bookmark_rating_score, save_bookmark_rating_score. The check_allowed_action method will show a page if the user is allowed to perform the action. Code cleanup was also done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Changing a couple of method calls, and adding conditions, as well as checking to see if a TaMapping exists&lt;br /&gt;
|Instead of a create method to create a bookmark rating, we call the new method with the same parameters, and call the save method. Also added a few conditionals to the 'when' blocks. Lastly, when the User is a TA, we can check to see if a TaMapping exists for the TA and a Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/helpers/authorization_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file was imported from the main Expertiza/Expertiza repo and functionality was added to integrate with the action_allowed? method to determine if users had valid privileges when trying to perform certain actions. However, the functionality in this file depends on session[:user], something that is not implemented in Expertiza/reimplementation-back-end. Due to this, this file was not used in this implementation, but the file and added functionality was kept for future use.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;app/models/bookmark_rating.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a validates statement&lt;br /&gt;
|The new validates statement will check to see if a bookmark's rating is present for a BookmarkRating.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Improving validates statement&lt;br /&gt;
|The validates statement now allows for only integers that are between 0 and 5.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Tests &amp;amp; Helpers ====&lt;br /&gt;
&lt;br /&gt;
===== Spec Files =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/requests/api/v1/bookmarks_controller_spec.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added and cleaned up happy and sad tests for getting bookmarks&lt;br /&gt;
|Cleaned up tests, and added expected functionality for the tests. Some tests were incorrectly named, so that was fixed as well. Added happy and sad tests such as not letting someone without a token access list of bookmarks, and letting the user access the list of bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding User type by role_id and creating headers for signing in, and adding tests.&lt;br /&gt;
|Added new tests to check for specific users such as TA, Instructor, and Student. Also, added headers that will be used as tokens in order to authorize User login.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Creating test cases for each User type, and removes the header authentication in this file.&lt;br /&gt;
|Added better tests to check for all types of Users, and removed the original getting a student and also moved the headers functionality from the file. Header authentication is now done within each test.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Add specific test cases for Students, TAs, Admin, and Super Admin&lt;br /&gt;
|Added better tests to check for all types of Users, such as letting a specific User type access lists of bookmarks, allowing a specific User type to query existing and non-existing bookmarks and seeing the results. Also, Users who are not signed in cannot access the list of bookmarks, or query bookmarks. Lastly, adds a create_bookmark method to make a bookmark while finding or creating a corresponding User, Course, Assignment, and SignUpTopic. The method will also decide that if the bookmark does not exist based on these values, then create it.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Adding specific test cases for BookmarkRatings&lt;br /&gt;
|Making test cases even more specific by adding test cases for all kinds of Users that may access BookmarkRatings. Also tests to see if BookmarkRatings can be accessed when a User is not logged in. Lastly, makes a make_bookmark_rating method that will create a bookmark if it doesn't exist, along with assigning a user to it (and creating a Student type if the user is nil).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Adding tests for adding, updating, deleting a bookmark, as well as other tests.&lt;br /&gt;
|Tests were created for seeing the path of how a Bookmark is created, updated, and deleted. Tests were also created in querying Bookmark Ratings for all kinds of Users (as well as signed out users), to make sure non-existent bookmarks will not be shown. There was also additions of sad tests to make sure that Users that are not Students cannot make, or update bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|Adding tests for adding, updating, and deleting a bookmark rating, as well as updating/deleting bookmarks for other Users.&lt;br /&gt;
|This PR adds happy and sad tests for functionality of adding, updating, and deleting bookmark ratings as a Student. Tests for adding, updating, and deleting Bookmarks by TA, Instructor, Admin, and SuperAdmin are also added. Lastly, functionality to look for a TA by role, and checking to see if a user is a TA is also added (and if a TA, then add the TA to the course).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Helpers =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/rails_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Seed the database&lt;br /&gt;
|If there are no Users in the database, then add functionality to seed the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/spec_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding SimpleCov functionality to specific files&lt;br /&gt;
|Making certain files (such as bookmarks_controller.rb and bookmark.rb) run to check coverage of the files.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/support/authentication_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Factories =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Assignment from factories&lt;br /&gt;
|Create Assignment data using factories. Then get an existing Instructor from the database or create a new one to add to each Assignment.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmark_ratings.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create Factory Bookmark Ratings&lt;br /&gt;
|Making data for bookmark ratings using Factory. Will make the bookmark and user null values (nil), and set a rating of 0).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmarks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create Factory Bookmarks&lt;br /&gt;
|Create Bookmark data using factories. We can add random strings to the title and description, as well as search the database for an existing Student to assign the Bookmark to.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/course.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Factory Course&lt;br /&gt;
|Create Course data using factories. Then get an Instructor from the database or create a new one. Then, use an existing institution or make a new Institution for each Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/institution.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/join_team_requests.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/roles.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/sign_up_topics.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Factory Topic&lt;br /&gt;
|Create Topics using factories, and assign an assignment id to each Topic.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/student_tasks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/users.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Database files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|All usages of ta mappings throughout the reimplementation-back-end repository use ta_id, whereas the schema refers to it as user_id. This created problems when trying to use ta mappings, especially in tests. To fix this, instead of refactoring all instances of ta mappings to have their field referred to as user_id, we changed the schema to reflect the existing usage of ta_id, while still having it understand that the foreign key refers to users. We created a migration (seen below) that accomplishes this task.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing users to TAs&lt;br /&gt;
|Instead of &amp;quot;user_id&amp;quot;, changed the value to ta_id. Also removing a foreign_key of mapping TA's to Users.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/seeds.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a role for the database&lt;br /&gt;
|Cleaned up the code, added useful comments, and added a role column for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding and Creating a User by email&lt;br /&gt;
|Based on the email type, Users will be created as seeds for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Remove all Code except Admin find and creation&lt;br /&gt;
|Only admin values will be found or created (for testing purposes). All other users will not be created using seed. From now on, User's will be created by factories instead of seeded into the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/migrate/20241030195109_update_ta_mappings_table_structure.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|Facilitates the changes made to the schema&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Deleted Files ====&lt;br /&gt;
&lt;br /&gt;
Two files regarding factories were deleted in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4]:&lt;br /&gt;
&lt;br /&gt;
* spec/factories.rb - the factories in this file were split into their own factory files in spec/factories/&lt;br /&gt;
* spec/factories/factories.rb - this was an empty file, deleted to clean up the repo&lt;br /&gt;
&lt;br /&gt;
=== Rubocop ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Why Rubocop ====&lt;br /&gt;
&lt;br /&gt;
Rubocop was one of the tools listed in the project instructions, and so we used it &amp;quot;to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods)&amp;quot;. We chose it in part because it was easy to apply to our system (simple CLI), and easy to make changes based on the feedback (provided line numbers and violation types).&lt;br /&gt;
&lt;br /&gt;
==== How it was applied ====&lt;br /&gt;
&lt;br /&gt;
We applied rubocop using simple one line commands based on what we wanted it to do. The general template we followed was:&lt;br /&gt;
  rubocop [-A] ./spec/requests/api/v1/bookmarks_controller_spec.rb [--out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt]&lt;br /&gt;
Where we would include&lt;br /&gt;
  -A&lt;br /&gt;
If we wanted it to auto-correct any automatically correctable violations, and&lt;br /&gt;
  --out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt&lt;br /&gt;
If we wanted output to be delivered to a file for improved readability&lt;br /&gt;
&lt;br /&gt;
==== What Changed ====&lt;br /&gt;
&lt;br /&gt;
Lots of small violations like trailing whitespace, unnecessary blank lines, using &amp;quot; == nil&amp;quot; instead of &amp;quot;.nil?&amp;quot;, and using double instead of single quotes were corrected automatically.&lt;br /&gt;
&lt;br /&gt;
Some bigger violations like brace indent alignment and inner field indentation were also able to be fixed automatically, although many of those came about after manual fixes to other violations, like:&lt;br /&gt;
&lt;br /&gt;
Line length violations were plentiful, most of them being caused by the long API commands. When we broke those down into their chunks, often times the `params:` argument would have its contents spread across multiple lines for readability (which caused some of the indent-related violations mentioned above). Other line length violations were on test descriptor lines (`it '&amp;lt;...&amp;gt;'`). The descriptors that triggered them covered complex tests, and so were intentionally detailed to inform future developers of what the test does, so shortening them was not ideal. These violations were resolved by splitting the descriptor across multiple lines.&lt;br /&gt;
&lt;br /&gt;
Overall, the readability of the test file improved substantially!&lt;br /&gt;
&lt;br /&gt;
==== What did not change, and why? ====&lt;br /&gt;
&lt;br /&gt;
There were some violations that were intentionally not corrected to preserve readability and consistency:&lt;br /&gt;
* Block length violations were dismissed because adhering to them would undermine the structure of our test file. Our test file is laid out in segments defined by the `describe` blocks. At the uppermost level there is a describe block encapsulating all of the tests in the file. From there tests are divided by user type, this reduces redundancy in data preparation, improving test efficiency by having separate `before(:each)` blocks for each user. Within users, tests are further divided by API call type. This way it is easy to determine the location of a failing test, improving the speed of debugging. Because our structure relies on nested `describe` blocks, those at the uppermost levels are prone to triggering block length violations. With this in mind, we made the conscious decision to disable rubocop block length metrics with the following comments at the start and end of our test file respectively:&lt;br /&gt;
  # rubocop:disable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
  # rubocop:enable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
== Tests == &lt;br /&gt;
&lt;br /&gt;
Originally, tests were run using RSpec, but these created 13/13 Bookmarks controller tests failed. These tests were removed, and remade.&lt;br /&gt;
&lt;br /&gt;
Swagger UI is a set of tools that is used by the Expertiza developers to run RSpec tests through an interface instead of the command line. Swagger was originally needed in order to view and run tests, because the RSpec tests for this project need to be fixed. However, since RSpec tests have been recreated, the use of Swagger will not be required to run tests, but only check for code smells and coverage.&lt;br /&gt;
&lt;br /&gt;
=== Running RSpec tests via Swagger ===&lt;br /&gt;
&lt;br /&gt;
Steps&lt;br /&gt;
* Build the containers&lt;br /&gt;
* Go to http://localhost:3002/api-docs&lt;br /&gt;
* Login via the Authentication block at the bottom (U: &amp;quot;admin&amp;quot;, P: &amp;quot;password123&amp;quot;)&lt;br /&gt;
* Copy the token in the response&lt;br /&gt;
* Scroll up to the top and click &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* In the popup, paste in the token and hit &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* Navigate to the test you want to run, edit the parameters, and run it&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
Tests for both Bookmark_Controller.rb and Bookmark.rb both have 100% coverage! Previously, tests were not comprehensive, and tests would not run at all. We recreated all of the tests and made sure coverage was at least above 90% (as expected in the Requirements). &lt;br /&gt;
&lt;br /&gt;
View the code for Bookmark_Controller.rb below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
See the coverage for both files below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[BookmarkCoverageE2480.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;BookmarksController.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[BookmarksControllerCoverageE2480.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Failing Tests ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Recommended next steps ==&lt;br /&gt;
&lt;br /&gt;
* There are methods in the authorization_helper.rb that check to see if a TA or Instructor can access an assignment, that have some code smells such as bad method names.&lt;br /&gt;
* The questionnaire (which is used to rate the bookmark) needs the functionality of identifying a user type. Possibly create a mixin to implement this.&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:BookmarkCoverageE2480.png&amp;diff=158660</id>
		<title>File:BookmarkCoverageE2480.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:BookmarkCoverageE2480.png&amp;diff=158660"/>
		<updated>2024-11-01T02:23:19Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158658</id>
		<title>CSC/ECE 517 Fall 2024 - E2480. Implement testing for new Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158658"/>
		<updated>2024-11-01T02:22:42Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2480: Implement testing for new Bookmarks Controller'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
A bookmark is a resource that a student can post for a certain topic, that other students may find useful if working on that topic. Students working on the topic have the ability to rate the bookmark based on usefulness, and using a rubric. The average of all ratings will be computed to get an average score.&lt;br /&gt;
&lt;br /&gt;
As discussed in E2480's background, the BookmarksController is implemented with CRUD operations, as well as the ability to rate bookmarks, calculate average ratings, and check for proper authorization when accessing a Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== Prior Work and Related Projects === &lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller#Problem_Statement E2424 Reimplement the Bookmarks Controller]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1786_OSS_Project_Juniper:_Bookmark_enhancements E1786 Bookmark enhancements]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=E1915_Authorization_Utilities E1915 Authorization Utilities]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Requirements === &lt;br /&gt;
&lt;br /&gt;
There are four main requirements assigned for the project, seen as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Add Tests and Generate API Documentation&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Develop comprehensive test cases for the BookmarksController to ensure the correctness of CRUD operations, bookmark ratings, and score calculations.&lt;br /&gt;
* The test coverage should aim to cover at least 90% of the code, ensuring thorough validation of edge cases and error handling.&lt;br /&gt;
* Utilize Swagger UI to generate API documentation for the controller and verify that routes are correctly defined.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Code Quality and Refactoring &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use tools like Rubocop and Code Climate to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods).&lt;br /&gt;
* Any unused or unclear functionality should be removed to improve maintainability.&lt;br /&gt;
* Rename methods with ambiguous names to improve clarity and ensure code follows the clean code principles.&lt;br /&gt;
* Review and optimize performance, particularly in areas where loops or methods can be refactored for better efficiency, such as handling the deletion of associated data (e.g., deleting all questions related to a questionnaire).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Authorization and Error Handling &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure proper enforcement of authorization rules and handle edge cases with informative error messages&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Final Deliverables &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure that all tests pass and API documentation is fully generated using Swagger UI.&lt;br /&gt;
* Confirm that code coverage exceeds 90%, and there are no significant code smells or performance issues flagged by Rubocop and Code Climate.&lt;br /&gt;
&lt;br /&gt;
==== Tasks ====&lt;br /&gt;
&lt;br /&gt;
We can simplify the above requirements down to the following tasks:&lt;br /&gt;
&lt;br /&gt;
* Create tests with at least 90% test coverage for BookmarksController&lt;br /&gt;
* Use Swagger UI to generate API documentation for the BookmarksController&lt;br /&gt;
* Fix and remove code smells, and refactor where necessary to optimize performance&lt;br /&gt;
* Implement authorization rules and handle edge cases using error messages that indicate what the error is&lt;br /&gt;
&lt;br /&gt;
There are two more tasks (see details in ''Process --&amp;gt; Findings'' below) that were given, which can be summed up as the following:&lt;br /&gt;
* Create an action_allowed? method to see if a User has access to a Course, and if a Student has access to a Bookmark&lt;br /&gt;
&lt;br /&gt;
== Process ==&lt;br /&gt;
&lt;br /&gt;
=== Findings ===&lt;br /&gt;
&lt;br /&gt;
Please note, the project repository was forked from reimplementation-back-end repository for Expertiza.&lt;br /&gt;
&lt;br /&gt;
After searching through the repository, we noticed a few issues with the reimplementation-back-end that were not discussed in the OSS project details. After discussing with Dr. Gehringer and the TA, we decided on specific tasks to focus on during this project. One such issue was checking for if a user such as a TA, Instructor, or Admin has access to the bookmark, which is determined by if the user has access to the course that contains the assignment, which contains a topic, which then contains the bookmark. &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Access&amp;quot; for different user types (Students are omitted, as they are only allowed to modify/delete bookmarks they created) is defined as follows: TAs have access if there exists a TaMapping between them and the course the bookmark is under. Intructors have access if they are the instructor for the course the bookmark is under. Admins have access if they are the parent of (created) the instructor of the course the bookmark is under. Super Admins always have access.&lt;br /&gt;
&lt;br /&gt;
Thus, the following additional tasks are expected in an action_allowed? method:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a User has access to a Course:&amp;lt;/b&amp;gt; The access a User (TA, Instructor, Admin) has to a Course is determined by the connection of Course to a Bookmark. A Course contains an Assignment, which contains a Topic, which then contains the Bookmark. Thus, if the user has access to a Course, they can access the Bookmark. &lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a Student has access to a Bookmark:&amp;lt;/b&amp;gt; This can be determined by checking to see if the Student had created the Bookmark. If so, then the Student can choose to edit or destroy the Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== New Changes ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the bookmark.rb file, the only change is to uncomment the line related to :topic. This way, we can identify which Users can identify Bookmarks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;bookmarks_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added action_allowed? functionality&lt;br /&gt;
|Code was added to include the AuthorizationHelper, as well as run the action_allowed? method before the other methods run, so the User type can be identified.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/3 Pull Request 3]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added 'index' to a When case for Students&lt;br /&gt;
|Identified Students by additionally looking for an'index' parameter, and using just this and the 'list' parameters to determine if the User is a student.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added 'show' and 'get_bookmark_rating_score' to a When case for Students&lt;br /&gt;
|Identified Students by looking for list, index, show, and get_bookmark_rating_score parameters. If the User is a Student, then the Student can view the bookmarks list.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/5 Pull Request 5]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Added check_action_allowed method&lt;br /&gt;
|Making the before action as the new method check_action_allowed, which will pull up an Unauthorized access json file if action_allowed is false.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Changing the methods, and added a check_action_allowed&lt;br /&gt;
|Adding searching for a bookmark by id functionality, and if the bookmark is not found, a json page will be returned for the show, destroy, update, get_bookmark_rating_score, save_bookmark_rating_score. The check_allowed_action method will show a page if the user is allowed to perform the action. Code cleanup was also done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Changing a couple of method calls, and adding conditions, as well as checking to see if a TaMapping exists&lt;br /&gt;
|Instead of a create method to create a bookmark rating, we call the new method with the same parameters, and call the save method. Also added a few conditionals to the 'when' blocks. Lastly, when the User is a TA, we can check to see if a TaMapping exists for the TA and a Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;authorization_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file is used to aid tests in logging in to different users. The action_allowed? method in bookmarks_controller.rb uses this file.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed details from login_admin&lt;br /&gt;
|If there are no users in the database, there is something wrong, because there should always be an admin in the database&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;models/bookmark_rating.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a validates statement&lt;br /&gt;
|The new validates statement will check to see if a bookmark's rating is present for a BookmarkRating.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Improving validates statement&lt;br /&gt;
|The validates statement now allows for only integers that are between 0 and 5.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Tests &amp;amp; Helpers ====&lt;br /&gt;
&lt;br /&gt;
===== Spec Files =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;bookmarks_controller_spec.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added and cleaned up happy and sad tests for getting bookmarks&lt;br /&gt;
|Cleaned up tests, and added expected functionality for the tests. Some tests were incorrectly named, so that was fixed as well. Added happy and sad tests such as not letting someone without a token access list of bookmarks, and letting the user access the list of bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding User type by role_id and creating headers for signing in, and adding tests.&lt;br /&gt;
|Added new tests to check for specific users such as TA, Instructor, and Student. Also, added headers that will be used as tokens in order to authorize User login.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Creating test cases for each User type, and removes the header authentication in this file.&lt;br /&gt;
|Added better tests to check for all types of Users, and removed the original getting a student and also moved the headers functionality from the file. Header authentication is now done within each test.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Add specific test cases for Students, TAs, Admin, and Super Admin&lt;br /&gt;
|Added better tests to check for all types of Users, such as letting a specific User type access lists of bookmarks, allowing a specific User type to query existing and non-existing bookmarks and seeing the results. Also, Users who are not signed in cannot access the list of bookmarks, or query bookmarks. Lastly, adds a create_bookmark method to make a bookmark while finding or creating a corresponding User, Course, Assignment, and SignUpTopic. The method will also decide that if the bookmark does not exist based on these values, then create it.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Adding specific test cases for BookmarkRatings&lt;br /&gt;
|Making test cases even more specific by adding test cases for all kinds of Users that may access BookmarkRatings. Also tests to see if BookmarkRatings can be accessed when a User is not logged in. Lastly, makes a make_bookmark_rating method that will create a bookmark if it doesn't exist, along with assigning a user to it (and creating a Student type if the user is nil).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Adding tests for adding, updating, deleting a bookmark, as well as other tests.&lt;br /&gt;
|Tests were created for seeing the path of how a Bookmark is created, updated, and deleted. Tests were also created in querying Bookmark Ratings for all kinds of Users (as well as signed out users), to make sure non-existent bookmarks will not be shown. There was also additions of sad tests to make sure that Users that are not Students cannot make, or update bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|Adding tests for adding, updating, and deleting a bookmark rating, as well as updating/deleting bookmarks for other Users.&lt;br /&gt;
|This PR adds happy and sad tests for functionality of adding, updating, and deleting bookmark ratings as a Student. Tests for adding, updating, and deleting Bookmarks by TA, Instructor, Admin, and SuperAdmin are also added. Lastly, functionality to look for a TA by role, and checking to see if a user is a TA is also added (and if a TA, then add the TA to the course).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===== Spec Helpers =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/spec_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding SimpleCov functionality to specific files&lt;br /&gt;
|Making certain files (such as bookmarks_controller.rb and bookmark.rb) run to check coverage of the files.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/rails_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Seed the database&lt;br /&gt;
|If there are no Users in the database, then add functionality to seed the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/support/authentication_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Spec Factories =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/sign_up_topics.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Factory Topic&lt;br /&gt;
|Create Topics using factories, and assign an assignment id to each Topic.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/course.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Factory Course&lt;br /&gt;
|Create Course data using factories. Then get an Instructor from the database or create a new one. Then, use an existing institution or make a new Institution for each Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Assignment from factories&lt;br /&gt;
|Create Assignment data using factories. Then get an existing Instructor from the database or create a new one to add to each Assignment.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmarks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create Factory Bookmarks&lt;br /&gt;
|Create Bookmark data using factories. We can add random strings to the title and description, as well as search the database for an existing Student to assign the Bookmark to.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmark_ratings.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create Factory Bookmark Ratings&lt;br /&gt;
|Making data for bookmark ratings using Factory. Will make the bookmark and user null values (nil), and set a rating of 0).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/roles.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file was renamed from spec/factories/role.rb to spec/factories/roles.rb (originally taken from Authentication functionality from Expertiza).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmarks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/institution.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/join_team_requests.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/role.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/student_tasks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/topics.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/users.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Database files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/seeds.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a role for the database&lt;br /&gt;
|Cleaned up the code, added useful comments, and added a role column for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding and Creating a User by email&lt;br /&gt;
|Based on the email type, Users will be created as seeds for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Remove all Code except Admin find and creation&lt;br /&gt;
|Only admin values will be found or created (for testing purposes). All other users will not be created using seed. From now on, User's will be created by factories instead of seeded into the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|All usages of ta mappings throughout the reimplementation-back-end repository use ta_id, whereas the schema refers to it as user_id. This created problems when trying to use ta mappings, especially in tests. To fix this, instead of refactoring all instances of ta mappings to have their field referred to as user_id, we changed the schema to reflect the existing usage of ta_id, while still having it understand that the foreign key refers to users. We created a migration (seen below) that accomplishes this task.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/migrate/20241030195109_update_ta_mappings_table_structure.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|Facilitates the changes made to the schema&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing users to TAs&lt;br /&gt;
|Instead of &amp;quot;user_id&amp;quot;, changed the value to ta_id. Also removing a foreign_key of mapping TA's to Users.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Deleted Files ====&lt;br /&gt;
&lt;br /&gt;
Two files regarding factories were deleted in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4]:&lt;br /&gt;
&lt;br /&gt;
* spec/factories.rb - the factories in this file were split into their own factory files in spec/factories/&lt;br /&gt;
* spec/factories/factories.rb - this was an empty file, deleted to clean up the repo&lt;br /&gt;
&lt;br /&gt;
=== Rubocop ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Why Rubocop ====&lt;br /&gt;
&lt;br /&gt;
Rubocop was one of the tools listed in the project instructions, and so we used it &amp;quot;to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods)&amp;quot;. We chose it in part because it was easy to apply to our system (simple CLI), and easy to make changes based on the feedback (provided line numbers and violation types).&lt;br /&gt;
&lt;br /&gt;
==== How it was applied ====&lt;br /&gt;
&lt;br /&gt;
We applied rubocop using simple one line commands based on what we wanted it to do. The general template we followed was:&lt;br /&gt;
  rubocop [-A] ./spec/requests/api/v1/bookmarks_controller_spec.rb [--out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt]&lt;br /&gt;
Where we would include&lt;br /&gt;
  -A&lt;br /&gt;
If we wanted it to auto-correct any automatically correctable violations, and&lt;br /&gt;
  --out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt&lt;br /&gt;
If we wanted output to be delivered to a file for improved readability&lt;br /&gt;
&lt;br /&gt;
==== What Changed ====&lt;br /&gt;
&lt;br /&gt;
Lots of small violations like trailing whitespace, unnecessary blank lines, using &amp;quot; == nil&amp;quot; instead of &amp;quot;.nil?&amp;quot;, and using double instead of single quotes were corrected automatically.&lt;br /&gt;
&lt;br /&gt;
Some bigger violations like brace indent alignment and inner field indentation were also able to be fixed automatically, although many of those came about after manual fixes to other violations, like:&lt;br /&gt;
&lt;br /&gt;
Line length violations were plentiful, most of them being caused by the long API commands. When we broke those down into their chunks, often times the `params:` argument would have its contents spread across multiple lines for readability (which caused some of the indent-related violations mentioned above). Other line length violations were on test descriptor lines (`it '&amp;lt;...&amp;gt;'`). The descriptors that triggered them covered complex tests, and so were intentionally detailed to inform future developers of what the test does, so shortening them was not ideal. These violations were resolved by splitting the descriptor across multiple lines.&lt;br /&gt;
&lt;br /&gt;
Overall, the readability of the test file improved substantially!&lt;br /&gt;
&lt;br /&gt;
==== What did not change, and why? ====&lt;br /&gt;
&lt;br /&gt;
There were some violations that were intentionally not corrected to preserve readability and consistency:&lt;br /&gt;
* Block length violations were dismissed because adhering to them would undermine the structure of our test file. Our test file is laid out in segments defined by the `describe` blocks. At the uppermost level there is a describe block encapsulating all of the tests in the file. From there tests are divided by user type, this reduces redundancy in data preparation, improving test efficiency by having separate `before(:each)` blocks for each user. Within users, tests are further divided by API call type. This way it is easy to determine the location of a failing test, improving the speed of debugging. Because our structure relies on nested `describe` blocks, those at the uppermost levels are prone to triggering block length violations. With this in mind, we made the conscious decision to disable rubocop block length metrics with the following comments at the start and end of our test file respectively:&lt;br /&gt;
  # rubocop:disable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
  # rubocop:enable Metrics/BlockLength&lt;br /&gt;
&lt;br /&gt;
== Tests == &lt;br /&gt;
&lt;br /&gt;
Originally, tests were run using RSpec, but these created 13/13 Bookmarks controller tests failed. These tests were removed, and remade.&lt;br /&gt;
&lt;br /&gt;
Swagger UI is a set of tools that is used by the Expertiza developers to run RSpec tests through an interface instead of the command line. Swagger was originally needed in order to view and run tests, because the RSpec tests for this project need to be fixed. However, since RSpec tests have been recreated, the use of Swagger will not be required to run tests, but only check for code smells and coverage.&lt;br /&gt;
&lt;br /&gt;
=== Running RSpec tests via Swagger ===&lt;br /&gt;
&lt;br /&gt;
Steps&lt;br /&gt;
* Build the containers&lt;br /&gt;
* Go to http://localhost:3002/api-docs&lt;br /&gt;
* Login via the Authentication block at the bottom (U: &amp;quot;admin&amp;quot;, P: &amp;quot;password123&amp;quot;)&lt;br /&gt;
* Copy the token in the response&lt;br /&gt;
* Scroll up to the top and click &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* In the popup, paste in the token and hit &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* Navigate to the test you want to run, edit the parameters, and run it&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
Tests for both Bookmark_Controller.rb and Bookmark.rb both have 100% coverage! Previously, tests were not comprehensive, and tests would not run at all. We recreated all of the tests and made sure coverage was at least above 90% (as expected in the Requirements).&lt;br /&gt;
&lt;br /&gt;
View the code for Bookmark_Controller.rb below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Failing Tests ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Recommended next steps ==&lt;br /&gt;
&lt;br /&gt;
* There are methods in the authorization_helper.rb that check to see if a TA or Instructor can access an assignment, that have some code smells such as bad method names.&lt;br /&gt;
* The questionnaire (which is used to rate the bookmark) needs the functionality of identifying a user type. Possibly create a mixin to implement this.&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158647</id>
		<title>CSC/ECE 517 Fall 2024 - E2480. Implement testing for new Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158647"/>
		<updated>2024-10-31T22:31:45Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project ''E2480: Implement testing for new Bookmarks Controller'' done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
A bookmark is a resource that a student can post for a certain topic, that other students may find useful if working on that topic. Students working on the topic have the ability to rate the bookmark based on usefulness, and using a rubric. The average of all ratings will be computed to get an average score.&lt;br /&gt;
&lt;br /&gt;
As discussed in E2480's background, the BookmarksController is implemented with CRUD operations, as well as the ability to rate bookmarks, calculate average ratings, and check for proper authorization when accessing a Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== Prior Work and Related Projects === &lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller#Problem_Statement E2424 Reimplement the Bookmarks Controller]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1786_OSS_Project_Juniper:_Bookmark_enhancements E1786 Bookmark enhancements]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=E1915_Authorization_Utilities E1915 Authorization Utilities]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Requirements === &lt;br /&gt;
&lt;br /&gt;
There are four main requirements assigned for the project, seen as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Add Tests and Generate API Documentation&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Develop comprehensive test cases for the BookmarksController to ensure the correctness of CRUD operations, bookmark ratings, and score calculations.&lt;br /&gt;
* The test coverage should aim to cover at least 90% of the code, ensuring thorough validation of edge cases and error handling.&lt;br /&gt;
* Utilize Swagger UI to generate API documentation for the controller and verify that routes are correctly defined.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Code Quality and Refactoring &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use tools like Rubocop and Code Climate to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods).&lt;br /&gt;
* Any unused or unclear functionality should be removed to improve maintainability.&lt;br /&gt;
* Rename methods with ambiguous names to improve clarity and ensure code follows the clean code principles.&lt;br /&gt;
* Review and optimize performance, particularly in areas where loops or methods can be refactored for better efficiency, such as handling the deletion of associated data (e.g., deleting all questions related to a questionnaire).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Authorization and Error Handling &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure proper enforcement of authorization rules and handle edge cases with informative error messages&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Final Deliverables &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure that all tests pass and API documentation is fully generated using Swagger UI.&lt;br /&gt;
* Confirm that code coverage exceeds 90%, and there are no significant code smells or performance issues flagged by Rubocop and Code Climate.&lt;br /&gt;
&lt;br /&gt;
==== Tasks ====&lt;br /&gt;
&lt;br /&gt;
We can simplify the above requirements down to the following tasks:&lt;br /&gt;
&lt;br /&gt;
* Create tests with at least 90% test coverage for BookmarksController&lt;br /&gt;
* Use Swagger UI to generate API documentation for the BookmarksController&lt;br /&gt;
* Fix and remove code smells, and refactor where necessary to optimize performance&lt;br /&gt;
* Implement authorization rules and handle edge cases using error messages that indicate what the error is&lt;br /&gt;
&lt;br /&gt;
There are two more tasks (see details in ''Process --&amp;gt; Findings'' below) that were given, which can be summed up as the following:&lt;br /&gt;
* Create an action_allowed? method to see if a User has access to a Course, and if a Student has access to a Bookmark&lt;br /&gt;
&lt;br /&gt;
== Process ==&lt;br /&gt;
&lt;br /&gt;
=== Findings ===&lt;br /&gt;
&lt;br /&gt;
Please note, the project repository was forked from reimplementation-back-end repository for Expertiza.&lt;br /&gt;
&lt;br /&gt;
After searching through the repository, we noticed a few issues with the reimplementation-back-end that were not discussed in the OSS project details. After discussing with Dr. Gehringer and the TA, we decided on specific tasks to focus on during this project. One such issue was checking for if a user such as a TA, Instructor, or Admin has access to the bookmark, which is determined by if the user has access to the course that contains the assignment, which contains a topic, which then contains the bookmark. &lt;br /&gt;
&lt;br /&gt;
Thus, the following additional tasks are expected in an action_allowed? method:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a User has access to a Course:&amp;lt;/b&amp;gt; The access a User (TA, Instructor, Admin) has to a Course is determined by the connection of Course to a Bookmark. A Course contains an Assignment, which contains a Topic, which then contains the Bookmark. Thus, if the user has access to a Course, they can access the Bookmark. &lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a Student has access to a Bookmark:&amp;lt;/b&amp;gt; This can be determined by checking to see if the Student had created the Bookmark. If so, then the Student can choose to edit or destroy the Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== New Changes ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the bookmark.rb file, the only change is to uncomment the line related to :topic. This way, we can identify which Users can identify Bookmarks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;bookmarks_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added action_allowed? functionality&lt;br /&gt;
|Code was added to include the AuthorizationHelper, as well as run the action_allowed? method before the other methods run, so the User type can be identified.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/3 Pull Request 3]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added 'index' to a When case for Students&lt;br /&gt;
|Identified Students by additionally looking for an'index' parameter, and using just this and the 'list' parameters to determine if the User is a student.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added 'show' and 'get_bookmark_rating_score' to a When case for Students&lt;br /&gt;
|Identified Students by looking for list, index, show, and get_bookmark_rating_score parameters. If the User is a Student, then the Student can view the bookmarks list.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/5 Pull Request 5]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Added check_action_allowed method&lt;br /&gt;
|Making the before action as the new method check_action_allowed, which will pull up an Unauthorized access json file if action_allowed is false.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Changing the methods, and added a check_action_allowed&lt;br /&gt;
|Adding searching for a bookmark by id functionality, and if the bookmark is not found, a json page will be returned for the show, destroy, update, get_bookmark_rating_score, save_bookmark_rating_score. The check_allowed_action method will show a page if the user is allowed to perform the action. Code cleanup was also done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Changing a couple of method calls, and adding conditions, as well as checking to see if a TaMapping exists&lt;br /&gt;
|Instead of a create method to create a bookmark rating, we call the new method with the same parameters, and call the save method. Also added a few conditionals to the 'when' blocks. Lastly, when the User is a TA, we can check to see if a TaMapping exists for the TA and a Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;authorization_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file is used to aid tests in logging in to different users. The action_allowed? method in bookmarks_controller.rb uses this file.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed details from login_admin&lt;br /&gt;
|If there are no users in the database, there is something wrong, because there should always be an admin in the database&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;models/bookmark_rating.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a validates statement&lt;br /&gt;
|The new validates statement will check to see if a bookmark's rating is present for a BookmarkRating.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Improving validates statement&lt;br /&gt;
|The validates statement now allows for only integers that are between 0 and 5.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Spec files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;bookmarks_controller_spec.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added and cleaned up happy and sad tests for getting bookmarks&lt;br /&gt;
|Cleaned up tests, and added expected functionality for the tests. Some tests were incorrectly named, so that was fixed as well. Added happy and sad tests such as not letting someone without a token access list of bookmarks, and letting the user access the list of bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding User type by role_id and creating headers for signing in, and adding tests.&lt;br /&gt;
|Added new tests to check for specific users such as TA, Instructor, and Student. Also, added headers that will be used as tokens in order to authorize User login.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Creating test cases for each User type, and removes the header authentication in this file.&lt;br /&gt;
|Added better tests to check for all types of Users, and removed the original getting a student and also moved the headers functionality from the file. Header authentication is now done within each test.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Add specific test cases for Students, TAs, Admin, and Super Admin&lt;br /&gt;
|Added better tests to check for all types of Users, such as letting a specific User type access lists of bookmarks, allowing a specific User type to query existing and non-existing bookmarks and seeing the results. Also, Users who are not signed in cannot access the list of bookmarks, or query bookmarks. Lastly, adds a create_bookmark method to make a bookmark while finding or creating a corresponding User, Course, Assignment, and SignUpTopic. The method will also decide that if the bookmark does not exist based on these values, then create it.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Adding specific test cases for BookmarkRatings&lt;br /&gt;
|Making test cases even more specific by adding test cases for all kinds of Users that may access BookmarkRatings. Also tests to see if BookmarkRatings can be accessed when a User is not logged in. Lastly, makes a make_bookmark_rating method that will create a bookmark if it doesn't exist, along with assigning a user to it (and creating a Student type if the user is nil).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Adding tests for adding, updating, deleting a bookmark, as well as other tests.&lt;br /&gt;
|Tests were created for seeing the path of how a Bookmark is created, updated, and deleted. Tests were also created in querying Bookmark Ratings for all kinds of Users (as well as signed out users), to make sure non-existent bookmarks will not be shown. There was also additions of sad tests to make sure that Users that are not Students cannot make, or update bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|Adding tests for adding, updating, and deleting a bookmark rating, as well as updating/deleting bookmarks for other Users.&lt;br /&gt;
|This PR adds happy and sad tests for functionality of adding, updating, and deleting bookmark ratings as a Student. Tests for adding, updating, and deleting Bookmarks by TA, Instructor, Admin, and SuperAdmin are also added. Lastly, functionality to look for a TA by role, and checking to see if a user is a TA is also added (and if a TA, then add the TA to the course).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/spec_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding SimpleCov functionality to specific files&lt;br /&gt;
|Making certain files (such as bookmarks_controller.rb and bookmark.rb) run to check coverage of the files.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/rails_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Seed the database&lt;br /&gt;
|If there are no Users in the database, then add functionality to seed the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/sign_up_topics.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Factory Topic&lt;br /&gt;
|Create Topics using factories, and assign an assignment id to each Topic.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/course.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Factory Course&lt;br /&gt;
|Create Course data using factories. Then get an Instructor from the database or create a new one. Then, use an existing institution or make a new Institution for each Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Assignment from factories&lt;br /&gt;
|Create Assignment data using factories. Then get an existing Instructor from the database or create a new one to add to each Assignment.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmarks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create Factory Bookmarks&lt;br /&gt;
|Create Bookmark data using factories. We can add random strings to the title and description, as well as search the database for an existing Student to assign the Bookmark to.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmark_ratings.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create Factory Bookmark Ratings&lt;br /&gt;
|Making data for bookmark ratings using Factory. Will make the bookmark and user null values (nil), and set a rating of 0).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/roles.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file was renamed from spec/factories/role.rb to spec/factories/roles.rb (originally taken from Authentication functionality from Expertiza).&lt;br /&gt;
&lt;br /&gt;
===== Authentication functionality from Expertiza=====&lt;br /&gt;
&lt;br /&gt;
The following were taken from the Expertiza repo and added into our repo for functionality purposes in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4]:&lt;br /&gt;
&lt;br /&gt;
*''spec/factories/bookmarks.rb''&lt;br /&gt;
*''spec/factories/institution.rb''&lt;br /&gt;
*''spec/factories/join_team_requests.rb''&lt;br /&gt;
*''spec/factories/role.rb'': Added a line to make any new roles created, a Student, in [https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request #6]. Removed previously created lines, implemented finding or creating a Student's id (of 5), and sets the name to 'Student' in [https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request #7]&lt;br /&gt;
*''spec/factories/student_tasks.rb''&lt;br /&gt;
*''spec/factories/topics.rb''&lt;br /&gt;
*''spec/factories/users.rb'': Changed the password and added functionality to use existing Student roles or Institutions, or to create new ones if none exists, in [https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request #7].&lt;br /&gt;
*''spec/support/authentication_helper.rb:'' Added checks to see if User, or  Token are nil values in [https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request #6].&lt;br /&gt;
&lt;br /&gt;
==== Database files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/seeds.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a role for the database&lt;br /&gt;
|Cleaned up the code, added useful comments, and added a role column for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding and Creating a User by email&lt;br /&gt;
|Based on the email type, Users will be created as seeds for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Remove all Code except Admin find and creation&lt;br /&gt;
|Only admin values will be found or created (for testing purposes). All other users will not be created using seed. From now on, User's will be created by factories instead of seeded into the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|All usages of ta mappings throughout the reimplementation-back-end repository use ta_id, whereas the schema refers to it as user_id. This created problems when trying to use ta mappings, especially in tests. To fix this, instead of refactoring all instances of ta mappings to have their field referred to as user_id, we changed the schema to reflect the existing usage of ta_id, while still having it understand that the foreign key refers to users. We created a migration (seen below) that accomplishes this task.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/migrate/20241030195109_update_ta_mappings_table_structure.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing ta_mappings references from user_id to ta_id&lt;br /&gt;
|Facilitates the changes made to the schema&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11] [https://github.com/Grochocinski/expertiza-E2480/pull/12 Pull Request 12]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing users to TAs&lt;br /&gt;
|Instead of &amp;quot;user_id&amp;quot;, changed the value to ta_id. Also removing a foreign_key of mapping TA's to Users.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Miscellaneous Files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;bookmark_tester.sh&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Trying to automate Bookmark testing&lt;br /&gt;
|Swagger tests must be manually run, so this file attempts to automate testing for the Bookmark. &lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Deleted Files ====&lt;br /&gt;
&lt;br /&gt;
The following are files that were deleted in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4] or other PR's if specified&lt;br /&gt;
&lt;br /&gt;
* spec/factories/bookmark.rb&lt;br /&gt;
* spec/factories.rb&lt;br /&gt;
* spec/factories/factories.rb&lt;br /&gt;
* spec/factories/topics.rb: [https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request #8] &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Rubocop ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Why Rubocop ====&lt;br /&gt;
&lt;br /&gt;
Rubocop was one of the tools listed in the project instructions, and so we used it &amp;quot;to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods)&amp;quot;. We chose it in part because it was easy to apply to our system (simple CLI), and easy to make changes based on the feedback (provided line numbers and violation types).&lt;br /&gt;
&lt;br /&gt;
==== How it was applied ====&lt;br /&gt;
&lt;br /&gt;
We applied rubocop using simple one line commands based on what we wanted it to do. The general template we followed was:&lt;br /&gt;
&lt;br /&gt;
* ~~rubocop [-A] ./spec/requests/api/v1/bookmarks_controller_spec.rb [--out ./spec/requests/&amp;lt;temporary file&amp;gt;.txt]~~&lt;br /&gt;
&lt;br /&gt;
== Tests == &lt;br /&gt;
&lt;br /&gt;
Originally, tests were run using RSpec, but these created 13/13 Bookmarks controller tests failed. These tests were removed, and remade.&lt;br /&gt;
&lt;br /&gt;
Swagger UI is a set of tools that is used by the Expertiza developers to run RSpec tests through an interface instead of the command line. Swagger was originally needed in order to view and run tests, because the RSpec tests for this project need to be fixed. However, since RSpec tests have been recreated, the use of Swagger will not be required to run tests, but only check for code smells and coverage.&lt;br /&gt;
&lt;br /&gt;
=== Running RSpec tests via Swagger ===&lt;br /&gt;
&lt;br /&gt;
Steps&lt;br /&gt;
* Build the containers&lt;br /&gt;
* Go to http://localhost:3002/api-docs&lt;br /&gt;
* Login via the Authentication block at the bottom (U: &amp;quot;admin&amp;quot;, P: &amp;quot;password123&amp;quot;)&lt;br /&gt;
* Copy the token in the response&lt;br /&gt;
* Scroll up to the top and click &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* In the popup, paste in the token and hit &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* Navigate to the test you want to run, edit the parameters, and run it&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Failing Tests ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Recommended next steps ==&lt;br /&gt;
&lt;br /&gt;
* There are methods in the authorization_helper.rb that check to see if a TA or Instructor can access an assignment, that have some code smells such as bad method names.&lt;br /&gt;
* The questionnaire (which is used to rate the bookmark) needs the functionality of identifying a user type. Possibly create a mixin to implement this.&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158637</id>
		<title>CSC/ECE 517 Fall 2024 - E2480. Implement testing for new Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158637"/>
		<updated>2024-10-31T22:10:29Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project E2480:Implement testing for new Bookmarks Controller done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
A bookmark is a resource that a student can post for a certain topic, that other students may find useful if working on that topic. Students working on the topic have the ability to rate the bookmark based on usefulness, and using a rubric. The average of all ratings will be computed to get an average score.&lt;br /&gt;
&lt;br /&gt;
As discussed in E2480's background, the BookmarksController is implemented with CRUD operations, as well as the ability to rate bookmarks, calculate average ratings, and check for proper authorization when accessing a Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== Prior Work and Related Projects === &lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller#Problem_Statement E2424 Reimplement the Bookmarks Controller]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1786_OSS_Project_Juniper:_Bookmark_enhancements E1786 Bookmark enhancements]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=E1915_Authorization_Utilities E1915 Authorization Utilities]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Requirements === &lt;br /&gt;
&lt;br /&gt;
There are four main requirements assigned for the project, seen as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Add Tests and Generate API Documentation&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Develop comprehensive test cases for the BookmarksController to ensure the correctness of CRUD operations, bookmark ratings, and score calculations.&lt;br /&gt;
* The test coverage should aim to cover at least 90% of the code, ensuring thorough validation of edge cases and error handling.&lt;br /&gt;
* Utilize Swagger UI to generate API documentation for the controller and verify that routes are correctly defined.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Code Quality and Refactoring &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use tools like Rubocop and Code Climate to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods).&lt;br /&gt;
* Any unused or unclear functionality should be removed to improve maintainability.&lt;br /&gt;
* Rename methods with ambiguous names to improve clarity and ensure code follows the clean code principles.&lt;br /&gt;
* Review and optimize performance, particularly in areas where loops or methods can be refactored for better efficiency, such as handling the deletion of associated data (e.g., deleting all questions related to a questionnaire).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Authorization and Error Handling &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure proper enforcement of authorization rules and handle edge cases with informative error messages&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Final Deliverables &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure that all tests pass and API documentation is fully generated using Swagger UI.&lt;br /&gt;
* Confirm that code coverage exceeds 90%, and there are no significant code smells or performance issues flagged by Rubocop and Code Climate.&lt;br /&gt;
&lt;br /&gt;
==== Tasks ====&lt;br /&gt;
&lt;br /&gt;
We can simplify the above requirements down to the following tasks:&lt;br /&gt;
&lt;br /&gt;
* Create tests with at least 90% test coverage for BookmarksController&lt;br /&gt;
* Use Swagger UI to generate API documentation for the BookmarksController&lt;br /&gt;
* Fix and remove code smells, and refactor where necessary to optimize performance&lt;br /&gt;
* Implement authorization rules and handle edge cases using error messages that indicate what the error is&lt;br /&gt;
&lt;br /&gt;
There are two more tasks (see details in ''Process --&amp;gt; Findings'' below) that were given, which can be summed up as the following:&lt;br /&gt;
* Create an action_allowed? method to see if a User has access to a Course, and if a Student has access to a Bookmark&lt;br /&gt;
&lt;br /&gt;
== Process ==&lt;br /&gt;
&lt;br /&gt;
=== Findings ===&lt;br /&gt;
&lt;br /&gt;
Please note, the project repository was forked from reimplementation-back-end repository for Expertiza.&lt;br /&gt;
&lt;br /&gt;
After searching through the repository, we noticed a few issues with the reimplementation-back-end that were not discussed in the OSS project details. After discussing with Dr. Gehringer and the TA, we decided on specific tasks to focus on during this project. One such issue was checking for if a user such as a TA, Instructor, or Admin has access to the bookmark, which is determined by if the user has access to the course that contains the assignment, which contains a topic, which then contains the bookmark. &lt;br /&gt;
&lt;br /&gt;
Thus, the following additional tasks are expected in an action_allowed? method:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a User has access to a Course:&amp;lt;/b&amp;gt; The access a User (TA, Instructor, Admin) has to a Course is determined by the connection of Course to a Bookmark. A Course contains an Assignment, which contains a Topic, which then contains the Bookmark. Thus, if the user has access to a Course, they can access the Bookmark. &lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a Student has access to a Bookmark:&amp;lt;/b&amp;gt; This can be determined by checking to see if the Student had created the Bookmark. If so, then the Student can choose to edit or destroy the Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== New Changes ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the bookmark.rb file, the only change is to uncomment the line related to :topic. This way, we can identify which Users can identify Bookmarks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;bookmarks_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added action_allowed? functionality&lt;br /&gt;
|Code was added to include the AuthorizationHelper, as well as run the action_allowed? method before the other methods run, so the User type can be identified.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/3 Pull Request 3]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added 'index' to a When case for Students&lt;br /&gt;
|Identified Students by additionally looking for an'index' parameter, and using just this and the 'list' parameters to determine if the User is a student.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added 'show' and 'get_bookmark_rating_score' to a When case for Students&lt;br /&gt;
|Identified Students by looking for list, index, show, and get_bookmark_rating_score parameters. If the User is a Student, then the Student can view the bookmarks list.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/5 Pull Request 5]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Added check_action_allowed method&lt;br /&gt;
|Making the before action as the new method check_action_allowed, which will pull up an Unauthorized access json file if action_allowed is false.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Changing the methods, and added a check_action_allowed&lt;br /&gt;
|Adding searching for a bookmark by id functionality, and if the bookmark is not found, a json page will be returned for the show, destroy, update, get_bookmark_rating_score, save_bookmark_rating_score. The check_allowed_action method will show a page if the user is allowed to perform the action. Code cleanup was also done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Changing a couple of method calls, and adding conditions, as well as checking to see if a TaMapping exists&lt;br /&gt;
|Instead of a create method to create a bookmark rating, we call the new method with the same parameters, and call the save method. Also added a few conditionals to the 'when' blocks. Lastly, when the User is a TA, we can check to see if a TaMapping exists for the TA and a Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;authorization_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file is used to aid tests in logging in to different users. The action_allowed? method in bookmarks_controller.rb uses this file.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed details from login_admin&lt;br /&gt;
|If there are no users in the database, there is something wrong, because there should always be an admin in the database&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;models/bookmark_rating.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a validates statement&lt;br /&gt;
|The new validates statement will check to see if a bookmark's rating is present for a BookmarkRating.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Improving validates statement&lt;br /&gt;
|The validates statement now allows for only integers that are between 0 and 5.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Spec files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;bookmarks_controller_spec.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added and cleaned up happy and sad tests for getting bookmarks&lt;br /&gt;
|Cleaned up tests, and added expected functionality for the tests. Some tests were incorrectly named, so that was fixed as well. Added happy and sad tests such as not letting someone without a token access list of bookmarks, and letting the user access the list of bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding User type by role_id and creating headers for signing in, and adding tests.&lt;br /&gt;
|Added new tests to check for specific users such as TA, Instructor, and Student. Also, added headers that will be used as tokens in order to authorize User login.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Creating test cases for each User type, and removes the header authentication in this file.&lt;br /&gt;
|Added better tests to check for all types of Users, and removed the original getting a student and also moved the headers functionality from the file. Header authentication is now done within each test.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Add specific test cases for Students, TAs, Admin, and Super Admin&lt;br /&gt;
|Added better tests to check for all types of Users, such as letting a specific User type access lists of bookmarks, allowing a specific User type to query existing and non-existing bookmarks and seeing the results. Also, Users who are not signed in cannot access the list of bookmarks, or query bookmarks. Lastly, adds a create_bookmark method to make a bookmark while finding or creating a corresponding User, Course, Assignment, and SignUpTopic. The method will also decide that if the bookmark does not exist based on these values, then create it.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Adding specific test cases for BookmarkRatings&lt;br /&gt;
|Making test cases even more specific by adding test cases for all kinds of Users that may access BookmarkRatings. Also tests to see if BookmarkRatings can be accessed when a User is not logged in. Lastly, makes a make_bookmark_rating method that will create a bookmark if it doesn't exist, along with assigning a user to it (and creating a Student type if the user is nil).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Adding tests for adding, updating, deleting a bookmark, as well as other tests.&lt;br /&gt;
|Tests were created for seeing the path of how a Bookmark is created, updated, and deleted. Tests were also created in querying Bookmark Ratings for all kinds of Users (as well as signed out users), to make sure non-existent bookmarks will not be shown. There was also additions of sad tests to make sure that Users that are not Students cannot make, or update bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|Adding tests for adding, updating, and deleting a bookmark rating, as well as updating/deleting bookmarks for other Users.&lt;br /&gt;
|This PR adds happy and sad tests for functionality of adding, updating, and deleting bookmark ratings as a Student. Tests for adding, updating, and deleting Bookmarks by TA, Instructor, Admin, and SuperAdmin are also added. Lastly, functionality to look for a TA by role, and checking to see if a user is a TA is also added (and if a TA, then add the TA to the course).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/spec_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding SimpleCov functionality to specific files&lt;br /&gt;
|Making certain files (such as bookmarks_controller.rb and bookmark.rb) run to check coverage of the files.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/rails_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Seed the database&lt;br /&gt;
|If there are no Users in the database, then add functionality to seed the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/sign_up_topics.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Factory Topic&lt;br /&gt;
|Create Topics using factories, and assign an assignment id to each Topic.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/course.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Factory Course&lt;br /&gt;
|Create Course data using factories. Then get an Instructor from the database or create a new one. Then, use an existing institution or make a new Institution for each Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Assignment from factories&lt;br /&gt;
|Create Assignment data using factories. Then get an existing Instructor from the database or create a new one to add to each Assignment.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmarks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create Factory Bookmarks&lt;br /&gt;
|Create Bookmark data using factories. We can add random strings to the title and description, as well as search the database for an existing Student to assign the Bookmark to.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmark_ratings.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create Factory Bookmark Ratings&lt;br /&gt;
|Making data for bookmark ratings using Factory. Will make the bookmark and user null values (nil), and set a rating of 0).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/roles.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file was renamed from spec/factories/role.rb to spec/factories/roles.rb (originally taken from Authentication functionality from Expertiza).&lt;br /&gt;
&lt;br /&gt;
===== Authentication functionality from Expertiza=====&lt;br /&gt;
&lt;br /&gt;
The following were taken from the Expertiza repo and added into our repo for functionality purposes in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4]:&lt;br /&gt;
&lt;br /&gt;
*''spec/factories/bookmarks.rb''&lt;br /&gt;
*''spec/factories/institution.rb''&lt;br /&gt;
*''spec/factories/join_team_requests.rb''&lt;br /&gt;
*''spec/factories/role.rb'': Added a line to make any new roles created, a Student, in [https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request #6]. Removed previously created lines, implemented finding or creating a Student's id (of 5), and sets the name to 'Student' in [https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request #7]&lt;br /&gt;
*''spec/factories/student_tasks.rb''&lt;br /&gt;
*''spec/factories/topics.rb''&lt;br /&gt;
*''spec/factories/users.rb'': Changed the password and added functionality to use existing Student roles or Institutions, or to create new ones if none exists, in [https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request #7].&lt;br /&gt;
*''spec/support/authentication_helper.rb:'' Added checks to see if User, or  Token are nil values in [https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request #6].&lt;br /&gt;
&lt;br /&gt;
==== Database files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/seeds.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a role for the database&lt;br /&gt;
|Cleaned up the code, added useful comments, and added a role column for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding and Creating a User by email&lt;br /&gt;
|Based on the email type, Users will be created as seeds for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Remove all Code except Admin find and creation&lt;br /&gt;
|Only admin values will be found or created (for testing purposes). All other users will not be created using seed. From now on, User's will be created by factories instead of seeded into the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing users to TAs&lt;br /&gt;
|Instead of &amp;quot;user_id&amp;quot;, changed the value to ta_id. Also removing a foreign_key of mapping TA's to Users.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Miscellaneous Files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;bookmark_tester.sh&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Trying to automate Bookmark testing&lt;br /&gt;
|Swagger tests must be manually run, so this file attempts to automate testing for the Bookmark. &lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Deleted Files ====&lt;br /&gt;
&lt;br /&gt;
The following are files that were deleted in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4] or other PR's if specified&lt;br /&gt;
&lt;br /&gt;
* spec/factories/bookmark.rb&lt;br /&gt;
* spec/factories.rb&lt;br /&gt;
* spec/factories/factories.rb&lt;br /&gt;
* spec/factories/topics.rb: [https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request #8] &lt;br /&gt;
&lt;br /&gt;
== Tests == &lt;br /&gt;
&lt;br /&gt;
Originally, tests were run using RSpec, but these created 13/13 Bookmarks controller tests failed. These tests were removed, and remade.&lt;br /&gt;
&lt;br /&gt;
Swagger UI is a set of tools that is used by the Expertiza developers to run RSpec tests through an interface instead of the command line. Swagger was originally needed in order to view and run tests, because the RSpec tests for this project need to be fixed. However, since RSpec tests have been recreated, the use of Swagger will not be required to run tests, but only check for code smells and coverage.&lt;br /&gt;
&lt;br /&gt;
=== Running RSpec tests via Swagger ===&lt;br /&gt;
&lt;br /&gt;
Steps&lt;br /&gt;
* Build the containers&lt;br /&gt;
* Go to http://localhost:3002/api-docs&lt;br /&gt;
* Login via the Authentication block at the bottom (U: &amp;quot;admin&amp;quot;, P: &amp;quot;password123&amp;quot;)&lt;br /&gt;
* Copy the token in the response&lt;br /&gt;
* Scroll up to the top and click &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* In the popup, paste in the token and hit &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* Navigate to the test you want to run, edit the parameters, and run it&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Failing Tests ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Recommended next steps ==&lt;br /&gt;
&lt;br /&gt;
* There are methods in the authorization_helper.rb that check to see if a TA or Instructor can access an assignment, that have some code smells such as bad method names.&lt;br /&gt;
* The questionnaire (which is used to rate the bookmark) needs the functionality of identifying a user type. Possibly create a mixin to implement this.&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158636</id>
		<title>CSC/ECE 517 Fall 2024 - E2480. Implement testing for new Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158636"/>
		<updated>2024-10-31T22:05:48Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project E2480:Implement testing for new Bookmarks Controller done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
A bookmark is a resource that a student can post for a certain topic, that other students may find useful if working on that topic. Students working on the topic have the ability to rate the bookmark based on usefulness, and using a rubric. The average of all ratings will be computed to get an average score.&lt;br /&gt;
&lt;br /&gt;
As discussed in E2480's background, the BookmarksController is implemented with CRUD operations, as well as the ability to rate bookmarks, calculate average ratings, and check for proper authorization when accessing a Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== Prior Work and Related Projects === &lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller#Problem_Statement E2424 Reimplement the Bookmarks Controller]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1786_OSS_Project_Juniper:_Bookmark_enhancements E1786 Bookmark enhancements]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=E1915_Authorization_Utilities E1915 Authorization Utilities]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Requirements === &lt;br /&gt;
&lt;br /&gt;
There are four main requirements assigned for the project, seen as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Add Tests and Generate API Documentation&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Develop comprehensive test cases for the BookmarksController to ensure the correctness of CRUD operations, bookmark ratings, and score calculations.&lt;br /&gt;
* The test coverage should aim to cover at least 90% of the code, ensuring thorough validation of edge cases and error handling.&lt;br /&gt;
* Utilize Swagger UI to generate API documentation for the controller and verify that routes are correctly defined.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Code Quality and Refactoring &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use tools like Rubocop and Code Climate to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods).&lt;br /&gt;
* Any unused or unclear functionality should be removed to improve maintainability.&lt;br /&gt;
* Rename methods with ambiguous names to improve clarity and ensure code follows the clean code principles.&lt;br /&gt;
* Review and optimize performance, particularly in areas where loops or methods can be refactored for better efficiency, such as handling the deletion of associated data (e.g., deleting all questions related to a questionnaire).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Authorization and Error Handling &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure proper enforcement of authorization rules and handle edge cases with informative error messages&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Final Deliverables &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure that all tests pass and API documentation is fully generated using Swagger UI.&lt;br /&gt;
* Confirm that code coverage exceeds 90%, and there are no significant code smells or performance issues flagged by Rubocop and Code Climate.&lt;br /&gt;
&lt;br /&gt;
==== Tasks ====&lt;br /&gt;
&lt;br /&gt;
We can simplify the above requirements down to the following tasks:&lt;br /&gt;
&lt;br /&gt;
* Create tests with at least 90% test coverage for BookmarksController&lt;br /&gt;
* Use Swagger UI to generate API documentation for the BookmarksController&lt;br /&gt;
* Fix and remove code smells, and refactor where necessary to optimize performance&lt;br /&gt;
* Implement authorization rules and handle edge cases using error messages that indicate what the error is&lt;br /&gt;
&lt;br /&gt;
There are two more tasks (see details in ''Process --&amp;gt; Findings'' below) that were given, which can be summed up as the following:&lt;br /&gt;
* Create an action_allowed? method to see if a User has access to a Course, and if a Student has access to a Bookmark&lt;br /&gt;
&lt;br /&gt;
== Process ==&lt;br /&gt;
&lt;br /&gt;
=== Findings ===&lt;br /&gt;
&lt;br /&gt;
Please note, the project repository was forked from reimplementation-back-end repository for Expertiza.&lt;br /&gt;
&lt;br /&gt;
After searching through the repository, we noticed a few issues with the reimplementation-back-end that were not discussed in the OSS project details. After discussing with Dr. Gehringer and the TA, we decided on specific tasks to focus on during this project. One such issue was checking for if a user such as a TA, Instructor, or Admin has access to the bookmark, which is determined by if the user has access to the course that contains the assignment, which contains a topic, which then contains the bookmark. &lt;br /&gt;
&lt;br /&gt;
Thus, the following additional tasks are expected in an action_allowed? method:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a User has access to a Course:&amp;lt;/b&amp;gt; The access a User (TA, Instructor, Admin) has to a Course is determined by the connection of Course to a Bookmark. A Course contains an Assignment, which contains a Topic, which then contains the Bookmark. Thus, if the user has access to a Course, they can access the Bookmark. &lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a Student has access to a Bookmark:&amp;lt;/b&amp;gt; This can be determined by checking to see if the Student had created the Bookmark. If so, then the Student can choose to edit or destroy the Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== New Changes ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the bookmark.rb file, the only change is to uncomment the line related to :topic. This way, we can identify which Users can identify Bookmarks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;bookmarks_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added action_allowed? functionality&lt;br /&gt;
|Code was added to include the AuthorizationHelper, as well as run the action_allowed? method before the other methods run, so the User type can be identified.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/3 Pull Request 3]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added 'index' to a When case for Students&lt;br /&gt;
|Identified Students by additionally looking for an'index' parameter, and using just this and the 'list' parameters to determine if the User is a student.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added 'show' and 'get_bookmark_rating_score' to a When case for Students&lt;br /&gt;
|Identified Students by looking for list, index, show, and get_bookmark_rating_score parameters. If the User is a Student, then the Student can view the bookmarks list.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/5 Pull Request 5]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Added check_action_allowed method&lt;br /&gt;
|Making the before action as the new method check_action_allowed, which will pull up an Unauthorized access json file if action_allowed is false.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Changing the methods, and added a check_action_allowed&lt;br /&gt;
|Adding searching for a bookmark by id functionality, and if the bookmark is not found, a json page will be returned for the show, destroy, update, get_bookmark_rating_score, save_bookmark_rating_score. The check_allowed_action method will show a page if the user is allowed to perform the action. Code cleanup was also done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Changing a couple of method calls, and adding conditions, as well as checking to see if a TaMapping exists&lt;br /&gt;
|Instead of a create method to create a bookmark rating, we call the new method with the same parameters, and call the save method. Also added a few conditionals to the 'when' blocks. Lastly, when the User is a TA, we can check to see if a TaMapping exists for the TA and a Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;authorization_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file is used to aid tests in logging in to different users. The action_allowed? method in bookmarks_controller.rb uses this file.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed details from login_admin&lt;br /&gt;
|If there are no users in the database, there is something wrong, because there should always be an admin in the database&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;models/bookmark_rating.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a validates statement&lt;br /&gt;
|The new validates statement will check to see if a bookmark's rating is present for a BookmarkRating.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Improving validates statement&lt;br /&gt;
|The validates statement now allows for only integers that are between 0 and 5.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Spec files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;bookmarks_controller_spec.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added and cleaned up happy and sad tests for getting bookmarks&lt;br /&gt;
|Cleaned up tests, and added expected functionality for the tests. Some tests were incorrectly named, so that was fixed as well. Added happy and sad tests such as not letting someone without a token access list of bookmarks, and letting the user access the list of bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding User type by role_id and creating headers for signing in, and adding tests.&lt;br /&gt;
|Added new tests to check for specific users such as TA, Instructor, and Student. Also, added headers that will be used as tokens in order to authorize User login.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Creating test cases for each User type, and removes the header authentication in this file.&lt;br /&gt;
|Added better tests to check for all types of Users, and removed the original getting a student and also moved the headers functionality from the file. Header authentication is now done within each test.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Add specific test cases for Students, TAs, Admin, and Super Admin&lt;br /&gt;
|Added better tests to check for all types of Users, such as letting a specific User type access lists of bookmarks, allowing a specific User type to query existing and non-existing bookmarks and seeing the results. Also, Users who are not signed in cannot access the list of bookmarks, or query bookmarks. Lastly, adds a create_bookmark method to make a bookmark while finding or creating a corresponding User, Course, Assignment, and SignUpTopic. The method will also decide that if the bookmark does not exist based on these values, then create it.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Adding specific test cases for BookmarkRatings&lt;br /&gt;
|Making test cases even more specific by adding test cases for all kinds of Users that may access BookmarkRatings. Also tests to see if BookmarkRatings can be accessed when a User is not logged in. Lastly, makes a make_bookmark_rating method that will create a bookmark if it doesn't exist, along with assigning a user to it (and creating a Student type if the user is nil).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Adding tests for adding, updating, deleting a bookmark, as well as other tests.&lt;br /&gt;
|Tests were created for seeing the path of how a Bookmark is created, updated, and deleted. Tests were also created in querying Bookmark Ratings for all kinds of Users (as well as signed out users), to make sure non-existent bookmarks will not be shown. There was also additions of sad tests to make sure that Users that are not Students cannot make, or update bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|Adding tests for adding, updating, and deleting a bookmark rating, as well as updating/deleting bookmarks for other Users.&lt;br /&gt;
|This PR adds happy and sad tests for functionality of adding, updating, and deleting bookmark ratings as a Student. Tests for adding, updating, and deleting Bookmarks by TA, Instructor, Admin, and SuperAdmin are also added.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/spec_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding SimpleCov functionality to specific files&lt;br /&gt;
|Making certain files (such as bookmarks_controller.rb and bookmark.rb) run to check coverage of the files.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/rails_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Seed the database&lt;br /&gt;
|If there are no Users in the database, then add functionality to seed the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/sign_up_topics.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Factory Topic&lt;br /&gt;
|Create Topics using factories, and assign an assignment id to each Topic.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/course.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Factory Course&lt;br /&gt;
|Create Course data using factories. Then get an Instructor from the database or create a new one. Then, use an existing institution or make a new Institution for each Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Assignment from factories&lt;br /&gt;
|Create Assignment data using factories. Then get an existing Instructor from the database or create a new one to add to each Assignment.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmarks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create Factory Bookmarks&lt;br /&gt;
|Create Bookmark data using factories. We can add random strings to the title and description, as well as search the database for an existing Student to assign the Bookmark to.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmark_ratings.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create Factory Bookmark Ratings&lt;br /&gt;
|Making data for bookmark ratings using Factory. Will make the bookmark and user null values (nil), and set a rating of 0).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/roles.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file was renamed from spec/factories/role.rb to spec/factories/roles.rb (originally taken from Authentication functionality from Expertiza).&lt;br /&gt;
&lt;br /&gt;
===== Authentication functionality from Expertiza=====&lt;br /&gt;
&lt;br /&gt;
The following were taken from the Expertiza repo and added into our repo for functionality purposes in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4]:&lt;br /&gt;
&lt;br /&gt;
*''spec/factories/bookmarks.rb''&lt;br /&gt;
*''spec/factories/institution.rb''&lt;br /&gt;
*''spec/factories/join_team_requests.rb''&lt;br /&gt;
*''spec/factories/role.rb'': Added a line to make any new roles created, a Student, in [https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request #6]. Removed previously created lines, implemented finding or creating a Student's id (of 5), and sets the name to 'Student' in [https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request #7]&lt;br /&gt;
*''spec/factories/student_tasks.rb''&lt;br /&gt;
*''spec/factories/topics.rb''&lt;br /&gt;
*''spec/factories/users.rb'': Changed the password and added functionality to use existing Student roles or Institutions, or to create new ones if none exists, in [https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request #7].&lt;br /&gt;
*''spec/support/authentication_helper.rb:'' Added checks to see if User, or  Token are nil values in [https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request #6].&lt;br /&gt;
&lt;br /&gt;
==== Database files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/seeds.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a role for the database&lt;br /&gt;
|Cleaned up the code, added useful comments, and added a role column for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding and Creating a User by email&lt;br /&gt;
|Based on the email type, Users will be created as seeds for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Remove all Code except Admin find and creation&lt;br /&gt;
|Only admin values will be found or created (for testing purposes). All other users will not be created using seed. From now on, User's will be created by factories instead of seeded into the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/schema.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Changing users to TAs&lt;br /&gt;
|Instead of &amp;quot;user_id&amp;quot;, changed the value to ta_id. Also removing a foreign_key of mapping TA's to Users.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/11 Pull Request 11]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Miscellaneous Files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;bookmark_tester.sh&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Trying to automate Bookmark testing&lt;br /&gt;
|Swagger tests must be manually run, so this file attempts to automate testing for the Bookmark. &lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Deleted Files ====&lt;br /&gt;
&lt;br /&gt;
The following are files that were deleted in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4] or other PR's if specified&lt;br /&gt;
&lt;br /&gt;
* spec/factories/bookmark.rb&lt;br /&gt;
* spec/factories.rb&lt;br /&gt;
* spec/factories/factories.rb&lt;br /&gt;
* spec/factories/topics.rb: [https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request #8] &lt;br /&gt;
&lt;br /&gt;
== Tests == &lt;br /&gt;
&lt;br /&gt;
Originally, tests were run using RSpec, but these created 13/13 Bookmarks controller tests failed. These tests were removed, and remade.&lt;br /&gt;
&lt;br /&gt;
Swagger UI is a set of tools that is used by the Expertiza developers to run RSpec tests through an interface instead of the command line. Swagger was originally needed in order to view and run tests, because the RSpec tests for this project need to be fixed. However, since RSpec tests have been recreated, the use of Swagger will not be required to run tests, but only check for code smells and coverage.&lt;br /&gt;
&lt;br /&gt;
=== Running RSpec tests via Swagger ===&lt;br /&gt;
&lt;br /&gt;
Steps&lt;br /&gt;
* Build the containers&lt;br /&gt;
* Go to http://localhost:3002/api-docs&lt;br /&gt;
* Login via the Authentication block at the bottom (U: &amp;quot;admin&amp;quot;, P: &amp;quot;password123&amp;quot;)&lt;br /&gt;
* Copy the token in the response&lt;br /&gt;
* Scroll up to the top and click &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* In the popup, paste in the token and hit &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* Navigate to the test you want to run, edit the parameters, and run it&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Failing Tests ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Recommended next steps ==&lt;br /&gt;
&lt;br /&gt;
* There are methods in the authorization_helper.rb that check to see if a TA or Instructor can access an assignment, that have some code smells such as bad method names.&lt;br /&gt;
* The questionnaire (which is used to rate the bookmark) needs the functionality of identifying a user type. Possibly create a mixin to implement this.&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158635</id>
		<title>CSC/ECE 517 Fall 2024 - E2480. Implement testing for new Bookmarks Controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2480._Implement_testing_for_new_Bookmarks_Controller&amp;diff=158635"/>
		<updated>2024-10-31T21:38:58Z</updated>

		<summary type="html">&lt;p&gt;Sdaniel8: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the details of OSS project E2480:Implement testing for new Bookmarks Controller done for Expertiza in Fall 2024.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Expertiza and Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open-source application used in CSC 517 (Object Oriented Design and Development) as a platform for creating teams, assigning programs, and reviewing submissions. Expertiza is also used to help students develop a working application in order to mimic how students will work on programs in the workplace.&lt;br /&gt;
&lt;br /&gt;
A bookmark is a resource that a student can post for a certain topic, that other students may find useful if working on that topic. Students working on the topic have the ability to rate the bookmark based on usefulness, and using a rubric. The average of all ratings will be computed to get an average score.&lt;br /&gt;
&lt;br /&gt;
As discussed in E2480's background, the BookmarksController is implemented with CRUD operations, as well as the ability to rate bookmarks, calculate average ratings, and check for proper authorization when accessing a Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== Prior Work and Related Projects === &lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2424._Reimplement_the_Bookmarks_Controller#Problem_Statement E2424 Reimplement the Bookmarks Controller]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1786_OSS_Project_Juniper:_Bookmark_enhancements E1786 Bookmark enhancements]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=E1915_Authorization_Utilities E1915 Authorization Utilities]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Requirements === &lt;br /&gt;
&lt;br /&gt;
There are four main requirements assigned for the project, seen as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;1. Add Tests and Generate API Documentation&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Develop comprehensive test cases for the BookmarksController to ensure the correctness of CRUD operations, bookmark ratings, and score calculations.&lt;br /&gt;
* The test coverage should aim to cover at least 90% of the code, ensuring thorough validation of edge cases and error handling.&lt;br /&gt;
* Utilize Swagger UI to generate API documentation for the controller and verify that routes are correctly defined.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;2. Code Quality and Refactoring &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use tools like Rubocop and Code Climate to assess code quality, remove code smells, and refactor any inefficient sections (e.g., redundant loops or methods).&lt;br /&gt;
* Any unused or unclear functionality should be removed to improve maintainability.&lt;br /&gt;
* Rename methods with ambiguous names to improve clarity and ensure code follows the clean code principles.&lt;br /&gt;
* Review and optimize performance, particularly in areas where loops or methods can be refactored for better efficiency, such as handling the deletion of associated data (e.g., deleting all questions related to a questionnaire).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;3. Authorization and Error Handling &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure proper enforcement of authorization rules and handle edge cases with informative error messages&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;4. Final Deliverables &amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure that all tests pass and API documentation is fully generated using Swagger UI.&lt;br /&gt;
* Confirm that code coverage exceeds 90%, and there are no significant code smells or performance issues flagged by Rubocop and Code Climate.&lt;br /&gt;
&lt;br /&gt;
==== Tasks ====&lt;br /&gt;
&lt;br /&gt;
We can simplify the above requirements down to the following tasks:&lt;br /&gt;
&lt;br /&gt;
* Create tests with at least 90% test coverage for BookmarksController&lt;br /&gt;
* Use Swagger UI to generate API documentation for the BookmarksController&lt;br /&gt;
* Fix and remove code smells, and refactor where necessary to optimize performance&lt;br /&gt;
* Implement authorization rules and handle edge cases using error messages that indicate what the error is&lt;br /&gt;
&lt;br /&gt;
There are two more tasks (see details in ''Process --&amp;gt; Findings'' below) that were given, which can be summed up as the following:&lt;br /&gt;
* Create an action_allowed? method to see if a User has access to a Course, and if a Student has access to a Bookmark&lt;br /&gt;
&lt;br /&gt;
== Process ==&lt;br /&gt;
&lt;br /&gt;
=== Findings ===&lt;br /&gt;
&lt;br /&gt;
Please note, the project repository was forked from reimplementation-back-end repository for Expertiza.&lt;br /&gt;
&lt;br /&gt;
After searching through the repository, we noticed a few issues with the reimplementation-back-end that were not discussed in the OSS project details. After discussing with Dr. Gehringer and the TA, we decided on specific tasks to focus on during this project. One such issue was checking for if a user such as a TA, Instructor, or Admin has access to the bookmark, which is determined by if the user has access to the course that contains the assignment, which contains a topic, which then contains the bookmark. &lt;br /&gt;
&lt;br /&gt;
Thus, the following additional tasks are expected in an action_allowed? method:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a User has access to a Course:&amp;lt;/b&amp;gt; The access a User (TA, Instructor, Admin) has to a Course is determined by the connection of Course to a Bookmark. A Course contains an Assignment, which contains a Topic, which then contains the Bookmark. Thus, if the user has access to a Course, they can access the Bookmark. &lt;br /&gt;
* &amp;lt;b&amp;gt;Check to see if a Student has access to a Bookmark:&amp;lt;/b&amp;gt; This can be determined by checking to see if the Student had created the Bookmark. If so, then the Student can choose to edit or destroy the Bookmark.&lt;br /&gt;
&lt;br /&gt;
=== New Changes ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;bookmark.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the bookmark.rb file, the only change is to uncomment the line related to :topic. This way, we can identify which Users can identify Bookmarks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;bookmarks_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added action_allowed? functionality&lt;br /&gt;
|Code was added to include the AuthorizationHelper, as well as run the action_allowed? method before the other methods run, so the User type can be identified.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/3 Pull Request 3]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added 'index' to a When case for Students&lt;br /&gt;
|Identified Students by additionally looking for an'index' parameter, and using just this and the 'list' parameters to determine if the User is a student.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added 'show' and 'get_bookmark_rating_score' to a When case for Students&lt;br /&gt;
|Identified Students by looking for list, index, show, and get_bookmark_rating_score parameters. If the User is a Student, then the Student can view the bookmarks list.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/5 Pull Request 5]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Added check_action_allowed method&lt;br /&gt;
|Making the before action as the new method check_action_allowed, which will pull up an Unauthorized access json file if action_allowed is false.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Changing the methods, and added a check_action_allowed&lt;br /&gt;
|Adding searching for a bookmark by id functionality, and if the bookmark is not found, a json page will be returned for the show, destroy, update, get_bookmark_rating_score, save_bookmark_rating_score. The check_allowed_action method will show a page if the user is allowed to perform the action. Code cleanup was also done.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;authorization_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file is used to aid tests in logging in to different users. The action_allowed? method in bookmarks_controller.rb uses this file.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed details from login_admin&lt;br /&gt;
|If there are no users in the database, there is something wrong, because there should always be an admin in the database&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;models/bookmark_rating.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a validates statement&lt;br /&gt;
|The new validates statement will check to see if a bookmark's rating is present for a BookmarkRating.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Improving validates statement&lt;br /&gt;
|The validates statement now allows for only integers that are between 0 and 5.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Spec files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;bookmarks_controller_spec.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added and cleaned up happy and sad tests for getting bookmarks&lt;br /&gt;
|Cleaned up tests, and added expected functionality for the tests. Some tests were incorrectly named, so that was fixed as well. Added happy and sad tests such as not letting someone without a token access list of bookmarks, and letting the user access the list of bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding User type by role_id and creating headers for signing in, and adding tests.&lt;br /&gt;
|Added new tests to check for specific users such as TA, Instructor, and Student. Also, added headers that will be used as tokens in order to authorize User login.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Creating test cases for each User type, and removes the header authentication in this file.&lt;br /&gt;
|Added better tests to check for all types of Users, and removed the original getting a student and also moved the headers functionality from the file. Header authentication is now done within each test.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Add specific test cases for Students, TAs, Admin, and Super Admin&lt;br /&gt;
|Added better tests to check for all types of Users, such as letting a specific User type access lists of bookmarks, allowing a specific User type to query existing and non-existing bookmarks and seeing the results. Also, Users who are not signed in cannot access the list of bookmarks, or query bookmarks. Lastly, adds a create_bookmark method to make a bookmark while finding or creating a corresponding User, Course, Assignment, and SignUpTopic. The method will also decide that if the bookmark does not exist based on these values, then create it.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Adding specific test cases for BookmarkRatings&lt;br /&gt;
|Making test cases even more specific by adding test cases for all kinds of Users that may access BookmarkRatings. Also tests to see if BookmarkRatings can be accessed when a User is not logged in. Lastly, makes a make_bookmark_rating method that will create a bookmark if it doesn't exist, along with assigning a user to it (and creating a Student type if the user is nil).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|Adding tests for adding, updating, deleting a bookmark, as well as other tests.&lt;br /&gt;
|Tests were created for seeing the path of how a Bookmark is created, updated, and deleted. Tests were also created in querying Bookmark Ratings for all kinds of Users (as well as signed out users), to make sure non-existent bookmarks will not be shown. There was also additions of sad tests to make sure that Users that are not Students cannot make, or update bookmarks.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/spec_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding SimpleCov functionality to specific files&lt;br /&gt;
|Making certain files (such as bookmarks_controller.rb and bookmark.rb) run to check coverage of the files.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/rails_helper.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Seed the database&lt;br /&gt;
|If there are no Users in the database, then add functionality to seed the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/sign_up_topics.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Factory Topic&lt;br /&gt;
|Create Topics using factories, and assign an assignment id to each Topic.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/course.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Factory Course&lt;br /&gt;
|Create Course data using factories. Then get an Instructor from the database or create a new one. Then, use an existing institution or make a new Institution for each Course.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/assignment.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create a Assignment from factories&lt;br /&gt;
|Create Assignment data using factories. Then get an existing Instructor from the database or create a new one to add to each Assignment.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmarks.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create Factory Bookmarks&lt;br /&gt;
|Create Bookmark data using factories. We can add random strings to the title and description, as well as search the database for an existing Student to assign the Bookmark to.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request 8]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/bookmark_ratings.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Create Factory Bookmark Ratings&lt;br /&gt;
|Making data for bookmark ratings using Factory. Will make the bookmark and user null values (nil), and set a rating of 0).&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/9 Pull Request 9]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;spec/factories/roles.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This file was renamed from spec/factories/role.rb to spec/factories/roles.rb (originally taken from Authentication functionality from Expertiza).&lt;br /&gt;
&lt;br /&gt;
===== Authentication functionality from Expertiza=====&lt;br /&gt;
&lt;br /&gt;
The following were taken from the Expertiza repo and added into our repo for functionality purposes in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4]:&lt;br /&gt;
&lt;br /&gt;
*''spec/factories/bookmarks.rb''&lt;br /&gt;
*''spec/factories/institution.rb''&lt;br /&gt;
*''spec/factories/join_team_requests.rb''&lt;br /&gt;
*''spec/factories/role.rb'': Added a line to make any new roles created, a Student, in [https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request #6]. Removed previously created lines, implemented finding or creating a Student's id (of 5), and sets the name to 'Student' in [https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request #7]&lt;br /&gt;
*''spec/factories/student_tasks.rb''&lt;br /&gt;
*''spec/factories/topics.rb''&lt;br /&gt;
*''spec/factories/users.rb'': Changed the password and added functionality to use existing Student roles or Institutions, or to create new ones if none exists, in [https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request #7].&lt;br /&gt;
*''spec/support/authentication_helper.rb:'' Added checks to see if User, or  Token are nil values in [https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request #6].&lt;br /&gt;
&lt;br /&gt;
==== Database files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;db/seeds.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Adding a role for the database&lt;br /&gt;
|Cleaned up the code, added useful comments, and added a role column for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Finding and Creating a User by email&lt;br /&gt;
|Based on the email type, Users will be created as seeds for the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/6 Pull Request 6]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Remove all Code except Admin find and creation&lt;br /&gt;
|Only admin values will be found or created (for testing purposes). All other users will not be created using seed. From now on, User's will be created by factories instead of seeded into the database.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/7 Pull Request 7]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Changing users to TAs&lt;br /&gt;
|Instead of &amp;quot;user_id&amp;quot;, change the value to ta_id. Also removing a foreign_key of mapping TA's to Users.&lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/10 Pull Request 10]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Miscellaneous Files ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;bookmark_tester.sh&amp;lt;/b&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! PR Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Trying to automate Bookmark testing&lt;br /&gt;
|Swagger tests must be manually run, so this file attempts to automate testing for the Bookmark. &lt;br /&gt;
|[https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request 4]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Deleted Files ====&lt;br /&gt;
&lt;br /&gt;
The following are files that were deleted in [https://github.com/Grochocinski/expertiza-E2480/pull/4 Pull Request #4] or other PR's if specified&lt;br /&gt;
&lt;br /&gt;
* spec/factories/bookmark.rb&lt;br /&gt;
* spec/factories.rb&lt;br /&gt;
* spec/factories/factories.rb&lt;br /&gt;
* spec/factories/topics.rb: [https://github.com/Grochocinski/expertiza-E2480/pull/8 Pull Request #8] &lt;br /&gt;
&lt;br /&gt;
== Tests == &lt;br /&gt;
&lt;br /&gt;
Originally, tests were run using RSpec, but these created 13/13 Bookmarks controller tests failed. These tests were removed, and remade.&lt;br /&gt;
&lt;br /&gt;
Swagger UI is a set of tools that is used by the Expertiza developers to run RSpec tests through an interface instead of the command line. Swagger was originally needed in order to view and run tests, because the RSpec tests for this project need to be fixed. However, since RSpec tests have been recreated, the use of Swagger will not be required to run tests, but only check for code smells and coverage.&lt;br /&gt;
&lt;br /&gt;
=== Running RSpec tests via Swagger ===&lt;br /&gt;
&lt;br /&gt;
Steps&lt;br /&gt;
* Build the containers&lt;br /&gt;
* Go to http://localhost:3002/api-docs&lt;br /&gt;
* Login via the Authentication block at the bottom (U: &amp;quot;admin&amp;quot;, P: &amp;quot;password123&amp;quot;)&lt;br /&gt;
* Copy the token in the response&lt;br /&gt;
* Scroll up to the top and click &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* In the popup, paste in the token and hit &amp;quot;Authorize&amp;quot;&lt;br /&gt;
* Navigate to the test you want to run, edit the parameters, and run it&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Failing Tests ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Recommended next steps ==&lt;br /&gt;
&lt;br /&gt;
* There are methods in the authorization_helper.rb that check to see if a TA or Instructor can access an assignment, that have some code smells such as bad method names.&lt;br /&gt;
* The questionnaire (which is used to rate the bookmark) needs the functionality of identifying a user type. Possibly create a mixin to implement this.&lt;/div&gt;</summary>
		<author><name>Sdaniel8</name></author>
	</entry>
</feed>