<?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=Kpallav</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=Kpallav"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Kpallav"/>
	<updated>2026-08-23T17:03:04Z</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_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=161040</id>
		<title>CSC/ECE 517 Fall 2024 - E2474. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=161040"/>
		<updated>2024-12-12T04:06:44Z</updated>

		<summary type="html">&lt;p&gt;Kpallav: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is about E2474 Phase 2 for Expertiza.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a [http://rubyonrails.org/ Ruby on Rails] based open source project. The Expertiza project is software for creating reusable learning objects through peer review. It also supports team projects and the submission of almost any document type, including URLs and wiki pages. The goal is to foster team collaboration through projects and provide a robust way to give feedback for these projects.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
For this project, we are expected to reimplement the student_quizzes_controller.rb file in the reimplementation-backend repository of Expertiza. This controller handles scoring, creating, and recording responses for quizzes that are done by students or reviewers for an assignment. The main issue with the previous implementation is that it violates several Rails design principles such as DRY violations. Along with this, various other issues that need to be addressed include code repetition, unclear method comments, and ambiguous variable names. The overall idea of this project is to ensure that we maintain the previous functionality while adhering to the best design practices.&lt;br /&gt;
&lt;br /&gt;
=== Specific Issues ===&lt;br /&gt;
* &amp;lt;strong&amp;gt;Single-Responsibility Principle&amp;lt;/strong&amp;gt; - Various functionalities are done in the student_quizzes_controller.rb that should be deferred to other models or controllers.&lt;br /&gt;
* &amp;lt;strong&amp;gt;DRY Violations&amp;lt;/strong&amp;gt; - There is a good amount of code repetition in the code that could be consolidated to a method.&lt;br /&gt;
* &amp;lt;strong&amp;gt;Unclear Method and Variable Names&amp;lt;/strong&amp;gt; - There are ambiguous methods names and variable names that should be changed. We can also add method comments to help explain functionality.&lt;br /&gt;
&lt;br /&gt;
== Design Plan ==&lt;br /&gt;
=== Single-Responsibility Principle ===&lt;br /&gt;
==== calculate_score ====&lt;br /&gt;
This method gets a response map and then gets the score from that response map. We can instead ask the ResponseMap model to get this information.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;strong&amp;gt;Solution:&amp;lt;/strong&amp;gt; Instead of response_map.score, we create a get_score method in ResponseMap model.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474 calculate score.png|600px]]&lt;br /&gt;
&lt;br /&gt;
==== process_answers ====&lt;br /&gt;
This method attempts to edit the submitted_answer field in ResponseMap. This should be done by ResponseMap model instead of our controller.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;strong&amp;gt;Solution:&amp;lt;/strong&amp;gt; We will fully move the process_answers method into the ResponseMap model.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474 process answer.png|600px]]&lt;br /&gt;
&lt;br /&gt;
==== check_instructor_role ====&lt;br /&gt;
The goal of this method is to get the role ID of the user to make sure they are an instructor. We want to let the Role model check this instead of checking it in the controller.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;strong&amp;gt;Solution:&amp;lt;/strong&amp;gt; Instead of &amp;quot;current_user.role_id == 2&amp;quot;, we will make use of the instructor? method in Role to check if the current user is an instructor.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474 check instructor role.png|600px]]&lt;br /&gt;
&lt;br /&gt;
==== Other methods ====&lt;br /&gt;
* Several methods could be moved into the model classes in adherence to MVC architecture. This includes build_response_map, etc.&lt;br /&gt;
&lt;br /&gt;
=== DRY Violations ===&lt;br /&gt;
==== find_resource_by_id ====&lt;br /&gt;
This is a method that is frequently called in this controller. We plan to separate this functionality into a concern or a shared utility function.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;strong&amp;gt;Solution:&amp;lt;/strong&amp;gt; We will move this method into a separate concern that is included in this controller. This can be used in other controllers as well.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474_renaming_variables.png|600px]]&lt;br /&gt;
&lt;br /&gt;
=== New Skippable Feature ===&lt;br /&gt;
We plan to add a new field for questions that allows the instructor to decide whether a question is required or skippable. This can be extended outside of quizzes.&lt;br /&gt;
&lt;br /&gt;
=== Renaming Method and Variable Names ===&lt;br /&gt;
* Rename the methods for assign_quiz_to_student and submit_answer to clarify their purpose. We can also add method comments to help with this.&lt;br /&gt;
* Refactor variable names to better reflect their purpose. The image below shows that model is not the best name along with find_resource_by_id&lt;br /&gt;
[[File:E2474_renaming_variables.png|600px]]&lt;br /&gt;
&lt;br /&gt;
== Main Methods to Create or Enhance ==&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; !! Method !! Purpose !! Description !! Commit&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
| &amp;lt;code&amp;gt; calculate_score &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; process_answers &amp;lt;/code&amp;gt;&lt;br /&gt;
| Ensure MVC compliance and adherence to the Single-Responsibility Principle&lt;br /&gt;
| Move both &amp;lt;code&amp;gt;calculate_score&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;process_answers&amp;lt;/code&amp;gt; to the &amp;lt;code&amp;gt;ResponseMap&amp;lt;/code&amp;gt; model, allowing the controller to focus only on handling requests and delegating logic to models.&lt;br /&gt;
|''' calculate_score Commit: [https://github.com/neerua08/reimplementation-back-end/commit/c1dd8c817d842df0817bde8fa408d760fb0a6fdd Link]&lt;br /&gt;
&amp;lt;strong&amp;gt;process_answers Commit: [https://github.com/neerua08/reimplementation-back-end/commit/dacecb623bbfa8cfff89a3c6deaa8affd8eaf0f5 Link]&amp;lt;/strong&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
| &amp;lt;code&amp;gt; find_resource_by_id &amp;lt;/code&amp;gt;&lt;br /&gt;
| Reduce DRY violations&lt;br /&gt;
| Implement this as a shared utility function to eliminate duplicate code and streamline resource retrieval in the controller.&lt;br /&gt;
| ''' Commit: ''' [https://github.com/neerua08/reimplementation-back-end/commit/0dc53dd139caa7d18d380c98d51578d98911ef3b Link]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
| &amp;lt;code&amp;gt; check_instructor_role &amp;lt;/code&amp;gt;&lt;br /&gt;
| Improve code readability&lt;br /&gt;
| Move the &amp;lt;code&amp;gt;check_instructor_role&amp;lt;/code&amp;gt; method to the &amp;lt;code&amp;gt;Role&amp;lt;/code&amp;gt; model, ensuring that role-related logic resides within the model rather than the controller.&lt;br /&gt;
| ''' Commit: ''' [https://github.com/neerua08/reimplementation-back-end/commit/55d860747ff08506aea134e182d98119eadc58e9 Link]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
| &amp;lt;code&amp;gt; build_response_map &amp;lt;/code&amp;gt;&lt;br /&gt;
| Improve modularity&lt;br /&gt;
| Transfer these methods from the controller to appropriate model classes, which aligns with the MVC pattern and keeps controller methods concise.&lt;br /&gt;
| ''' Commit: ''' [https://github.com/neerua08/reimplementation-back-end/commit/9b3c0342c6a407766e38ea2cb860434cbf10efcd Link]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
| &amp;lt;code&amp;gt; assign_quiz_to_student &amp;lt;/code&amp;gt;&lt;br /&gt;
| Improve code readability&lt;br /&gt;
| Rename these methods to more descriptive names and add comments to explain functionality, making the codebase easier to understand and maintain.&lt;br /&gt;
| ''' Commit: ''' [https://github.com/neerua08/reimplementation-back-end/commit/865857ea2dcc0eb73d87cff87e1610bf8ba6d142 Link]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== Files Added or Changed ===&lt;br /&gt;
* Added student_quizzes_controller.rb&lt;br /&gt;
* Changed ResponseMap.rb&lt;br /&gt;
* Added resource_finder.rb&lt;br /&gt;
* Changed question.rb and questionnaire.rb&lt;br /&gt;
&lt;br /&gt;
=== Changes Made ===&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 Description !! Old !! New&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
| Initially, we calculate_score directly called the score variable in the controller. We decided to implement a get score to adhere to SRP. We also implemented a new calculate_score as the old version did not implement a method that calculates anything.&lt;br /&gt;
| [[File:E2474 calculate score.png|600px]]&lt;br /&gt;
| [[File:E2474_calculate_score_new.png|600px]]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
| We moved all of process_answer into ResponseMap to adhere with SRP.&lt;br /&gt;
| [[File:E2474 process answer.png|600px]]&lt;br /&gt;
| [[File:E2474 process answer new.png|600px]]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
| find_resource_by_id was called frequently in this controller, so we moved this into a separate concern which is called in this controller. The file for this is resource_finder.rb.&lt;br /&gt;
| [[File:E2474_renaming_variables.png|600px]]&lt;br /&gt;
| [[File:E2474 find resource by id new.png|600px]]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
| check_instructor_role used to check the role ID number, which violates SRP. We decided to use the instructor? method for role to determine if the current user is an instructor.&lt;br /&gt;
| [[File:E2474 check instructor role.png|600px]]&lt;br /&gt;
| [[File:E2474 check instructor role new.png|600px]]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
| Added some new functionality to make questions skippable or not skippable in questionnaires. This includes changes in the database schema to add this new field.&lt;br /&gt;
| No old code.&lt;br /&gt;
| [[File:E2474 skippable.png|600px]]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
| Clearer method names and method comments were added in this controller. One example is assign_quiz_to_student, which is shown in the images.&lt;br /&gt;
| [[File:E2474 assign quiz old.png|300px]]&lt;br /&gt;
| [[File:E2474 assign quiz new.png|300px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
As we are reimplementing this file from scratch, we plan to do some manual testing to verify our code. If time permits, we can add some automated tests. Currently, we plan to use a variety of tools to test our code including:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Postman&amp;lt;/strong&amp;gt; - Test our API calls for the controller to ensure their functionality. The main purpose is to validate the behavior of the controller. This can be done by testing all relevant CRUD operations for quiz creation, submission, and scoring, verifying that the controller responds with appropriate status codes, ensure that all input validations are working as expected including edge cases, and validate that the controller adheres to any role-based access restrictions. Examples of what we have done are shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;POST /api/v1/students_quizzes: Endpoint to login as the instructor&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Postman.png|500px]]&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;POST /api/v1/students_quizzes: Endpoint to create a quiz&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:cQuiz.png|500px]]&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;POST /api/v1/students_quizzes/assign: Endpoint to assign quiz to participant&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:AssignQuiz.png|500px]]&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;POST /api/v1/students_quizzes/submit_quiz: Endpoint to submit answers&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:sAnswers.png|500px]]&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;GET /api/v1/students_quizzes/7/get_score: Endpoint to get score and for this test use 7 as our response id&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:GetScore.png|500px]]&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;PUT /api/v1/students_quizzes/9: Endpoint to update quiz&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:UQuiz.png|500px]]&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;DEL /api/v1/students_quizzes/3: Endpoint to delete a quiz&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:DQuiz.png|500px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Automated RSpec Tests&amp;lt;/strong&amp;gt; - Test the various methods in our controller to determine if they are functioning as expected. The main purpose is to verify the internal logic of the controller and related methods ensuring they are functioning as expected. This can be done by creating unit tests for methods within the controller especially methods that will be refactored or moved to the model, creating model tests for if any logic is moved to the models to verify that the new functionality works correctly, and create controller tests to ensure that the controller actions work as expected like assigning quizzes to students, submitting answers and recording results, and calculating scores correctly.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Test Coverage&amp;lt;/strong&amp;gt; - Using SimpleCov to ensure sufficient test coverage of all key methods and code paths, preventing any untested code from being deployed. We can do this by integrating SimpleCov to measure code coverage across the entire application, create coverage goals and aim for like a high code coverage (e.g., 90% or higher) to ensure all key methods in the controller and related models are thoroughly tested, monitor coverage reports to identify any untested methods or areas of the codebase and add tests for those areas as needed, and refactor based on coverage so if we see significant gaps in test coverage, we can refactor the tests or implementation to ensure better coverage.&lt;br /&gt;
&lt;br /&gt;
We don't plan on adding new scenarios but instead we plan on retesting scenarios: creating a new student quiz, handling invalid student quiz creation, calculating quiz score, assigning quiz to student, submitting quiz answers, and updating a student quiz to see if those scenarios still work when we reimplement student_quizzes_controller.rb as a whole. We might add multiple scenarios as we go.&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
* More methods can be moved into other models to respect MVC including quiz_already_assigned?, find_response_map_for_current_user, etc.&lt;br /&gt;
* Some method names can be further improved.&lt;br /&gt;
* Some frontend changes may need to be added to include the new skippable feature added.&lt;br /&gt;
* More testing can be added to test new features that have been added thoroughly.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
# Akhilesh Neeruganti (asneerug@ncsu.edu)&lt;br /&gt;
# Krishna Pallavalli (kpallav@ncsu.edu)&lt;br /&gt;
# Aarya Rajoju (arajoju@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Mentor: Richard Li (rli14@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links == &lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2420._Reimplement_student_quizzes_controller This wiki page] contains detailed information on the previous team's work on this feature.&lt;br /&gt;
* '''Github Repository:''' https://github.com/neerua08/reimplementation-back-end&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/141&lt;br /&gt;
* '''Demo Video Link:''' https://youtu.be/hi_4GVLCpdY&lt;/div&gt;</summary>
		<author><name>Kpallav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:DQuiz.png&amp;diff=161039</id>
		<title>File:DQuiz.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:DQuiz.png&amp;diff=161039"/>
		<updated>2024-12-12T04:06:04Z</updated>

		<summary type="html">&lt;p&gt;Kpallav: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Kpallav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:UQuiz.png&amp;diff=161038</id>
		<title>File:UQuiz.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:UQuiz.png&amp;diff=161038"/>
		<updated>2024-12-12T04:05:16Z</updated>

		<summary type="html">&lt;p&gt;Kpallav: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Kpallav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:GetScore.png&amp;diff=161037</id>
		<title>File:GetScore.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:GetScore.png&amp;diff=161037"/>
		<updated>2024-12-12T04:04:05Z</updated>

		<summary type="html">&lt;p&gt;Kpallav: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Kpallav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:SAnswers.png&amp;diff=161036</id>
		<title>File:SAnswers.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:SAnswers.png&amp;diff=161036"/>
		<updated>2024-12-12T04:03:35Z</updated>

		<summary type="html">&lt;p&gt;Kpallav: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Kpallav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:AssignQuiz.png&amp;diff=161035</id>
		<title>File:AssignQuiz.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:AssignQuiz.png&amp;diff=161035"/>
		<updated>2024-12-12T04:02:36Z</updated>

		<summary type="html">&lt;p&gt;Kpallav: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Kpallav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=161034</id>
		<title>CSC/ECE 517 Fall 2024 - E2474. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=161034"/>
		<updated>2024-12-12T04:01:54Z</updated>

		<summary type="html">&lt;p&gt;Kpallav: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is about E2474 Phase 2 for Expertiza.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a [http://rubyonrails.org/ Ruby on Rails] based open source project. The Expertiza project is software for creating reusable learning objects through peer review. It also supports team projects and the submission of almost any document type, including URLs and wiki pages. The goal is to foster team collaboration through projects and provide a robust way to give feedback for these projects.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
For this project, we are expected to reimplement the student_quizzes_controller.rb file in the reimplementation-backend repository of Expertiza. This controller handles scoring, creating, and recording responses for quizzes that are done by students or reviewers for an assignment. The main issue with the previous implementation is that it violates several Rails design principles such as DRY violations. Along with this, various other issues that need to be addressed include code repetition, unclear method comments, and ambiguous variable names. The overall idea of this project is to ensure that we maintain the previous functionality while adhering to the best design practices.&lt;br /&gt;
&lt;br /&gt;
=== Specific Issues ===&lt;br /&gt;
* &amp;lt;strong&amp;gt;Single-Responsibility Principle&amp;lt;/strong&amp;gt; - Various functionalities are done in the student_quizzes_controller.rb that should be deferred to other models or controllers.&lt;br /&gt;
* &amp;lt;strong&amp;gt;DRY Violations&amp;lt;/strong&amp;gt; - There is a good amount of code repetition in the code that could be consolidated to a method.&lt;br /&gt;
* &amp;lt;strong&amp;gt;Unclear Method and Variable Names&amp;lt;/strong&amp;gt; - There are ambiguous methods names and variable names that should be changed. We can also add method comments to help explain functionality.&lt;br /&gt;
&lt;br /&gt;
== Design Plan ==&lt;br /&gt;
=== Single-Responsibility Principle ===&lt;br /&gt;
==== calculate_score ====&lt;br /&gt;
This method gets a response map and then gets the score from that response map. We can instead ask the ResponseMap model to get this information.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;strong&amp;gt;Solution:&amp;lt;/strong&amp;gt; Instead of response_map.score, we create a get_score method in ResponseMap model.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474 calculate score.png|600px]]&lt;br /&gt;
&lt;br /&gt;
==== process_answers ====&lt;br /&gt;
This method attempts to edit the submitted_answer field in ResponseMap. This should be done by ResponseMap model instead of our controller.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;strong&amp;gt;Solution:&amp;lt;/strong&amp;gt; We will fully move the process_answers method into the ResponseMap model.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474 process answer.png|600px]]&lt;br /&gt;
&lt;br /&gt;
==== check_instructor_role ====&lt;br /&gt;
The goal of this method is to get the role ID of the user to make sure they are an instructor. We want to let the Role model check this instead of checking it in the controller.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;strong&amp;gt;Solution:&amp;lt;/strong&amp;gt; Instead of &amp;quot;current_user.role_id == 2&amp;quot;, we will make use of the instructor? method in Role to check if the current user is an instructor.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474 check instructor role.png|600px]]&lt;br /&gt;
&lt;br /&gt;
==== Other methods ====&lt;br /&gt;
* Several methods could be moved into the model classes in adherence to MVC architecture. This includes build_response_map, etc.&lt;br /&gt;
&lt;br /&gt;
=== DRY Violations ===&lt;br /&gt;
==== find_resource_by_id ====&lt;br /&gt;
This is a method that is frequently called in this controller. We plan to separate this functionality into a concern or a shared utility function.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;strong&amp;gt;Solution:&amp;lt;/strong&amp;gt; We will move this method into a separate concern that is included in this controller. This can be used in other controllers as well.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474_renaming_variables.png|600px]]&lt;br /&gt;
&lt;br /&gt;
=== New Skippable Feature ===&lt;br /&gt;
We plan to add a new field for questions that allows the instructor to decide whether a question is required or skippable. This can be extended outside of quizzes.&lt;br /&gt;
&lt;br /&gt;
=== Renaming Method and Variable Names ===&lt;br /&gt;
* Rename the methods for assign_quiz_to_student and submit_answer to clarify their purpose. We can also add method comments to help with this.&lt;br /&gt;
* Refactor variable names to better reflect their purpose. The image below shows that model is not the best name along with find_resource_by_id&lt;br /&gt;
[[File:E2474_renaming_variables.png|600px]]&lt;br /&gt;
&lt;br /&gt;
== Main Methods to Create or Enhance ==&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; !! Method !! Purpose !! Description !! Commit&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
| &amp;lt;code&amp;gt; calculate_score &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; process_answers &amp;lt;/code&amp;gt;&lt;br /&gt;
| Ensure MVC compliance and adherence to the Single-Responsibility Principle&lt;br /&gt;
| Move both &amp;lt;code&amp;gt;calculate_score&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;process_answers&amp;lt;/code&amp;gt; to the &amp;lt;code&amp;gt;ResponseMap&amp;lt;/code&amp;gt; model, allowing the controller to focus only on handling requests and delegating logic to models.&lt;br /&gt;
|''' calculate_score Commit: [https://github.com/neerua08/reimplementation-back-end/commit/c1dd8c817d842df0817bde8fa408d760fb0a6fdd Link]&lt;br /&gt;
&amp;lt;strong&amp;gt;process_answers Commit: [https://github.com/neerua08/reimplementation-back-end/commit/dacecb623bbfa8cfff89a3c6deaa8affd8eaf0f5 Link]&amp;lt;/strong&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
| &amp;lt;code&amp;gt; find_resource_by_id &amp;lt;/code&amp;gt;&lt;br /&gt;
| Reduce DRY violations&lt;br /&gt;
| Implement this as a shared utility function to eliminate duplicate code and streamline resource retrieval in the controller.&lt;br /&gt;
| ''' Commit: ''' [https://github.com/neerua08/reimplementation-back-end/commit/0dc53dd139caa7d18d380c98d51578d98911ef3b Link]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
| &amp;lt;code&amp;gt; check_instructor_role &amp;lt;/code&amp;gt;&lt;br /&gt;
| Improve code readability&lt;br /&gt;
| Move the &amp;lt;code&amp;gt;check_instructor_role&amp;lt;/code&amp;gt; method to the &amp;lt;code&amp;gt;Role&amp;lt;/code&amp;gt; model, ensuring that role-related logic resides within the model rather than the controller.&lt;br /&gt;
| ''' Commit: ''' [https://github.com/neerua08/reimplementation-back-end/commit/55d860747ff08506aea134e182d98119eadc58e9 Link]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
| &amp;lt;code&amp;gt; build_response_map &amp;lt;/code&amp;gt;&lt;br /&gt;
| Improve modularity&lt;br /&gt;
| Transfer these methods from the controller to appropriate model classes, which aligns with the MVC pattern and keeps controller methods concise.&lt;br /&gt;
| ''' Commit: ''' [https://github.com/neerua08/reimplementation-back-end/commit/9b3c0342c6a407766e38ea2cb860434cbf10efcd Link]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
| &amp;lt;code&amp;gt; assign_quiz_to_student &amp;lt;/code&amp;gt;&lt;br /&gt;
| Improve code readability&lt;br /&gt;
| Rename these methods to more descriptive names and add comments to explain functionality, making the codebase easier to understand and maintain.&lt;br /&gt;
| ''' Commit: ''' [https://github.com/neerua08/reimplementation-back-end/commit/865857ea2dcc0eb73d87cff87e1610bf8ba6d142 Link]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== Files Added or Changed ===&lt;br /&gt;
* Added student_quizzes_controller.rb&lt;br /&gt;
* Changed ResponseMap.rb&lt;br /&gt;
* Added resource_finder.rb&lt;br /&gt;
* Changed question.rb and questionnaire.rb&lt;br /&gt;
&lt;br /&gt;
=== Changes Made ===&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 Description !! Old !! New&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
| Initially, we calculate_score directly called the score variable in the controller. We decided to implement a get score to adhere to SRP. We also implemented a new calculate_score as the old version did not implement a method that calculates anything.&lt;br /&gt;
| [[File:E2474 calculate score.png|600px]]&lt;br /&gt;
| [[File:E2474_calculate_score_new.png|600px]]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
| We moved all of process_answer into ResponseMap to adhere with SRP.&lt;br /&gt;
| [[File:E2474 process answer.png|600px]]&lt;br /&gt;
| [[File:E2474 process answer new.png|600px]]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
| find_resource_by_id was called frequently in this controller, so we moved this into a separate concern which is called in this controller. The file for this is resource_finder.rb.&lt;br /&gt;
| [[File:E2474_renaming_variables.png|600px]]&lt;br /&gt;
| [[File:E2474 find resource by id new.png|600px]]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
| check_instructor_role used to check the role ID number, which violates SRP. We decided to use the instructor? method for role to determine if the current user is an instructor.&lt;br /&gt;
| [[File:E2474 check instructor role.png|600px]]&lt;br /&gt;
| [[File:E2474 check instructor role new.png|600px]]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
| Added some new functionality to make questions skippable or not skippable in questionnaires. This includes changes in the database schema to add this new field.&lt;br /&gt;
| No old code.&lt;br /&gt;
| [[File:E2474 skippable.png|600px]]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
| Clearer method names and method comments were added in this controller. One example is assign_quiz_to_student, which is shown in the images.&lt;br /&gt;
| [[File:E2474 assign quiz old.png|300px]]&lt;br /&gt;
| [[File:E2474 assign quiz new.png|300px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
As we are reimplementing this file from scratch, we plan to do some manual testing to verify our code. If time permits, we can add some automated tests. Currently, we plan to use a variety of tools to test our code including:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Postman&amp;lt;/strong&amp;gt; - Test our API calls for the controller to ensure their functionality. The main purpose is to validate the behavior of the controller. This can be done by testing all relevant CRUD operations for quiz creation, submission, and scoring, verifying that the controller responds with appropriate status codes, ensure that all input validations are working as expected including edge cases, and validate that the controller adheres to any role-based access restrictions. Examples of what we have done are shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;POST /api/v1/students_quizzes: Endpoint to login as the instructor&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Postman.png|500px]]&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;POST /api/v1/students_quizzes: Endpoint to create a quiz&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:cQuiz.png|500px]]&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;POST /api/v1/students_quizzes/assign: Endpoint to assign quiz to participant&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
image&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;POST /api/v1/students_quizzes/submit_quiz: Endpoint to submit answers&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
image&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;GET /api/v1/students_quizzes/7/get_score: Endpoint to get score and for this test use 7 as our response id&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
image&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;PUT /api/v1/students_quizzes/9: Endpoint to update quiz&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
image&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;DEL /api/v1/students_quizzes/3: Endpoint to delete a quiz&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
image&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Automated RSpec Tests&amp;lt;/strong&amp;gt; - Test the various methods in our controller to determine if they are functioning as expected. The main purpose is to verify the internal logic of the controller and related methods ensuring they are functioning as expected. This can be done by creating unit tests for methods within the controller especially methods that will be refactored or moved to the model, creating model tests for if any logic is moved to the models to verify that the new functionality works correctly, and create controller tests to ensure that the controller actions work as expected like assigning quizzes to students, submitting answers and recording results, and calculating scores correctly.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Test Coverage&amp;lt;/strong&amp;gt; - Using SimpleCov to ensure sufficient test coverage of all key methods and code paths, preventing any untested code from being deployed. We can do this by integrating SimpleCov to measure code coverage across the entire application, create coverage goals and aim for like a high code coverage (e.g., 90% or higher) to ensure all key methods in the controller and related models are thoroughly tested, monitor coverage reports to identify any untested methods or areas of the codebase and add tests for those areas as needed, and refactor based on coverage so if we see significant gaps in test coverage, we can refactor the tests or implementation to ensure better coverage.&lt;br /&gt;
&lt;br /&gt;
We don't plan on adding new scenarios but instead we plan on retesting scenarios: creating a new student quiz, handling invalid student quiz creation, calculating quiz score, assigning quiz to student, submitting quiz answers, and updating a student quiz to see if those scenarios still work when we reimplement student_quizzes_controller.rb as a whole. We might add multiple scenarios as we go.&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
* More methods can be moved into other models to respect MVC including quiz_already_assigned?, find_response_map_for_current_user, etc.&lt;br /&gt;
* Some method names can be further improved.&lt;br /&gt;
* Some frontend changes may need to be added to include the new skippable feature added.&lt;br /&gt;
* More testing can be added to test new features that have been added thoroughly.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
# Akhilesh Neeruganti (asneerug@ncsu.edu)&lt;br /&gt;
# Krishna Pallavalli (kpallav@ncsu.edu)&lt;br /&gt;
# Aarya Rajoju (arajoju@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Mentor: Richard Li (rli14@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links == &lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2420._Reimplement_student_quizzes_controller This wiki page] contains detailed information on the previous team's work on this feature.&lt;br /&gt;
* '''Github Repository:''' https://github.com/neerua08/reimplementation-back-end&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/141&lt;br /&gt;
* '''Demo Video Link:''' https://youtu.be/hi_4GVLCpdY&lt;/div&gt;</summary>
		<author><name>Kpallav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:CQuiz.png&amp;diff=161033</id>
		<title>File:CQuiz.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:CQuiz.png&amp;diff=161033"/>
		<updated>2024-12-12T04:00:41Z</updated>

		<summary type="html">&lt;p&gt;Kpallav: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Kpallav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:CreateQuiz.png&amp;diff=161032</id>
		<title>File:CreateQuiz.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:CreateQuiz.png&amp;diff=161032"/>
		<updated>2024-12-12T03:28:51Z</updated>

		<summary type="html">&lt;p&gt;Kpallav: Kpallav uploaded a new version of File:CreateQuiz.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Kpallav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=161031</id>
		<title>CSC/ECE 517 Fall 2024 - E2474. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=161031"/>
		<updated>2024-12-12T03:28:04Z</updated>

		<summary type="html">&lt;p&gt;Kpallav: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is about E2474 Phase 2 for Expertiza.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a [http://rubyonrails.org/ Ruby on Rails] based open source project. The Expertiza project is software for creating reusable learning objects through peer review. It also supports team projects and the submission of almost any document type, including URLs and wiki pages. The goal is to foster team collaboration through projects and provide a robust way to give feedback for these projects.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
For this project, we are expected to reimplement the student_quizzes_controller.rb file in the reimplementation-backend repository of Expertiza. This controller handles scoring, creating, and recording responses for quizzes that are done by students or reviewers for an assignment. The main issue with the previous implementation is that it violates several Rails design principles such as DRY violations. Along with this, various other issues that need to be addressed include code repetition, unclear method comments, and ambiguous variable names. The overall idea of this project is to ensure that we maintain the previous functionality while adhering to the best design practices.&lt;br /&gt;
&lt;br /&gt;
=== Specific Issues ===&lt;br /&gt;
* &amp;lt;strong&amp;gt;Single-Responsibility Principle&amp;lt;/strong&amp;gt; - Various functionalities are done in the student_quizzes_controller.rb that should be deferred to other models or controllers.&lt;br /&gt;
* &amp;lt;strong&amp;gt;DRY Violations&amp;lt;/strong&amp;gt; - There is a good amount of code repetition in the code that could be consolidated to a method.&lt;br /&gt;
* &amp;lt;strong&amp;gt;Unclear Method and Variable Names&amp;lt;/strong&amp;gt; - There are ambiguous methods names and variable names that should be changed. We can also add method comments to help explain functionality.&lt;br /&gt;
&lt;br /&gt;
== Design Plan ==&lt;br /&gt;
=== Single-Responsibility Principle ===&lt;br /&gt;
==== calculate_score ====&lt;br /&gt;
This method gets a response map and then gets the score from that response map. We can instead ask the ResponseMap model to get this information.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;strong&amp;gt;Solution:&amp;lt;/strong&amp;gt; Instead of response_map.score, we create a get_score method in ResponseMap model.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474 calculate score.png|600px]]&lt;br /&gt;
&lt;br /&gt;
==== process_answers ====&lt;br /&gt;
This method attempts to edit the submitted_answer field in ResponseMap. This should be done by ResponseMap model instead of our controller.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;strong&amp;gt;Solution:&amp;lt;/strong&amp;gt; We will fully move the process_answers method into the ResponseMap model.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474 process answer.png|600px]]&lt;br /&gt;
&lt;br /&gt;
==== check_instructor_role ====&lt;br /&gt;
The goal of this method is to get the role ID of the user to make sure they are an instructor. We want to let the Role model check this instead of checking it in the controller.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;strong&amp;gt;Solution:&amp;lt;/strong&amp;gt; Instead of &amp;quot;current_user.role_id == 2&amp;quot;, we will make use of the instructor? method in Role to check if the current user is an instructor.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474 check instructor role.png|600px]]&lt;br /&gt;
&lt;br /&gt;
==== Other methods ====&lt;br /&gt;
* Several methods could be moved into the model classes in adherence to MVC architecture. This includes build_response_map, etc.&lt;br /&gt;
&lt;br /&gt;
=== DRY Violations ===&lt;br /&gt;
==== find_resource_by_id ====&lt;br /&gt;
This is a method that is frequently called in this controller. We plan to separate this functionality into a concern or a shared utility function.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;strong&amp;gt;Solution:&amp;lt;/strong&amp;gt; We will move this method into a separate concern that is included in this controller. This can be used in other controllers as well.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474_renaming_variables.png|600px]]&lt;br /&gt;
&lt;br /&gt;
=== New Skippable Feature ===&lt;br /&gt;
We plan to add a new field for questions that allows the instructor to decide whether a question is required or skippable. This can be extended outside of quizzes.&lt;br /&gt;
&lt;br /&gt;
=== Renaming Method and Variable Names ===&lt;br /&gt;
* Rename the methods for assign_quiz_to_student and submit_answer to clarify their purpose. We can also add method comments to help with this.&lt;br /&gt;
* Refactor variable names to better reflect their purpose. The image below shows that model is not the best name along with find_resource_by_id&lt;br /&gt;
[[File:E2474_renaming_variables.png|600px]]&lt;br /&gt;
&lt;br /&gt;
== Main Methods to Create or Enhance ==&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; !! Method !! Purpose !! Description !! Commit&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
| &amp;lt;code&amp;gt; calculate_score &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; process_answers &amp;lt;/code&amp;gt;&lt;br /&gt;
| Ensure MVC compliance and adherence to the Single-Responsibility Principle&lt;br /&gt;
| Move both &amp;lt;code&amp;gt;calculate_score&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;process_answers&amp;lt;/code&amp;gt; to the &amp;lt;code&amp;gt;ResponseMap&amp;lt;/code&amp;gt; model, allowing the controller to focus only on handling requests and delegating logic to models.&lt;br /&gt;
|''' calculate_score Commit: [https://github.com/neerua08/reimplementation-back-end/commit/c1dd8c817d842df0817bde8fa408d760fb0a6fdd Link]&lt;br /&gt;
&amp;lt;strong&amp;gt;process_answers Commit: [https://github.com/neerua08/reimplementation-back-end/commit/dacecb623bbfa8cfff89a3c6deaa8affd8eaf0f5 Link]&amp;lt;/strong&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
| &amp;lt;code&amp;gt; find_resource_by_id &amp;lt;/code&amp;gt;&lt;br /&gt;
| Reduce DRY violations&lt;br /&gt;
| Implement this as a shared utility function to eliminate duplicate code and streamline resource retrieval in the controller.&lt;br /&gt;
| ''' Commit: ''' [https://github.com/neerua08/reimplementation-back-end/commit/0dc53dd139caa7d18d380c98d51578d98911ef3b Link]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
| &amp;lt;code&amp;gt; check_instructor_role &amp;lt;/code&amp;gt;&lt;br /&gt;
| Improve code readability&lt;br /&gt;
| Move the &amp;lt;code&amp;gt;check_instructor_role&amp;lt;/code&amp;gt; method to the &amp;lt;code&amp;gt;Role&amp;lt;/code&amp;gt; model, ensuring that role-related logic resides within the model rather than the controller.&lt;br /&gt;
| ''' Commit: ''' [https://github.com/neerua08/reimplementation-back-end/commit/55d860747ff08506aea134e182d98119eadc58e9 Link]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
| &amp;lt;code&amp;gt; build_response_map &amp;lt;/code&amp;gt;&lt;br /&gt;
| Improve modularity&lt;br /&gt;
| Transfer these methods from the controller to appropriate model classes, which aligns with the MVC pattern and keeps controller methods concise.&lt;br /&gt;
| ''' Commit: ''' [https://github.com/neerua08/reimplementation-back-end/commit/9b3c0342c6a407766e38ea2cb860434cbf10efcd Link]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
| &amp;lt;code&amp;gt; assign_quiz_to_student &amp;lt;/code&amp;gt;&lt;br /&gt;
| Improve code readability&lt;br /&gt;
| Rename these methods to more descriptive names and add comments to explain functionality, making the codebase easier to understand and maintain.&lt;br /&gt;
| ''' Commit: ''' [https://github.com/neerua08/reimplementation-back-end/commit/865857ea2dcc0eb73d87cff87e1610bf8ba6d142 Link]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== Files Added or Changed ===&lt;br /&gt;
* Added student_quizzes_controller.rb&lt;br /&gt;
* Changed ResponseMap.rb&lt;br /&gt;
* Added resource_finder.rb&lt;br /&gt;
* Changed question.rb and questionnaire.rb&lt;br /&gt;
&lt;br /&gt;
=== Changes Made ===&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 Description !! Old !! New&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
| Initially, we calculate_score directly called the score variable in the controller. We decided to implement a get score to adhere to SRP. We also implemented a new calculate_score as the old version did not implement a method that calculates anything.&lt;br /&gt;
| [[File:E2474 calculate score.png|600px]]&lt;br /&gt;
| [[File:E2474_calculate_score_new.png|600px]]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
| We moved all of process_answer into ResponseMap to adhere with SRP.&lt;br /&gt;
| [[File:E2474 process answer.png|600px]]&lt;br /&gt;
| [[File:E2474 process answer new.png|600px]]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
| find_resource_by_id was called frequently in this controller, so we moved this into a separate concern which is called in this controller. The file for this is resource_finder.rb.&lt;br /&gt;
| [[File:E2474_renaming_variables.png|600px]]&lt;br /&gt;
| [[File:E2474 find resource by id new.png|600px]]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
| check_instructor_role used to check the role ID number, which violates SRP. We decided to use the instructor? method for role to determine if the current user is an instructor.&lt;br /&gt;
| [[File:E2474 check instructor role.png|600px]]&lt;br /&gt;
| [[File:E2474 check instructor role new.png|600px]]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
| Added some new functionality to make questions skippable or not skippable in questionnaires. This includes changes in the database schema to add this new field.&lt;br /&gt;
| No old code.&lt;br /&gt;
| [[File:E2474 skippable.png|600px]]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
| Clearer method names and method comments were added in this controller. One example is assign_quiz_to_student, which is shown in the images.&lt;br /&gt;
| [[File:E2474 assign quiz old.png|300px]]&lt;br /&gt;
| [[File:E2474 assign quiz new.png|300px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
As we are reimplementing this file from scratch, we plan to do some manual testing to verify our code. If time permits, we can add some automated tests. Currently, we plan to use a variety of tools to test our code including:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Postman&amp;lt;/strong&amp;gt; - Test our API calls for the controller to ensure their functionality. The main purpose is to validate the behavior of the controller. This can be done by testing all relevant CRUD operations for quiz creation, submission, and scoring, verifying that the controller responds with appropriate status codes, ensure that all input validations are working as expected including edge cases, and validate that the controller adheres to any role-based access restrictions. Examples of what we have done are shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;POST /api/v1/students_quizzes: Endpoint to login as the instructor&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Postman.png|500px]]&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;POST /api/v1/students_quizzes: Endpoint to create a quiz&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
image&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;POST /api/v1/students_quizzes/assign: Endpoint to assign quiz to participant&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
image&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;POST /api/v1/students_quizzes/submit_quiz: Endpoint to submit answers&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
image&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;GET /api/v1/students_quizzes/7/get_score: Endpoint to get score and for this test use 7 as our response id&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
image&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;PUT /api/v1/students_quizzes/9: Endpoint to update quiz&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
image&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;DEL /api/v1/students_quizzes/3: Endpoint to delete a quiz&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
image&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Automated RSpec Tests&amp;lt;/strong&amp;gt; - Test the various methods in our controller to determine if they are functioning as expected. The main purpose is to verify the internal logic of the controller and related methods ensuring they are functioning as expected. This can be done by creating unit tests for methods within the controller especially methods that will be refactored or moved to the model, creating model tests for if any logic is moved to the models to verify that the new functionality works correctly, and create controller tests to ensure that the controller actions work as expected like assigning quizzes to students, submitting answers and recording results, and calculating scores correctly.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Test Coverage&amp;lt;/strong&amp;gt; - Using SimpleCov to ensure sufficient test coverage of all key methods and code paths, preventing any untested code from being deployed. We can do this by integrating SimpleCov to measure code coverage across the entire application, create coverage goals and aim for like a high code coverage (e.g., 90% or higher) to ensure all key methods in the controller and related models are thoroughly tested, monitor coverage reports to identify any untested methods or areas of the codebase and add tests for those areas as needed, and refactor based on coverage so if we see significant gaps in test coverage, we can refactor the tests or implementation to ensure better coverage.&lt;br /&gt;
&lt;br /&gt;
We don't plan on adding new scenarios but instead we plan on retesting scenarios: creating a new student quiz, handling invalid student quiz creation, calculating quiz score, assigning quiz to student, submitting quiz answers, and updating a student quiz to see if those scenarios still work when we reimplement student_quizzes_controller.rb as a whole. We might add multiple scenarios as we go.&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
* More methods can be moved into other models to respect MVC including quiz_already_assigned?, find_response_map_for_current_user, etc.&lt;br /&gt;
* Some method names can be further improved.&lt;br /&gt;
* Some frontend changes may need to be added to include the new skippable feature added.&lt;br /&gt;
* More testing can be added to test new features that have been added thoroughly.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
# Akhilesh Neeruganti (asneerug@ncsu.edu)&lt;br /&gt;
# Krishna Pallavalli (kpallav@ncsu.edu)&lt;br /&gt;
# Aarya Rajoju (arajoju@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Mentor: Richard Li (rli14@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links == &lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2420._Reimplement_student_quizzes_controller This wiki page] contains detailed information on the previous team's work on this feature.&lt;br /&gt;
* '''Github Repository:''' https://github.com/neerua08/reimplementation-back-end&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/141&lt;br /&gt;
* '''Demo Video Link:''' https://youtu.be/hi_4GVLCpdY&lt;/div&gt;</summary>
		<author><name>Kpallav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=161030</id>
		<title>CSC/ECE 517 Fall 2024 - E2474. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=161030"/>
		<updated>2024-12-12T03:14:33Z</updated>

		<summary type="html">&lt;p&gt;Kpallav: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is about E2474 Phase 2 for Expertiza.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a [http://rubyonrails.org/ Ruby on Rails] based open source project. The Expertiza project is software for creating reusable learning objects through peer review. It also supports team projects and the submission of almost any document type, including URLs and wiki pages. The goal is to foster team collaboration through projects and provide a robust way to give feedback for these projects.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
For this project, we are expected to reimplement the student_quizzes_controller.rb file in the reimplementation-backend repository of Expertiza. This controller handles scoring, creating, and recording responses for quizzes that are done by students or reviewers for an assignment. The main issue with the previous implementation is that it violates several Rails design principles such as DRY violations. Along with this, various other issues that need to be addressed include code repetition, unclear method comments, and ambiguous variable names. The overall idea of this project is to ensure that we maintain the previous functionality while adhering to the best design practices.&lt;br /&gt;
&lt;br /&gt;
=== Specific Issues ===&lt;br /&gt;
* &amp;lt;strong&amp;gt;Single-Responsibility Principle&amp;lt;/strong&amp;gt; - Various functionalities are done in the student_quizzes_controller.rb that should be deferred to other models or controllers.&lt;br /&gt;
* &amp;lt;strong&amp;gt;DRY Violations&amp;lt;/strong&amp;gt; - There is a good amount of code repetition in the code that could be consolidated to a method.&lt;br /&gt;
* &amp;lt;strong&amp;gt;Unclear Method and Variable Names&amp;lt;/strong&amp;gt; - There are ambiguous methods names and variable names that should be changed. We can also add method comments to help explain functionality.&lt;br /&gt;
&lt;br /&gt;
== Design Plan ==&lt;br /&gt;
=== Single-Responsibility Principle ===&lt;br /&gt;
==== calculate_score ====&lt;br /&gt;
This method gets a response map and then gets the score from that response map. We can instead ask the ResponseMap model to get this information.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;strong&amp;gt;Solution:&amp;lt;/strong&amp;gt; Instead of response_map.score, we create a get_score method in ResponseMap model.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474 calculate score.png|600px]]&lt;br /&gt;
&lt;br /&gt;
==== process_answers ====&lt;br /&gt;
This method attempts to edit the submitted_answer field in ResponseMap. This should be done by ResponseMap model instead of our controller.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;strong&amp;gt;Solution:&amp;lt;/strong&amp;gt; We will fully move the process_answers method into the ResponseMap model.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474 process answer.png|600px]]&lt;br /&gt;
&lt;br /&gt;
==== check_instructor_role ====&lt;br /&gt;
The goal of this method is to get the role ID of the user to make sure they are an instructor. We want to let the Role model check this instead of checking it in the controller.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;strong&amp;gt;Solution:&amp;lt;/strong&amp;gt; Instead of &amp;quot;current_user.role_id == 2&amp;quot;, we will make use of the instructor? method in Role to check if the current user is an instructor.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474 check instructor role.png|600px]]&lt;br /&gt;
&lt;br /&gt;
==== Other methods ====&lt;br /&gt;
* Several methods could be moved into the model classes in adherence to MVC architecture. This includes build_response_map, etc.&lt;br /&gt;
&lt;br /&gt;
=== DRY Violations ===&lt;br /&gt;
==== find_resource_by_id ====&lt;br /&gt;
This is a method that is frequently called in this controller. We plan to separate this functionality into a concern or a shared utility function.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;strong&amp;gt;Solution:&amp;lt;/strong&amp;gt; We will move this method into a separate concern that is included in this controller. This can be used in other controllers as well.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474_renaming_variables.png|600px]]&lt;br /&gt;
&lt;br /&gt;
=== New Skippable Feature ===&lt;br /&gt;
We plan to add a new field for questions that allows the instructor to decide whether a question is required or skippable. This can be extended outside of quizzes.&lt;br /&gt;
&lt;br /&gt;
=== Renaming Method and Variable Names ===&lt;br /&gt;
* Rename the methods for assign_quiz_to_student and submit_answer to clarify their purpose. We can also add method comments to help with this.&lt;br /&gt;
* Refactor variable names to better reflect their purpose. The image below shows that model is not the best name along with find_resource_by_id&lt;br /&gt;
[[File:E2474_renaming_variables.png|600px]]&lt;br /&gt;
&lt;br /&gt;
== Main Methods to Create or Enhance ==&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; !! Method !! Purpose !! Description !! Commit&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
| &amp;lt;code&amp;gt; calculate_score &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; process_answers &amp;lt;/code&amp;gt;&lt;br /&gt;
| Ensure MVC compliance and adherence to the Single-Responsibility Principle&lt;br /&gt;
| Move both &amp;lt;code&amp;gt;calculate_score&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;process_answers&amp;lt;/code&amp;gt; to the &amp;lt;code&amp;gt;ResponseMap&amp;lt;/code&amp;gt; model, allowing the controller to focus only on handling requests and delegating logic to models.&lt;br /&gt;
|''' calculate_score Commit: [https://github.com/neerua08/reimplementation-back-end/commit/c1dd8c817d842df0817bde8fa408d760fb0a6fdd Link]&lt;br /&gt;
&amp;lt;strong&amp;gt;process_answers Commit: [https://github.com/neerua08/reimplementation-back-end/commit/dacecb623bbfa8cfff89a3c6deaa8affd8eaf0f5 Link]&amp;lt;/strong&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
| &amp;lt;code&amp;gt; find_resource_by_id &amp;lt;/code&amp;gt;&lt;br /&gt;
| Reduce DRY violations&lt;br /&gt;
| Implement this as a shared utility function to eliminate duplicate code and streamline resource retrieval in the controller.&lt;br /&gt;
| ''' Commit: ''' [https://github.com/neerua08/reimplementation-back-end/commit/0dc53dd139caa7d18d380c98d51578d98911ef3b Link]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
| &amp;lt;code&amp;gt; check_instructor_role &amp;lt;/code&amp;gt;&lt;br /&gt;
| Improve code readability&lt;br /&gt;
| Move the &amp;lt;code&amp;gt;check_instructor_role&amp;lt;/code&amp;gt; method to the &amp;lt;code&amp;gt;Role&amp;lt;/code&amp;gt; model, ensuring that role-related logic resides within the model rather than the controller.&lt;br /&gt;
| ''' Commit: ''' [https://github.com/neerua08/reimplementation-back-end/commit/55d860747ff08506aea134e182d98119eadc58e9 Link]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
| &amp;lt;code&amp;gt; build_response_map &amp;lt;/code&amp;gt;&lt;br /&gt;
| Improve modularity&lt;br /&gt;
| Transfer these methods from the controller to appropriate model classes, which aligns with the MVC pattern and keeps controller methods concise.&lt;br /&gt;
| ''' Commit: ''' [https://github.com/neerua08/reimplementation-back-end/commit/9b3c0342c6a407766e38ea2cb860434cbf10efcd Link]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
| &amp;lt;code&amp;gt; assign_quiz_to_student &amp;lt;/code&amp;gt;&lt;br /&gt;
| Improve code readability&lt;br /&gt;
| Rename these methods to more descriptive names and add comments to explain functionality, making the codebase easier to understand and maintain.&lt;br /&gt;
| ''' Commit: ''' [https://github.com/neerua08/reimplementation-back-end/commit/865857ea2dcc0eb73d87cff87e1610bf8ba6d142 Link]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== Files Added or Changed ===&lt;br /&gt;
* Added student_quizzes_controller.rb&lt;br /&gt;
* Changed ResponseMap.rb&lt;br /&gt;
* Added resource_finder.rb&lt;br /&gt;
* Changed question.rb and questionnaire.rb&lt;br /&gt;
&lt;br /&gt;
=== Changes Made ===&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 Description !! Old !! New&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
| Initially, we calculate_score directly called the score variable in the controller. We decided to implement a get score to adhere to SRP. We also implemented a new calculate_score as the old version did not implement a method that calculates anything.&lt;br /&gt;
| [[File:E2474 calculate score.png|600px]]&lt;br /&gt;
| [[File:E2474_calculate_score_new.png|600px]]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
| We moved all of process_answer into ResponseMap to adhere with SRP.&lt;br /&gt;
| [[File:E2474 process answer.png|600px]]&lt;br /&gt;
| [[File:E2474 process answer new.png|600px]]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
| find_resource_by_id was called frequently in this controller, so we moved this into a separate concern which is called in this controller. The file for this is resource_finder.rb.&lt;br /&gt;
| [[File:E2474_renaming_variables.png|600px]]&lt;br /&gt;
| [[File:E2474 find resource by id new.png|600px]]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
| check_instructor_role used to check the role ID number, which violates SRP. We decided to use the instructor? method for role to determine if the current user is an instructor.&lt;br /&gt;
| [[File:E2474 check instructor role.png|600px]]&lt;br /&gt;
| [[File:E2474 check instructor role new.png|600px]]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
| Added some new functionality to make questions skippable or not skippable in questionnaires. This includes changes in the database schema to add this new field.&lt;br /&gt;
| No old code.&lt;br /&gt;
| [[File:E2474 skippable.png|600px]]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
| Clearer method names and method comments were added in this controller. One example is assign_quiz_to_student, which is shown in the images.&lt;br /&gt;
| [[File:E2474 assign quiz old.png|300px]]&lt;br /&gt;
| [[File:E2474 assign quiz new.png|300px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
As we are reimplementing this file from scratch, we plan to do some manual testing to verify our code. If time permits, we can add some automated tests. Currently, we plan to use a variety of tools to test our code including:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Postman&amp;lt;/strong&amp;gt; - Test our API calls for the controller to ensure their functionality. The main purpose is to validate the behavior of the controller. This can be done by testing all relevant CRUD operations for quiz creation, submission, and scoring, verifying that the controller responds with appropriate status codes, ensure that all input validations are working as expected including edge cases, and validate that the controller adheres to any role-based access restrictions. Examples of what we have done are shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;b&amp;gt;POST /api/v1/students_quizzes: Endpoint to login as the instructor&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Postman.png|500px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Automated RSpec Tests&amp;lt;/strong&amp;gt; - Test the various methods in our controller to determine if they are functioning as expected. The main purpose is to verify the internal logic of the controller and related methods ensuring they are functioning as expected. This can be done by creating unit tests for methods within the controller especially methods that will be refactored or moved to the model, creating model tests for if any logic is moved to the models to verify that the new functionality works correctly, and create controller tests to ensure that the controller actions work as expected like assigning quizzes to students, submitting answers and recording results, and calculating scores correctly.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Test Coverage&amp;lt;/strong&amp;gt; - Using SimpleCov to ensure sufficient test coverage of all key methods and code paths, preventing any untested code from being deployed. We can do this by integrating SimpleCov to measure code coverage across the entire application, create coverage goals and aim for like a high code coverage (e.g., 90% or higher) to ensure all key methods in the controller and related models are thoroughly tested, monitor coverage reports to identify any untested methods or areas of the codebase and add tests for those areas as needed, and refactor based on coverage so if we see significant gaps in test coverage, we can refactor the tests or implementation to ensure better coverage.&lt;br /&gt;
&lt;br /&gt;
We don't plan on adding new scenarios but instead we plan on retesting scenarios: creating a new student quiz, handling invalid student quiz creation, calculating quiz score, assigning quiz to student, submitting quiz answers, and updating a student quiz to see if those scenarios still work when we reimplement student_quizzes_controller.rb as a whole. We might add multiple scenarios as we go.&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
* More methods can be moved into other models to respect MVC including quiz_already_assigned?, find_response_map_for_current_user, etc.&lt;br /&gt;
* Some method names can be further improved.&lt;br /&gt;
* Some frontend changes may need to be added to include the new skippable feature added.&lt;br /&gt;
* More testing can be added to test new features that have been added thoroughly.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
# Akhilesh Neeruganti (asneerug@ncsu.edu)&lt;br /&gt;
# Krishna Pallavalli (kpallav@ncsu.edu)&lt;br /&gt;
# Aarya Rajoju (arajoju@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Mentor: Richard Li (rli14@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links == &lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2420._Reimplement_student_quizzes_controller This wiki page] contains detailed information on the previous team's work on this feature.&lt;br /&gt;
* '''Github Repository:''' https://github.com/neerua08/reimplementation-back-end&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/141&lt;br /&gt;
* '''Demo Video Link:''' https://youtu.be/hi_4GVLCpdY&lt;/div&gt;</summary>
		<author><name>Kpallav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Postman.png&amp;diff=161029</id>
		<title>File:Postman.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Postman.png&amp;diff=161029"/>
		<updated>2024-12-12T03:10:10Z</updated>

		<summary type="html">&lt;p&gt;Kpallav: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Kpallav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=161028</id>
		<title>CSC/ECE 517 Fall 2024 - E2474. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=161028"/>
		<updated>2024-12-12T02:56:59Z</updated>

		<summary type="html">&lt;p&gt;Kpallav: /* Main Methods to Create or Enhance */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is about E2474 Phase 2 for Expertiza.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a [http://rubyonrails.org/ Ruby on Rails] based open source project. The Expertiza project is software for creating reusable learning objects through peer review. It also supports team projects and the submission of almost any document type, including URLs and wiki pages. The goal is to foster team collaboration through projects and provide a robust way to give feedback for these projects.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
For this project, we are expected to reimplement the student_quizzes_controller.rb file in the reimplementation-backend repository of Expertiza. This controller handles scoring, creating, and recording responses for quizzes that are done by students or reviewers for an assignment. The main issue with the previous implementation is that it violates several Rails design principles such as DRY violations. Along with this, various other issues that need to be addressed include code repetition, unclear method comments, and ambiguous variable names. The overall idea of this project is to ensure that we maintain the previous functionality while adhering to the best design practices.&lt;br /&gt;
&lt;br /&gt;
=== Specific Issues ===&lt;br /&gt;
* &amp;lt;strong&amp;gt;Single-Responsibility Principle&amp;lt;/strong&amp;gt; - Various functionalities are done in the student_quizzes_controller.rb that should be deferred to other models or controllers.&lt;br /&gt;
* &amp;lt;strong&amp;gt;DRY Violations&amp;lt;/strong&amp;gt; - There is a good amount of code repetition in the code that could be consolidated to a method.&lt;br /&gt;
* &amp;lt;strong&amp;gt;Unclear Method and Variable Names&amp;lt;/strong&amp;gt; - There are ambiguous methods names and variable names that should be changed. We can also add method comments to help explain functionality.&lt;br /&gt;
&lt;br /&gt;
== Design Plan ==&lt;br /&gt;
=== Single-Responsibility Principle ===&lt;br /&gt;
==== calculate_score ====&lt;br /&gt;
This method gets a response map and then gets the score from that response map. We can instead ask the ResponseMap model to get this information.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;strong&amp;gt;Solution:&amp;lt;/strong&amp;gt; Instead of response_map.score, we create a get_score method in ResponseMap model.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474 calculate score.png|600px]]&lt;br /&gt;
&lt;br /&gt;
==== process_answers ====&lt;br /&gt;
This method attempts to edit the submitted_answer field in ResponseMap. This should be done by ResponseMap model instead of our controller.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;strong&amp;gt;Solution:&amp;lt;/strong&amp;gt; We will fully move the process_answers method into the ResponseMap model.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474 process answer.png|600px]]&lt;br /&gt;
&lt;br /&gt;
==== check_instructor_role ====&lt;br /&gt;
The goal of this method is to get the role ID of the user to make sure they are an instructor. We want to let the Role model check this instead of checking it in the controller.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;strong&amp;gt;Solution:&amp;lt;/strong&amp;gt; Instead of &amp;quot;current_user.role_id == 2&amp;quot;, we will make use of the instructor? method in Role to check if the current user is an instructor.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474 check instructor role.png|600px]]&lt;br /&gt;
&lt;br /&gt;
==== Other methods ====&lt;br /&gt;
* Several methods could be moved into the model classes in adherence to MVC architecture. This includes build_response_map, etc.&lt;br /&gt;
&lt;br /&gt;
=== DRY Violations ===&lt;br /&gt;
==== find_resource_by_id ====&lt;br /&gt;
This is a method that is frequently called in this controller. We plan to separate this functionality into a concern or a shared utility function.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;strong&amp;gt;Solution:&amp;lt;/strong&amp;gt; We will move this method into a separate concern that is included in this controller. This can be used in other controllers as well.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474_renaming_variables.png|600px]]&lt;br /&gt;
&lt;br /&gt;
=== New Skippable Feature ===&lt;br /&gt;
We plan to add a new field for questions that allows the instructor to decide whether a question is required or skippable. This can be extended outside of quizzes.&lt;br /&gt;
&lt;br /&gt;
=== Renaming Method and Variable Names ===&lt;br /&gt;
* Rename the methods for assign_quiz_to_student and submit_answer to clarify their purpose. We can also add method comments to help with this.&lt;br /&gt;
* Refactor variable names to better reflect their purpose. The image below shows that model is not the best name along with find_resource_by_id&lt;br /&gt;
[[File:E2474_renaming_variables.png|600px]]&lt;br /&gt;
&lt;br /&gt;
== Main Methods to Create or Enhance ==&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; !! Method !! Purpose !! Description !! Commit&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
| &amp;lt;code&amp;gt; calculate_score &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; process_answers &amp;lt;/code&amp;gt;&lt;br /&gt;
| Ensure MVC compliance and adherence to the Single-Responsibility Principle&lt;br /&gt;
| Move both &amp;lt;code&amp;gt;calculate_score&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;process_answers&amp;lt;/code&amp;gt; to the &amp;lt;code&amp;gt;ResponseMap&amp;lt;/code&amp;gt; model, allowing the controller to focus only on handling requests and delegating logic to models.&lt;br /&gt;
|''' calculate_score Commit: [https://github.com/neerua08/reimplementation-back-end/commit/c1dd8c817d842df0817bde8fa408d760fb0a6fdd Link]&lt;br /&gt;
&amp;lt;strong&amp;gt;process_answers Commit: [https://github.com/neerua08/reimplementation-back-end/commit/dacecb623bbfa8cfff89a3c6deaa8affd8eaf0f5 Link]&amp;lt;/strong&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
| &amp;lt;code&amp;gt; find_resource_by_id &amp;lt;/code&amp;gt;&lt;br /&gt;
| Reduce DRY violations&lt;br /&gt;
| Implement this as a shared utility function to eliminate duplicate code and streamline resource retrieval in the controller.&lt;br /&gt;
| ''' Commit: ''' [https://github.com/neerua08/reimplementation-back-end/commit/0dc53dd139caa7d18d380c98d51578d98911ef3b Link]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
| &amp;lt;code&amp;gt; check_instructor_role &amp;lt;/code&amp;gt;&lt;br /&gt;
| Improve code readability&lt;br /&gt;
| Move the &amp;lt;code&amp;gt;check_instructor_role&amp;lt;/code&amp;gt; method to the &amp;lt;code&amp;gt;Role&amp;lt;/code&amp;gt; model, ensuring that role-related logic resides within the model rather than the controller.&lt;br /&gt;
| ''' Commit: ''' [https://github.com/neerua08/reimplementation-back-end/commit/55d860747ff08506aea134e182d98119eadc58e9 Link]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
| &amp;lt;code&amp;gt; build_response_map &amp;lt;/code&amp;gt;&lt;br /&gt;
| Improve modularity&lt;br /&gt;
| Transfer these methods from the controller to appropriate model classes, which aligns with the MVC pattern and keeps controller methods concise.&lt;br /&gt;
| ''' Commit: ''' [https://github.com/neerua08/reimplementation-back-end/commit/9b3c0342c6a407766e38ea2cb860434cbf10efcd Link]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
| &amp;lt;code&amp;gt; assign_quiz_to_student &amp;lt;/code&amp;gt;&lt;br /&gt;
| Improve code readability&lt;br /&gt;
| Rename these methods to more descriptive names and add comments to explain functionality, making the codebase easier to understand and maintain.&lt;br /&gt;
| ''' Commit: ''' [https://github.com/neerua08/reimplementation-back-end/commit/865857ea2dcc0eb73d87cff87e1610bf8ba6d142 Link]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
=== Files Added or Changed ===&lt;br /&gt;
* Added student_quizzes_controller.rb&lt;br /&gt;
* Changed ResponseMap.rb&lt;br /&gt;
* Added resource_finder.rb&lt;br /&gt;
* Changed question.rb and questionnaire.rb&lt;br /&gt;
&lt;br /&gt;
=== Changes Made ===&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 Description !! Old !! New&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
| Initially, we calculate_score directly called the score variable in the controller. We decided to implement a get score to adhere to SRP. We also implemented a new calculate_score as the old version did not implement a method that calculates anything.&lt;br /&gt;
| [[File:E2474 calculate score.png|600px]]&lt;br /&gt;
| [[File:E2474_calculate_score_new.png|600px]]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
| We moved all of process_answer into ResponseMap to adhere with SRP.&lt;br /&gt;
| [[File:E2474 process answer.png|600px]]&lt;br /&gt;
| [[File:E2474 process answer new.png|600px]]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
| find_resource_by_id was called frequently in this controller, so we moved this into a separate concern which is called in this controller. The file for this is resource_finder.rb.&lt;br /&gt;
| [[File:E2474_renaming_variables.png|600px]]&lt;br /&gt;
| [[File:E2474 find resource by id new.png|600px]]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
| check_instructor_role used to check the role ID number, which violates SRP. We decided to use the instructor? method for role to determine if the current user is an instructor.&lt;br /&gt;
| [[File:E2474 check instructor role.png|600px]]&lt;br /&gt;
| [[File:E2474 check instructor role new.png|600px]]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
| Added some new functionality to make questions skippable or not skippable in questionnaires. This includes changes in the database schema to add this new field.&lt;br /&gt;
| No old code.&lt;br /&gt;
| [[File:E2474 skippable.png|600px]]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
| Clearer method names and method comments were added in this controller. One example is assign_quiz_to_student, which is shown in the images.&lt;br /&gt;
| [[File:E2474 assign quiz old.png|300px]]&lt;br /&gt;
| [[File:E2474 assign quiz new.png|300px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
As we are reimplementing this file from scratch, we plan to do some manual testing to verify our code. If time permits, we can add some automated tests. Currently, we plan to use a variety of tools to test our code including:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Postman&amp;lt;/strong&amp;gt; - Test our API calls for the controller to ensure their functionality. The main purpose is to validate the behavior of the controller. This can be done by testing all relevant CRUD operations for quiz creation, submission, and scoring, verifying that the controller responds with appropriate status codes, ensure that all input validations are working as expected including edge cases, and validate that the controller adheres to any role-based access restrictions.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Automated RSpec Tests&amp;lt;/strong&amp;gt; - Test the various methods in our controller to determine if they are functioning as expected. The main purpose is to verify the internal logic of the controller and related methods ensuring they are functioning as expected. This can be done by creating unit tests for methods within the controller especially methods that will be refactored or moved to the model, creating model tests for if any logic is moved to the models to verify that the new functionality works correctly, and create controller tests to ensure that the controller actions work as expected like assigning quizzes to students, submitting answers and recording results, and calculating scores correctly.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Test Coverage&amp;lt;/strong&amp;gt; - Using SimpleCov to ensure sufficient test coverage of all key methods and code paths, preventing any untested code from being deployed. We can do this by integrating SimpleCov to measure code coverage across the entire application, create coverage goals and aim for like a high code coverage (e.g., 90% or higher) to ensure all key methods in the controller and related models are thoroughly tested, monitor coverage reports to identify any untested methods or areas of the codebase and add tests for those areas as needed, and refactor based on coverage so if we see significant gaps in test coverage, we can refactor the tests or implementation to ensure better coverage.&lt;br /&gt;
&lt;br /&gt;
We don't plan on adding new scenarios but instead we plan on retesting scenarios: creating a new student quiz, handling invalid student quiz creation, calculating quiz score, assigning quiz to student, submitting quiz answers, and updating a student quiz to see if those scenarios still work when we reimplement student_quizzes_controller.rb as a whole. We might add multiple scenarios as we go.&lt;br /&gt;
&lt;br /&gt;
== Future Work ==&lt;br /&gt;
* More methods can be moved into other models to respect MVC including quiz_already_assigned?, find_response_map_for_current_user, etc.&lt;br /&gt;
* Some method names can be further improved.&lt;br /&gt;
* Some frontend changes may need to be added to include the new skippable feature added.&lt;br /&gt;
* More testing can be added to test new features that have been added thoroughly.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
# Akhilesh Neeruganti (asneerug@ncsu.edu)&lt;br /&gt;
# Krishna Pallavalli (kpallav@ncsu.edu)&lt;br /&gt;
# Aarya Rajoju (arajoju@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Mentor: Richard Li (rli14@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links == &lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2420._Reimplement_student_quizzes_controller This wiki page] contains detailed information on the previous team's work on this feature.&lt;br /&gt;
* '''Github Repository:''' https://github.com/neerua08/reimplementation-back-end&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/141&lt;br /&gt;
* '''Demo Video Link:''' https://youtu.be/hi_4GVLCpdY&lt;/div&gt;</summary>
		<author><name>Kpallav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=160990</id>
		<title>CSC/ECE 517 Fall 2024 - E2474. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=160990"/>
		<updated>2024-12-11T05:19:32Z</updated>

		<summary type="html">&lt;p&gt;Kpallav: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is about E2474 Phase 2 for Expertiza.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a [http://rubyonrails.org/ Ruby on Rails] based open source project. The Expertiza project is software for creating reusable learning objects through peer review. It also supports team projects and the submission of almost any document type, including URLs and wiki pages. The goal is to foster team collaboration through projects and provide a robust way to give feedback for these projects.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
For this project, we are expected to reimplement the student_quizzes_controller.rb file in the reimplementation-backend repository of Expertiza. This controller handles scoring, creating, and recording responses for quizzes that are done by students or reviewers for an assignment. The main issue with the previous implementation is that it violates several Rails design principles such as DRY violations. Along with this, various other issues that need to be addressed include code repetition, unclear method comments, and ambiguous variable names. The overall idea of this project is to ensure that we maintain the previous functionality while adhering to the best design practices.&lt;br /&gt;
&lt;br /&gt;
=== Specific Issues ===&lt;br /&gt;
* &amp;lt;strong&amp;gt;Single-Responsibility Principle&amp;lt;/strong&amp;gt; - Various functionalities are done in the student_quizzes_controller.rb that should be deferred to other models or controllers.&lt;br /&gt;
* &amp;lt;strong&amp;gt;DRY Violations&amp;lt;/strong&amp;gt; - There is a good amount of code repetition in the code that could be consolidated to a method.&lt;br /&gt;
* &amp;lt;strong&amp;gt;Unclear Method and Variable Names&amp;lt;/strong&amp;gt; - There are ambiguous methods names and variable names that should be changed. We can also add method comments to help explain functionality.&lt;br /&gt;
&lt;br /&gt;
== Design Plan ==&lt;br /&gt;
=== Single-Responsibility Principle ===&lt;br /&gt;
==== calculate_score ====&lt;br /&gt;
This method gets a response map and then gets the score from that response map. We can instead ask the ResponseMap model to get this information.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474 calculate score.png|600px]]&lt;br /&gt;
==== process_answers ====&lt;br /&gt;
This method attempts to edit the submitted_answer field in response map. This should be done by ResponseMap model instead of our controller. &lt;br /&gt;
&lt;br /&gt;
[[File:E2474 process answer.png|600px]]&lt;br /&gt;
==== check_instructor_role ====&lt;br /&gt;
The goal of this method is to get the role ID of the user to make sure they are an instructor. We want to let the Role model check this instead of checking it in the controller.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474 check instructor role.png|600px]]&lt;br /&gt;
==== Other methods ====&lt;br /&gt;
* Several methods could be moved into the model classes in adherence to MVC architecture. This includes build_response_map, etc.&lt;br /&gt;
&lt;br /&gt;
=== DRY Violations ===&lt;br /&gt;
==== find_resource_by_id ====&lt;br /&gt;
This is a method that is frequently called in this controller. We plan to separate this functionality into a concern or a shared utility function.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474_renaming_variables.png|600px]]&lt;br /&gt;
&lt;br /&gt;
=== Renaming Method and Variable Names ===&lt;br /&gt;
* Rename the methods for assign_quiz_to_student and submit_answer to clarify their purpose. We can also add method comments to help with this.&lt;br /&gt;
* Refactor variable names to better reflect their purpose. The image below shows that model is not the best name along with find_resource_by_id&lt;br /&gt;
[[File:E2474_renaming_variables.png|600px]]&lt;br /&gt;
&lt;br /&gt;
== Main Methods to Create or Enhance ==&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; !! Method !! Purpose !! Description !! Commit&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
| &amp;lt;code&amp;gt; calculate_score &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; process_answers &amp;lt;/code&amp;gt;&lt;br /&gt;
| Ensure MVC compliance and adherence to the Single-Responsibility Principle&lt;br /&gt;
| Move both &amp;lt;code&amp;gt;calculate_score&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;process_answers&amp;lt;/code&amp;gt; to the &amp;lt;code&amp;gt;ResponseMap&amp;lt;/code&amp;gt; model, allowing the controller to focus only on handling requests and delegating logic to models.&lt;br /&gt;
|''' calculate_score Commit: https://github.com/neerua08/reimplementation-back-end/commit/c1dd8c817d842df0817bde8fa408d760fb0a6fdd &lt;br /&gt;
 ''' process_answers Commit: https://github.com/neerua08/reimplementation-back-end/commit/dacecb623bbfa8cfff89a3c6deaa8affd8eaf0f5&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
| &amp;lt;code&amp;gt; find_resource_by_id &amp;lt;/code&amp;gt;&lt;br /&gt;
| Reduce DRY violations&lt;br /&gt;
| Implement this as a shared utility function to eliminate duplicate code and streamline resource retrieval in the controller.&lt;br /&gt;
| ''' Commit: ''' https://github.com/neerua08/reimplementation-back-end/commit/0dc53dd139caa7d18d380c98d51578d98911ef3b&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
| &amp;lt;code&amp;gt; check_instructor_role &amp;lt;/code&amp;gt;&lt;br /&gt;
| Improve code readability&lt;br /&gt;
| Move the &amp;lt;code&amp;gt;check_instructor_role&amp;lt;/code&amp;gt; method to the &amp;lt;code&amp;gt;Role&amp;lt;/code&amp;gt; model, ensuring that role-related logic resides within the model rather than the controller.&lt;br /&gt;
| ''' Commit: ''' https://github.com/neerua08/reimplementation-back-end/commit/55d860747ff08506aea134e182d98119eadc58e9&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
| &amp;lt;code&amp;gt; build_response_map &amp;lt;/code&amp;gt;&lt;br /&gt;
| Improve modularity&lt;br /&gt;
| Transfer these methods from the controller to appropriate model classes, which aligns with the MVC pattern and keeps controller methods concise.&lt;br /&gt;
| ''' Commit: ''' https://github.com/neerua08/reimplementation-back-end/commit/9b3c0342c6a407766e38ea2cb860434cbf10efcd&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
| &amp;lt;code&amp;gt; assign_quiz_to_student &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; submit_answer &amp;lt;/code&amp;gt;&lt;br /&gt;
| Improve code readability&lt;br /&gt;
| Rename these methods to more descriptive names and add comments to explain functionality, making the codebase easier to understand and maintain.&lt;br /&gt;
| ''' Commit: ''' https://github.com/neerua08/reimplementation-back-end/commit/865857ea2dcc0eb73d87cff87e1610bf8ba6d142&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
Student quizzes Controller contains APIs which allows the instructor to create a new quiz and perform other CRUD operations on quiz. It allows the students to submit answers to the quizzes and check their scores. Our implementation plan includes reimplementing existing methods and adding new methods. Student quizzes Controller does now adhere to best practices while ensuring that existing functionalities remain unchanged.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
As we are reimplementing this file from scratch, we plan to do some manual testing to verify our code. If time permits, we can add some automated tests. Currently, we plan to use a variety of tools to test our code including:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Postman&amp;lt;/strong&amp;gt; - Test our API calls for the controller to ensure their functionality. The main purpose is to validate the behavior of the controller. This can be done by testing all relevant CRUD operations for quiz creation, submission, and scoring, verifying that the controller responds with appropriate status codes, ensure that all input validations are working as expected including edge cases, and validate that the controller adheres to any role-based access restrictions.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Automated RSpec Tests&amp;lt;/strong&amp;gt; - Test the various methods in our controller to determine if they are functioning as expected. The main purpose is to verify the internal logic of the controller and related methods ensuring they are functioning as expected. This can be done by creating unit tests for methods within the controller especially methods that will be refactored or moved to the model, creating model tests for if any logic is moved to the models to verify that the new functionality works correctly, and create controller tests to ensure that the controller actions work as expected like assigning quizzes to students, submitting answers and recording results, and calculating scores correctly.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Black Box Testing&amp;lt;/strong&amp;gt; - Running through the application to determine if any errors or inconsistent functionalities occur. The main purpose is to ensure the overall functionality of the system from the perspective of an end user.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Test Coverage&amp;lt;/strong&amp;gt; - Using SimpleCov to ensure sufficient test coverage of all key methods and code paths, preventing any untested code from being deployed. We can do this by integrating SimpleCov to measure code coverage across the entire application, create coverage goals and aim for like a high code coverage (e.g., 90% or higher) to ensure all key methods in the controller and related models are thoroughly tested, monitor coverage reports to identify any untested methods or areas of the codebase and add tests for those areas as needed, and refactor based on coverage so if we see significant gaps in test coverage, we can refactor the tests or implementation to ensure better coverage.&lt;br /&gt;
&lt;br /&gt;
We don't plan on adding new scenarios but instead we plan on retesting scenarios: creating a new student quiz, handling invalid student quiz creation, calculating quiz score, assigning quiz to student, submitting quiz answers, and updating a student quiz to see if those scenarios still work when we reimplement student_quizzes_controller.rb as a whole. We might add multiple scenarios as we go.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
# Akhilesh Neeruganti (asneerug@ncsu.edu)&lt;br /&gt;
# Krishna Pallavalli (kpallav@ncsu.edu)&lt;br /&gt;
# Aarya Rajoju (arajoju@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Mentor: Richard Li (rli14@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links == &lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2420._Reimplement_student_quizzes_controller This wiki page] contains detailed information on the previous team's work on this feature.&lt;br /&gt;
* '''Github Repository:''' https://github.com/neerua08/reimplementation-back-end&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/141&lt;br /&gt;
* '''Demo Video Link:''' https://youtu.be/hi_4GVLCpdY&lt;/div&gt;</summary>
		<author><name>Kpallav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=160988</id>
		<title>CSC/ECE 517 Fall 2024 - E2474. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=160988"/>
		<updated>2024-12-11T05:17:03Z</updated>

		<summary type="html">&lt;p&gt;Kpallav: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is about E2474 Phase 2 for Expertiza.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a [http://rubyonrails.org/ Ruby on Rails] based open source project. The Expertiza project is software for creating reusable learning objects through peer review. It also supports team projects and the submission of almost any document type, including URLs and wiki pages. The goal is to foster team collaboration through projects and provide a robust way to give feedback for these projects.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
For this project, we are expected to reimplement the student_quizzes_controller.rb file in the reimplementation-backend repository of Expertiza. This controller handles scoring, creating, and recording responses for quizzes that are done by students or reviewers for an assignment. The main issue with the previous implementation is that it violates several Rails design principles such as DRY violations. Along with this, various other issues that need to be addressed include code repetition, unclear method comments, and ambiguous variable names. The overall idea of this project is to ensure that we maintain the previous functionality while adhering to the best design practices.&lt;br /&gt;
&lt;br /&gt;
=== Specific Issues ===&lt;br /&gt;
* &amp;lt;strong&amp;gt;Single-Responsibility Principle&amp;lt;/strong&amp;gt; - Various functionalities are done in the student_quizzes_controller.rb that should be deferred to other models or controllers.&lt;br /&gt;
* &amp;lt;strong&amp;gt;DRY Violations&amp;lt;/strong&amp;gt; - There is a good amount of code repetition in the code that could be consolidated to a method.&lt;br /&gt;
* &amp;lt;strong&amp;gt;Unclear Method and Variable Names&amp;lt;/strong&amp;gt; - There are ambiguous methods names and variable names that should be changed. We can also add method comments to help explain functionality.&lt;br /&gt;
&lt;br /&gt;
== Design Plan ==&lt;br /&gt;
=== Single-Responsibility Principle ===&lt;br /&gt;
==== calculate_score ====&lt;br /&gt;
This method gets a response map and then gets the score from that response map. We can instead ask the ResponseMap model to get this information.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474 calculate score.png|600px]]&lt;br /&gt;
==== process_answers ====&lt;br /&gt;
This method attempts to edit the submitted_answer field in response map. This should be done by ResponseMap model instead of our controller. &lt;br /&gt;
&lt;br /&gt;
[[File:E2474 process answer.png|600px]]&lt;br /&gt;
==== check_instructor_role ====&lt;br /&gt;
The goal of this method is to get the role ID of the user to make sure they are an instructor. We want to let the Role model check this instead of checking it in the controller.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474 check instructor role.png|600px]]&lt;br /&gt;
==== Other methods ====&lt;br /&gt;
* Several methods could be moved into the model classes in adherence to MVC architecture. This includes create_questionaire, build_response_map, etc.&lt;br /&gt;
&lt;br /&gt;
=== DRY Violations ===&lt;br /&gt;
==== find_resource_by_id ====&lt;br /&gt;
This is a method that is frequently called in this controller. We plan to separate this functionality into a concern or a shared utility function.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474_renaming_variables.png|600px]]&lt;br /&gt;
&lt;br /&gt;
=== Renaming Method and Variable Names ===&lt;br /&gt;
* Rename the methods for assign_quiz_to_student and submit_answer to clarify their purpose. We can also add method comments to help with this.&lt;br /&gt;
* Refactor variable names to better reflect their purpose. The image below shows that model is not the best name along with find_resource_by_id&lt;br /&gt;
[[File:E2474_renaming_variables.png|600px]]&lt;br /&gt;
&lt;br /&gt;
== Main Methods to Create or Enhance ==&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; !! Method !! Purpose !! Description !! Commit&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
| &amp;lt;code&amp;gt; calculate_score &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; process_answers &amp;lt;/code&amp;gt;&lt;br /&gt;
| Ensure MVC compliance and adherence to the Single-Responsibility Principle&lt;br /&gt;
| Move both &amp;lt;code&amp;gt;calculate_score&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;process_answers&amp;lt;/code&amp;gt; to the &amp;lt;code&amp;gt;ResponseMap&amp;lt;/code&amp;gt; model, allowing the controller to focus only on handling requests and delegating logic to models.&lt;br /&gt;
|''' calculate_score Commit: https://github.com/neerua08/reimplementation-back-end/commit/c1dd8c817d842df0817bde8fa408d760fb0a6fdd &lt;br /&gt;
 ''' process_answers Commit: https://github.com/neerua08/reimplementation-back-end/commit/dacecb623bbfa8cfff89a3c6deaa8affd8eaf0f5&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
| &amp;lt;code&amp;gt; find_resource_by_id &amp;lt;/code&amp;gt;&lt;br /&gt;
| Reduce DRY violations&lt;br /&gt;
| Implement this as a shared utility function to eliminate duplicate code and streamline resource retrieval in the controller.&lt;br /&gt;
| ''' Commit: ''' https://github.com/neerua08/reimplementation-back-end/commit/0dc53dd139caa7d18d380c98d51578d98911ef3b&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
| &amp;lt;code&amp;gt; check_instructor_role &amp;lt;/code&amp;gt;&lt;br /&gt;
| Improve code readability&lt;br /&gt;
| Move the &amp;lt;code&amp;gt;check_instructor_role&amp;lt;/code&amp;gt; method to the &amp;lt;code&amp;gt;Role&amp;lt;/code&amp;gt; model, ensuring that role-related logic resides within the model rather than the controller.&lt;br /&gt;
| ''' Commit: ''' https://github.com/neerua08/reimplementation-back-end/commit/55d860747ff08506aea134e182d98119eadc58e9&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
| &amp;lt;code&amp;gt; create_questionnaire &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; build_response_map &amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
| Improve modularity&lt;br /&gt;
| Transfer these methods from the controller to appropriate model classes, which aligns with the MVC pattern and keeps controller methods concise.&lt;br /&gt;
| ''' Commit: ''' &lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
| &amp;lt;code&amp;gt; assign_quiz_to_student &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; submit_answer &amp;lt;/code&amp;gt;&lt;br /&gt;
| Improve code readability&lt;br /&gt;
| Rename these methods to more descriptive names and add comments to explain functionality, making the codebase easier to understand and maintain.&lt;br /&gt;
| ''' Commit: ''' https://github.com/neerua08/reimplementation-back-end/commit/865857ea2dcc0eb73d87cff87e1610bf8ba6d142&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
Student quizzes Controller contains APIs which allows the instructor to create a new quiz and perform other CRUD operations on quiz. It allows the students to submit answers to the quizzes and check their scores. Our implementation plan includes reimplementing existing methods and adding new methods. Student quizzes Controller does now adhere to best practices while ensuring that existing functionalities remain unchanged.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
As we are reimplementing this file from scratch, we plan to do some manual testing to verify our code. If time permits, we can add some automated tests. Currently, we plan to use a variety of tools to test our code including:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Postman&amp;lt;/strong&amp;gt; - Test our API calls for the controller to ensure their functionality. The main purpose is to validate the behavior of the controller. This can be done by testing all relevant CRUD operations for quiz creation, submission, and scoring, verifying that the controller responds with appropriate status codes, ensure that all input validations are working as expected including edge cases, and validate that the controller adheres to any role-based access restrictions.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Automated RSpec Tests&amp;lt;/strong&amp;gt; - Test the various methods in our controller to determine if they are functioning as expected. The main purpose is to verify the internal logic of the controller and related methods ensuring they are functioning as expected. This can be done by creating unit tests for methods within the controller especially methods that will be refactored or moved to the model, creating model tests for if any logic is moved to the models to verify that the new functionality works correctly, and create controller tests to ensure that the controller actions work as expected like assigning quizzes to students, submitting answers and recording results, and calculating scores correctly.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Black Box Testing&amp;lt;/strong&amp;gt; - Running through the application to determine if any errors or inconsistent functionalities occur. The main purpose is to ensure the overall functionality of the system from the perspective of an end user.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Test Coverage&amp;lt;/strong&amp;gt; - Using SimpleCov to ensure sufficient test coverage of all key methods and code paths, preventing any untested code from being deployed. We can do this by integrating SimpleCov to measure code coverage across the entire application, create coverage goals and aim for like a high code coverage (e.g., 90% or higher) to ensure all key methods in the controller and related models are thoroughly tested, monitor coverage reports to identify any untested methods or areas of the codebase and add tests for those areas as needed, and refactor based on coverage so if we see significant gaps in test coverage, we can refactor the tests or implementation to ensure better coverage.&lt;br /&gt;
&lt;br /&gt;
We don't plan on adding new scenarios but instead we plan on retesting scenarios: creating a new student quiz, handling invalid student quiz creation, calculating quiz score, assigning quiz to student, submitting quiz answers, and updating a student quiz to see if those scenarios still work when we reimplement student_quizzes_controller.rb as a whole. We might add multiple scenarios as we go.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
# Akhilesh Neeruganti (asneerug@ncsu.edu)&lt;br /&gt;
# Krishna Pallavalli (kpallav@ncsu.edu)&lt;br /&gt;
# Aarya Rajoju (arajoju@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Mentor: Richard Li (rli14@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links == &lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2420._Reimplement_student_quizzes_controller This wiki page] contains detailed information on the previous team's work on this feature.&lt;br /&gt;
* '''Github Repository:''' https://github.com/neerua08/reimplementation-back-end&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/141&lt;br /&gt;
* '''Demo Video Link:''' https://youtu.be/hi_4GVLCpdY&lt;/div&gt;</summary>
		<author><name>Kpallav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=160987</id>
		<title>CSC/ECE 517 Fall 2024 - E2474. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=160987"/>
		<updated>2024-12-11T05:09:36Z</updated>

		<summary type="html">&lt;p&gt;Kpallav: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is about E2474 Phase 2 for Expertiza.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a [http://rubyonrails.org/ Ruby on Rails] based open source project. The Expertiza project is software for creating reusable learning objects through peer review. It also supports team projects and the submission of almost any document type, including URLs and wiki pages. The goal is to foster team collaboration through projects and provide a robust way to give feedback for these projects.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
For this project, we are expected to reimplement the student_quizzes_controller.rb file in the reimplementation-backend repository of Expertiza. This controller handles scoring, creating, and recording responses for quizzes that are done by students or reviewers for an assignment. The main issue with the previous implementation is that it violates several Rails design principles such as DRY violations. Along with this, various other issues that need to be addressed include code repetition, unclear method comments, and ambiguous variable names. The overall idea of this project is to ensure that we maintain the previous functionality while adhering to the best design practices.&lt;br /&gt;
&lt;br /&gt;
=== Specific Issues ===&lt;br /&gt;
* &amp;lt;strong&amp;gt;Single-Responsibility Principle&amp;lt;/strong&amp;gt; - Various functionalities are done in the student_quizzes_controller.rb that should be deferred to other models or controllers.&lt;br /&gt;
* &amp;lt;strong&amp;gt;DRY Violations&amp;lt;/strong&amp;gt; - There is a good amount of code repetition in the code that could be consolidated to a method.&lt;br /&gt;
* &amp;lt;strong&amp;gt;Unclear Method and Variable Names&amp;lt;/strong&amp;gt; - There are ambiguous methods names and variable names that should be changed. We can also add method comments to help explain functionality.&lt;br /&gt;
&lt;br /&gt;
== Design Plan ==&lt;br /&gt;
=== Single-Responsibility Principle ===&lt;br /&gt;
==== calculate_score ====&lt;br /&gt;
This method gets a response map and then gets the score from that response map. We can instead ask the ResponseMap model to get this information.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474 calculate score.png|600px]]&lt;br /&gt;
==== process_answers ====&lt;br /&gt;
This method attempts to edit the submitted_answer field in response map. This should be done by ResponseMap model instead of our controller. &lt;br /&gt;
&lt;br /&gt;
[[File:E2474 process answer.png|600px]]&lt;br /&gt;
==== check_instructor_role ====&lt;br /&gt;
The goal of this method is to get the role ID of the user to make sure they are an instructor. We want to let the Role model check this instead of checking it in the controller.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474 check instructor role.png|600px]]&lt;br /&gt;
==== Other methods ====&lt;br /&gt;
* Several methods could be moved into the model classes in adherence to MVC architecture. This includes create_questionaire, build_response_map, etc.&lt;br /&gt;
&lt;br /&gt;
=== DRY Violations ===&lt;br /&gt;
==== find_resource_by_id ====&lt;br /&gt;
This is a method that is frequently called in this controller. We plan to separate this functionality into a concern or a shared utility function.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474_renaming_variables.png|600px]]&lt;br /&gt;
&lt;br /&gt;
=== Renaming Method and Variable Names ===&lt;br /&gt;
* Rename the methods for assign_quiz_to_student and submit_answer to clarify their purpose. We can also add method comments to help with this.&lt;br /&gt;
* Refactor variable names to better reflect their purpose. The image below shows that model is not the best name along with find_resource_by_id&lt;br /&gt;
[[File:E2474_renaming_variables.png|600px]]&lt;br /&gt;
&lt;br /&gt;
== Main Methods to Create or Enhance ==&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; !! Method !! Purpose !! Description !! Commit&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
| &amp;lt;code&amp;gt; calculate_score &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; process_answers &amp;lt;/code&amp;gt;&lt;br /&gt;
| Ensure MVC compliance and adherence to the Single-Responsibility Principle&lt;br /&gt;
| Move both &amp;lt;code&amp;gt;calculate_score&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;process_answers&amp;lt;/code&amp;gt; to the &amp;lt;code&amp;gt;ResponseMap&amp;lt;/code&amp;gt; model, allowing the controller to focus only on handling requests and delegating logic to models.&lt;br /&gt;
|''' calculate_score Commit: https://github.com/neerua08/reimplementation-back-end/commit/c1dd8c817d842df0817bde8fa408d760fb0a6fdd &lt;br /&gt;
 ''' process_answers Commit: https://github.com/neerua08/reimplementation-back-end/commit/dacecb623bbfa8cfff89a3c6deaa8affd8eaf0f5&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
| &amp;lt;code&amp;gt; find_resource_by_id &amp;lt;/code&amp;gt;&lt;br /&gt;
| Reduce DRY violations&lt;br /&gt;
| Implement this as a shared utility function to eliminate duplicate code and streamline resource retrieval in the controller.&lt;br /&gt;
| ''' Commit: ''' https://github.com/neerua08/reimplementation-back-end/commit/0dc53dd139caa7d18d380c98d51578d98911ef3b&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
| &amp;lt;code&amp;gt; check_instructor_role &amp;lt;/code&amp;gt;&lt;br /&gt;
| Improve code readability&lt;br /&gt;
| Move the &amp;lt;code&amp;gt;check_instructor_role&amp;lt;/code&amp;gt; method to the &amp;lt;code&amp;gt;Role&amp;lt;/code&amp;gt; model, ensuring that role-related logic resides within the model rather than the controller.&lt;br /&gt;
| Placeholder for Commit.&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
| &amp;lt;code&amp;gt; create_questionnaire &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; build_response_map &amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
| Improve modularity&lt;br /&gt;
| Transfer these methods from the controller to appropriate model classes, which aligns with the MVC pattern and keeps controller methods concise.&lt;br /&gt;
| Placeholder for Commit.&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
| &amp;lt;code&amp;gt; assign_quiz_to_student &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; submit_answer &amp;lt;/code&amp;gt;&lt;br /&gt;
| Improve code readability&lt;br /&gt;
| Rename these methods to more descriptive names and add comments to explain functionality, making the codebase easier to understand and maintain.&lt;br /&gt;
| ''' Commit: ''' https://github.com/neerua08/reimplementation-back-end/commit/865857ea2dcc0eb73d87cff87e1610bf8ba6d142&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
Student quizzes Controller contains APIs which allows the instructor to create a new quiz and perform other CRUD operations on quiz. It allows the students to submit answers to the quizzes and check their scores. Our implementation plan includes reimplementing existing methods and adding new methods. Student quizzes Controller does now adhere to best practices while ensuring that existing functionalities remain unchanged.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
As we are reimplementing this file from scratch, we plan to do some manual testing to verify our code. If time permits, we can add some automated tests. Currently, we plan to use a variety of tools to test our code including:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Postman&amp;lt;/strong&amp;gt; - Test our API calls for the controller to ensure their functionality. The main purpose is to validate the behavior of the controller. This can be done by testing all relevant CRUD operations for quiz creation, submission, and scoring, verifying that the controller responds with appropriate status codes, ensure that all input validations are working as expected including edge cases, and validate that the controller adheres to any role-based access restrictions.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Automated RSpec Tests&amp;lt;/strong&amp;gt; - Test the various methods in our controller to determine if they are functioning as expected. The main purpose is to verify the internal logic of the controller and related methods ensuring they are functioning as expected. This can be done by creating unit tests for methods within the controller especially methods that will be refactored or moved to the model, creating model tests for if any logic is moved to the models to verify that the new functionality works correctly, and create controller tests to ensure that the controller actions work as expected like assigning quizzes to students, submitting answers and recording results, and calculating scores correctly.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Black Box Testing&amp;lt;/strong&amp;gt; - Running through the application to determine if any errors or inconsistent functionalities occur. The main purpose is to ensure the overall functionality of the system from the perspective of an end user.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Test Coverage&amp;lt;/strong&amp;gt; - Using SimpleCov to ensure sufficient test coverage of all key methods and code paths, preventing any untested code from being deployed. We can do this by integrating SimpleCov to measure code coverage across the entire application, create coverage goals and aim for like a high code coverage (e.g., 90% or higher) to ensure all key methods in the controller and related models are thoroughly tested, monitor coverage reports to identify any untested methods or areas of the codebase and add tests for those areas as needed, and refactor based on coverage so if we see significant gaps in test coverage, we can refactor the tests or implementation to ensure better coverage.&lt;br /&gt;
&lt;br /&gt;
We don't plan on adding new scenarios but instead we plan on retesting scenarios: creating a new student quiz, handling invalid student quiz creation, calculating quiz score, assigning quiz to student, submitting quiz answers, and updating a student quiz to see if those scenarios still work when we reimplement student_quizzes_controller.rb as a whole. We might add multiple scenarios as we go.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
# Akhilesh Neeruganti (asneerug@ncsu.edu)&lt;br /&gt;
# Krishna Pallavalli (kpallav@ncsu.edu)&lt;br /&gt;
# Aarya Rajoju (arajoju@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Mentor: Richard Li (rli14@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links == &lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2420._Reimplement_student_quizzes_controller This wiki page] contains detailed information on the previous team's work on this feature.&lt;br /&gt;
* '''Github Repository:''' https://github.com/neerua08/reimplementation-back-end&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/reimplementation-back-end/pull/141&lt;br /&gt;
* '''Demo Video Link:''' https://youtu.be/hi_4GVLCpdY&lt;/div&gt;</summary>
		<author><name>Kpallav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=160692</id>
		<title>CSC/ECE 517 Fall 2024 - E2474. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=160692"/>
		<updated>2024-12-04T04:58:36Z</updated>

		<summary type="html">&lt;p&gt;Kpallav: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is about E2474 Phase 2 for Expertiza.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a [http://rubyonrails.org/ Ruby on Rails] based open source project. The Expertiza project is software for creating reusable learning objects through peer review. It also supports team projects and the submission of almost any document type, including URLs and wiki pages. The goal is to foster team collaboration through projects and provide a robust way to give feedback for these projects.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
For this project, we are expected to reimplement the student_quizzes_controller.rb file in the reimplementation-backend repository of Expertiza. This controller handles scoring, creating, and recording responses for quizzes that are done by students or reviewers for an assignment. The main issue with the previous implementation is that it violates several Rails design principles such as DRY violations. Along with this, various other issues that need to be addressed include code repetition, unclear method comments, and ambiguous variable names. The overall idea of this project is to ensure that we maintain the previous functionality while adhering to the best design practices.&lt;br /&gt;
&lt;br /&gt;
=== Specific Issues ===&lt;br /&gt;
* &amp;lt;strong&amp;gt;Single-Responsibility Principle&amp;lt;/strong&amp;gt; - Various functionalities are done in the student_quizzes_controller.rb that should be deferred to other models or controllers.&lt;br /&gt;
* &amp;lt;strong&amp;gt;DRY Violations&amp;lt;/strong&amp;gt; - There is a good amount of code repetition in the code that could be consolidated to a method.&lt;br /&gt;
* &amp;lt;strong&amp;gt;Unclear Method and Variable Names&amp;lt;/strong&amp;gt; - There are ambiguous methods names and variable names that should be changed. We can also add method comments to help explain functionality.&lt;br /&gt;
&lt;br /&gt;
== Design Plan ==&lt;br /&gt;
=== Single-Responsibility Principle ===&lt;br /&gt;
==== calculate_score ====&lt;br /&gt;
This method gets a response map and then gets the score from that response map. We can instead ask the ResponseMap model to get this information.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474 calculate score.png|600px]]&lt;br /&gt;
==== process_answers ====&lt;br /&gt;
This method attempts to edit the submitted_answer field in response map. This should be done by ResponseMap model instead of our controller. &lt;br /&gt;
&lt;br /&gt;
[[File:E2474 process answer.png|600px]]&lt;br /&gt;
==== check_instructor_role ====&lt;br /&gt;
The goal of this method is to get the role ID of the user to make sure they are an instructor. We want to let the Role model check this instead of checking it in the controller.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474 check instructor role.png|600px]]&lt;br /&gt;
==== Other methods ====&lt;br /&gt;
* Several methods could be moved into the model classes in adherence to MVC architecture. This includes create_questionaire, build_response_map, set_student_quiz, etc.&lt;br /&gt;
&lt;br /&gt;
=== DRY Violations ===&lt;br /&gt;
==== find_resource_by_id ====&lt;br /&gt;
This is a method that is frequently called in this controller. We plan to separate this functionality into a concern or a shared utility function.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474_renaming_variables.png|600px]]&lt;br /&gt;
==== Other methods ====&lt;br /&gt;
* Multiple methods have code repetition that can be reduced in this controller. These include find_or_initialize_response and assign_quiz_to_student.&lt;br /&gt;
&lt;br /&gt;
=== Renaming Method and Variable Names ===&lt;br /&gt;
* Rename the methods for assign_quiz_to_student and submit_answer to clarify their purpose. We can also add method comments to help with this.&lt;br /&gt;
* Refactor variable names to better reflect their purpose. The image below shows that model is not the best name along with find_resource_by_id&lt;br /&gt;
[[File:E2474_renaming_variables.png|600px]]&lt;br /&gt;
&lt;br /&gt;
== Main Methods to Create or Enhance ==&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; !! Method !! Purpose !! Description !! Commit&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
| &amp;lt;code&amp;gt; calculate_score &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; process_answers &amp;lt;/code&amp;gt;&lt;br /&gt;
| Ensure MVC compliance and adherence to the Single-Responsibility Principle&lt;br /&gt;
| Move both &amp;lt;code&amp;gt;calculate_score&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;process_answers&amp;lt;/code&amp;gt; to the &amp;lt;code&amp;gt;ResponseMap&amp;lt;/code&amp;gt; model, allowing the controller to focus only on handling requests and delegating logic to models.&lt;br /&gt;
|''' calculate_score Commit: https://github.com/neerua08/reimplementation-back-end/commit/c1dd8c817d842df0817bde8fa408d760fb0a6fdd &lt;br /&gt;
 ''' process_answers Commit: https://github.com/neerua08/reimplementation-back-end/commit/dacecb623bbfa8cfff89a3c6deaa8affd8eaf0f5&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
| &amp;lt;code&amp;gt; find_resource_by_id &amp;lt;/code&amp;gt;&lt;br /&gt;
| Reduce DRY violations&lt;br /&gt;
| Implement this as a shared utility function to eliminate duplicate code and streamline resource retrieval in the controller.&lt;br /&gt;
| ''' Commit: ''' https://github.com/neerua08/reimplementation-back-end/commit/0dc53dd139caa7d18d380c98d51578d98911ef3b&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
| &amp;lt;code&amp;gt; check_instructor_role &amp;lt;/code&amp;gt;&lt;br /&gt;
| Improve code readability&lt;br /&gt;
| Move the &amp;lt;code&amp;gt;check_instructor_role&amp;lt;/code&amp;gt; method to the &amp;lt;code&amp;gt;Role&amp;lt;/code&amp;gt; model, ensuring that role-related logic resides within the model rather than the controller.&lt;br /&gt;
| Placeholder for Commit.&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
| &amp;lt;code&amp;gt; create_questionnaire &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; build_response_map &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; set_student_quiz &amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
| Improve modularity&lt;br /&gt;
| Transfer these methods from the controller to appropriate model classes, which aligns with the MVC pattern and keeps controller methods concise.&lt;br /&gt;
| Placeholder for Commit.&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
| &amp;lt;code&amp;gt; assign_quiz_to_student &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; submit_answer &amp;lt;/code&amp;gt;&lt;br /&gt;
| Improve code readability&lt;br /&gt;
| Rename these methods to more descriptive names and add comments to explain functionality, making the codebase easier to understand and maintain.&lt;br /&gt;
| ''' Commit: ''' https://github.com/neerua08/reimplementation-back-end/commit/865857ea2dcc0eb73d87cff87e1610bf8ba6d142&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
Student quizzes Controller contains APIs which allows the instructor to create a new quiz and perform other CRUD operations on quiz. It allows the students to submit answers to the quizzes and check their scores. Our implementation plan includes reimplementing existing methods and adding new methods. Student quizzes Controller does now adhere to best practices while ensuring that existing functionalities remain unchanged.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
As we are reimplementing this file from scratch, we plan to do some manual testing to verify our code. If time permits, we can add some automated tests. Currently, we plan to use a variety of tools to test our code including:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Postman&amp;lt;/strong&amp;gt; - Test our API calls for the controller to ensure their functionality. The main purpose is to validate the behavior of the controller. This can be done by testing all relevant CRUD operations for quiz creation, submission, and scoring, verifying that the controller responds with appropriate status codes, ensure that all input validations are working as expected including edge cases, and validate that the controller adheres to any role-based access restrictions.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Automated RSpec Tests&amp;lt;/strong&amp;gt; - Test the various methods in our controller to determine if they are functioning as expected. The main purpose is to verify the internal logic of the controller and related methods ensuring they are functioning as expected. This can be done by creating unit tests for methods within the controller especially methods that will be refactored or moved to the model, creating model tests for if any logic is moved to the models to verify that the new functionality works correctly, and create controller tests to ensure that the controller actions work as expected like assigning quizzes to students, submitting answers and recording results, and calculating scores correctly.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Black Box Testing&amp;lt;/strong&amp;gt; - Running through the application to determine if any errors or inconsistent functionalities occur. The main purpose is to ensure the overall functionality of the system from the perspective of an end user.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Test Coverage&amp;lt;/strong&amp;gt; - Using SimpleCov to ensure sufficient test coverage of all key methods and code paths, preventing any untested code from being deployed. We can do this by integrating SimpleCov to measure code coverage across the entire application, create coverage goals and aim for like a high code coverage (e.g., 90% or higher) to ensure all key methods in the controller and related models are thoroughly tested, monitor coverage reports to identify any untested methods or areas of the codebase and add tests for those areas as needed, and refactor based on coverage so if we see significant gaps in test coverage, we can refactor the tests or implementation to ensure better coverage.&lt;br /&gt;
&lt;br /&gt;
We don't plan on adding new scenarios but instead we plan on retesting scenarios: creating a new student quiz, handling invalid student quiz creation, calculating quiz score, assigning quiz to student, submitting quiz answers, and updating a student quiz to see if those scenarios still work when we reimplement student_quizzes_controller.rb as a whole. We might add multiple scenarios as we go.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
# Akhilesh Neeruganti (asneerug@ncsu.edu)&lt;br /&gt;
# Krishna Pallavalli (kpallav@ncsu.edu)&lt;br /&gt;
# Aarya Rajoju (arajoju@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Mentor: Richard Li (rli14@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links == &lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2420._Reimplement_student_quizzes_controller This wiki page] contains detailed information on the previous team's work on this feature.&lt;br /&gt;
* '''Github Repository:''' https://github.com/neerua08/reimplementation-back-end&lt;br /&gt;
* '''Pull Request:''' (placeholder for later)&lt;/div&gt;</summary>
		<author><name>Kpallav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=160638</id>
		<title>CSC/ECE 517 Fall 2024 - E2474. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=160638"/>
		<updated>2024-12-04T04:16:57Z</updated>

		<summary type="html">&lt;p&gt;Kpallav: /* Main Methods to Create or Enhance */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is about E2474 Phase 2 for Expertiza.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a [http://rubyonrails.org/ Ruby on Rails] based open source project. The Expertiza project is software for creating reusable learning objects through peer review. It also supports team projects and the submission of almost any document type, including URLs and wiki pages. The goal is to foster team collaboration through projects and provide a robust way to give feedback for these projects.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
For this project, we are expected to reimplement the student_quizzes_controller.rb file in the reimplementation-backend repository of Expertiza. This controller handles scoring, creating, and recording responses for quizzes that are done by students or reviewers for an assignment. The main issue with the previous implementation is that it violates several Rails design principles such as DRY violations. Along with this, various other issues that need to be addressed include code repetition, unclear method comments, and ambiguous variable names. The overall idea of this project is to ensure that we maintain the previous functionality while adhering to the best design practices.&lt;br /&gt;
&lt;br /&gt;
=== Specific Issues ===&lt;br /&gt;
* &amp;lt;strong&amp;gt;Single-Responsibility Principle&amp;lt;/strong&amp;gt; - Various functionalities are done in the student_quizzes_controller.rb that should be deferred to other models or controllers.&lt;br /&gt;
* &amp;lt;strong&amp;gt;DRY Violations&amp;lt;/strong&amp;gt; - There is a good amount of code repetition in the code that could be consolidated to a method.&lt;br /&gt;
* &amp;lt;strong&amp;gt;Unclear Method and Variable Names&amp;lt;/strong&amp;gt; - There are ambiguous methods names and variable names that should be changed. We can also add method comments to help explain functionality.&lt;br /&gt;
&lt;br /&gt;
== Design Plan ==&lt;br /&gt;
=== Single-Responsibility Principle ===&lt;br /&gt;
==== calculate_score ====&lt;br /&gt;
This method gets a response map and then gets the score from that response map. We can instead ask the ResponseMap model to get this information.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474 calculate score.png|600px]]&lt;br /&gt;
==== process_answers ====&lt;br /&gt;
This method attempts to edit the submitted_answer field in response map. This should be done by ResponseMap model instead of our controller. &lt;br /&gt;
&lt;br /&gt;
[[File:E2474 process answer.png|600px]]&lt;br /&gt;
==== check_instructor_role ====&lt;br /&gt;
The goal of this method is to get the role ID of the user to make sure they are an instructor. We want to let the Role model check this instead of checking it in the controller.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474 check instructor role.png|600px]]&lt;br /&gt;
==== Other methods ====&lt;br /&gt;
* Several methods could be moved into the model classes in adherence to MVC architecture. This includes create_questionaire, build_response_map, set_student_quiz, etc.&lt;br /&gt;
&lt;br /&gt;
=== DRY Violations ===&lt;br /&gt;
==== find_resource_by_id ====&lt;br /&gt;
This is a method that is frequently called in this controller. We plan to separate this functionality into a concern or a shared utility function.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474_renaming_variables.png|600px]]&lt;br /&gt;
==== Other methods ====&lt;br /&gt;
* Multiple methods have code repetition that can be reduced in this controller. These include find_or_initialize_response and assign_quiz_to_student.&lt;br /&gt;
&lt;br /&gt;
=== Renaming Method and Variable Names ===&lt;br /&gt;
* Rename the methods for assign_quiz_to_student and submit_answer to clarify their purpose. We can also add method comments to help with this.&lt;br /&gt;
* Refactor variable names to better reflect their purpose. The image below shows that model is not the best name along with find_resource_by_id&lt;br /&gt;
[[File:E2474_renaming_variables.png|600px]]&lt;br /&gt;
&lt;br /&gt;
== Main Methods to Create or Enhance ==&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; !! Method !! Purpose !! Description !! Commit&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
| &amp;lt;code&amp;gt; calculate_score &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; process_answers &amp;lt;/code&amp;gt;&lt;br /&gt;
| Ensure MVC compliance and adherence to the Single-Responsibility Principle&lt;br /&gt;
| Move both &amp;lt;code&amp;gt;calculate_score&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;process_answers&amp;lt;/code&amp;gt; to the &amp;lt;code&amp;gt;ResponseMap&amp;lt;/code&amp;gt; model, allowing the controller to focus only on handling requests and delegating logic to models.&lt;br /&gt;
|''' calculate_score Commit: https://github.com/neerua08/reimplementation-back-end/commit/c1dd8c817d842df0817bde8fa408d760fb0a6fdd &lt;br /&gt;
 ''' process_answers Commit: https://github.com/neerua08/reimplementation-back-end/commit/dacecb623bbfa8cfff89a3c6deaa8affd8eaf0f5&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
| &amp;lt;code&amp;gt; find_resource_by_id &amp;lt;/code&amp;gt;&lt;br /&gt;
| Reduce DRY violations&lt;br /&gt;
| Implement this as a shared utility function to eliminate duplicate code and streamline resource retrieval in the controller.&lt;br /&gt;
| ''' Commit: ''' https://github.com/neerua08/reimplementation-back-end/commit/0dc53dd139caa7d18d380c98d51578d98911ef3b&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
| &amp;lt;code&amp;gt; check_instructor_role &amp;lt;/code&amp;gt;&lt;br /&gt;
| Improve code readability&lt;br /&gt;
| Move the &amp;lt;code&amp;gt;check_instructor_role&amp;lt;/code&amp;gt; method to the &amp;lt;code&amp;gt;Role&amp;lt;/code&amp;gt; model, ensuring that role-related logic resides within the model rather than the controller.&lt;br /&gt;
| Placeholder for Commit.&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
| &amp;lt;code&amp;gt; create_questionnaire &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; build_response_map &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; set_student_quiz &amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
| Improve modularity&lt;br /&gt;
| Transfer these methods from the controller to appropriate model classes, which aligns with the MVC pattern and keeps controller methods concise.&lt;br /&gt;
| Placeholder for Commit.&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
| &amp;lt;code&amp;gt; assign_quiz_to_student &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; submit_answer &amp;lt;/code&amp;gt;&lt;br /&gt;
| Improve code readability&lt;br /&gt;
| Rename these methods to more descriptive names and add comments to explain functionality, making the codebase easier to understand and maintain.&lt;br /&gt;
| ''' Commit: ''' https://github.com/neerua08/reimplementation-back-end/commit/865857ea2dcc0eb73d87cff87e1610bf8ba6d142&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
Section to place our work in (Placeholder).&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
As we are reimplementing this file from scratch, we plan to do some manual testing to verify our code. If time permits, we can add some automated tests. Currently, we plan to use a variety of tools to test our code including:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Postman&amp;lt;/strong&amp;gt; - Test our API calls for the controller to ensure their functionality. The main purpose is to validate the behavior of the controller. This can be done by testing all relevant CRUD operations for quiz creation, submission, and scoring, verifying that the controller responds with appropriate status codes, ensure that all input validations are working as expected including edge cases, and validate that the controller adheres to any role-based access restrictions.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Automated RSpec Tests&amp;lt;/strong&amp;gt; - Test the various methods in our controller to determine if they are functioning as expected. The main purpose is to verify the internal logic of the controller and related methods ensuring they are functioning as expected. This can be done by creating unit tests for methods within the controller especially methods that will be refactored or moved to the model, creating model tests for if any logic is moved to the models to verify that the new functionality works correctly, and create controller tests to ensure that the controller actions work as expected like assigning quizzes to students, submitting answers and recording results, and calculating scores correctly.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Black Box Testing&amp;lt;/strong&amp;gt; - Running through the application to determine if any errors or inconsistent functionalities occur. The main purpose is to ensure the overall functionality of the system from the perspective of an end user.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Test Coverage&amp;lt;/strong&amp;gt; - Using SimpleCov to ensure sufficient test coverage of all key methods and code paths, preventing any untested code from being deployed. We can do this by integrating SimpleCov to measure code coverage across the entire application, create coverage goals and aim for like a high code coverage (e.g., 90% or higher) to ensure all key methods in the controller and related models are thoroughly tested, monitor coverage reports to identify any untested methods or areas of the codebase and add tests for those areas as needed, and refactor based on coverage so if we see significant gaps in test coverage, we can refactor the tests or implementation to ensure better coverage.&lt;br /&gt;
&lt;br /&gt;
We don't plan on adding new scenarios but instead we plan on retesting scenarios: creating a new student quiz, handling invalid student quiz creation, calculating quiz score, assigning quiz to student, submitting quiz answers, and updating a student quiz to see if those scenarios still work when we reimplement student_quizzes_controller.rb as a whole. We might add multiple scenarios as we go.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
# Akhilesh Neeruganti (asneerug@ncsu.edu)&lt;br /&gt;
# Krishna Pallavalli (kpallav@ncsu.edu)&lt;br /&gt;
# Aarya Rajoju (arajoju@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Mentor: Richard Li (rli14@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links == &lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2420._Reimplement_student_quizzes_controller This wiki page] contains detailed information on the previous team's work on this feature.&lt;br /&gt;
* '''Github Repository:''' https://github.com/neerua08/reimplementation-back-end&lt;br /&gt;
* '''Pull Request:''' (placeholder for later)&lt;/div&gt;</summary>
		<author><name>Kpallav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=160637</id>
		<title>CSC/ECE 517 Fall 2024 - E2474. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=160637"/>
		<updated>2024-12-04T04:16:35Z</updated>

		<summary type="html">&lt;p&gt;Kpallav: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is about E2474 Phase 2 for Expertiza.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a [http://rubyonrails.org/ Ruby on Rails] based open source project. The Expertiza project is software for creating reusable learning objects through peer review. It also supports team projects and the submission of almost any document type, including URLs and wiki pages. The goal is to foster team collaboration through projects and provide a robust way to give feedback for these projects.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
For this project, we are expected to reimplement the student_quizzes_controller.rb file in the reimplementation-backend repository of Expertiza. This controller handles scoring, creating, and recording responses for quizzes that are done by students or reviewers for an assignment. The main issue with the previous implementation is that it violates several Rails design principles such as DRY violations. Along with this, various other issues that need to be addressed include code repetition, unclear method comments, and ambiguous variable names. The overall idea of this project is to ensure that we maintain the previous functionality while adhering to the best design practices.&lt;br /&gt;
&lt;br /&gt;
=== Specific Issues ===&lt;br /&gt;
* &amp;lt;strong&amp;gt;Single-Responsibility Principle&amp;lt;/strong&amp;gt; - Various functionalities are done in the student_quizzes_controller.rb that should be deferred to other models or controllers.&lt;br /&gt;
* &amp;lt;strong&amp;gt;DRY Violations&amp;lt;/strong&amp;gt; - There is a good amount of code repetition in the code that could be consolidated to a method.&lt;br /&gt;
* &amp;lt;strong&amp;gt;Unclear Method and Variable Names&amp;lt;/strong&amp;gt; - There are ambiguous methods names and variable names that should be changed. We can also add method comments to help explain functionality.&lt;br /&gt;
&lt;br /&gt;
== Design Plan ==&lt;br /&gt;
=== Single-Responsibility Principle ===&lt;br /&gt;
==== calculate_score ====&lt;br /&gt;
This method gets a response map and then gets the score from that response map. We can instead ask the ResponseMap model to get this information.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474 calculate score.png|600px]]&lt;br /&gt;
==== process_answers ====&lt;br /&gt;
This method attempts to edit the submitted_answer field in response map. This should be done by ResponseMap model instead of our controller. &lt;br /&gt;
&lt;br /&gt;
[[File:E2474 process answer.png|600px]]&lt;br /&gt;
==== check_instructor_role ====&lt;br /&gt;
The goal of this method is to get the role ID of the user to make sure they are an instructor. We want to let the Role model check this instead of checking it in the controller.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474 check instructor role.png|600px]]&lt;br /&gt;
==== Other methods ====&lt;br /&gt;
* Several methods could be moved into the model classes in adherence to MVC architecture. This includes create_questionaire, build_response_map, set_student_quiz, etc.&lt;br /&gt;
&lt;br /&gt;
=== DRY Violations ===&lt;br /&gt;
==== find_resource_by_id ====&lt;br /&gt;
This is a method that is frequently called in this controller. We plan to separate this functionality into a concern or a shared utility function.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474_renaming_variables.png|600px]]&lt;br /&gt;
==== Other methods ====&lt;br /&gt;
* Multiple methods have code repetition that can be reduced in this controller. These include find_or_initialize_response and assign_quiz_to_student.&lt;br /&gt;
&lt;br /&gt;
=== Renaming Method and Variable Names ===&lt;br /&gt;
* Rename the methods for assign_quiz_to_student and submit_answer to clarify their purpose. We can also add method comments to help with this.&lt;br /&gt;
* Refactor variable names to better reflect their purpose. The image below shows that model is not the best name along with find_resource_by_id&lt;br /&gt;
[[File:E2474_renaming_variables.png|600px]]&lt;br /&gt;
&lt;br /&gt;
== Main Methods to Create or Enhance ==&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; !! Method !! Purpose !! Description !! Commit&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
| &amp;lt;code&amp;gt; calculate_score &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; process_answers &amp;lt;/code&amp;gt;&lt;br /&gt;
| Ensure MVC compliance and adherence to the Single-Responsibility Principle&lt;br /&gt;
| Move both &amp;lt;code&amp;gt;calculate_score&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;process_answers&amp;lt;/code&amp;gt; to the &amp;lt;code&amp;gt;ResponseMap&amp;lt;/code&amp;gt; model, allowing the controller to focus only on handling requests and delegating logic to models.&lt;br /&gt;
| ''' calculate_score Commit: https://github.com/neerua08/reimplementation-back-end/commit/c1dd8c817d842df0817bde8fa408d760fb0a6fdd &lt;br /&gt;
 ''' process_answers Commit: https://github.com/neerua08/reimplementation-back-end/commit/dacecb623bbfa8cfff89a3c6deaa8affd8eaf0f5&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
| &amp;lt;code&amp;gt; find_resource_by_id &amp;lt;/code&amp;gt;&lt;br /&gt;
| Reduce DRY violations&lt;br /&gt;
| Implement this as a shared utility function to eliminate duplicate code and streamline resource retrieval in the controller.&lt;br /&gt;
| ''' Commit: ''' https://github.com/neerua08/reimplementation-back-end/commit/0dc53dd139caa7d18d380c98d51578d98911ef3b&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
| &amp;lt;code&amp;gt; check_instructor_role &amp;lt;/code&amp;gt;&lt;br /&gt;
| Improve code readability&lt;br /&gt;
| Move the &amp;lt;code&amp;gt;check_instructor_role&amp;lt;/code&amp;gt; method to the &amp;lt;code&amp;gt;Role&amp;lt;/code&amp;gt; model, ensuring that role-related logic resides within the model rather than the controller.&lt;br /&gt;
| Placeholder for Commit.&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
| &amp;lt;code&amp;gt; create_questionnaire &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; build_response_map &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; set_student_quiz &amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
| Improve modularity&lt;br /&gt;
| Transfer these methods from the controller to appropriate model classes, which aligns with the MVC pattern and keeps controller methods concise.&lt;br /&gt;
| Placeholder for Commit.&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
| &amp;lt;code&amp;gt; assign_quiz_to_student &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; submit_answer &amp;lt;/code&amp;gt;&lt;br /&gt;
| Improve code readability&lt;br /&gt;
| Rename these methods to more descriptive names and add comments to explain functionality, making the codebase easier to understand and maintain.&lt;br /&gt;
| ''' Commit: ''' https://github.com/neerua08/reimplementation-back-end/commit/865857ea2dcc0eb73d87cff87e1610bf8ba6d142&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
Section to place our work in (Placeholder).&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
As we are reimplementing this file from scratch, we plan to do some manual testing to verify our code. If time permits, we can add some automated tests. Currently, we plan to use a variety of tools to test our code including:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Postman&amp;lt;/strong&amp;gt; - Test our API calls for the controller to ensure their functionality. The main purpose is to validate the behavior of the controller. This can be done by testing all relevant CRUD operations for quiz creation, submission, and scoring, verifying that the controller responds with appropriate status codes, ensure that all input validations are working as expected including edge cases, and validate that the controller adheres to any role-based access restrictions.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Automated RSpec Tests&amp;lt;/strong&amp;gt; - Test the various methods in our controller to determine if they are functioning as expected. The main purpose is to verify the internal logic of the controller and related methods ensuring they are functioning as expected. This can be done by creating unit tests for methods within the controller especially methods that will be refactored or moved to the model, creating model tests for if any logic is moved to the models to verify that the new functionality works correctly, and create controller tests to ensure that the controller actions work as expected like assigning quizzes to students, submitting answers and recording results, and calculating scores correctly.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Black Box Testing&amp;lt;/strong&amp;gt; - Running through the application to determine if any errors or inconsistent functionalities occur. The main purpose is to ensure the overall functionality of the system from the perspective of an end user.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Test Coverage&amp;lt;/strong&amp;gt; - Using SimpleCov to ensure sufficient test coverage of all key methods and code paths, preventing any untested code from being deployed. We can do this by integrating SimpleCov to measure code coverage across the entire application, create coverage goals and aim for like a high code coverage (e.g., 90% or higher) to ensure all key methods in the controller and related models are thoroughly tested, monitor coverage reports to identify any untested methods or areas of the codebase and add tests for those areas as needed, and refactor based on coverage so if we see significant gaps in test coverage, we can refactor the tests or implementation to ensure better coverage.&lt;br /&gt;
&lt;br /&gt;
We don't plan on adding new scenarios but instead we plan on retesting scenarios: creating a new student quiz, handling invalid student quiz creation, calculating quiz score, assigning quiz to student, submitting quiz answers, and updating a student quiz to see if those scenarios still work when we reimplement student_quizzes_controller.rb as a whole. We might add multiple scenarios as we go.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
# Akhilesh Neeruganti (asneerug@ncsu.edu)&lt;br /&gt;
# Krishna Pallavalli (kpallav@ncsu.edu)&lt;br /&gt;
# Aarya Rajoju (arajoju@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Mentor: Richard Li (rli14@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links == &lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2420._Reimplement_student_quizzes_controller This wiki page] contains detailed information on the previous team's work on this feature.&lt;br /&gt;
* '''Github Repository:''' https://github.com/neerua08/reimplementation-back-end&lt;br /&gt;
* '''Pull Request:''' (placeholder for later)&lt;/div&gt;</summary>
		<author><name>Kpallav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=160632</id>
		<title>CSC/ECE 517 Fall 2024 - E2474. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=160632"/>
		<updated>2024-12-04T04:12:01Z</updated>

		<summary type="html">&lt;p&gt;Kpallav: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is about E2474 Phase 2 for Expertiza.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a [http://rubyonrails.org/ Ruby on Rails] based open source project. The Expertiza project is software for creating reusable learning objects through peer review. It also supports team projects and the submission of almost any document type, including URLs and wiki pages. The goal is to foster team collaboration through projects and provide a robust way to give feedback for these projects.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
For this project, we are expected to reimplement the student_quizzes_controller.rb file in the reimplementation-backend repository of Expertiza. This controller handles scoring, creating, and recording responses for quizzes that are done by students or reviewers for an assignment. The main issue with the previous implementation is that it violates several Rails design principles such as DRY violations. Along with this, various other issues that need to be addressed include code repetition, unclear method comments, and ambiguous variable names. The overall idea of this project is to ensure that we maintain the previous functionality while adhering to the best design practices.&lt;br /&gt;
&lt;br /&gt;
=== Specific Issues ===&lt;br /&gt;
* &amp;lt;strong&amp;gt;Single-Responsibility Principle&amp;lt;/strong&amp;gt; - Various functionalities are done in the student_quizzes_controller.rb that should be deferred to other models or controllers.&lt;br /&gt;
* &amp;lt;strong&amp;gt;DRY Violations&amp;lt;/strong&amp;gt; - There is a good amount of code repetition in the code that could be consolidated to a method.&lt;br /&gt;
* &amp;lt;strong&amp;gt;Unclear Method and Variable Names&amp;lt;/strong&amp;gt; - There are ambiguous methods names and variable names that should be changed. We can also add method comments to help explain functionality.&lt;br /&gt;
&lt;br /&gt;
== Design Plan ==&lt;br /&gt;
=== Single-Responsibility Principle ===&lt;br /&gt;
==== calculate_score ====&lt;br /&gt;
This method gets a response map and then gets the score from that response map. We can instead ask the ResponseMap model to get this information.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474 calculate score.png|600px]]&lt;br /&gt;
==== process_answers ====&lt;br /&gt;
This method attempts to edit the submitted_answer field in response map. This should be done by ResponseMap model instead of our controller. &lt;br /&gt;
&lt;br /&gt;
[[File:E2474 process answer.png|600px]]&lt;br /&gt;
==== check_instructor_role ====&lt;br /&gt;
The goal of this method is to get the role ID of the user to make sure they are an instructor. We want to let the Role model check this instead of checking it in the controller.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474 check instructor role.png|600px]]&lt;br /&gt;
==== Other methods ====&lt;br /&gt;
* Several methods could be moved into the model classes in adherence to MVC architecture. This includes create_questionaire, build_response_map, set_student_quiz, etc.&lt;br /&gt;
&lt;br /&gt;
=== DRY Violations ===&lt;br /&gt;
==== find_resource_by_id ====&lt;br /&gt;
This is a method that is frequently called in this controller. We plan to separate this functionality into a concern or a shared utility function.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474_renaming_variables.png|600px]]&lt;br /&gt;
==== Other methods ====&lt;br /&gt;
* Multiple methods have code repetition that can be reduced in this controller. These include find_or_initialize_response and assign_quiz_to_student.&lt;br /&gt;
&lt;br /&gt;
=== Renaming Method and Variable Names ===&lt;br /&gt;
* Rename the methods for assign_quiz_to_student and submit_answer to clarify their purpose. We can also add method comments to help with this.&lt;br /&gt;
* Refactor variable names to better reflect their purpose. The image below shows that model is not the best name along with find_resource_by_id&lt;br /&gt;
[[File:E2474_renaming_variables.png|600px]]&lt;br /&gt;
&lt;br /&gt;
== Main Methods to Create or Enhance ==&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; !! Method !! Purpose !! Description !! Commit&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
| &amp;lt;code&amp;gt; calculate_score &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; process_answers &amp;lt;/code&amp;gt;&lt;br /&gt;
| Ensure MVC compliance and adherence to the Single-Responsibility Principle&lt;br /&gt;
| Move both &amp;lt;code&amp;gt;calculate_score&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;process_answers&amp;lt;/code&amp;gt; to the &amp;lt;code&amp;gt;ResponseMap&amp;lt;/code&amp;gt; model, allowing the controller to focus only on handling requests and delegating logic to models.&lt;br /&gt;
| Placeholder for Commit.&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
| &amp;lt;code&amp;gt; find_resource_by_id &amp;lt;/code&amp;gt;&lt;br /&gt;
| Reduce DRY violations&lt;br /&gt;
| Implement this as a shared utility function to eliminate duplicate code and streamline resource retrieval in the controller.&lt;br /&gt;
| ''' Commit: ''' https://github.com/neerua08/reimplementation-back-end/commit/0dc53dd139caa7d18d380c98d51578d98911ef3b&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
| &amp;lt;code&amp;gt; check_instructor_role &amp;lt;/code&amp;gt;&lt;br /&gt;
| Improve code readability&lt;br /&gt;
| Move the &amp;lt;code&amp;gt;check_instructor_role&amp;lt;/code&amp;gt; method to the &amp;lt;code&amp;gt;Role&amp;lt;/code&amp;gt; model, ensuring that role-related logic resides within the model rather than the controller.&lt;br /&gt;
| Placeholder for Commit.&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
| &amp;lt;code&amp;gt; create_questionnaire &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; build_response_map &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; set_student_quiz &amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
| Improve modularity&lt;br /&gt;
| Transfer these methods from the controller to appropriate model classes, which aligns with the MVC pattern and keeps controller methods concise.&lt;br /&gt;
| Placeholder for Commit.&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
| &amp;lt;code&amp;gt; assign_quiz_to_student &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; submit_answer &amp;lt;/code&amp;gt;&lt;br /&gt;
| Improve code readability&lt;br /&gt;
| Rename these methods to more descriptive names and add comments to explain functionality, making the codebase easier to understand and maintain.&lt;br /&gt;
| ''' Commit: ''' https://github.com/neerua08/reimplementation-back-end/commit/865857ea2dcc0eb73d87cff87e1610bf8ba6d142&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
Section to place our work in (Placeholder).&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
As we are reimplementing this file from scratch, we plan to do some manual testing to verify our code. If time permits, we can add some automated tests. Currently, we plan to use a variety of tools to test our code including:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Postman&amp;lt;/strong&amp;gt; - Test our API calls for the controller to ensure their functionality. The main purpose is to validate the behavior of the controller. This can be done by testing all relevant CRUD operations for quiz creation, submission, and scoring, verifying that the controller responds with appropriate status codes, ensure that all input validations are working as expected including edge cases, and validate that the controller adheres to any role-based access restrictions.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Automated RSpec Tests&amp;lt;/strong&amp;gt; - Test the various methods in our controller to determine if they are functioning as expected. The main purpose is to verify the internal logic of the controller and related methods ensuring they are functioning as expected. This can be done by creating unit tests for methods within the controller especially methods that will be refactored or moved to the model, creating model tests for if any logic is moved to the models to verify that the new functionality works correctly, and create controller tests to ensure that the controller actions work as expected like assigning quizzes to students, submitting answers and recording results, and calculating scores correctly.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Black Box Testing&amp;lt;/strong&amp;gt; - Running through the application to determine if any errors or inconsistent functionalities occur. The main purpose is to ensure the overall functionality of the system from the perspective of an end user.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Test Coverage&amp;lt;/strong&amp;gt; - Using SimpleCov to ensure sufficient test coverage of all key methods and code paths, preventing any untested code from being deployed. We can do this by integrating SimpleCov to measure code coverage across the entire application, create coverage goals and aim for like a high code coverage (e.g., 90% or higher) to ensure all key methods in the controller and related models are thoroughly tested, monitor coverage reports to identify any untested methods or areas of the codebase and add tests for those areas as needed, and refactor based on coverage so if we see significant gaps in test coverage, we can refactor the tests or implementation to ensure better coverage.&lt;br /&gt;
&lt;br /&gt;
We don't plan on adding new scenarios but instead we plan on retesting scenarios: creating a new student quiz, handling invalid student quiz creation, calculating quiz score, assigning quiz to student, submitting quiz answers, and updating a student quiz to see if those scenarios still work when we reimplement student_quizzes_controller.rb as a whole. We might add multiple scenarios as we go.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
# Akhilesh Neeruganti (asneerug@ncsu.edu)&lt;br /&gt;
# Krishna Pallavalli (kpallav@ncsu.edu)&lt;br /&gt;
# Aarya Rajoju (arajoju@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Mentor: Richard Li (rli14@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links == &lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2420._Reimplement_student_quizzes_controller This wiki page] contains detailed information on the previous team's work on this feature.&lt;br /&gt;
* '''Github Repository:''' https://github.com/neerua08/reimplementation-back-end&lt;br /&gt;
* '''Pull Request:''' (placeholder for later)&lt;/div&gt;</summary>
		<author><name>Kpallav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=160629</id>
		<title>CSC/ECE 517 Fall 2024 - E2474. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=160629"/>
		<updated>2024-12-04T04:09:53Z</updated>

		<summary type="html">&lt;p&gt;Kpallav: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is about E2474 Phase 2 for Expertiza.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a [http://rubyonrails.org/ Ruby on Rails] based open source project. The Expertiza project is software for creating reusable learning objects through peer review. It also supports team projects and the submission of almost any document type, including URLs and wiki pages. The goal is to foster team collaboration through projects and provide a robust way to give feedback for these projects.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
For this project, we are expected to reimplement the student_quizzes_controller.rb file in the reimplementation-backend repository of Expertiza. This controller handles scoring, creating, and recording responses for quizzes that are done by students or reviewers for an assignment. The main issue with the previous implementation is that it violates several Rails design principles such as DRY violations. Along with this, various other issues that need to be addressed include code repetition, unclear method comments, and ambiguous variable names. The overall idea of this project is to ensure that we maintain the previous functionality while adhering to the best design practices.&lt;br /&gt;
&lt;br /&gt;
=== Specific Issues ===&lt;br /&gt;
* &amp;lt;strong&amp;gt;Single-Responsibility Principle&amp;lt;/strong&amp;gt; - Various functionalities are done in the student_quizzes_controller.rb that should be deferred to other models or controllers.&lt;br /&gt;
* &amp;lt;strong&amp;gt;DRY Violations&amp;lt;/strong&amp;gt; - There is a good amount of code repetition in the code that could be consolidated to a method.&lt;br /&gt;
* &amp;lt;strong&amp;gt;Unclear Method and Variable Names&amp;lt;/strong&amp;gt; - There are ambiguous methods names and variable names that should be changed. We can also add method comments to help explain functionality.&lt;br /&gt;
&lt;br /&gt;
== Design Plan ==&lt;br /&gt;
=== Single-Responsibility Principle ===&lt;br /&gt;
==== calculate_score ====&lt;br /&gt;
This method gets a response map and then gets the score from that response map. We can instead ask the ResponseMap model to get this information.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474 calculate score.png|600px]]&lt;br /&gt;
==== process_answers ====&lt;br /&gt;
This method attempts to edit the submitted_answer field in response map. This should be done by ResponseMap model instead of our controller. &lt;br /&gt;
&lt;br /&gt;
[[File:E2474 process answer.png|600px]]&lt;br /&gt;
==== check_instructor_role ====&lt;br /&gt;
The goal of this method is to get the role ID of the user to make sure they are an instructor. We want to let the Role model check this instead of checking it in the controller.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474 check instructor role.png|600px]]&lt;br /&gt;
==== Other methods ====&lt;br /&gt;
* Several methods could be moved into the model classes in adherence to MVC architecture. This includes create_questionaire, build_response_map, set_student_quiz, etc.&lt;br /&gt;
&lt;br /&gt;
=== DRY Violations ===&lt;br /&gt;
==== find_resource_by_id ====&lt;br /&gt;
This is a method that is frequently called in this controller. We plan to separate this functionality into a concern or a shared utility function.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474_renaming_variables.png|600px]]&lt;br /&gt;
==== Other methods ====&lt;br /&gt;
* Multiple methods have code repetition that can be reduced in this controller. These include find_or_initialize_response and assign_quiz_to_student.&lt;br /&gt;
&lt;br /&gt;
=== Renaming Method and Variable Names ===&lt;br /&gt;
* Rename the methods for assign_quiz_to_student and submit_answer to clarify their purpose. We can also add method comments to help with this.&lt;br /&gt;
* Refactor variable names to better reflect their purpose. The image below shows that model is not the best name along with find_resource_by_id&lt;br /&gt;
[[File:E2474_renaming_variables.png|600px]]&lt;br /&gt;
&lt;br /&gt;
== Main Methods to Create or Enhance ==&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; !! Method !! Purpose !! Description !! Commit&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
| &amp;lt;code&amp;gt; calculate_score &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; process_answers &amp;lt;/code&amp;gt;&lt;br /&gt;
| Ensure MVC compliance and adherence to the Single-Responsibility Principle&lt;br /&gt;
| Move both &amp;lt;code&amp;gt;calculate_score&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;process_answers&amp;lt;/code&amp;gt; to the &amp;lt;code&amp;gt;ResponseMap&amp;lt;/code&amp;gt; model, allowing the controller to focus only on handling requests and delegating logic to models.&lt;br /&gt;
| Placeholder for Commit.&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
| &amp;lt;code&amp;gt; find_resource_by_id &amp;lt;/code&amp;gt;&lt;br /&gt;
| Reduce DRY violations&lt;br /&gt;
| Implement this as a shared utility function to eliminate duplicate code and streamline resource retrieval in the controller.&lt;br /&gt;
| Placeholder for Commit.&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
| &amp;lt;code&amp;gt; check_instructor_role &amp;lt;/code&amp;gt;&lt;br /&gt;
| Improve code readability&lt;br /&gt;
| Move the &amp;lt;code&amp;gt;check_instructor_role&amp;lt;/code&amp;gt; method to the &amp;lt;code&amp;gt;Role&amp;lt;/code&amp;gt; model, ensuring that role-related logic resides within the model rather than the controller.&lt;br /&gt;
| Placeholder for Commit.&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
| &amp;lt;code&amp;gt; create_questionnaire &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; build_response_map &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; set_student_quiz &amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
| Improve modularity&lt;br /&gt;
| Transfer these methods from the controller to appropriate model classes, which aligns with the MVC pattern and keeps controller methods concise.&lt;br /&gt;
| Placeholder for Commit.&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
| &amp;lt;code&amp;gt; assign_quiz_to_student &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; submit_answer &amp;lt;/code&amp;gt;&lt;br /&gt;
| Improve code readability&lt;br /&gt;
| Rename these methods to more descriptive names and add comments to explain functionality, making the codebase easier to understand and maintain.&lt;br /&gt;
| ''' Commit: ''' https://github.com/neerua08/reimplementation-back-end/commit/865857ea2dcc0eb73d87cff87e1610bf8ba6d142&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
Section to place our work in (Placeholder).&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
As we are reimplementing this file from scratch, we plan to do some manual testing to verify our code. If time permits, we can add some automated tests. Currently, we plan to use a variety of tools to test our code including:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Postman&amp;lt;/strong&amp;gt; - Test our API calls for the controller to ensure their functionality. The main purpose is to validate the behavior of the controller. This can be done by testing all relevant CRUD operations for quiz creation, submission, and scoring, verifying that the controller responds with appropriate status codes, ensure that all input validations are working as expected including edge cases, and validate that the controller adheres to any role-based access restrictions.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Automated RSpec Tests&amp;lt;/strong&amp;gt; - Test the various methods in our controller to determine if they are functioning as expected. The main purpose is to verify the internal logic of the controller and related methods ensuring they are functioning as expected. This can be done by creating unit tests for methods within the controller especially methods that will be refactored or moved to the model, creating model tests for if any logic is moved to the models to verify that the new functionality works correctly, and create controller tests to ensure that the controller actions work as expected like assigning quizzes to students, submitting answers and recording results, and calculating scores correctly.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Black Box Testing&amp;lt;/strong&amp;gt; - Running through the application to determine if any errors or inconsistent functionalities occur. The main purpose is to ensure the overall functionality of the system from the perspective of an end user.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Test Coverage&amp;lt;/strong&amp;gt; - Using SimpleCov to ensure sufficient test coverage of all key methods and code paths, preventing any untested code from being deployed. We can do this by integrating SimpleCov to measure code coverage across the entire application, create coverage goals and aim for like a high code coverage (e.g., 90% or higher) to ensure all key methods in the controller and related models are thoroughly tested, monitor coverage reports to identify any untested methods or areas of the codebase and add tests for those areas as needed, and refactor based on coverage so if we see significant gaps in test coverage, we can refactor the tests or implementation to ensure better coverage.&lt;br /&gt;
&lt;br /&gt;
We don't plan on adding new scenarios but instead we plan on retesting scenarios: creating a new student quiz, handling invalid student quiz creation, calculating quiz score, assigning quiz to student, submitting quiz answers, and updating a student quiz to see if those scenarios still work when we reimplement student_quizzes_controller.rb as a whole. We might add multiple scenarios as we go.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
# Akhilesh Neeruganti (asneerug@ncsu.edu)&lt;br /&gt;
# Krishna Pallavalli (kpallav@ncsu.edu)&lt;br /&gt;
# Aarya Rajoju (arajoju@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Mentor: Richard Li (rli14@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links == &lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2420._Reimplement_student_quizzes_controller This wiki page] contains detailed information on the previous team's work on this feature.&lt;br /&gt;
* '''Github Repository:''' https://github.com/neerua08/reimplementation-back-end&lt;br /&gt;
* '''Pull Request:''' (placeholder for later)&lt;/div&gt;</summary>
		<author><name>Kpallav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=159376</id>
		<title>CSC/ECE 517 Fall 2024 - E2474. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=159376"/>
		<updated>2024-11-13T02:33:17Z</updated>

		<summary type="html">&lt;p&gt;Kpallav: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is about E2474 Phase 2 for Expertiza.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a [http://rubyonrails.org/ Ruby on Rails] based open source project. The Expertiza project is software for creating reusable learning objects through peer review. It also supports team projects and the submission of almost any document type, including URLs and wiki pages. The goal is to foster team collaboration through projects and provide a robust way to give feedback for these projects.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
For this project, we are expected to reimplement the student_quizzes_controller.rb file in the reimplementation-backend repository of Expertiza. This controller handles scoring, creating, and recording responses for quizzes that are done by students or reviewers for an assignment. The main issue with the previous implementation is that it violates several Rails design principles such as DRY violations. Along with this, various other issues that need to be addressed include code repetition, unclear method comments, and ambiguous variable names. The overall idea of this project is to ensure that we maintain the previous functionality while adhering to the best design practices.&lt;br /&gt;
&lt;br /&gt;
=== Specific Issues ===&lt;br /&gt;
* &amp;lt;strong&amp;gt;Single-Responsibility Principle&amp;lt;/strong&amp;gt; - Various functionalities are done in the student_quizzes_controller.rb that should be deferred to other models or controllers.&lt;br /&gt;
* &amp;lt;strong&amp;gt;DRY Violations&amp;lt;/strong&amp;gt; - There is a good amount of code repetition in the code that could be consolidated to a method.&lt;br /&gt;
* &amp;lt;strong&amp;gt;Unclear Method and Variable Names&amp;lt;/strong&amp;gt; - There are ambiguous methods names and variable names that should be changed. We can also add method comments to help explain functionality.&lt;br /&gt;
&lt;br /&gt;
== Design Plan ==&lt;br /&gt;
=== Single-Responsibility Principle ===&lt;br /&gt;
==== calculate_score ====&lt;br /&gt;
This method gets a response map and then gets the score from that response map. We can instead ask the ResponseMap model to get this information.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474 calculate score.png|600px]]&lt;br /&gt;
==== process_answers ====&lt;br /&gt;
This method attempts to edit the submitted_answer field in response map. This should be done by ResponseMap model instead of our controller. &lt;br /&gt;
&lt;br /&gt;
[[File:E2474 process answer.png|600px]]&lt;br /&gt;
==== check_instructor_role ====&lt;br /&gt;
The goal of this method is to get the role ID of the user to make sure they are an instructor. We want to let the Role model check this instead of checking it in the controller.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474 check instructor role.png|600px]]&lt;br /&gt;
==== Other methods ====&lt;br /&gt;
* Several methods could be moved into the model classes in adherence to MVC architecture. This includes create_questionaire, build_response_map, set_student_quiz, etc.&lt;br /&gt;
&lt;br /&gt;
=== DRY Violations ===&lt;br /&gt;
==== find_resource_by_id ====&lt;br /&gt;
This is a method that is frequently called in this controller. We plan to separate this functionality into a concern or a shared utility function.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474_renaming_variables.png|600px]]&lt;br /&gt;
==== Other methods ====&lt;br /&gt;
* Multiple methods have code repetition that can be reduced in this controller. These include find_or_initialize_response and assign_quiz_to_student.&lt;br /&gt;
&lt;br /&gt;
=== Renaming Method and Variable Names ===&lt;br /&gt;
* Rename the methods for assign_quiz_to_student and submit_answer to clarify their purpose. We can also add method comments to help with this.&lt;br /&gt;
* Refactor variable names to better reflect their purpose. The image below shows that model is not the best name along with find_resource_by_id&lt;br /&gt;
[[File:E2474_renaming_variables.png|600px]]&lt;br /&gt;
&lt;br /&gt;
== Main Methods to Create or Enhance ==&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; !! Method !! Purpose !! Description !! Commit&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
| &amp;lt;code&amp;gt; calculate_score &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; process_answers &amp;lt;/code&amp;gt;&lt;br /&gt;
| Ensure MVC compliance and adherence to the Single-Responsibility Principle&lt;br /&gt;
| Move both &amp;lt;code&amp;gt;calculate_score&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;process_answers&amp;lt;/code&amp;gt; to the &amp;lt;code&amp;gt;ResponseMap&amp;lt;/code&amp;gt; model, allowing the controller to focus only on handling requests and delegating logic to models.&lt;br /&gt;
| Placeholder for Commit.&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
| &amp;lt;code&amp;gt; find_resource_by_id &amp;lt;/code&amp;gt;&lt;br /&gt;
| Reduce DRY violations&lt;br /&gt;
| Implement this as a shared utility function to eliminate duplicate code and streamline resource retrieval in the controller.&lt;br /&gt;
| Placeholder for Commit.&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
| &amp;lt;code&amp;gt; check_instructor_role &amp;lt;/code&amp;gt;&lt;br /&gt;
| Improve code readability&lt;br /&gt;
| Move the &amp;lt;code&amp;gt;check_instructor_role&amp;lt;/code&amp;gt; method to the &amp;lt;code&amp;gt;Role&amp;lt;/code&amp;gt; model, ensuring that role-related logic resides within the model rather than the controller.&lt;br /&gt;
| Placeholder for Commit.&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
| &amp;lt;code&amp;gt; create_questionnaire &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; build_response_map &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; set_student_quiz &amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
| Improve modularity&lt;br /&gt;
| Transfer these methods from the controller to appropriate model classes, which aligns with the MVC pattern and keeps controller methods concise.&lt;br /&gt;
| Placeholder for Commit.&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
| &amp;lt;code&amp;gt; assign_quiz_to_student &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; submit_answer &amp;lt;/code&amp;gt;&lt;br /&gt;
| Improve code readability&lt;br /&gt;
| Rename these methods to more descriptive names and add comments to explain functionality, making the codebase easier to understand and maintain.&lt;br /&gt;
| Placeholder for Commit.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
Section to place our work in (Placeholder).&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
As we are reimplementing this file from scratch, we plan to do some manual testing to verify our code. If time permits, we can add some automated tests. Currently, we plan to use a variety of tools to test our code including:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Postman&amp;lt;/strong&amp;gt; - Test our API calls for the controller to ensure their functionality. The main purpose is to validate the behavior of the controller. This can be done by testing all relevant CRUD operations for quiz creation, submission, and scoring, verifying that the controller responds with appropriate status codes, ensure that all input validations are working as expected including edge cases, and validate that the controller adheres to any role-based access restrictions.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Automated RSpec Tests&amp;lt;/strong&amp;gt; - Test the various methods in our controller to determine if they are functioning as expected. The main purpose is to verify the internal logic of the controller and related methods ensuring they are functioning as expected. This can be done by creating unit tests for methods within the controller especially methods that will be refactored or moved to the model, creating model tests for if any logic is moved to the models to verify that the new functionality works correctly, and create controller tests to ensure that the controller actions work as expected like assigning quizzes to students, submitting answers and recording results, and calculating scores correctly.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Black Box Testing&amp;lt;/strong&amp;gt; - Running through the application to determine if any errors or inconsistent functionalities occur. The main purpose is to ensure the overall functionality of the system from the perspective of an end user.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Test Coverage&amp;lt;/strong&amp;gt; - Using SimpleCov to ensure sufficient test coverage of all key methods and code paths, preventing any untested code from being deployed. We can do this by integrating SimpleCov to measure code coverage across the entire application, create coverage goals and aim for like a high code coverage (e.g., 90% or higher) to ensure all key methods in the controller and related models are thoroughly tested, monitor coverage reports to identify any untested methods or areas of the codebase and add tests for those areas as needed, and refactor based on coverage so if we see significant gaps in test coverage, we can refactor the tests or implementation to ensure better coverage.&lt;br /&gt;
&lt;br /&gt;
We don't plan on adding new scenarios but instead we plan on retesting scenarios: creating a new student quiz, handling invalid student quiz creation, calculating quiz score, assigning quiz to student, submitting quiz answers, and updating a student quiz to see if those scenarios still work when we reimplement student_quizzes_controller.rb as a whole. We might add multiple scenarios as we go.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
# Akhilesh Neeruganti (asneerug@ncsu.edu)&lt;br /&gt;
# Krishna Pallavalli (kpallav@ncsu.edu)&lt;br /&gt;
# Aarya Rajoju (arajoju@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Mentor: Richard Li (rli14@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links == &lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2420._Reimplement_student_quizzes_controller This wiki page] contains detailed information on the previous team's work on this feature.&lt;br /&gt;
* '''Github Repository:''' https://github.com/neerua08/reimplementation-back-end&lt;br /&gt;
* '''Pull Request:''' (placeholder for later)&lt;/div&gt;</summary>
		<author><name>Kpallav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=159366</id>
		<title>CSC/ECE 517 Fall 2024 - E2474. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=159366"/>
		<updated>2024-11-13T02:11:39Z</updated>

		<summary type="html">&lt;p&gt;Kpallav: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is about E2474 Phase 2 for Expertiza.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a [http://rubyonrails.org/ Ruby on Rails] based open source project. The Expertiza project is software for creating reusable learning objects through peer review. It also supports team projects and the submission of almost any document type, including URLs and wiki pages. The goal is to foster team collaboration through projects and provide a robust way to give feedback for these projects.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
For this project, we are expected to reimplement the student_quizzes_controller.rb file in the reimplementation-backend repository of Expertiza. This controller handles scoring, creating, and recording responses for quizzes that are done by students or reviewers for an assignment. The main issue with the previous implementation is that it violates several Rails design principles such as DRY violations. Along with this, various other issues that need to be addressed include code repetition, unclear method comments, and ambiguous variable names. The overall idea of this project is to ensure that we maintain the previous functionality while adhering to the best design practices.&lt;br /&gt;
&lt;br /&gt;
=== Specific Issues ===&lt;br /&gt;
* &amp;lt;strong&amp;gt;Single-Responsibility Principle&amp;lt;/strong&amp;gt; - Various functionalities are done in the student_quizzes_controller.rb that should be deferred to other models or controllers.&lt;br /&gt;
* &amp;lt;strong&amp;gt;DRY Violations&amp;lt;/strong&amp;gt; - There is a good amount of code repetition in the code that could be consolidated to a method.&lt;br /&gt;
* &amp;lt;strong&amp;gt;Unclear Method and Variable Names&amp;lt;/strong&amp;gt; - There are ambiguous methods names and variable names that should be changed. We can also add method comments to help explain functionality.&lt;br /&gt;
&lt;br /&gt;
== Design Plan ==&lt;br /&gt;
=== Single-Responsibility Principle ===&lt;br /&gt;
==== calculate_score ====&lt;br /&gt;
This method gets a response map and then gets the score from that response map. We can instead ask the ResponseMap model to get this information.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474 calculate score.png|600px]]&lt;br /&gt;
==== process_answers ====&lt;br /&gt;
This method attempts to edit the submitted_answer field in response map. This should be done by ResponseMap model instead of our controller. &lt;br /&gt;
&lt;br /&gt;
[[File:E2474 process answer.png|600px]]&lt;br /&gt;
==== check_instructor_role ====&lt;br /&gt;
The goal of this method is to get the role ID of the user to make sure they are an instructor. We want to let the Role model check this instead of checking it in the controller.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474 check instructor role.png|600px]]&lt;br /&gt;
&lt;br /&gt;
* Several methods could be moved into the model classes in adherence to MVC architecture. This includes create_questionaire, build_response_map, set_student_quiz, etc.&lt;br /&gt;
&lt;br /&gt;
=== DRY Violations ===&lt;br /&gt;
* The find_resource_by_id method seems to be used a lot in the controller. We could extract this into a shared utility function or concern.&lt;br /&gt;
* Consolidate shared code into functions to reduce code repetition.&lt;br /&gt;
&lt;br /&gt;
=== Renaming Method and Variable Names ===&lt;br /&gt;
* Rename the methods for assign_quiz_to_student and submit_answer to clarify their purpose. We can also add method comments to help with this.&lt;br /&gt;
* Refactor variable names to better reflect their purpose. The image below shows that model is not the best name along with find_resource_by_id&lt;br /&gt;
[[File:E2474_renaming_variables.png|600px]]&lt;br /&gt;
&lt;br /&gt;
== Main Methods to Create or Enhance ==&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; !! Method !! Purpose !! Description !! Commit&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
| &amp;lt;code&amp;gt; calculate_score &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; process_answers &amp;lt;/code&amp;gt;&lt;br /&gt;
| Ensure MVC compliance and adherence to the Single-Responsibility Principle&lt;br /&gt;
| Move both &amp;lt;code&amp;gt;calculate_score&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;process_answers&amp;lt;/code&amp;gt; to the &amp;lt;code&amp;gt;ResponseMap&amp;lt;/code&amp;gt; model, allowing the controller to focus only on handling requests and delegating logic to models.&lt;br /&gt;
| Placeholder for Commit.&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
| &amp;lt;code&amp;gt; find_resource_by_id &amp;lt;/code&amp;gt;&lt;br /&gt;
| Reduce DRY violations&lt;br /&gt;
| Implement this as a shared utility function to eliminate duplicate code and streamline resource retrieval in the controller.&lt;br /&gt;
| Placeholder for Commit.&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
| &amp;lt;code&amp;gt; check_instructor_role &amp;lt;/code&amp;gt;&lt;br /&gt;
| Improve code readability&lt;br /&gt;
| Move the &amp;lt;code&amp;gt;check_instructor_role&amp;lt;/code&amp;gt; method to the &amp;lt;code&amp;gt;Role&amp;lt;/code&amp;gt; model, ensuring that role-related logic resides within the model rather than the controller.&lt;br /&gt;
| Placeholder for Commit.&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
| &amp;lt;code&amp;gt; create_questionnaire &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; build_response_map &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; set_student_quiz &amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
| Improve modularity&lt;br /&gt;
| Transfer these methods from the controller to appropriate model classes, which aligns with the MVC pattern and keeps controller methods concise.&lt;br /&gt;
| Placeholder for Commit.&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
| &amp;lt;code&amp;gt; assign_quiz_to_student &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; submit_answer &amp;lt;/code&amp;gt;&lt;br /&gt;
| Improve code readability&lt;br /&gt;
| Rename these methods to more descriptive names and add comments to explain functionality, making the codebase easier to understand and maintain.&lt;br /&gt;
| Placeholder for Commit.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
Section to place our work in (Placeholder).&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
As we are reimplementing this file from scratch, we plan to do some manual testing to verify our code. If time permits, we can add some automated tests. Currently, we plan to use a variety of tools to test our code including:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Postman&amp;lt;/strong&amp;gt; - Test our API calls for the controller to ensure their functionality. The main purpose is to validate the behavior of the controller. This can be done by testing all relevant CRUD operations for quiz creation, submission, and scoring, verifying that the controller responds with appropriate status codes, ensure that all input validations are working as expected including edge cases, and validate that the controller adheres to any role-based access restrictions.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Automated RSpec Tests&amp;lt;/strong&amp;gt; - Test the various methods in our controller to determine if they are functioning as expected. The main purpose is to verify the internal logic of the controller and related methods ensuring they are functioning as expected. This can be done by creating unit tests for methods within the controller especially methods that will be refactored or moved to the model, creating model tests for if any logic is moved to the models to verify that the new functionality works correctly, and create controller tests to ensure that the controller actions work as expected like assigning quizzes to students, submitting answers and recording results, and calculating scores correctly.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Black Box Testing&amp;lt;/strong&amp;gt; - Running through the application to determine if any errors or inconsistent functionalities occur. The main purpose is to ensure the overall functionality of the system from the perspective of an end user.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Test Coverage&amp;lt;/strong&amp;gt; - Using SimpleCov to ensure sufficient test coverage of all key methods and code paths, preventing any untested code from being deployed. We can do this by integrating SimpleCov to measure code coverage across the entire application, create coverage goals and aim for like a high code coverage (e.g., 90% or higher) to ensure all key methods in the controller and related models are thoroughly tested, monitor coverage reports to identify any untested methods or areas of the codebase and add tests for those areas as needed, and refactor based on coverage so if we see significant gaps in test coverage, we can refactor the tests or implementation to ensure better coverage.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
# Akhilesh Neeruganti (asneerug@ncsu.edu)&lt;br /&gt;
# Krishna Pallavalli (kpallav@ncsu.edu)&lt;br /&gt;
# Aarya Rajoju (arajoju@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Mentor: Richard Li (rli14@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links == &lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2420._Reimplement_student_quizzes_controller This wiki page] contains detailed information on the previous team's work on this feature.&lt;br /&gt;
* '''Github Repository:''' https://github.com/neerua08/reimplementation-back-end&lt;br /&gt;
* '''Pull Request:''' (placeholder for later)&lt;/div&gt;</summary>
		<author><name>Kpallav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=159363</id>
		<title>CSC/ECE 517 Fall 2024 - E2474. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=159363"/>
		<updated>2024-11-13T02:04:03Z</updated>

		<summary type="html">&lt;p&gt;Kpallav: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is about E2474 Phase 2 for Expertiza.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a [http://rubyonrails.org/ Ruby on Rails] based open source project. The Expertiza project is software for creating reusable learning objects through peer review. It also supports team projects and the submission of almost any document type, including URLs and wiki pages. The goal is to foster team collaboration through projects and provide a robust way to give feedback for these projects.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
For this project, we are expected to reimplement the student_quizzes_controller.rb file in the reimplementation-backend repository of Expertiza. This controller handles scoring, creating, and recording responses for quizzes that are done by students or reviewers for an assignment. The main issue with the previous implementation is that it violates several Rails design principles such as DRY violations. Along with this, various other issues that need to be addressed include code repetition, unclear method comments, and ambiguous variable names. The overall idea of this project is to ensure that we maintain the previous functionality while adhering to the best design practices.&lt;br /&gt;
&lt;br /&gt;
=== Specific Issues ===&lt;br /&gt;
* &amp;lt;strong&amp;gt;Single-Responsibility Principle&amp;lt;/strong&amp;gt; - Various functionalities are done in the student_quizzes_controller.rb that should be deferred to other models or controllers.&lt;br /&gt;
* &amp;lt;strong&amp;gt;DRY Violations&amp;lt;/strong&amp;gt; - There is a good amount of code repetition in the code that could be consolidated to a method.&lt;br /&gt;
* &amp;lt;strong&amp;gt;Unclear Method and Variable Names&amp;lt;/strong&amp;gt; - There are ambiguous methods names and variable names that should be changed. We can also add method comments to help explain functionality.&lt;br /&gt;
&lt;br /&gt;
== Design Plan ==&lt;br /&gt;
=== Single-Responsibility Principle ===&lt;br /&gt;
* Move calculate_score and process_answers methods to ResponseMap model as this should not be done in the controller.&lt;br /&gt;
==== calculate_score ====&lt;br /&gt;
This method gets a response map and then gets the score from that response map. We can instead ask the ResponseMap model to get this information.&lt;br /&gt;
&lt;br /&gt;
[[File:E2474 calculate score.png|600px]]&lt;br /&gt;
==== process_answers ====&lt;br /&gt;
This method attempts to edit the submitted_answer field in response map. This should be done by ResponseMap model instead of our controller. &lt;br /&gt;
&lt;br /&gt;
[[File:E2474 process answer.png|600px]]&lt;br /&gt;
* Currently, the check_instructor_role method finds the role ID directly. We want to defer to the Role model to give us the ID.&lt;br /&gt;
* Several methods could be moved into the model classes in adherence to MVC architecture. This includes create_questionaire, build_response_map, set_student_quiz, etc.&lt;br /&gt;
&lt;br /&gt;
=== DRY Violations ===&lt;br /&gt;
* The find_resource_by_id method seems to be used a lot in the controller. We could extract this into a shared utility function or concern.&lt;br /&gt;
* Consolidate shared code into functions to reduce code repetition.&lt;br /&gt;
&lt;br /&gt;
=== Renaming Method and Variable Names ===&lt;br /&gt;
* Rename the methods for assign_quiz_to_student and submit_answer to clarify their purpose. We can also add method comments to help with this.&lt;br /&gt;
* Refactor variable names to better reflect their purpose. The image below shows that model is not the best name along with find_resource_by_id&lt;br /&gt;
[[File:E2474_renaming_variables.png|600px]]&lt;br /&gt;
&lt;br /&gt;
== Main Methods to Create or Enhance ==&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; !! Method !! Purpose !! Description !! Commit&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
| &amp;lt;code&amp;gt; calculate_score &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; process_answers &amp;lt;/code&amp;gt;&lt;br /&gt;
| Ensure MVC compliance and adherence to the Single-Responsibility Principle&lt;br /&gt;
| Move both &amp;lt;code&amp;gt;calculate_score&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;process_answers&amp;lt;/code&amp;gt; to the &amp;lt;code&amp;gt;ResponseMap&amp;lt;/code&amp;gt; model, allowing the controller to focus only on handling requests and delegating logic to models.&lt;br /&gt;
| Placeholder for Commit.&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
| &amp;lt;code&amp;gt; find_resource_by_id &amp;lt;/code&amp;gt;&lt;br /&gt;
| Reduce DRY violations&lt;br /&gt;
| Implement this as a shared utility function to eliminate duplicate code and streamline resource retrieval in the controller.&lt;br /&gt;
| Placeholder for Commit.&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
| &amp;lt;code&amp;gt; check_instructor_role &amp;lt;/code&amp;gt;&lt;br /&gt;
| Improve code readability&lt;br /&gt;
| Move the &amp;lt;code&amp;gt;check_instructor_role&amp;lt;/code&amp;gt; method to the &amp;lt;code&amp;gt;Role&amp;lt;/code&amp;gt; model, ensuring that role-related logic resides within the model rather than the controller.&lt;br /&gt;
| Placeholder for Commit.&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
| &amp;lt;code&amp;gt; create_questionnaire &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; build_response_map &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; set_student_quiz &amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
| Improve modularity&lt;br /&gt;
| Transfer these methods from the controller to appropriate model classes, which aligns with the MVC pattern and keeps controller methods concise.&lt;br /&gt;
| Placeholder for Commit.&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
| &amp;lt;code&amp;gt; assign_quiz_to_student &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; submit_answer &amp;lt;/code&amp;gt;&lt;br /&gt;
| Improve code readability&lt;br /&gt;
| Rename these methods to more descriptive names and add comments to explain functionality, making the codebase easier to understand and maintain.&lt;br /&gt;
| Placeholder for Commit.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
Section to place our work in (Placeholder).&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
As we are reimplementing this file from scratch, we plan to do some manual testing to verify our code. If time permits, we can add some automated tests. Currently, we plan to use a variety of tools to test our code including:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Postman&amp;lt;/strong&amp;gt; - Test our API calls for the controller to ensure their functionality. The main purpose is to validate the behavior of the controller. This can be done by testing all relevant CRUD operations for quiz creation, submission, and scoring, verifying that the controller responds with appropriate status codes, ensure that all input validations are working as expected including edge cases, and validate that the controller adheres to any role-based access restrictions.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Automated RSpec Tests&amp;lt;/strong&amp;gt; - Test the various methods in our controller to determine if they are functioning as expected. The main purpose is to verify the internal logic of the controller and related methods ensuring they are functioning as expected. This can be done by creating unit tests for methods within the controller especially methods that will be refactored or moved to the model, creating model tests for if any logic is moved to the models to verify that the new functionality works correctly, and create controller tests to ensure that the controller actions work as expected like assigning quizzes to students, submitting answers and recording results, and calculating scores correctly.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Black Box Testing&amp;lt;/strong&amp;gt; - Running through the application to determine if any errors or inconsistent functionalities occur. The main purpose is to ensure the overall functionality of the system from the perspective of an end user.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Test Coverage&amp;lt;/strong&amp;gt; - Using SimpleCov to ensure sufficient test coverage of all key methods and code paths, preventing any untested code from being deployed. We can do this by integrating SimpleCov to measure code coverage across the entire application, create coverage goals and aim for like a high code coverage (e.g., 90% or higher) to ensure all key me controller and related models are thoroughly tested, monitor coverage reports to identify any untested methods or areas of the codebase and add tests for those areas as needed, and refactor based on coverage so if we see significant gaps in test coverage, we can refactor the tests or implementation to ensure better coverage.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
# Akhilesh Neeruganti (asneerug@ncsu.edu)&lt;br /&gt;
# Krishna Pallavalli (kpallav@ncsu.edu)&lt;br /&gt;
# Aarya Rajoju (arajoju@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Mentor: Richard Li (rli14@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links == &lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2420._Reimplement_student_quizzes_controller This wiki page] contains detailed information on the previous team's work on this feature.&lt;br /&gt;
* '''Github Repository:''' https://github.com/neerua08/reimplementation-back-end&lt;br /&gt;
* '''Pull Request:''' (placeholder for later)&lt;/div&gt;</summary>
		<author><name>Kpallav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=159360</id>
		<title>CSC/ECE 517 Fall 2024 - E2474. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=159360"/>
		<updated>2024-11-13T01:58:28Z</updated>

		<summary type="html">&lt;p&gt;Kpallav: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is about E2474 Phase 2 for Expertiza.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a [http://rubyonrails.org/ Ruby on Rails] based open source project. The Expertiza project is software for creating reusable learning objects through peer review. It also supports team projects and the submission of almost any document type, including URLs and wiki pages. The goal is to foster team collaboration through projects and provide a robust way to give feedback for these projects.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
For this project, we are expected to reimplement the student_quizzes_controller.rb file in the reimplementation-backend repository of Expertiza. This controller handles scoring, creating, and recording responses for quizzes that are done by students or reviewers for an assignment. The main issue with the previous implementation is that it violates several Rails design principles such as DRY violations. Along with this, various other issues that need to be addressed include code repetition, unclear method comments, and ambiguous variable names. The overall idea of this project is to ensure that we maintain the previous functionality while adhering to the best design practices.&lt;br /&gt;
&lt;br /&gt;
=== Specific Issues ===&lt;br /&gt;
* &amp;lt;strong&amp;gt;Single-Responsibility Principle&amp;lt;/strong&amp;gt; - Various functionalities are done in the student_quizzes_controller.rb that should be deferred to other models or controllers.&lt;br /&gt;
* &amp;lt;strong&amp;gt;DRY Violations&amp;lt;/strong&amp;gt; - There is a good amount of code repetition in the code that could be consolidated to a method.&lt;br /&gt;
* &amp;lt;strong&amp;gt;Unclear Method and Variable Names&amp;lt;/strong&amp;gt; - There are ambiguous methods names and variable names that should be changed. We can also add method comments to help explain functionality.&lt;br /&gt;
&lt;br /&gt;
== Design Plan ==&lt;br /&gt;
=== Single-Responsibility Principle ===&lt;br /&gt;
* Move calculate_score and process_answers methods to ResponseMap model as this should not be done in the controller.&lt;br /&gt;
* Currently, the check_instructor_role method finds the role ID directly. We want to defer to the Role model to give us the ID.&lt;br /&gt;
* Several methods could be moved into the model classes in adherence to MVC architecture. This includes create_questionaire, build_response_map, set_student_quiz, etc.&lt;br /&gt;
&lt;br /&gt;
=== DRY Violations ===&lt;br /&gt;
* The find_resource_by_id method seems to be used a lot in the controller. We could extract this into a shared utility function or concern.&lt;br /&gt;
* Consolidate shared code into functions to reduce code repetition.&lt;br /&gt;
&lt;br /&gt;
=== Renaming Method and Variable Names ===&lt;br /&gt;
* Rename the methods for assign_quiz_to_student and submit_answer to clarify their purpose. We can also add method comments to help with this.&lt;br /&gt;
* Refactor variable names to better reflect their purpose. The image below shows that model is not the best name along with find_resource_by_id&lt;br /&gt;
[[File:E2474_renaming_variables.png|600px]]&lt;br /&gt;
&lt;br /&gt;
== Main Methods to Create or Enhance ==&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; !! Method !! Purpose !! Description !! Commit&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
| &amp;lt;code&amp;gt; calculate_score &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; process_answers &amp;lt;/code&amp;gt;&lt;br /&gt;
| Ensure MVC compliance and adherence to the Single-Responsibility Principle&lt;br /&gt;
| Move both &amp;lt;code&amp;gt;calculate_score&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;process_answers&amp;lt;/code&amp;gt; to the &amp;lt;code&amp;gt;ResponseMap&amp;lt;/code&amp;gt; model, allowing the controller to focus only on handling requests and delegating logic to models.&lt;br /&gt;
| Placeholder for Commit.&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
| &amp;lt;code&amp;gt; find_resource_by_id &amp;lt;/code&amp;gt;&lt;br /&gt;
| Reduce DRY violations&lt;br /&gt;
| Implement this as a shared utility function to eliminate duplicate code and streamline resource retrieval in the controller.&lt;br /&gt;
| Placeholder for Commit.&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
| &amp;lt;code&amp;gt; check_instructor_role &amp;lt;/code&amp;gt;&lt;br /&gt;
| Improve code readability&lt;br /&gt;
| Move the &amp;lt;code&amp;gt;check_instructor_role&amp;lt;/code&amp;gt; method to the &amp;lt;code&amp;gt;Role&amp;lt;/code&amp;gt; model, ensuring that role-related logic resides within the model rather than the controller.&lt;br /&gt;
| Placeholder for Commit.&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
| &amp;lt;code&amp;gt; create_questionnaire &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; build_response_map &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; set_student_quiz &amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
| Improve modularity&lt;br /&gt;
| Transfer these methods from the controller to appropriate model classes, which aligns with the MVC pattern and keeps controller methods concise.&lt;br /&gt;
| Placeholder for Commit.&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
| &amp;lt;code&amp;gt; assign_quiz_to_student &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; submit_answer &amp;lt;/code&amp;gt;&lt;br /&gt;
| Improve code readability&lt;br /&gt;
| Rename these methods to more descriptive names and add comments to explain functionality, making the codebase easier to understand and maintain.&lt;br /&gt;
| Placeholder for Commit.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
Section to place our work in (Placeholder).&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
As we are reimplementing this file from scratch, we plan to do some manual testing to verify our code. If time permits, we can add some automated tests. Currently, we plan to use a variety of tools to test our code including:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Postman&amp;lt;/strong&amp;gt; - Test our API calls for the controller to ensure their functionality. The main purpose is to validate the behavior of the controller. This can be done by testing all relevant CRUD operations for quiz creation, submission, and scoring, verifying that the controller responds with appropriate status codes, ensure that all input validations are working as expected including edge cases, and validate that the controller adheres to any role-based access restrictions.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Automated RSpec Tests&amp;lt;/strong&amp;gt; - Test the various methods in our controller to determine if they are functioning as expected. The main purpose is to verify the internal logic of the controller and related methods ensuring they are functioning as expected. This can be done by creating unit tests for methods within the controller especially methods that will be refactored or moved to the model, creating model tests for if any logic is moved to the models to verify that the new functionality works correctly, and create controller tests to ensure that the controller actions work as expected like assigning quizzes to students, submitting answers and recording results, and calculating scores correctly.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Black Box Testing&amp;lt;/strong&amp;gt; - Running through the application to determine if any errors or inconsistent functionalities occur. The main purpose is to ensure the overall functionality of the system from the perspective of an end user.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Test Coverage&amp;lt;/strong&amp;gt; - Utilizing SimpleCov to ensure adequate test coverage of all critical methods and paths to prevent untested code from going live. We can do this by integrating SimpleCov to measure code coverage across the entire application, create coverage goals and aim for like a high code coverage (e.g., 90% or higher) to ensure all key me controller and related models are thoroughly tested, monitor coverage reports to identify any untested methods or areas of the codebase and add tests for those areas as needed, and refactor based on coverage so if we see significant gaps in test coverage, we can refactor the tests or implementation to ensure better coverage.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
# Akhilesh Neeruganti (asneerug@ncsu.edu)&lt;br /&gt;
# Krishna Pallavalli (kpallav@ncsu.edu)&lt;br /&gt;
# Aarya Rajoju (arajoju@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Mentor: Richard Li (rli14@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links == &lt;br /&gt;
* [https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2420._Reimplement_student_quizzes_controller This wiki page] contains detailed information on the previous team's work on this feature.&lt;br /&gt;
* '''Github Repository:''' https://github.com/neerua08/reimplementation-back-end&lt;br /&gt;
* '''Pull Request:''' (placeholder for later)&lt;/div&gt;</summary>
		<author><name>Kpallav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=159336</id>
		<title>CSC/ECE 517 Fall 2024 - E2474. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=159336"/>
		<updated>2024-11-13T01:34:00Z</updated>

		<summary type="html">&lt;p&gt;Kpallav: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is about E2474 Phase 2 for Expertiza.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a [http://rubyonrails.org/ Ruby on Rails] based open source project. The Expertiza project is software for creating reusable learning objects through peer review. It also supports team projects and the submission of almost any document type, including URLs and wiki pages. The goal is to foster team collaboration through projects and provide a robust way to give feedback for these projects.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
For this project, we are expected to reimplement the student_quizzes_controller.rb file in the reimplementation-backend repository of Expertiza. This controller handles scoring, creating, and recording responses for quizzes that are done by students or reviewers for an assignment. The main issue with the previous implementation is that it violates several Rails design principles such as DRY violations. Along with this, various other issues that need to be addressed include code repetition, unclear method comments, and ambiguous variable names. The overall idea of this project is to ensure that we maintain the previous functionality while adhering to the best design practices.&lt;br /&gt;
&lt;br /&gt;
=== Specific Issues ===&lt;br /&gt;
* &amp;lt;strong&amp;gt;Single-Responsibility Principle&amp;lt;/strong&amp;gt; - Various functionalities are done in the student_quizzes_controller.rb that should be deferred to other models or controllers.&lt;br /&gt;
* &amp;lt;strong&amp;gt;DRY Violations&amp;lt;/strong&amp;gt; - There is a good amount of code repetition in the code that could be consolidated to a method.&lt;br /&gt;
* &amp;lt;strong&amp;gt;Unclear Method and Variable Names&amp;lt;/strong&amp;gt; - There are ambiguous methods names and variable names that should be changed. We can also add method comments to help explain functionality.&lt;br /&gt;
&lt;br /&gt;
== Design Plan ==&lt;br /&gt;
=== Single-Responsibility Principle ===&lt;br /&gt;
* Move calculate_score and process_answers methods to ResponseMap model as this should not be done in the controller.&lt;br /&gt;
* Currently, the check_instructor_role method finds the role ID directly. We want to defer to the Role model to give us the ID.&lt;br /&gt;
* Several methods could be moved into the model classes in adherence to MVC architecture. This includes create_questionaire, build_response_map, set_student_quiz, etc.&lt;br /&gt;
&lt;br /&gt;
=== DRY Violations ===&lt;br /&gt;
* The find_resource_by_id method seems to be used a lot in the controller. We could extract this into a shared utility function or concern.&lt;br /&gt;
* Consolidate shared code into functions to reduce code repetition.&lt;br /&gt;
&lt;br /&gt;
=== Renaming Method and Variable Names ===&lt;br /&gt;
* Rename the methods for assign_quiz_to_student and submit_answer to clarify their purpose. We can also add method comments to help with this.&lt;br /&gt;
* Refactor variable names to better reflect their purpose. The image below shows that model is not the best name along with find_resource_by_id&lt;br /&gt;
[[File:E2474_renaming_variables.png|600px]]&lt;br /&gt;
&lt;br /&gt;
== Main Methods to Create or Enhance ==&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; !! Method !! Purpose !! Description !! Commit&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
| &amp;lt;code&amp;gt; calculate_score &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; process_answers &amp;lt;/code&amp;gt;&lt;br /&gt;
| Ensure MVC compliance and adherence to the Single-Responsibility Principle&lt;br /&gt;
| Move both &amp;lt;code&amp;gt;calculate_score&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;process_answers&amp;lt;/code&amp;gt; to the &amp;lt;code&amp;gt;ResponseMap&amp;lt;/code&amp;gt; model, allowing the controller to focus only on handling requests and delegating logic to models.&lt;br /&gt;
| Placeholder for Commit.&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
| &amp;lt;code&amp;gt; find_resource_by_id &amp;lt;/code&amp;gt;&lt;br /&gt;
| Reduce DRY violations&lt;br /&gt;
| Implement this as a shared utility function to eliminate duplicate code and streamline resource retrieval in the controller.&lt;br /&gt;
| Placeholder for Commit.&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
| &amp;lt;code&amp;gt; check_instructor_role &amp;lt;/code&amp;gt;&lt;br /&gt;
| Improve code readability&lt;br /&gt;
| Move the &amp;lt;code&amp;gt;check_instructor_role&amp;lt;/code&amp;gt; method to the &amp;lt;code&amp;gt;Role&amp;lt;/code&amp;gt; model, ensuring that role-related logic resides within the model rather than the controller.&lt;br /&gt;
| Placeholder for Commit.&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
| &amp;lt;code&amp;gt; create_questionnaire &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; build_response_map &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; set_student_quiz &amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
| Improve modularity&lt;br /&gt;
| Transfer these methods from the controller to appropriate model classes, which aligns with the MVC pattern and keeps controller methods concise.&lt;br /&gt;
| Placeholder for Commit.&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
| &amp;lt;code&amp;gt; assign_quiz_to_student &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; submit_answer &amp;lt;/code&amp;gt;&lt;br /&gt;
| Improve code readability&lt;br /&gt;
| Rename these methods to more descriptive names and add comments to explain functionality, making the codebase easier to understand and maintain.&lt;br /&gt;
| Placeholder for Commit.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
Section to place our work in (Placeholder).&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
As we are reimplementing this file from scratch, we plan to do some manual testing to verify our code. If time permits, we can add some automated tests. Currently, we plan to use a variety of tools to test our code including:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Postman&amp;lt;/strong&amp;gt; - Test our API calls for the controller to ensure their functionality. The main purpose is to validate the behavior of the controller. This can be done by testing all relevant CRUD operations for quiz creation, submission, and scoring, verifying that the controller responds with appropriate status codes, ensure that all input validations are working as expected including edge cases, and validate that the controller adheres to any role-based access restrictions.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Automated RSpec Tests&amp;lt;/strong&amp;gt; - Test the various methods in our controller to determine if they are functioning as expected. The main purpose is to verify the internal logic of the controller and related methods ensuring they are functioning as expected. This can be done by creating unit tests for methods within the controller especially methods that will be refactored or moved to the model, creating model tests for if any logic is moved to the models to verify that the new functionality works correctly, and create controller tests to ensure that the controller actions work as expected like assigning quizzes to students, submitting answers and recording results, and calculating scores correctly.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Black Box Testing&amp;lt;/strong&amp;gt; - running through the application to determine if any errors or inconsistent functionalities occur. The main purpose is to ensure the overall functionality of the system from the perspective of an end user.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
# Akhilesh Neeruganti (asneerug@ncsu.edu)&lt;br /&gt;
# Krishna Pallavalli (kpallav@ncsu.edu)&lt;br /&gt;
# Aarya Rajoju (arajoju@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Mentor: Richard Li (rli14@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links == &lt;br /&gt;
[https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2420._Reimplement_student_quizzes_controller This wiki page] contains detailed information on the previous team's work on this feature.&lt;br /&gt;
* '''Github Repository:''' https://github.com/neerua08/reimplementation-back-end&lt;/div&gt;</summary>
		<author><name>Kpallav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=159335</id>
		<title>CSC/ECE 517 Fall 2024 - E2474. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=159335"/>
		<updated>2024-11-13T01:32:10Z</updated>

		<summary type="html">&lt;p&gt;Kpallav: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is about E2474 Phase 2 for Expertiza.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a [http://rubyonrails.org/ Ruby on Rails] based open source project. The Expertiza project is software for creating reusable learning objects through peer review. It also supports team projects and the submission of almost any document type, including URLs and wiki pages. The goal is to foster team collaboration through projects and provide a robust way to give feedback for these projects.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
For this project, we are expected to reimplement the student_quizzes_controller.rb file in the reimplementation-backend repository of Expertiza. This controller handles scoring, creating, and recording responses for quizzes that are done by students or reviewers for an assignment. The main issue with the previous implementation is that it violates several Rails design principles such as DRY violations. Along with this, various other issues that need to be addressed include code repetition, unclear method comments, and ambiguous variable names. The overall idea of this project is to ensure that we maintain the previous functionality while adhering to the best design practices.&lt;br /&gt;
&lt;br /&gt;
=== Specific Issues ===&lt;br /&gt;
* &amp;lt;strong&amp;gt;Single-Responsibility Principle&amp;lt;/strong&amp;gt; - Various functionalities are done in the student_quizzes_controller.rb that should be deferred to other models or controllers.&lt;br /&gt;
* &amp;lt;strong&amp;gt;DRY Violations&amp;lt;/strong&amp;gt; - There is a good amount of code repetition in the code that could be consolidated to a method.&lt;br /&gt;
* &amp;lt;strong&amp;gt;Unclear Method and Variable Names&amp;lt;/strong&amp;gt; - There are ambiguous methods names and variable names that should be changed. We can also add method comments to help explain functionality.&lt;br /&gt;
&lt;br /&gt;
== Design Plan ==&lt;br /&gt;
=== Single-Responsibility Principle ===&lt;br /&gt;
* Move calculate_score and process_answers methods to ResponseMap model as this should not be done in the controller.&lt;br /&gt;
* Currently, the check_instructor_role method finds the role ID directly. We want to defer to the Role model to give us the ID.&lt;br /&gt;
* Several methods could be moved into the model classes in adherence to MVC architecture. This includes create_questionaire, build_response_map, set_student_quiz, etc.&lt;br /&gt;
&lt;br /&gt;
=== DRY Violations ===&lt;br /&gt;
* The find_resource_by_id method seems to be used a lot in the controller. We could extract this into a shared utility function or concern.&lt;br /&gt;
* Consolidate shared code into functions to reduce code repetition.&lt;br /&gt;
&lt;br /&gt;
=== Renaming Method and Variable Names ===&lt;br /&gt;
* Rename the methods for assign_quiz_to_student and submit_answer to clarify their purpose. We can also add method comments to help with this.&lt;br /&gt;
* Refactor variable names to better reflect their purpose. The image below shows that model is not the best name along with find_resource_by_id&lt;br /&gt;
[[File:E2474_renaming_variables.png|600px]]&lt;br /&gt;
&lt;br /&gt;
== Main Methods to Create or Enhance ==&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; !! Method !! Purpose !! Description !! Commit&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
| &amp;lt;code&amp;gt; calculate_score &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; process_answers &amp;lt;/code&amp;gt;&lt;br /&gt;
| Ensure MVC compliance and adherence to the Single-Responsibility Principle&lt;br /&gt;
| Move both &amp;lt;code&amp;gt;calculate_score&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;process_answers&amp;lt;/code&amp;gt; to the &amp;lt;code&amp;gt;ResponseMap&amp;lt;/code&amp;gt; model, allowing the controller to focus only on handling requests and delegating logic to models.&lt;br /&gt;
| Placeholder for Commit.&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
| &amp;lt;code&amp;gt; find_resource_by_id &amp;lt;/code&amp;gt;&lt;br /&gt;
| Reduce DRY violations&lt;br /&gt;
| Implement this as a shared utility function to eliminate duplicate code and streamline resource retrieval in the controller.&lt;br /&gt;
| Placeholder for Commit.&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
| &amp;lt;code&amp;gt; check_instructor_role &amp;lt;/code&amp;gt;&lt;br /&gt;
| Improve code readability&lt;br /&gt;
| Move the &amp;lt;code&amp;gt;check_instructor_role&amp;lt;/code&amp;gt; method to the &amp;lt;code&amp;gt;Role&amp;lt;/code&amp;gt; model, ensuring that role-related logic resides within the model rather than the controller.&lt;br /&gt;
| Placeholder for Commit.&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
| &amp;lt;code&amp;gt; create_questionnaire &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; build_response_map &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; set_student_quiz &amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
| Improve modularity&lt;br /&gt;
| Transfer these methods from the controller to appropriate model classes, which aligns with the MVC pattern and keeps controller methods concise.&lt;br /&gt;
| Placeholder for Commit.&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
| &amp;lt;code&amp;gt; assign_quiz_to_student &amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; submit_answer &amp;lt;/code&amp;gt;&lt;br /&gt;
| Improve code readability&lt;br /&gt;
| Rename these methods to more descriptive names and add comments to explain functionality, making the codebase easier to understand and maintain.&lt;br /&gt;
| Placeholder for Commit.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
Section to place our work in (Placeholder).&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
As we are reimplementing this file from scratch, we plan to do some manual testing to verify our code. If time permits, we can add some automated tests. Currently, we plan to use a variety of tools to test our code including:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Postman&amp;lt;/strong&amp;gt; - Test our API calls for the controller to ensure their functionality. The main purpose is to validate the behavior of the controller. This can be done by testing all relevant CRUD operations for quiz creation, submission, and scoring, verifying that the controller responds with appropriate status codes, ensure that all input validations are working as expected including edge cases, and validate that the controller adheres to any role-based access restrictions.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Automated RSpec Tests&amp;lt;/strong&amp;gt; - Test the various methods in our controller to determine if they are functioning as expected. The main purpose is to verify the internal logic of the controller and related methods ensuring they are functioning as expected. This can be done by creating unit tests for methods within the controller especially methods that will be refactored or moved to the model, creating model tests for if any logic is moved to the models to verify that the new functionality works correctly, and create controller tests to ensure that the controller actions work as expected like assigning quizzes to students, submitting answers and recording results, and calculating scores correctly.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Black Box Testing&amp;lt;/strong&amp;gt; - running through the application to determine if any errors or inconsistent functionalities occur. The main purpose is to ensure the overall functionality of the system from the perspective of an end user. &lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
# Akhilesh Neeruganti (asneerug@ncsu.edu)&lt;br /&gt;
# Krishna Pallavalli (kpallav@ncsu.edu)&lt;br /&gt;
# Aarya Rajoju (arajoju@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Mentor: Richard Li (rli14@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links == &lt;br /&gt;
[https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2420._Reimplement_student_quizzes_controller This wiki page] contains detailed information on the previous team's work on this feature.&lt;br /&gt;
* '''Github Repository:''' https://github.com/neerua08/reimplementation-back-end&lt;/div&gt;</summary>
		<author><name>Kpallav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=159313</id>
		<title>CSC/ECE 517 Fall 2024 - E2474. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=159313"/>
		<updated>2024-11-13T01:20:38Z</updated>

		<summary type="html">&lt;p&gt;Kpallav: /* Main Methods to Create or Enhance */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is about E2474 Phase 2 for Expertiza.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a [http://rubyonrails.org/ Ruby on Rails] based open source project. The Expertiza project is software for creating reusable learning objects through peer review. It also supports team projects and the submission of almost any document type, including URLs and wiki pages. The goal is to foster team collaboration through projects and provide a robust way to give feedback for these projects.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
For this project, we are expected to reimplement the student_quizzes_controller.rb file in the reimplementation-backend repository of Expertiza. This controller handles scoring, creating, and recording responses for quizzes that are done by students or reviewers for an assignment. The main issue with the previous implementation is that it violates several Rails design principles such as DRY violations. Along with this, various other issues that need to be addressed include code repetition, unclear method comments, and ambiguous variable names. The overall idea of this project is to ensure that we maintain the previous functionality while adhering to the best design practices.&lt;br /&gt;
&lt;br /&gt;
=== Specific Issues ===&lt;br /&gt;
* &amp;lt;strong&amp;gt;Single-Responsibility Principle&amp;lt;/strong&amp;gt; - Various functionalities are done in the student_quizzes_controller.rb that should be deferred to other models or controllers.&lt;br /&gt;
* &amp;lt;strong&amp;gt;DRY Violations&amp;lt;/strong&amp;gt; - There is a good amount of code repetition in the code that could be consolidated to a method.&lt;br /&gt;
* &amp;lt;strong&amp;gt;Unclear Method and Variable Names&amp;lt;/strong&amp;gt; - There are ambiguous methods names and variable names that should be changed. We can also add method comments to help explain functionality.&lt;br /&gt;
&lt;br /&gt;
== Design Plan ==&lt;br /&gt;
=== Single-Responsibility Principle ===&lt;br /&gt;
This is a consistent issue that is noticed throughout this file. (Add images here)&lt;br /&gt;
&lt;br /&gt;
=== DRY Violations ===&lt;br /&gt;
This is a consistent issue that is noticed throughout this file. (Add images here)&lt;br /&gt;
&lt;br /&gt;
=== Renaming Method and Variable Names ===&lt;br /&gt;
This is a consistent issue that is noticed throughout this file. (Add images here)&lt;br /&gt;
&lt;br /&gt;
== Main Methods to Create or Enhance ==&lt;br /&gt;
Here is an overview of the methods we plan on creating or enhancing and the main rationale behind their implementation as previous code needed to be refactored due to the methods themselves being redundant and we needed to create new methods to help address specific issues in this task.&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; !! Method !! Purpose !! Description !! Commit&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
&amp;lt;code&amp;gt;Placeholder&amp;lt;/code&amp;gt;&lt;br /&gt;
|Placeholder for Method&lt;br /&gt;
|Placeholder for Purpose.&lt;br /&gt;
|Placeholder for Description.&lt;br /&gt;
|Placeholder for Commit.&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
Section to place our work in (Placeholder).&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
As we are reimplementing this file from scratch, we plan to do some manual testing to verify our code. If time permits, we can add some automated tests. Currently, we plan to use a variety of tools to test our code including:&lt;br /&gt;
* &amp;lt;strong&amp;gt;Postman&amp;lt;/strong&amp;gt; - test our API calls for the controller to ensure their functionality&lt;br /&gt;
* &amp;lt;strong&amp;gt;Automated RSpec Tests&amp;lt;/strong&amp;gt; - test the various methods in our controller to determine if they are functioning as expected.&lt;br /&gt;
* &amp;lt;strong&amp;gt;Black Box Testing&amp;lt;/strong&amp;gt; - running through the application to determine if any errors or inconsistent functionalities occur.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
# Akhilesh Neeruganti (asneerug@ncsu.edu)&lt;br /&gt;
# Krishna Pallavalli (kpallav@ncsu.edu)&lt;br /&gt;
# Aarya Rajoju (arajoju@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Mentor: Richard Li (rli14@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links == &lt;br /&gt;
[https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2420._Reimplement_student_quizzes_controller This wiki page] contains detailed information on the previous team's work on this feature.&lt;br /&gt;
* '''Github Repository:''' https://github.com/neerua08/reimplementation-back-end&lt;/div&gt;</summary>
		<author><name>Kpallav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=159310</id>
		<title>CSC/ECE 517 Fall 2024 - E2474. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=159310"/>
		<updated>2024-11-13T01:17:52Z</updated>

		<summary type="html">&lt;p&gt;Kpallav: /* Main Methods to Create or Enhance */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is about E2474 Phase 2 for Expertiza.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a [http://rubyonrails.org/ Ruby on Rails] based open source project. The Expertiza project is software for creating reusable learning objects through peer review. It also supports team projects and the submission of almost any document type, including URLs and wiki pages. The goal is to foster team collaboration through projects and provide a robust way to give feedback for these projects.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
For this project, we are expected to reimplement the student_quizzes_controller.rb file in the reimplementation-backend repository of Expertiza. This controller handles scoring, creating, and recording responses for quizzes that are done by students or reviewers for an assignment. The main issue with the previous implementation is that it violates several Rails design principles such as DRY violations. Along with this, various other issues that need to be addressed include code repetition, unclear method comments, and ambiguous variable names. The overall idea of this project is to ensure that we maintain the previous functionality while adhering to the best design practices.&lt;br /&gt;
&lt;br /&gt;
=== Specific Issues ===&lt;br /&gt;
* Move calculate_score and process_answers methods to ResponseMap model as this should not be done in the controller. These methods violate the Single-Responsibility Principle.&lt;br /&gt;
* Currently, the check_instructor_role method finds the role ID directly. We want to defer to the Role model to give us the ID. This method violates the Single-Responsibility Principle.&lt;br /&gt;
* The find_resource_by_id method seems to be used a lot in the controller. We could extract this into a shared utility function or concern.&lt;br /&gt;
* Rename the methods for assign_quiz_to_student and submit_answer to clarify their purpose. We can also add method comments to help with this.&lt;br /&gt;
* Several methods could be moved into the model classes in adherence to MVC architecture. This includes create_questionaire, build_response_map, set_student_quiz, etc.&lt;br /&gt;
* Some method comments are unclear such as find_resource_by_id and find_or_initialize_response which have method comments that repeat the function name.&lt;br /&gt;
* Consolidate shared code into functions to reduce code repetition.&lt;br /&gt;
* Refactor variable names to better reflect their purpose.&lt;br /&gt;
&lt;br /&gt;
== Design Plan ==&lt;br /&gt;
=== Single-Responsibility Principle ===&lt;br /&gt;
This is a consistent issue that is noticed throughout this file. (Add images here)&lt;br /&gt;
&lt;br /&gt;
=== DRY Violations ===&lt;br /&gt;
This is a consistent issue that is noticed throughout this file. (Add images here)&lt;br /&gt;
&lt;br /&gt;
=== Renaming Method and Variable Names ===&lt;br /&gt;
This is a consistent issue that is noticed throughout this file. (Add images here)&lt;br /&gt;
&lt;br /&gt;
== Main Methods to Create or Enhance ==&lt;br /&gt;
Make table of the changes we made for the design plan.&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; !! Method !! Purpose !! Description !! Commit&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
&amp;lt;code&amp;gt;Placeholder&amp;lt;/code&amp;gt;&lt;br /&gt;
|Placeholder for Method&lt;br /&gt;
|Placeholder for Purpose.&lt;br /&gt;
|Placeholder for Description.&lt;br /&gt;
|Placeholder for Commit.&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
Section to place our work in (Placeholder).&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
As we are reimplementing this file from scratch, we plan to do some manual testing to verify our code. If time permits, we can add some automated tests. Currently, we plan to use a variety of tools to test our code including:&lt;br /&gt;
* &amp;lt;strong&amp;gt;Postman&amp;lt;/strong&amp;gt; - test our API calls for the controller to ensure their functionality&lt;br /&gt;
* &amp;lt;strong&amp;gt;Automated RSpec Tests&amp;lt;/strong&amp;gt; - test the various methods in our controller to determine if they are functioning as expected.&lt;br /&gt;
* &amp;lt;strong&amp;gt;Black Box Testing&amp;lt;/strong&amp;gt; - running through the application to determine if any errors or inconsistent functionalities occur.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
# Akhilesh Neeruganti (asneerug@ncsu.edu)&lt;br /&gt;
# Krishna Pallavalli (kpallav@ncsu.edu)&lt;br /&gt;
# Aarya Rajoju (arajoju@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Mentor: Richard Li (rli14@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links == &lt;br /&gt;
[https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2420._Reimplement_student_quizzes_controller This wiki page] contains detailed information on the previous team's work on this feature.&lt;br /&gt;
* '''Github Repository:''' https://github.com/neerua08/reimplementation-back-end&lt;/div&gt;</summary>
		<author><name>Kpallav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=159308</id>
		<title>CSC/ECE 517 Fall 2024 - E2474. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=159308"/>
		<updated>2024-11-13T01:16:16Z</updated>

		<summary type="html">&lt;p&gt;Kpallav: /* New and enhanced methods */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is about E2474 Phase 2 for Expertiza.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a [http://rubyonrails.org/ Ruby on Rails] based open source project. The Expertiza project is software for creating reusable learning objects through peer review. It also supports team projects and the submission of almost any document type, including URLs and wiki pages. The goal is to foster team collaboration through projects and provide a robust way to give feedback for these projects.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
For this project, we are expected to reimplement the student_quizzes_controller.rb file in the reimplementation-backend repository of Expertiza. This controller handles scoring, creating, and recording responses for quizzes that are done by students or reviewers for an assignment. The main issue with the previous implementation is that it violates several Rails design principles such as DRY violations. Along with this, various other issues that need to be addressed include code repetition, unclear method comments, and ambiguous variable names. The overall idea of this project is to ensure that we maintain the previous functionality while adhering to the best design practices.&lt;br /&gt;
&lt;br /&gt;
=== Specific Issues ===&lt;br /&gt;
* Move calculate_score and process_answers methods to ResponseMap model as this should not be done in the controller. These methods violate the Single-Responsibility Principle.&lt;br /&gt;
* Currently, the check_instructor_role method finds the role ID directly. We want to defer to the Role model to give us the ID. This method violates the Single-Responsibility Principle.&lt;br /&gt;
* The find_resource_by_id method seems to be used a lot in the controller. We could extract this into a shared utility function or concern.&lt;br /&gt;
* Rename the methods for assign_quiz_to_student and submit_answer to clarify their purpose. We can also add method comments to help with this.&lt;br /&gt;
* Several methods could be moved into the model classes in adherence to MVC architecture. This includes create_questionaire, build_response_map, set_student_quiz, etc.&lt;br /&gt;
* Some method comments are unclear such as find_resource_by_id and find_or_initialize_response which have method comments that repeat the function name.&lt;br /&gt;
* Consolidate shared code into functions to reduce code repetition.&lt;br /&gt;
* Refactor variable names to better reflect their purpose.&lt;br /&gt;
&lt;br /&gt;
== Design Plan ==&lt;br /&gt;
=== Single-Responsibility Principle ===&lt;br /&gt;
This is a consistent issue that is noticed throughout this file. (Add images here)&lt;br /&gt;
&lt;br /&gt;
=== DRY Violations ===&lt;br /&gt;
This is a consistent issue that is noticed throughout this file. (Add images here)&lt;br /&gt;
&lt;br /&gt;
=== Renaming Method and Variable Names ===&lt;br /&gt;
This is a consistent issue that is noticed throughout this file. (Add images here)&lt;br /&gt;
&lt;br /&gt;
== Main Methods to Create or Enhance ==&lt;br /&gt;
Make table of the changes we made for the design plan.&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; !! Method !! Purpose !! Description !! Commit&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
&amp;lt;code&amp;gt;Placeholder&amp;lt;/code&amp;gt;&lt;br /&gt;
|Placeholder for Purpose.&lt;br /&gt;
|Placeholder for Description.&lt;br /&gt;
|Placeholder for Commit.&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
Section to place our work in (Placeholder).&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
As we are reimplementing this file from scratch, we plan to do some manual testing to verify our code. If time permits, we can add some automated tests. Currently, we plan to use a variety of tools to test our code including:&lt;br /&gt;
* &amp;lt;strong&amp;gt;Postman&amp;lt;/strong&amp;gt; - test our API calls for the controller to ensure their functionality&lt;br /&gt;
* &amp;lt;strong&amp;gt;Automated RSpec Tests&amp;lt;/strong&amp;gt; - test the various methods in our controller to determine if they are functioning as expected.&lt;br /&gt;
* &amp;lt;strong&amp;gt;Black Box Testing&amp;lt;/strong&amp;gt; - running through the application to determine if any errors or inconsistent functionalities occur.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
# Akhilesh Neeruganti (asneerug@ncsu.edu)&lt;br /&gt;
# Krishna Pallavalli (kpallav@ncsu.edu)&lt;br /&gt;
# Aarya Rajoju (arajoju@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Mentor: Richard Li (rli14@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links == &lt;br /&gt;
[https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2420._Reimplement_student_quizzes_controller This wiki page] contains detailed information on the previous team's work on this feature.&lt;br /&gt;
* '''Github Repository:''' https://github.com/neerua08/reimplementation-back-end&lt;/div&gt;</summary>
		<author><name>Kpallav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=159289</id>
		<title>CSC/ECE 517 Fall 2024 - E2474. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=159289"/>
		<updated>2024-11-13T01:06:49Z</updated>

		<summary type="html">&lt;p&gt;Kpallav: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is about E2474 Phase 2 for Expertiza.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a [http://rubyonrails.org/ Ruby on Rails] based open source project. The Expertiza project is software for creating reusable learning objects through peer review. It also supports team projects and the submission of almost any document type, including URLs and wiki pages. The goal is to foster team collaboration through projects and provide a robust way to give feedback for these projects.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
For this project, we are expected to reimplement the student_quizzes_controller.rb file in the reimplementation-backend repository of Expertiza. This controller handles scoring, creating, and recording responses for quizzes that are done by students or reviewers for an assignment. The main issue with the previous implementation is that it violates several Rails design principles such as DRY violations. Along with this, various other issues that need to be addressed include code repetition, unclear method comments, and ambiguous variable names. The overall idea of this project is to ensure that we maintain the previous functionality while adhering to the best design practices.&lt;br /&gt;
&lt;br /&gt;
=== Specific Issues ===&lt;br /&gt;
* Move calculate_score and process_answers methods to ResponseMap model as this should not be done in the controller. These methods violate the Single-Responsibility Principle.&lt;br /&gt;
* Currently, the check_instructor_role method finds the role ID directly. We want to defer to the Role model to give us the ID. This method violates the Single-Responsibility Principle.&lt;br /&gt;
* The find_resource_by_id method seems to be used a lot in the controller. We could extract this into a shared utility function or concern.&lt;br /&gt;
* Rename the methods for assign_quiz_to_student and submit_answer to clarify their purpose. We can also add method comments to help with this.&lt;br /&gt;
* Several methods could be moved into the model classes in adherence to MVC architecture. This includes create_questionaire, build_response_map, set_student_quiz, etc.&lt;br /&gt;
* Some method comments are unclear such as find_resource_by_id and find_or_initialize_response which have method comments that repeat the function name.&lt;br /&gt;
* Consolidate shared code into functions to reduce code repetition.&lt;br /&gt;
* Refactor variable names to better reflect their purpose.&lt;br /&gt;
&lt;br /&gt;
== Design Plan ==&lt;br /&gt;
Need to add design strategy here.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== New and enhanced methods ==&lt;br /&gt;
Make table of the changes we made for the design plan.&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
Section to place our work in (Placeholder).&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
As we are reimplementing this file from scratch, we plan to do some manual testing to verify our code. If time permits, we can add some automated tests. Currently, we plan to use a variety of tools to test our code including:&lt;br /&gt;
* &amp;lt;strong&amp;gt;Postman&amp;lt;/strong&amp;gt; - test our API calls for the controller to ensure their functionality&lt;br /&gt;
* &amp;lt;strong&amp;gt;Automated RSpec Tests&amp;lt;/strong&amp;gt; - test the various methods in our controller to determine if they are functioning as expected.&lt;br /&gt;
* &amp;lt;strong&amp;gt;Black Box Testing&amp;lt;/strong&amp;gt; - running through the application to determine if any errors or inconsistent functionalities occur.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
# Akhilesh Neeruganti (asneerug@ncsu.edu)&lt;br /&gt;
# Krishna Pallavalli (kpallav@ncsu.edu)&lt;br /&gt;
# Aarya Rajoju (arajoju@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Mentor: Richard Li (rli14@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links == &lt;br /&gt;
[https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2420._Reimplement_student_quizzes_controller This wiki page] contains detailed information on the previous team's work on this feature.&lt;br /&gt;
* '''Github Repository:''' https://github.com/neerua08/reimplementation-back-end&lt;/div&gt;</summary>
		<author><name>Kpallav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=159271</id>
		<title>CSC/ECE 517 Fall 2024 - E2474. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=159271"/>
		<updated>2024-11-13T00:57:20Z</updated>

		<summary type="html">&lt;p&gt;Kpallav: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is about E2474 Phase 2 for Expertiza.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a [http://rubyonrails.org/ Ruby on Rails] based open source project. The Expertiza project is software for creating reusable learning objects through peer review. It also supports team projects and the submission of almost any document type, including URLs and wiki pages. The goal is to foster team collaboration through projects and provide a robust way to give feedback for these projects.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
For this project, we are expected to reimplement the student_quizzes_controller.rb file in the reimplementation-backend repository of Expertiza. This controller handles scoring, creating, and recording responses for quizzes that are done by students or reviewers for an assignment. The main issue with the previous implementation is that it violates several Rails design principles such as DRY violations. Along with this, various other issues that need to be addressed include code repetition, unclear method comments, and ambiguous variable names. The overall idea of this project is to ensure that we maintain the previous functionality while adhering to the best design practices.&lt;br /&gt;
&lt;br /&gt;
=== Specific Issues ===&lt;br /&gt;
* Move calculate_score and process_answers methods to ResponseMap model as this should not be done in the controller. These methods violate the Single-Responsibility Principle.&lt;br /&gt;
* Currently, the check_instructor_role method finds the role ID directly. We want to defer to the Role model to give us the ID. This method violates the Single-Responsibility Principle.&lt;br /&gt;
* The find_resource_by_id method seems to be used a lot in the controller. We could extract this into a shared utility function or concern.&lt;br /&gt;
* Rename the methods for assign_quiz_to_student and submit_answer to clarify their purpose. We can also add method comments to help with this.&lt;br /&gt;
* Several methods could be moved into the model classes in adherence to MVC architecture. This includes create_questionaire, build_response_map, set_student_quiz, etc.&lt;br /&gt;
* Some method comments are unclear such as find_resource_by_id and find_or_initialize_response which have method comments that repeat the function name.&lt;br /&gt;
* Consolidate shared code into functions to reduce code repetition.&lt;br /&gt;
* Refactor variable names to better reflect their purpose.&lt;br /&gt;
&lt;br /&gt;
== Design Plan ==&lt;br /&gt;
Need to add design strategy here.&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
Section to place our work in (Placeholder).&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
As we are reimplementing this file from scratch, we plan to do some manual testing to verify our code. If time permits, we can add some automated tests. Currently, we plan to use a variety of tools to test our code including:&lt;br /&gt;
* &amp;lt;strong&amp;gt;Postman&amp;lt;/strong&amp;gt; - test our API calls for the controller to ensure their functionality&lt;br /&gt;
* &amp;lt;strong&amp;gt;Automated RSpec Tests&amp;lt;/strong&amp;gt; - test the various methods in our controller to determine if they are functioning as expected.&lt;br /&gt;
* &amp;lt;strong&amp;gt;Black Box Testing&amp;lt;/strong&amp;gt; - running through the application to determine if any errors or inconsistent functionalities occur.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
# Akhilesh Neeruganti (asneerug@ncsu.edu)&lt;br /&gt;
# Krishna Pallavalli (kpallav@ncsu.edu)&lt;br /&gt;
# Aarya Rajoju (arajoju@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Mentor: Richard Li (rli14@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links == &lt;br /&gt;
[https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2420._Reimplement_student_quizzes_controller This wiki page] contains detailed information on the previous team's work on this feature.&lt;br /&gt;
* '''Github Repository:''' https://github.com/neerua08/reimplementation-back-end&lt;/div&gt;</summary>
		<author><name>Kpallav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=159261</id>
		<title>CSC/ECE 517 Fall 2024 - E2474. Reimplement student quizzes controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2474._Reimplement_student_quizzes_controller.rb&amp;diff=159261"/>
		<updated>2024-11-13T00:48:30Z</updated>

		<summary type="html">&lt;p&gt;Kpallav: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is about E2474 Phase 2 for Expertiza.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a [http://rubyonrails.org/ Ruby on Rails] based open source project. The Expertiza project is software for creating reusable learning objects through peer review. It also supports team projects and the submission of almost any document type, including URLs and wiki pages. The goal is to foster team collaboration through projects and provide a robust way to give feedback for these projects.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
For this project, we are expected to reimplement the student_quizzes_controller.rb file in the reimplementation-backend repository of Expertiza. This controller handles scoring, creating, and recording responses for quizzes that are done by students or reviewers for an assignment. The main issue with the previous implementation is that it violates several Rails design principles such as DRY violations. Along with this, various other issues that need to be addressed include code repetition, unclear method comments, and ambiguous variable names. The overall idea of this project is to ensure that we maintain the previous functionality while adhering to the best design practices.&lt;br /&gt;
&lt;br /&gt;
=== Specific Issues ===&lt;br /&gt;
* Move calculate_score and process_answers methods to ResponseMap model as this should not be done in the controller. These methods violate the Single-Responsibility Principle.&lt;br /&gt;
* Currently, the check_instructor_role method finds the role ID directly. We want to defer to the Role model to give us the ID. This method violates the Single-Responsibility Principle.&lt;br /&gt;
* The find_resource_by_id method seems to be used a lot in the controller. We could extract this into a shared utility function or concern.&lt;br /&gt;
* Rename the methods for assign_quiz_to_student and submit_answer to clarify their purpose. We can also add method comments to help with this.&lt;br /&gt;
* Several methods could be moved into the model classes in adherence to MVC architecture. This includes create_questionaire, build_response_map, set_student_quiz, etc.&lt;br /&gt;
* Some method comments are unclear such as find_resource_by_id and find_or_initialize_response which have method comments that repeat the function name.&lt;br /&gt;
* Consolidate shared code into functions to reduce code repetition.&lt;br /&gt;
* Refactor variable names to better reflect their purpose.&lt;br /&gt;
&lt;br /&gt;
== Design Plan ==&lt;br /&gt;
Need to add design strategy here.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
As we are reimplementing this file from scratch, we plan to do some manual testing to verify our code. If time permits, we can add some automated tests. Currently, we plan to use a variety of tools to test our code including:&lt;br /&gt;
* &amp;lt;strong&amp;gt;Postman&amp;lt;/strong&amp;gt; - test our API calls for the controller to ensure their functionality&lt;br /&gt;
* &amp;lt;strong&amp;gt;Automated RSpec Tests&amp;lt;/strong&amp;gt; - test the various methods in our controller to determine if they are functioning as expected.&lt;br /&gt;
* &amp;lt;strong&amp;gt;Black Box Testing&amp;lt;/strong&amp;gt; - running through the application to determine if any errors or inconsistent functionalities occur.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
# Akhilesh Neeruganti (asneerug@ncsu.edu)&lt;br /&gt;
# Krishna Pallavalli (kpallav@ncsu.edu)&lt;br /&gt;
# Aarya Rajoju (arajoju@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Mentor: Richard Li (rli14@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links == &lt;br /&gt;
[https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2420._Reimplement_student_quizzes_controller This wiki page] contains detailed information on the previous team's work on this feature.&lt;br /&gt;
* '''Github Repository:''' https://github.com/neerua08/reimplementation-back-end&lt;/div&gt;</summary>
		<author><name>Kpallav</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2453._Refactor_review_mapping_helper.rb&amp;diff=158482</id>
		<title>CSC/ECE 517 Fall 2024 - E2453. Refactor review mapping helper.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2024_-_E2453._Refactor_review_mapping_helper.rb&amp;diff=158482"/>
		<updated>2024-10-30T03:31:14Z</updated>

		<summary type="html">&lt;p&gt;Kpallav: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is about E2453 for Expertiza.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
Expertiza is software that uses Ruby on Rails to manage a website for managing assignments, teams, submissions, and reviews. This web application is managed by students and faculty at NC State, offering instructors full control over class assignments. Expertiza supports a variety of functions, including topic creation, group assignments, and peer review, making it a robust tool for handling diverse types of assignments. For a complete overview of Expertiza's capabilities, visit the Expertiza wiki.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
The review_mapping_helper.rb file has methods that exceed the limit on lines of code Also, it is missing proper comments for each functionality. The cyclomatic complexity of most of the methods is way too high as per the standard defined in Code Climate. The scope of this project is to refactor the review_mapping_helper.rb to make it more readable and reduce complexity. This file is generally used to hold helper methods for review frontend pages.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
=== Complexity ===&lt;br /&gt;
There are several methods that exceed cyclomatic complexity and ABC complexity. This is the main priority for our refactoring.&lt;br /&gt;
&lt;br /&gt;
=== Refactor for readability ===&lt;br /&gt;
* Several methods have confusing variable names and method names&lt;br /&gt;
* Some comments are unnecessary or are ambiguous.&lt;br /&gt;
* Some inconsistent formatting in the code.&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
Only three files were changed as this file is not called in many other places. These are:&lt;br /&gt;
* app/helpers/review_mapping_helpers.rb&lt;br /&gt;
* app/views/reports/_review_report.html.erb&lt;br /&gt;
* spec/helpers/review_mapping_helper_spec.rb&lt;br /&gt;
&lt;br /&gt;
== Changes Made ==&lt;br /&gt;
&lt;br /&gt;
=== Cyclomatic Complexity ===&lt;br /&gt;
&lt;br /&gt;
==== get_team_color ====&lt;br /&gt;
&lt;br /&gt;
Old code:&lt;br /&gt;
&lt;br /&gt;
[[File:E2453_old_get_team_color.png|700px]]&lt;br /&gt;
&lt;br /&gt;
New code:&lt;br /&gt;
&lt;br /&gt;
[[File:E2453_new_get_team_color.png|700px]]&lt;br /&gt;
&lt;br /&gt;
This code exceeded cyclomatic complexity due to the nesting if statements. We can split the if statements into separate methods as they represent their own functionalities. This also reduces the ABC complexity as well.&lt;br /&gt;
&lt;br /&gt;
==== check_submission_state ====&lt;br /&gt;
&lt;br /&gt;
Old code:&lt;br /&gt;
&lt;br /&gt;
[[File:E2453_old_check_submission_state.png|700px]]&lt;br /&gt;
&lt;br /&gt;
New code:&lt;br /&gt;
&lt;br /&gt;
[[File:E2453_new_check_submission_state.png|700px]]&lt;br /&gt;
&lt;br /&gt;
This code exceeded cyclomatic complexity due to the nesting if statements. Along with this, the conditional is complicated enough to be its own method. We can split this into many methods to ensure the method is not doing too much.&lt;br /&gt;
&lt;br /&gt;
Along with this, this method has 5 parameters, which is too much. We removed the colors parameter and decided to use colors outside the method so that we could push strings into it.&lt;br /&gt;
&lt;br /&gt;
It also had an ABC complexity of 16.79 so the method split reduces this.&lt;br /&gt;
&lt;br /&gt;
=== ABC Complexity ===&lt;br /&gt;
&lt;br /&gt;
==== list_hyperlink_submission ====&lt;br /&gt;
&lt;br /&gt;
Old code:&lt;br /&gt;
&lt;br /&gt;
[[File:E2453_old_list_hyperlink_submission.png|700px]]&lt;br /&gt;
&lt;br /&gt;
New code:&lt;br /&gt;
&lt;br /&gt;
[[File:E2453_new_list_hyperlink_submission.png|700px]]&lt;br /&gt;
&lt;br /&gt;
This code exceeded ABC complexity. Looking at this method, we can see that it is doing several functionalities at once. We can separate this into multiple methods for readability and reduced complexity.&lt;br /&gt;
&lt;br /&gt;
==== sort_reviewer_by_review_volume_desc ====&lt;br /&gt;
&lt;br /&gt;
Old code:&lt;br /&gt;
&lt;br /&gt;
[[File:E2453_old_sort_reviewer_by_review_volume_desc.png|700px]]&lt;br /&gt;
&lt;br /&gt;
New code:&lt;br /&gt;
&lt;br /&gt;
[[File:E2453_new_sort_reviewer_by_review_volume_desc.png|700px]]&lt;br /&gt;
&lt;br /&gt;
This method was the hardest to refactor as it was doing too much in one method. Initially, this had an ABC Complexity of 32.7, which is very high. We split the functionalities for getting volumes for each review and the average volume into its own private methods. This significantly reduced the ABC complexity of this method.&lt;br /&gt;
&lt;br /&gt;
=== Renaming Variable Names and Methods ===&lt;br /&gt;
Several variables were ambiguously named. For example, rspan was supposed to represent the row number, but this is not obvious so we changed it to row_number. &lt;br /&gt;
&lt;br /&gt;
Another example is using r to represent a reviewer. We change this to reviewer as it is more readable.&lt;br /&gt;
&lt;br /&gt;
Along with this, we changed various method names as they can be ambiguous in terms of the intended function of these methods.&lt;br /&gt;
&lt;br /&gt;
=== Consistent Formatting ===&lt;br /&gt;
There was a big portion of code that was indented inconsistently compared to the rest of the code. This was fixed.&lt;br /&gt;
&lt;br /&gt;
Also, there was inconsitent spacing between methods, so we changed this spacing to be one line between each method.&lt;br /&gt;
&lt;br /&gt;
=== Reformatting Test File ===&lt;br /&gt;
As we changed method names, we had to refactor the test file to match the new method names. &lt;br /&gt;
&lt;br /&gt;
Along with this, get_team_color had a massive change in output, so we had to change the test to match the new version of the method.&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
All of the tests pass for helpers. This is shown in the image below. We did not significantly alter the testing from the previous iteration.&lt;br /&gt;
&lt;br /&gt;
[[File:E2453_testing.png]]&lt;br /&gt;
&lt;br /&gt;
== Future Scope ==&lt;br /&gt;
&lt;br /&gt;
# spec/helpers/review_mapping_helper_spec.rb has repetitive code that can be combined into a method&lt;br /&gt;
# There are parts of review_mapping_helper with long JSON data that exceeds line count. This could be migrated to a JSON file instead of storing it in the code. One example of this is the data variable from method display_volume_metric_chart.&lt;br /&gt;
# In review_mapping_helper.rb, there is a method get_css_style_for_calibration_report that should be moved to a different file.&lt;br /&gt;
# review_mapping_helper.rb can always use more refactoring for variable and method names&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
# Akhilesh Neeruganti (asneerug@ncsu.edu)&lt;br /&gt;
# Krishna Pallavalli (kpallav@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Mentor: Richard Li (rli14@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links == &lt;br /&gt;
Github Pull Request - https://github.com/expertiza/expertiza/pull/2886&lt;br /&gt;
&lt;br /&gt;
Github Repo - https://github.com/neerua08/Expertiza_Refactor_ReviewMappingHelper&lt;br /&gt;
&lt;br /&gt;
[https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2024_-_E2406_Refactor_review_mapping_helper.rb] contains detailed information on the previous team's work on this feature.&lt;/div&gt;</summary>
		<author><name>Kpallav</name></author>
	</entry>
</feed>