<?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=Cdandre5</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=Cdandre5"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Cdandre5"/>
	<updated>2026-05-08T15:56:24Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164565</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164565"/>
		<updated>2025-04-22T12:56:55Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* UI and API Integration Tests */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of this project is to integrate the frontend of the grades view page with the reimplemented '''''grades_controller.rb (E2510)''''' backend in Expertiza, ensuring a seamless connection between both layers. This integration involves refining the interaction between the UI and backend while adhering to best design principles such as modularity, maintainability, and scalability. The grades_controller.rb is responsible for managing grading functionality, allowing instructors to view and modify assignment grades while enabling students to access their evaluations. By following SOLID and DRY principles, this reimplementation enhances code clarity, reduces redundancy, and improves overall system efficiency.&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
The &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; is responsible for managing and delivering grading data to users in the Expertiza system. It enables instructors to view, calculate, and release grades to students, while also allowing students to view feedback and scores for assignments. The controller plays an important role in coordinating backend logic for reviews and grade visibility.&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
The previous implementation successfully created a functional frontend UI page in Expertiza, addressing design inconsistencies and improving usability. It introduced a visually cohesive interface with an intuitive layout, enhanced responsiveness, and improved information display, allowing users to navigate grading data more efficiently. However, the interface was populated using dummy data, limiting its practical use. This reimplemented UI will utilize real data from the database (that has been populated in this round), ensuring that grading information is dynamically retrieved and displayed accurately through JSON objects. Additionally, this phase will connect the redesigned frontend with some new components in the grades_controller.rb. Specifically, the GET functions in the grades_controller were reimplemented to return JSON objects (instead of instance variables) that could be accessed via an API call. Thus, this new implementation ensures seamless communication between the UI and backend while adhering to best design practices for maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
This project focuses on integrating the frontend of the grades view page with the reimplemented '''grades_controller.rb (E2510)''' backend in Expertiza. This integration requires modifications to both the frontend and backend to establish a seamless connection, ensuring that grading data is dynamically retrieved and displayed accurately. By adhering to best design principles such as modularity, maintainability, and scalability, the implementation will enhance system efficiency and long-term usability. Key improvements include replacing dummy data with real database values, refining data flow between the UI and backend, and optimizing API interactions for better performance. These enhancements will create a more intuitive and reliable grading system, providing a seamless experience for instructors and students while maintaining a well-structured and adaptable codebase for future development.&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
# '''Establish a Robust Connection Between the Frontend and Backend''': Ensure smooth data retrieval and updates between the grades view page and the backend by integrating dynamic data through API calls, replacing the current hardcoded dummy data.&lt;br /&gt;
# '''Define and Implement Clear API Endpoints''': Create well-structured API endpoints in grades_controller.rb for retrieving and displaying grades, ensuring they return appropriate data based on user roles (students, instructors, TAs) and maintain role-based access controls.&lt;br /&gt;
# '''Dynamic Data Integration''': Modify the frontend to consume real-time data fetched from the backend, ensuring an intuitive and responsive UI that reflects the actual grading information. &lt;br /&gt;
# '''Reimplement Frontend and Backend Components''': Reimplement both the frontend and backend as necessary to align with SOLID and DRY principles, ensuring modularity, maintainability, and scalability. This includes eliminating redundant logic and optimizing code for better readability.&lt;br /&gt;
# '''Implement Proper Permission Checks''': Ensure that only authorized users can access grade information by implementing robust privilege checks and ensuring that the data is securely accessible to students, instructors, and TAs based on their roles.&lt;br /&gt;
# '''Optimize Database Queries and API Responses''': Enhance the efficiency of database queries and API responses to reduce unnecessary load and ensure that data is retrieved and displayed promptly.&lt;br /&gt;
# '''Testing and Validation''': Implement comprehensive unit and integration tests to verify the correctness of data flow, UI interactions, and role-based access controls, ensuring that the system functions correctly and securely.&lt;br /&gt;
&lt;br /&gt;
=Reimplementation Plan=&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populated data with the appropriate HTTP GET and HTTP POST calls. This shift is necessary to ensure that our application reflects real-time data from the backend rather than relying on static or hardcoded values, which can quickly become outdated or inconsistent. It also enables better scalability and maintainability, as changes to the data only need to be made in the backend, without requiring manual updates in the frontend code.&lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
'''Author Feedback''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
'''Heatmap Data''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
'''Team-mate Data''':&lt;br /&gt;
   {&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The current implementation caters to the backend for a Ruby-embedded front-end, where data is rendered server-side and passed directly into the view. We need to update the APIs to return data in a format that can be consumed by the React UI, typically JSON. This shift is essential to decouple the front-end from the server-side rendering logic, allowing for a more interactive and dynamic user experience. By transitioning to a React-based interface, we gain better control over UI state and responsiveness, while also aligning with modern web development practices. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and instead return plain JSON objects using render json: in the response. This change is necessary to align with a frontend architecture that uses React or another JavaScript framework, which expects structured data from the backend in JSON format rather than relying on server-rendered templates. By shifting to JSON responses, we enable cleaner API endpoints, facilitate easier testing and debugging, and support a more maintainable, decoupled frontend-backend integration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
  1.1. Students&lt;br /&gt;
  1.2. Teams&lt;br /&gt;
  1.3. TA&lt;br /&gt;
  1.4. Instructir&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
  2.1 assignments&lt;br /&gt;
  2.2 assignment_questionnaire&lt;br /&gt;
  2.3 questionnaires&lt;br /&gt;
  2.4 participants&lt;br /&gt;
  2.5 signed_up_teams&lt;br /&gt;
  2.6 teams_users&lt;br /&gt;
  2.9 questions&lt;br /&gt;
  2.10 users&lt;br /&gt;
  2.11 teams&lt;br /&gt;
  2.12 sign_up_topics&lt;br /&gt;
  2.13 response_maps&lt;br /&gt;
  2.14 responses&lt;br /&gt;
  2.15 answers&lt;br /&gt;
  2.16 score_views&lt;br /&gt;
  2.17 tag_prompts&lt;br /&gt;
  2.18 tag_prompts_deployments&lt;br /&gt;
&lt;br /&gt;
== Data Flow Overview ==&lt;br /&gt;
The diagram below illustrates how data flows between the frontend React components and the grades_controller.rb backend during a typical grading data fetch operation.&lt;br /&gt;
&lt;br /&gt;
* The user (e.g., instructor or student) interacts with the React-based grades view (e.g., ReviewTable, RoundSelector, or Statistics).&lt;br /&gt;
* The component triggers an API request to a specific action in grades_controller.rb (e.g., GET /grades/:id/summary).&lt;br /&gt;
*The controller action queries the relevant models (e.g., Assignment, Team, ReviewResponseMap) and compiles a JSON response.&lt;br /&gt;
* The response is sent back to the frontend and parsed.&lt;br /&gt;
*The React components update the UI (tables, heatmaps, statistics) based on the received data.&lt;br /&gt;
&lt;br /&gt;
This architecture ensures a clean separation between frontend and backend logic, improving maintainability and testability.&lt;br /&gt;
[[File:Dataflow.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
The test plan for Phase 2 focuses on verifying the successful integration of the newly reimplemented &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the React-based UI components. We aim to ensure data is:&lt;br /&gt;
&lt;br /&gt;
* Correctly fetched from the backend  &lt;br /&gt;
* Appropriately displayed in the frontend  &lt;br /&gt;
* Functionally sound under both normal and edge-case scenarios&lt;br /&gt;
&lt;br /&gt;
== Tools and Frameworks ==&lt;br /&gt;
We plan to use the following tools and frameworks for testing:&lt;br /&gt;
&lt;br /&gt;
* '''Frontend''': Jest and React Testing Library for unit and integration tests&lt;br /&gt;
* '''Backend''': RSpec for controller and model tests&lt;br /&gt;
* '''Integration Testing''': Capybara and Selenium for simulating real user behavior&lt;br /&gt;
* '''Test Coverage''': SimpleCov&lt;br /&gt;
&lt;br /&gt;
== 1. UI Integration Tests ==&lt;br /&gt;
&lt;br /&gt;
These tests ensure the frontend correctly interacts with backend APIs and renders the data appropriately.&lt;br /&gt;
&lt;br /&gt;
=== ReviewTable Component ===&lt;br /&gt;
&lt;br /&gt;
* Validate that the component makes a successful API call to fetch author feedback  &lt;br /&gt;
* Ensure feedback is rendered in the correct table structure  &lt;br /&gt;
* Test loading state before data is fetched  &lt;br /&gt;
* Handle empty or malformed feedback responses gracefully  &lt;br /&gt;
&lt;br /&gt;
=== RoundSelector Component ===&lt;br /&gt;
&lt;br /&gt;
* Verify API call to fetch heatmap data is triggered on component load  &lt;br /&gt;
* Check that heatmap data is correctly visualized for different review rounds  &lt;br /&gt;
* Test behavior with no data, incomplete data, or delayed response  &lt;br /&gt;
&lt;br /&gt;
=== Statistics Component ===&lt;br /&gt;
&lt;br /&gt;
* Confirm it correctly fetches teammate evaluations and author feedback  &lt;br /&gt;
* Ensure charts or tables reflect the received backend data accurately  &lt;br /&gt;
* Test switching between different teams or assignments and verify correct display  &lt;br /&gt;
&lt;br /&gt;
=== General UI Considerations ===&lt;br /&gt;
&lt;br /&gt;
* Test frontend responsiveness to backend failures (500, 404, timeout)  &lt;br /&gt;
* Ensure authorization errors are handled and appropriate messages displayed  &lt;br /&gt;
&lt;br /&gt;
== 2. Backend API Tests ==&lt;br /&gt;
&lt;br /&gt;
While unit tests exist, integration-level tests will be added or updated to ensure UI compatibility.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
* Validate all &amp;lt;code&amp;gt;GET&amp;lt;/code&amp;gt; endpoints return properly structured JSON objects  &lt;br /&gt;
* Simulate various user roles (student, TA, instructor) and ensure access control  &lt;br /&gt;
* Include test cases for:&lt;br /&gt;
** No grades present  &lt;br /&gt;
** Partial data (e.g. missing feedback or evaluations)  &lt;br /&gt;
** Large number of records  &lt;br /&gt;
&lt;br /&gt;
=== Security &amp;amp; Permissions ===&lt;br /&gt;
&lt;br /&gt;
* Ensure students can only fetch their grades and feedback  &lt;br /&gt;
* Ensure TAs and instructors can access full assignment data  &lt;br /&gt;
* Test token/session-based access restrictions (if applicable)  &lt;br /&gt;
&lt;br /&gt;
== 3. Database Preparation ==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, seed data will simulate real-world usage and we will ensure that:&lt;br /&gt;
* Tests will use isolated fixtures or factories to ensure data consistency&lt;br /&gt;
* All database states will be reset before each test suite run&lt;br /&gt;
&lt;br /&gt;
=== Tables and Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;assignments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_participant&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;participants&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;questionnaires&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;questions&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_questionnaire&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;signed_up_teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;teams_users&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;late_policies&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
=== Scenarios ===&lt;br /&gt;
&lt;br /&gt;
* Single student assigned  &lt;br /&gt;
* Team assignments with/without feedback  &lt;br /&gt;
* Late submissions triggering late policies  &lt;br /&gt;
* Multiple review rounds per assignment&lt;br /&gt;
&lt;br /&gt;
== 4. Regression &amp;amp; CI Testing ==&lt;br /&gt;
&lt;br /&gt;
To ensure updates do not break existing functionality:&lt;br /&gt;
&lt;br /&gt;
* Re-run all existing unit tests  &lt;br /&gt;
* Include snapshot tests for frontend components  &lt;br /&gt;
* Use CI pipelines to automatically trigger tests on pull requests  &lt;br /&gt;
&lt;br /&gt;
== Test Plan Summary ==&lt;br /&gt;
&lt;br /&gt;
This test plan outlines the approach for integrating &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the frontend. By combining backend tests, UI integration checks, and realistic database scenarios, we aim to deliver a seamless user experience. The plan emphasizes early detection of issues and supports long-term maintainability through regression testing. As development progresses, the plan will be updated to cover new insights and edge cases.&lt;br /&gt;
&lt;br /&gt;
=Completed Reimplementation Details=&lt;br /&gt;
&lt;br /&gt;
This section outlines the changes that were actually implemented as part of the reimplementation effort. It provides a detailed breakdown of how the frontend was decoupled from the legacy Ruby-embedded views, and how dynamic data flow was established using API endpoints. Specific components were modified to replace hardcoded or mock data with real-time API calls to the backend, ensuring that the application now reflects live grading data. Additionally, backend controller actions were updated to return clean, structured JSON responses, and the data retrieval logic was centralized to improve maintainability and testability. &lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The previous implementation was designed for a Ruby-embedded front-end, where data was rendered server-side and injected directly into the view. We have since updated the APIs to return data in a format suitable for consumption by the React UI, typically as JSON objects. This change successfully decouples the front-end from the server-side rendering logic, enabling a more interactive and responsive user experience. By transitioning to a React-based interface, we now have improved control over UI state and better alignment with modern web development practices.&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
In this controller, we have updated the GET functions to remove the use of instance variables and instead return plain JSON objects using render json: in the response. This update was essential to align with the frontend architecture, which now relies on a React-based interface that expects structured data from the backend in JSON format rather than server-rendered templates. By returning JSON responses, we’ve established cleaner and more consistent API endpoints, improved the testability and debuggability of our backend logic, and created a more maintainable and decoupled integration between the frontend and backend systems. The following functions were updated as part of this integration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  def view_grading_report&lt;br /&gt;
    assignment_id = params[:id].to_i&lt;br /&gt;
    data = get_data_for_heat_map(assignment_id)&lt;br /&gt;
    &lt;br /&gt;
    render json: data, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
    &lt;br /&gt;
  def view_my_scores&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team_id = TeamsUser.team_id(participant.assignment_id, participant.user_id)&lt;br /&gt;
  &lt;br /&gt;
    questions = fetch_questionnaires_and_questions(assignment)&lt;br /&gt;
    pscore = fetch_participant_scores(participant, questions)&lt;br /&gt;
    topic_id = SignedUpTeam.find_topic_id_for_user(participant.assignment.id, participant.user_id)&lt;br /&gt;
    stage = participant.assignment.current_stage(topic_id)&lt;br /&gt;
    &lt;br /&gt;
    sum = SummaryHelper::Summary.new.summarize_reviews_by_reviewee(questions, assignment, team_id, 'http://peerlogic.csc.ncsu.edu/sum/v1.0/summary/8/lsa', session)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      topic_id: topic_id,&lt;br /&gt;
      stage: stage,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      summary: sum.summary,&lt;br /&gt;
      avg_scores_by_round: sum.avg_scores_by_round,&lt;br /&gt;
      avg_scores_by_criterion: sum.avg_scores_by_criterion&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def view_team&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    team_id = team.id&lt;br /&gt;
  &lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: assignment.id).map(&amp;amp;:questionnaire)&lt;br /&gt;
    questions = retrieve_questions(questionnaires, assignment.id)&lt;br /&gt;
    pscore = Response.participant_scores(participant, questions)&lt;br /&gt;
    vmlist = process_questionare_for_team(assignment, team_id,questionnaires, team, participant)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team: team,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      vmlist: vmlist&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These updates were important for the backend and ensured seamless communication with the React frontend. By removing instance variables and returning structured JSON responses, we eliminated dependencies on server-side rendering and enabled the frontend to dynamically manage and render data. This not only enhances performance and flexibility but also improves maintainability and scalability as the application evolves. Moreover, it allows the backend and frontend to evolve independently, supporting better separation of concerns and aligning with current best practices in full-stack web development.&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We have successfully reimplemented the previously pre-populated data with appropriate HTTP GET calls to the backend. This ensures that our application now reflects real-time data directly from the server, improving data accuracy and consistency across the UI. This update also enhances scalability and maintainability, as the frontend no longer depends on static content and can adapt to backend changes without manual intervention. This was the main focus of this project. &lt;br /&gt;
&lt;br /&gt;
All dummy data throughout these components has been successfully removed and replaced with real-time API integrations. This transition allows for a fully dynamic, data-driven React frontend that remains synchronized with backend updates and user interactions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Files and components that were updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' This component, loaded from App.tsx, initially used dummyAuthorFeedback data. Our goal was to replace this with an API call to retrieve real-time author feedback data from the backend. The updated implementation was reviewed to ensure proper API integration and dynamic rendering of review tables.&lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' Initially using dummy heatmap data, this component was updated to fetch live heatmap data via an API call. The review ensured that the component responds appropriately to data updates and correctly renders the heatmap.&lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:''' This component previously relied on static data for team-mates and author feedback. We mapped these to backend APIs. The review focused on validating the accuracy of the displayed statistics and their alignment with backend data.&lt;br /&gt;
&lt;br /&gt;
   '''ShowReview.tsx:''' This component was updated to dynamically display review content using data fetched from the backend instead of static placeholders. We reviewed this update to ensure it correctly loads the appropriate review details and handles edge cases like missing or malformed data.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Finally, we integrated all components with actual API calls, completing the transition from static content to dynamic, backend-driven data flow across the React frontend.&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
A key component of this project involved populating the necessary database tables that the grades_controller.rb relies on to serve real-time data to the frontend. This step was essential for replacing the previously hardcoded or pre-populated dummy data with dynamic, API-driven content. Below is a list of the database tables that were seeded with mock data specifically for development and testing purposes in this project:&lt;br /&gt;
&lt;br /&gt;
* roles&lt;br /&gt;
* institutions&lt;br /&gt;
* users&lt;br /&gt;
* assignments&lt;br /&gt;
* teams &lt;br /&gt;
* teams_users&lt;br /&gt;
* sign_up_topics&lt;br /&gt;
* signed_up_teams&lt;br /&gt;
* participants&lt;br /&gt;
* questionnaires&lt;br /&gt;
* questions &lt;br /&gt;
* assignment_questionaires&lt;br /&gt;
* response_maps&lt;br /&gt;
* responses&lt;br /&gt;
* score_views&lt;br /&gt;
* tag-prompts&lt;br /&gt;
* tag_prompt_deployments&lt;br /&gt;
&lt;br /&gt;
In order to correctly populate each database, we referenced the Expertiza Database Documentation to understand the schema, and then mapped out the relevant tables needed by grades_controller.rb. Then we populated them with mock data to support development and testing of the new API-driven frontend.&lt;br /&gt;
&lt;br /&gt;
==Data Flow Overview==&lt;br /&gt;
&lt;br /&gt;
The diagram from the implementation plan remained the same, illustrating the consistent data flow between the React frontend components and the grades_controller.rb backend during grading data retrieval.&lt;br /&gt;
&lt;br /&gt;
* The user (such as an instructor or student) interacts with the React-based grades interface—components like ReviewTable, RoundSelector, or Statistics.&lt;br /&gt;
&lt;br /&gt;
* In response to this interaction, the component initiates an API request to a specific endpoint in grades_controller.rb.&lt;br /&gt;
&lt;br /&gt;
* The controller action then queries the relevant backend models (such as Assignment, Team, and ReviewResponseMap) and constructs a structured JSON response.&lt;br /&gt;
&lt;br /&gt;
* This JSON data is returned to the frontend, where it is parsed by the corresponding React component.&lt;br /&gt;
&lt;br /&gt;
* Finally, the React components dynamically update the UI—populating tables, generating heatmaps, or displaying statistics—based on the data received.&lt;br /&gt;
&lt;br /&gt;
This architecture promotes a clear separation of concerns between frontend and backend layers, enabling more scalable development, easier debugging, and improved maintainability and testability across the application.&lt;br /&gt;
&lt;br /&gt;
==Adhering to Priciples==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
=Testing=&lt;br /&gt;
&lt;br /&gt;
==Testing Overview==&lt;br /&gt;
&lt;br /&gt;
After modifying several methods in grades_controller.rb to return JSON responses and support the new React-based frontend, we conducted comprehensive testing to ensure that both the backend logic and frontend integration functioned as intended. It was essential to validate not only that the backend endpoints behaved correctly in isolation, but also that the frontend components were able to successfully consume and render the data returned by the updated APIs.&lt;br /&gt;
&lt;br /&gt;
We retested all affected methods to verify that data was retrieved accurately, permission checks were enforced, and updates were correctly persisted. In addition to running automated RSpec tests, we manually tested the backend endpoints using authenticated curl commands. These terminal-based tests allowed us to simulate real API usage, verify response structures, and confirm compatibility with the frontend. This dual-layered testing approach ensured a smooth and reliable interaction between the React UI and the Rails backend.&lt;br /&gt;
&lt;br /&gt;
==Database Preparation==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, we populated the database with carefully designed mock data that simulates a variety of real-world grading scenarios. This approach ensured that our test environment closely mirrors actual usage patterns, allowing for more meaningful validation of the grades_controller.rb logic and its interactions with related models.&lt;br /&gt;
 &lt;br /&gt;
We created test scenarios that covered a range of use cases, including individual and team assignments, review rounds, and various submissions, to verify that each controller action behaves as expected under different conditions. By populating the relevant tables with representative data, we were able to rigorously test features like permission checks, grade updates, response mapping, and feedback rendering.&lt;br /&gt;
&lt;br /&gt;
The specific databases that were populated can be found in the Database section.&lt;br /&gt;
&lt;br /&gt;
[[File:Grades_Database.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==Backend Tests==&lt;br /&gt;
&lt;br /&gt;
After modifying several methods in grades_controller.rb to return JSON responses and integrate with the new React-based frontend, we conducted targeted RSpec tests to validate the backend functionality to ensure frontend compatibility. These tests ensured that each controller method operated correctly in isolation and that the frontend components could successfully consume the API responses as expected.&lt;br /&gt;
&lt;br /&gt;
RSpec tests were written for the following controller methods:&lt;br /&gt;
&lt;br /&gt;
* action_allowed?&lt;br /&gt;
* view_my_scores&lt;br /&gt;
* view_team&lt;br /&gt;
* edit_participant_scores&lt;br /&gt;
* update_participant_grade&lt;br /&gt;
* update_team&lt;br /&gt;
* instructor_review&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:rspec_grades.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==API Endpoint Tests==&lt;br /&gt;
&lt;br /&gt;
We used Postman to test our API endpoints during development and deployment. It allowed us to easily send HTTP requests and validate the structure and content of the responses. By simulating real client requests, we were able to verify authentication flows, check for correct status codes, and confirm that our endpoints returned the expected data, ensuring the backend was functioning as intended.&lt;br /&gt;
&lt;br /&gt;
=== view_grading_report ===&lt;br /&gt;
[[File:API1.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== view_my_scores ===&lt;br /&gt;
[[File:API2.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== view_team ===&lt;br /&gt;
[[File:API3.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UI and API Integration Tests==&lt;br /&gt;
&lt;br /&gt;
To ensure the correctness and stability of our updated React components and their interaction with the backend, we conducted comprehensive UI and API integration tests. These tests were aimed at verifying both data flow and user experience across the full stack.&lt;br /&gt;
&lt;br /&gt;
1. API Connectivity Testing --- We validated each API endpoint integrated into the frontend components by confirming:&lt;br /&gt;
&lt;br /&gt;
*Successful HTTP GET requests and accurate response structures&lt;br /&gt;
*Proper handling of edge cases, such as missing or malformed data&lt;br /&gt;
*Consistent response times and error management (e.g., fallback behavior for failed requests)&lt;br /&gt;
&lt;br /&gt;
2. Component-Level Integration --- Each React component (ReviewTable.tsx, RoundSelector.tsx, Statistics.tsx, and ShowReview.tsx) was tested in isolation to ensure:&lt;br /&gt;
&lt;br /&gt;
*Correct rendering of dynamic content based on backend responses&lt;br /&gt;
*Smooth updates to the UI without page reloads&lt;br /&gt;
*Appropriate fallback UI for loading states or API errors&lt;br /&gt;
&lt;br /&gt;
3. End-to-End Testing Scenarios --- We simulated real user interactions—such as selecting rounds, viewing reviews, and exploring statistics—to verify that:&lt;br /&gt;
&lt;br /&gt;
*API calls are correctly triggered on user events&lt;br /&gt;
*The DOM updates accurately reflect the underlying data&lt;br /&gt;
*There are no regressions or stale data displayed&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164564</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164564"/>
		<updated>2025-04-22T12:56:06Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* UI and API Integration Tests */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of this project is to integrate the frontend of the grades view page with the reimplemented '''''grades_controller.rb (E2510)''''' backend in Expertiza, ensuring a seamless connection between both layers. This integration involves refining the interaction between the UI and backend while adhering to best design principles such as modularity, maintainability, and scalability. The grades_controller.rb is responsible for managing grading functionality, allowing instructors to view and modify assignment grades while enabling students to access their evaluations. By following SOLID and DRY principles, this reimplementation enhances code clarity, reduces redundancy, and improves overall system efficiency.&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
The &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; is responsible for managing and delivering grading data to users in the Expertiza system. It enables instructors to view, calculate, and release grades to students, while also allowing students to view feedback and scores for assignments. The controller plays an important role in coordinating backend logic for reviews and grade visibility.&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
The previous implementation successfully created a functional frontend UI page in Expertiza, addressing design inconsistencies and improving usability. It introduced a visually cohesive interface with an intuitive layout, enhanced responsiveness, and improved information display, allowing users to navigate grading data more efficiently. However, the interface was populated using dummy data, limiting its practical use. This reimplemented UI will utilize real data from the database (that has been populated in this round), ensuring that grading information is dynamically retrieved and displayed accurately through JSON objects. Additionally, this phase will connect the redesigned frontend with some new components in the grades_controller.rb. Specifically, the GET functions in the grades_controller were reimplemented to return JSON objects (instead of instance variables) that could be accessed via an API call. Thus, this new implementation ensures seamless communication between the UI and backend while adhering to best design practices for maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
This project focuses on integrating the frontend of the grades view page with the reimplemented '''grades_controller.rb (E2510)''' backend in Expertiza. This integration requires modifications to both the frontend and backend to establish a seamless connection, ensuring that grading data is dynamically retrieved and displayed accurately. By adhering to best design principles such as modularity, maintainability, and scalability, the implementation will enhance system efficiency and long-term usability. Key improvements include replacing dummy data with real database values, refining data flow between the UI and backend, and optimizing API interactions for better performance. These enhancements will create a more intuitive and reliable grading system, providing a seamless experience for instructors and students while maintaining a well-structured and adaptable codebase for future development.&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
# '''Establish a Robust Connection Between the Frontend and Backend''': Ensure smooth data retrieval and updates between the grades view page and the backend by integrating dynamic data through API calls, replacing the current hardcoded dummy data.&lt;br /&gt;
# '''Define and Implement Clear API Endpoints''': Create well-structured API endpoints in grades_controller.rb for retrieving and displaying grades, ensuring they return appropriate data based on user roles (students, instructors, TAs) and maintain role-based access controls.&lt;br /&gt;
# '''Dynamic Data Integration''': Modify the frontend to consume real-time data fetched from the backend, ensuring an intuitive and responsive UI that reflects the actual grading information. &lt;br /&gt;
# '''Reimplement Frontend and Backend Components''': Reimplement both the frontend and backend as necessary to align with SOLID and DRY principles, ensuring modularity, maintainability, and scalability. This includes eliminating redundant logic and optimizing code for better readability.&lt;br /&gt;
# '''Implement Proper Permission Checks''': Ensure that only authorized users can access grade information by implementing robust privilege checks and ensuring that the data is securely accessible to students, instructors, and TAs based on their roles.&lt;br /&gt;
# '''Optimize Database Queries and API Responses''': Enhance the efficiency of database queries and API responses to reduce unnecessary load and ensure that data is retrieved and displayed promptly.&lt;br /&gt;
# '''Testing and Validation''': Implement comprehensive unit and integration tests to verify the correctness of data flow, UI interactions, and role-based access controls, ensuring that the system functions correctly and securely.&lt;br /&gt;
&lt;br /&gt;
=Reimplementation Plan=&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populated data with the appropriate HTTP GET and HTTP POST calls. This shift is necessary to ensure that our application reflects real-time data from the backend rather than relying on static or hardcoded values, which can quickly become outdated or inconsistent. It also enables better scalability and maintainability, as changes to the data only need to be made in the backend, without requiring manual updates in the frontend code.&lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
'''Author Feedback''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
'''Heatmap Data''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
'''Team-mate Data''':&lt;br /&gt;
   {&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The current implementation caters to the backend for a Ruby-embedded front-end, where data is rendered server-side and passed directly into the view. We need to update the APIs to return data in a format that can be consumed by the React UI, typically JSON. This shift is essential to decouple the front-end from the server-side rendering logic, allowing for a more interactive and dynamic user experience. By transitioning to a React-based interface, we gain better control over UI state and responsiveness, while also aligning with modern web development practices. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and instead return plain JSON objects using render json: in the response. This change is necessary to align with a frontend architecture that uses React or another JavaScript framework, which expects structured data from the backend in JSON format rather than relying on server-rendered templates. By shifting to JSON responses, we enable cleaner API endpoints, facilitate easier testing and debugging, and support a more maintainable, decoupled frontend-backend integration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
  1.1. Students&lt;br /&gt;
  1.2. Teams&lt;br /&gt;
  1.3. TA&lt;br /&gt;
  1.4. Instructir&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
  2.1 assignments&lt;br /&gt;
  2.2 assignment_questionnaire&lt;br /&gt;
  2.3 questionnaires&lt;br /&gt;
  2.4 participants&lt;br /&gt;
  2.5 signed_up_teams&lt;br /&gt;
  2.6 teams_users&lt;br /&gt;
  2.9 questions&lt;br /&gt;
  2.10 users&lt;br /&gt;
  2.11 teams&lt;br /&gt;
  2.12 sign_up_topics&lt;br /&gt;
  2.13 response_maps&lt;br /&gt;
  2.14 responses&lt;br /&gt;
  2.15 answers&lt;br /&gt;
  2.16 score_views&lt;br /&gt;
  2.17 tag_prompts&lt;br /&gt;
  2.18 tag_prompts_deployments&lt;br /&gt;
&lt;br /&gt;
== Data Flow Overview ==&lt;br /&gt;
The diagram below illustrates how data flows between the frontend React components and the grades_controller.rb backend during a typical grading data fetch operation.&lt;br /&gt;
&lt;br /&gt;
* The user (e.g., instructor or student) interacts with the React-based grades view (e.g., ReviewTable, RoundSelector, or Statistics).&lt;br /&gt;
* The component triggers an API request to a specific action in grades_controller.rb (e.g., GET /grades/:id/summary).&lt;br /&gt;
*The controller action queries the relevant models (e.g., Assignment, Team, ReviewResponseMap) and compiles a JSON response.&lt;br /&gt;
* The response is sent back to the frontend and parsed.&lt;br /&gt;
*The React components update the UI (tables, heatmaps, statistics) based on the received data.&lt;br /&gt;
&lt;br /&gt;
This architecture ensures a clean separation between frontend and backend logic, improving maintainability and testability.&lt;br /&gt;
[[File:Dataflow.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
The test plan for Phase 2 focuses on verifying the successful integration of the newly reimplemented &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the React-based UI components. We aim to ensure data is:&lt;br /&gt;
&lt;br /&gt;
* Correctly fetched from the backend  &lt;br /&gt;
* Appropriately displayed in the frontend  &lt;br /&gt;
* Functionally sound under both normal and edge-case scenarios&lt;br /&gt;
&lt;br /&gt;
== Tools and Frameworks ==&lt;br /&gt;
We plan to use the following tools and frameworks for testing:&lt;br /&gt;
&lt;br /&gt;
* '''Frontend''': Jest and React Testing Library for unit and integration tests&lt;br /&gt;
* '''Backend''': RSpec for controller and model tests&lt;br /&gt;
* '''Integration Testing''': Capybara and Selenium for simulating real user behavior&lt;br /&gt;
* '''Test Coverage''': SimpleCov&lt;br /&gt;
&lt;br /&gt;
== 1. UI Integration Tests ==&lt;br /&gt;
&lt;br /&gt;
These tests ensure the frontend correctly interacts with backend APIs and renders the data appropriately.&lt;br /&gt;
&lt;br /&gt;
=== ReviewTable Component ===&lt;br /&gt;
&lt;br /&gt;
* Validate that the component makes a successful API call to fetch author feedback  &lt;br /&gt;
* Ensure feedback is rendered in the correct table structure  &lt;br /&gt;
* Test loading state before data is fetched  &lt;br /&gt;
* Handle empty or malformed feedback responses gracefully  &lt;br /&gt;
&lt;br /&gt;
=== RoundSelector Component ===&lt;br /&gt;
&lt;br /&gt;
* Verify API call to fetch heatmap data is triggered on component load  &lt;br /&gt;
* Check that heatmap data is correctly visualized for different review rounds  &lt;br /&gt;
* Test behavior with no data, incomplete data, or delayed response  &lt;br /&gt;
&lt;br /&gt;
=== Statistics Component ===&lt;br /&gt;
&lt;br /&gt;
* Confirm it correctly fetches teammate evaluations and author feedback  &lt;br /&gt;
* Ensure charts or tables reflect the received backend data accurately  &lt;br /&gt;
* Test switching between different teams or assignments and verify correct display  &lt;br /&gt;
&lt;br /&gt;
=== General UI Considerations ===&lt;br /&gt;
&lt;br /&gt;
* Test frontend responsiveness to backend failures (500, 404, timeout)  &lt;br /&gt;
* Ensure authorization errors are handled and appropriate messages displayed  &lt;br /&gt;
&lt;br /&gt;
== 2. Backend API Tests ==&lt;br /&gt;
&lt;br /&gt;
While unit tests exist, integration-level tests will be added or updated to ensure UI compatibility.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
* Validate all &amp;lt;code&amp;gt;GET&amp;lt;/code&amp;gt; endpoints return properly structured JSON objects  &lt;br /&gt;
* Simulate various user roles (student, TA, instructor) and ensure access control  &lt;br /&gt;
* Include test cases for:&lt;br /&gt;
** No grades present  &lt;br /&gt;
** Partial data (e.g. missing feedback or evaluations)  &lt;br /&gt;
** Large number of records  &lt;br /&gt;
&lt;br /&gt;
=== Security &amp;amp; Permissions ===&lt;br /&gt;
&lt;br /&gt;
* Ensure students can only fetch their grades and feedback  &lt;br /&gt;
* Ensure TAs and instructors can access full assignment data  &lt;br /&gt;
* Test token/session-based access restrictions (if applicable)  &lt;br /&gt;
&lt;br /&gt;
== 3. Database Preparation ==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, seed data will simulate real-world usage and we will ensure that:&lt;br /&gt;
* Tests will use isolated fixtures or factories to ensure data consistency&lt;br /&gt;
* All database states will be reset before each test suite run&lt;br /&gt;
&lt;br /&gt;
=== Tables and Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;assignments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_participant&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;participants&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;questionnaires&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;questions&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_questionnaire&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;signed_up_teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;teams_users&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;late_policies&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
=== Scenarios ===&lt;br /&gt;
&lt;br /&gt;
* Single student assigned  &lt;br /&gt;
* Team assignments with/without feedback  &lt;br /&gt;
* Late submissions triggering late policies  &lt;br /&gt;
* Multiple review rounds per assignment&lt;br /&gt;
&lt;br /&gt;
== 4. Regression &amp;amp; CI Testing ==&lt;br /&gt;
&lt;br /&gt;
To ensure updates do not break existing functionality:&lt;br /&gt;
&lt;br /&gt;
* Re-run all existing unit tests  &lt;br /&gt;
* Include snapshot tests for frontend components  &lt;br /&gt;
* Use CI pipelines to automatically trigger tests on pull requests  &lt;br /&gt;
&lt;br /&gt;
== Test Plan Summary ==&lt;br /&gt;
&lt;br /&gt;
This test plan outlines the approach for integrating &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the frontend. By combining backend tests, UI integration checks, and realistic database scenarios, we aim to deliver a seamless user experience. The plan emphasizes early detection of issues and supports long-term maintainability through regression testing. As development progresses, the plan will be updated to cover new insights and edge cases.&lt;br /&gt;
&lt;br /&gt;
=Completed Reimplementation Details=&lt;br /&gt;
&lt;br /&gt;
This section outlines the changes that were actually implemented as part of the reimplementation effort. It provides a detailed breakdown of how the frontend was decoupled from the legacy Ruby-embedded views, and how dynamic data flow was established using API endpoints. Specific components were modified to replace hardcoded or mock data with real-time API calls to the backend, ensuring that the application now reflects live grading data. Additionally, backend controller actions were updated to return clean, structured JSON responses, and the data retrieval logic was centralized to improve maintainability and testability. &lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The previous implementation was designed for a Ruby-embedded front-end, where data was rendered server-side and injected directly into the view. We have since updated the APIs to return data in a format suitable for consumption by the React UI, typically as JSON objects. This change successfully decouples the front-end from the server-side rendering logic, enabling a more interactive and responsive user experience. By transitioning to a React-based interface, we now have improved control over UI state and better alignment with modern web development practices.&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
In this controller, we have updated the GET functions to remove the use of instance variables and instead return plain JSON objects using render json: in the response. This update was essential to align with the frontend architecture, which now relies on a React-based interface that expects structured data from the backend in JSON format rather than server-rendered templates. By returning JSON responses, we’ve established cleaner and more consistent API endpoints, improved the testability and debuggability of our backend logic, and created a more maintainable and decoupled integration between the frontend and backend systems. The following functions were updated as part of this integration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  def view_grading_report&lt;br /&gt;
    assignment_id = params[:id].to_i&lt;br /&gt;
    data = get_data_for_heat_map(assignment_id)&lt;br /&gt;
    &lt;br /&gt;
    render json: data, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
    &lt;br /&gt;
  def view_my_scores&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team_id = TeamsUser.team_id(participant.assignment_id, participant.user_id)&lt;br /&gt;
  &lt;br /&gt;
    questions = fetch_questionnaires_and_questions(assignment)&lt;br /&gt;
    pscore = fetch_participant_scores(participant, questions)&lt;br /&gt;
    topic_id = SignedUpTeam.find_topic_id_for_user(participant.assignment.id, participant.user_id)&lt;br /&gt;
    stage = participant.assignment.current_stage(topic_id)&lt;br /&gt;
    &lt;br /&gt;
    sum = SummaryHelper::Summary.new.summarize_reviews_by_reviewee(questions, assignment, team_id, 'http://peerlogic.csc.ncsu.edu/sum/v1.0/summary/8/lsa', session)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      topic_id: topic_id,&lt;br /&gt;
      stage: stage,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      summary: sum.summary,&lt;br /&gt;
      avg_scores_by_round: sum.avg_scores_by_round,&lt;br /&gt;
      avg_scores_by_criterion: sum.avg_scores_by_criterion&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def view_team&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    team_id = team.id&lt;br /&gt;
  &lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: assignment.id).map(&amp;amp;:questionnaire)&lt;br /&gt;
    questions = retrieve_questions(questionnaires, assignment.id)&lt;br /&gt;
    pscore = Response.participant_scores(participant, questions)&lt;br /&gt;
    vmlist = process_questionare_for_team(assignment, team_id,questionnaires, team, participant)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team: team,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      vmlist: vmlist&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These updates were important for the backend and ensured seamless communication with the React frontend. By removing instance variables and returning structured JSON responses, we eliminated dependencies on server-side rendering and enabled the frontend to dynamically manage and render data. This not only enhances performance and flexibility but also improves maintainability and scalability as the application evolves. Moreover, it allows the backend and frontend to evolve independently, supporting better separation of concerns and aligning with current best practices in full-stack web development.&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We have successfully reimplemented the previously pre-populated data with appropriate HTTP GET calls to the backend. This ensures that our application now reflects real-time data directly from the server, improving data accuracy and consistency across the UI. This update also enhances scalability and maintainability, as the frontend no longer depends on static content and can adapt to backend changes without manual intervention. This was the main focus of this project. &lt;br /&gt;
&lt;br /&gt;
All dummy data throughout these components has been successfully removed and replaced with real-time API integrations. This transition allows for a fully dynamic, data-driven React frontend that remains synchronized with backend updates and user interactions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Files and components that were updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' This component, loaded from App.tsx, initially used dummyAuthorFeedback data. Our goal was to replace this with an API call to retrieve real-time author feedback data from the backend. The updated implementation was reviewed to ensure proper API integration and dynamic rendering of review tables.&lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' Initially using dummy heatmap data, this component was updated to fetch live heatmap data via an API call. The review ensured that the component responds appropriately to data updates and correctly renders the heatmap.&lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:''' This component previously relied on static data for team-mates and author feedback. We mapped these to backend APIs. The review focused on validating the accuracy of the displayed statistics and their alignment with backend data.&lt;br /&gt;
&lt;br /&gt;
   '''ShowReview.tsx:''' This component was updated to dynamically display review content using data fetched from the backend instead of static placeholders. We reviewed this update to ensure it correctly loads the appropriate review details and handles edge cases like missing or malformed data.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Finally, we integrated all components with actual API calls, completing the transition from static content to dynamic, backend-driven data flow across the React frontend.&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
A key component of this project involved populating the necessary database tables that the grades_controller.rb relies on to serve real-time data to the frontend. This step was essential for replacing the previously hardcoded or pre-populated dummy data with dynamic, API-driven content. Below is a list of the database tables that were seeded with mock data specifically for development and testing purposes in this project:&lt;br /&gt;
&lt;br /&gt;
* roles&lt;br /&gt;
* institutions&lt;br /&gt;
* users&lt;br /&gt;
* assignments&lt;br /&gt;
* teams &lt;br /&gt;
* teams_users&lt;br /&gt;
* sign_up_topics&lt;br /&gt;
* signed_up_teams&lt;br /&gt;
* participants&lt;br /&gt;
* questionnaires&lt;br /&gt;
* questions &lt;br /&gt;
* assignment_questionaires&lt;br /&gt;
* response_maps&lt;br /&gt;
* responses&lt;br /&gt;
* score_views&lt;br /&gt;
* tag-prompts&lt;br /&gt;
* tag_prompt_deployments&lt;br /&gt;
&lt;br /&gt;
In order to correctly populate each database, we referenced the Expertiza Database Documentation to understand the schema, and then mapped out the relevant tables needed by grades_controller.rb. Then we populated them with mock data to support development and testing of the new API-driven frontend.&lt;br /&gt;
&lt;br /&gt;
==Data Flow Overview==&lt;br /&gt;
&lt;br /&gt;
The diagram from the implementation plan remained the same, illustrating the consistent data flow between the React frontend components and the grades_controller.rb backend during grading data retrieval.&lt;br /&gt;
&lt;br /&gt;
* The user (such as an instructor or student) interacts with the React-based grades interface—components like ReviewTable, RoundSelector, or Statistics.&lt;br /&gt;
&lt;br /&gt;
* In response to this interaction, the component initiates an API request to a specific endpoint in grades_controller.rb.&lt;br /&gt;
&lt;br /&gt;
* The controller action then queries the relevant backend models (such as Assignment, Team, and ReviewResponseMap) and constructs a structured JSON response.&lt;br /&gt;
&lt;br /&gt;
* This JSON data is returned to the frontend, where it is parsed by the corresponding React component.&lt;br /&gt;
&lt;br /&gt;
* Finally, the React components dynamically update the UI—populating tables, generating heatmaps, or displaying statistics—based on the data received.&lt;br /&gt;
&lt;br /&gt;
This architecture promotes a clear separation of concerns between frontend and backend layers, enabling more scalable development, easier debugging, and improved maintainability and testability across the application.&lt;br /&gt;
&lt;br /&gt;
==Adhering to Priciples==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
=Testing=&lt;br /&gt;
&lt;br /&gt;
==Testing Overview==&lt;br /&gt;
&lt;br /&gt;
After modifying several methods in grades_controller.rb to return JSON responses and support the new React-based frontend, we conducted comprehensive testing to ensure that both the backend logic and frontend integration functioned as intended. It was essential to validate not only that the backend endpoints behaved correctly in isolation, but also that the frontend components were able to successfully consume and render the data returned by the updated APIs.&lt;br /&gt;
&lt;br /&gt;
We retested all affected methods to verify that data was retrieved accurately, permission checks were enforced, and updates were correctly persisted. In addition to running automated RSpec tests, we manually tested the backend endpoints using authenticated curl commands. These terminal-based tests allowed us to simulate real API usage, verify response structures, and confirm compatibility with the frontend. This dual-layered testing approach ensured a smooth and reliable interaction between the React UI and the Rails backend.&lt;br /&gt;
&lt;br /&gt;
==Database Preparation==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, we populated the database with carefully designed mock data that simulates a variety of real-world grading scenarios. This approach ensured that our test environment closely mirrors actual usage patterns, allowing for more meaningful validation of the grades_controller.rb logic and its interactions with related models.&lt;br /&gt;
 &lt;br /&gt;
We created test scenarios that covered a range of use cases, including individual and team assignments, review rounds, and various submissions, to verify that each controller action behaves as expected under different conditions. By populating the relevant tables with representative data, we were able to rigorously test features like permission checks, grade updates, response mapping, and feedback rendering.&lt;br /&gt;
&lt;br /&gt;
The specific databases that were populated can be found in the Database section.&lt;br /&gt;
&lt;br /&gt;
[[File:Grades_Database.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==Backend Tests==&lt;br /&gt;
&lt;br /&gt;
After modifying several methods in grades_controller.rb to return JSON responses and integrate with the new React-based frontend, we conducted targeted RSpec tests to validate the backend functionality to ensure frontend compatibility. These tests ensured that each controller method operated correctly in isolation and that the frontend components could successfully consume the API responses as expected.&lt;br /&gt;
&lt;br /&gt;
RSpec tests were written for the following controller methods:&lt;br /&gt;
&lt;br /&gt;
* action_allowed?&lt;br /&gt;
* view_my_scores&lt;br /&gt;
* view_team&lt;br /&gt;
* edit_participant_scores&lt;br /&gt;
* update_participant_grade&lt;br /&gt;
* update_team&lt;br /&gt;
* instructor_review&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:rspec_grades.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==API Endpoint Tests==&lt;br /&gt;
&lt;br /&gt;
We used Postman to test our API endpoints during development and deployment. It allowed us to easily send HTTP requests and validate the structure and content of the responses. By simulating real client requests, we were able to verify authentication flows, check for correct status codes, and confirm that our endpoints returned the expected data, ensuring the backend was functioning as intended.&lt;br /&gt;
&lt;br /&gt;
=== view_grading_report ===&lt;br /&gt;
[[File:API1.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== view_my_scores ===&lt;br /&gt;
[[File:API2.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== view_team ===&lt;br /&gt;
[[File:API3.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UI and API Integration Tests==&lt;br /&gt;
&lt;br /&gt;
To ensure the correctness and stability of our updated React components and their interaction with the backend, we conducted comprehensive UI and API integration tests. These tests were aimed at verifying both data flow and user experience across the full stack.&lt;br /&gt;
&lt;br /&gt;
1. API Connectivity Testing&lt;br /&gt;
&lt;br /&gt;
We validated each API endpoint integrated into the frontend components by confirming:&lt;br /&gt;
&lt;br /&gt;
*Successful HTTP GET requests and accurate response structures&lt;br /&gt;
*Proper handling of edge cases, such as missing or malformed data&lt;br /&gt;
*Consistent response times and error management (e.g., fallback behavior for failed requests)&lt;br /&gt;
&lt;br /&gt;
2. Component-Level Integration&lt;br /&gt;
&lt;br /&gt;
Each React component (ReviewTable.tsx, RoundSelector.tsx, Statistics.tsx, and ShowReview.tsx) was tested in isolation to ensure:&lt;br /&gt;
&lt;br /&gt;
*Correct rendering of dynamic content based on backend responses&lt;br /&gt;
*Smooth updates to the UI without page reloads&lt;br /&gt;
*Appropriate fallback UI for loading states or API errors&lt;br /&gt;
&lt;br /&gt;
3. End-to-End Testing Scenarios&lt;br /&gt;
&lt;br /&gt;
We simulated real user interactions—such as selecting rounds, viewing reviews, and exploring statistics—to verify that:&lt;br /&gt;
&lt;br /&gt;
*API calls are correctly triggered on user events&lt;br /&gt;
*The DOM updates accurately reflect the underlying data&lt;br /&gt;
*There are no regressions or stale data displayed&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164563</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164563"/>
		<updated>2025-04-22T12:49:55Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of this project is to integrate the frontend of the grades view page with the reimplemented '''''grades_controller.rb (E2510)''''' backend in Expertiza, ensuring a seamless connection between both layers. This integration involves refining the interaction between the UI and backend while adhering to best design principles such as modularity, maintainability, and scalability. The grades_controller.rb is responsible for managing grading functionality, allowing instructors to view and modify assignment grades while enabling students to access their evaluations. By following SOLID and DRY principles, this reimplementation enhances code clarity, reduces redundancy, and improves overall system efficiency.&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
The &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; is responsible for managing and delivering grading data to users in the Expertiza system. It enables instructors to view, calculate, and release grades to students, while also allowing students to view feedback and scores for assignments. The controller plays an important role in coordinating backend logic for reviews and grade visibility.&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
The previous implementation successfully created a functional frontend UI page in Expertiza, addressing design inconsistencies and improving usability. It introduced a visually cohesive interface with an intuitive layout, enhanced responsiveness, and improved information display, allowing users to navigate grading data more efficiently. However, the interface was populated using dummy data, limiting its practical use. This reimplemented UI will utilize real data from the database (that has been populated in this round), ensuring that grading information is dynamically retrieved and displayed accurately through JSON objects. Additionally, this phase will connect the redesigned frontend with some new components in the grades_controller.rb. Specifically, the GET functions in the grades_controller were reimplemented to return JSON objects (instead of instance variables) that could be accessed via an API call. Thus, this new implementation ensures seamless communication between the UI and backend while adhering to best design practices for maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
This project focuses on integrating the frontend of the grades view page with the reimplemented '''grades_controller.rb (E2510)''' backend in Expertiza. This integration requires modifications to both the frontend and backend to establish a seamless connection, ensuring that grading data is dynamically retrieved and displayed accurately. By adhering to best design principles such as modularity, maintainability, and scalability, the implementation will enhance system efficiency and long-term usability. Key improvements include replacing dummy data with real database values, refining data flow between the UI and backend, and optimizing API interactions for better performance. These enhancements will create a more intuitive and reliable grading system, providing a seamless experience for instructors and students while maintaining a well-structured and adaptable codebase for future development.&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
# '''Establish a Robust Connection Between the Frontend and Backend''': Ensure smooth data retrieval and updates between the grades view page and the backend by integrating dynamic data through API calls, replacing the current hardcoded dummy data.&lt;br /&gt;
# '''Define and Implement Clear API Endpoints''': Create well-structured API endpoints in grades_controller.rb for retrieving and displaying grades, ensuring they return appropriate data based on user roles (students, instructors, TAs) and maintain role-based access controls.&lt;br /&gt;
# '''Dynamic Data Integration''': Modify the frontend to consume real-time data fetched from the backend, ensuring an intuitive and responsive UI that reflects the actual grading information. &lt;br /&gt;
# '''Reimplement Frontend and Backend Components''': Reimplement both the frontend and backend as necessary to align with SOLID and DRY principles, ensuring modularity, maintainability, and scalability. This includes eliminating redundant logic and optimizing code for better readability.&lt;br /&gt;
# '''Implement Proper Permission Checks''': Ensure that only authorized users can access grade information by implementing robust privilege checks and ensuring that the data is securely accessible to students, instructors, and TAs based on their roles.&lt;br /&gt;
# '''Optimize Database Queries and API Responses''': Enhance the efficiency of database queries and API responses to reduce unnecessary load and ensure that data is retrieved and displayed promptly.&lt;br /&gt;
# '''Testing and Validation''': Implement comprehensive unit and integration tests to verify the correctness of data flow, UI interactions, and role-based access controls, ensuring that the system functions correctly and securely.&lt;br /&gt;
&lt;br /&gt;
=Reimplementation Plan=&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populated data with the appropriate HTTP GET and HTTP POST calls. This shift is necessary to ensure that our application reflects real-time data from the backend rather than relying on static or hardcoded values, which can quickly become outdated or inconsistent. It also enables better scalability and maintainability, as changes to the data only need to be made in the backend, without requiring manual updates in the frontend code.&lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
'''Author Feedback''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
'''Heatmap Data''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
'''Team-mate Data''':&lt;br /&gt;
   {&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The current implementation caters to the backend for a Ruby-embedded front-end, where data is rendered server-side and passed directly into the view. We need to update the APIs to return data in a format that can be consumed by the React UI, typically JSON. This shift is essential to decouple the front-end from the server-side rendering logic, allowing for a more interactive and dynamic user experience. By transitioning to a React-based interface, we gain better control over UI state and responsiveness, while also aligning with modern web development practices. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and instead return plain JSON objects using render json: in the response. This change is necessary to align with a frontend architecture that uses React or another JavaScript framework, which expects structured data from the backend in JSON format rather than relying on server-rendered templates. By shifting to JSON responses, we enable cleaner API endpoints, facilitate easier testing and debugging, and support a more maintainable, decoupled frontend-backend integration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
  1.1. Students&lt;br /&gt;
  1.2. Teams&lt;br /&gt;
  1.3. TA&lt;br /&gt;
  1.4. Instructir&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
  2.1 assignments&lt;br /&gt;
  2.2 assignment_questionnaire&lt;br /&gt;
  2.3 questionnaires&lt;br /&gt;
  2.4 participants&lt;br /&gt;
  2.5 signed_up_teams&lt;br /&gt;
  2.6 teams_users&lt;br /&gt;
  2.9 questions&lt;br /&gt;
  2.10 users&lt;br /&gt;
  2.11 teams&lt;br /&gt;
  2.12 sign_up_topics&lt;br /&gt;
  2.13 response_maps&lt;br /&gt;
  2.14 responses&lt;br /&gt;
  2.15 answers&lt;br /&gt;
  2.16 score_views&lt;br /&gt;
  2.17 tag_prompts&lt;br /&gt;
  2.18 tag_prompts_deployments&lt;br /&gt;
&lt;br /&gt;
== Data Flow Overview ==&lt;br /&gt;
The diagram below illustrates how data flows between the frontend React components and the grades_controller.rb backend during a typical grading data fetch operation.&lt;br /&gt;
&lt;br /&gt;
* The user (e.g., instructor or student) interacts with the React-based grades view (e.g., ReviewTable, RoundSelector, or Statistics).&lt;br /&gt;
* The component triggers an API request to a specific action in grades_controller.rb (e.g., GET /grades/:id/summary).&lt;br /&gt;
*The controller action queries the relevant models (e.g., Assignment, Team, ReviewResponseMap) and compiles a JSON response.&lt;br /&gt;
* The response is sent back to the frontend and parsed.&lt;br /&gt;
*The React components update the UI (tables, heatmaps, statistics) based on the received data.&lt;br /&gt;
&lt;br /&gt;
This architecture ensures a clean separation between frontend and backend logic, improving maintainability and testability.&lt;br /&gt;
[[File:Dataflow.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
The test plan for Phase 2 focuses on verifying the successful integration of the newly reimplemented &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the React-based UI components. We aim to ensure data is:&lt;br /&gt;
&lt;br /&gt;
* Correctly fetched from the backend  &lt;br /&gt;
* Appropriately displayed in the frontend  &lt;br /&gt;
* Functionally sound under both normal and edge-case scenarios&lt;br /&gt;
&lt;br /&gt;
== Tools and Frameworks ==&lt;br /&gt;
We plan to use the following tools and frameworks for testing:&lt;br /&gt;
&lt;br /&gt;
* '''Frontend''': Jest and React Testing Library for unit and integration tests&lt;br /&gt;
* '''Backend''': RSpec for controller and model tests&lt;br /&gt;
* '''Integration Testing''': Capybara and Selenium for simulating real user behavior&lt;br /&gt;
* '''Test Coverage''': SimpleCov&lt;br /&gt;
&lt;br /&gt;
== 1. UI Integration Tests ==&lt;br /&gt;
&lt;br /&gt;
These tests ensure the frontend correctly interacts with backend APIs and renders the data appropriately.&lt;br /&gt;
&lt;br /&gt;
=== ReviewTable Component ===&lt;br /&gt;
&lt;br /&gt;
* Validate that the component makes a successful API call to fetch author feedback  &lt;br /&gt;
* Ensure feedback is rendered in the correct table structure  &lt;br /&gt;
* Test loading state before data is fetched  &lt;br /&gt;
* Handle empty or malformed feedback responses gracefully  &lt;br /&gt;
&lt;br /&gt;
=== RoundSelector Component ===&lt;br /&gt;
&lt;br /&gt;
* Verify API call to fetch heatmap data is triggered on component load  &lt;br /&gt;
* Check that heatmap data is correctly visualized for different review rounds  &lt;br /&gt;
* Test behavior with no data, incomplete data, or delayed response  &lt;br /&gt;
&lt;br /&gt;
=== Statistics Component ===&lt;br /&gt;
&lt;br /&gt;
* Confirm it correctly fetches teammate evaluations and author feedback  &lt;br /&gt;
* Ensure charts or tables reflect the received backend data accurately  &lt;br /&gt;
* Test switching between different teams or assignments and verify correct display  &lt;br /&gt;
&lt;br /&gt;
=== General UI Considerations ===&lt;br /&gt;
&lt;br /&gt;
* Test frontend responsiveness to backend failures (500, 404, timeout)  &lt;br /&gt;
* Ensure authorization errors are handled and appropriate messages displayed  &lt;br /&gt;
&lt;br /&gt;
== 2. Backend API Tests ==&lt;br /&gt;
&lt;br /&gt;
While unit tests exist, integration-level tests will be added or updated to ensure UI compatibility.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
* Validate all &amp;lt;code&amp;gt;GET&amp;lt;/code&amp;gt; endpoints return properly structured JSON objects  &lt;br /&gt;
* Simulate various user roles (student, TA, instructor) and ensure access control  &lt;br /&gt;
* Include test cases for:&lt;br /&gt;
** No grades present  &lt;br /&gt;
** Partial data (e.g. missing feedback or evaluations)  &lt;br /&gt;
** Large number of records  &lt;br /&gt;
&lt;br /&gt;
=== Security &amp;amp; Permissions ===&lt;br /&gt;
&lt;br /&gt;
* Ensure students can only fetch their grades and feedback  &lt;br /&gt;
* Ensure TAs and instructors can access full assignment data  &lt;br /&gt;
* Test token/session-based access restrictions (if applicable)  &lt;br /&gt;
&lt;br /&gt;
== 3. Database Preparation ==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, seed data will simulate real-world usage and we will ensure that:&lt;br /&gt;
* Tests will use isolated fixtures or factories to ensure data consistency&lt;br /&gt;
* All database states will be reset before each test suite run&lt;br /&gt;
&lt;br /&gt;
=== Tables and Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;assignments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_participant&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;participants&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;questionnaires&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;questions&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_questionnaire&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;signed_up_teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;teams_users&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;late_policies&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
=== Scenarios ===&lt;br /&gt;
&lt;br /&gt;
* Single student assigned  &lt;br /&gt;
* Team assignments with/without feedback  &lt;br /&gt;
* Late submissions triggering late policies  &lt;br /&gt;
* Multiple review rounds per assignment&lt;br /&gt;
&lt;br /&gt;
== 4. Regression &amp;amp; CI Testing ==&lt;br /&gt;
&lt;br /&gt;
To ensure updates do not break existing functionality:&lt;br /&gt;
&lt;br /&gt;
* Re-run all existing unit tests  &lt;br /&gt;
* Include snapshot tests for frontend components  &lt;br /&gt;
* Use CI pipelines to automatically trigger tests on pull requests  &lt;br /&gt;
&lt;br /&gt;
== Test Plan Summary ==&lt;br /&gt;
&lt;br /&gt;
This test plan outlines the approach for integrating &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the frontend. By combining backend tests, UI integration checks, and realistic database scenarios, we aim to deliver a seamless user experience. The plan emphasizes early detection of issues and supports long-term maintainability through regression testing. As development progresses, the plan will be updated to cover new insights and edge cases.&lt;br /&gt;
&lt;br /&gt;
=Completed Reimplementation Details=&lt;br /&gt;
&lt;br /&gt;
This section outlines the changes that were actually implemented as part of the reimplementation effort. It provides a detailed breakdown of how the frontend was decoupled from the legacy Ruby-embedded views, and how dynamic data flow was established using API endpoints. Specific components were modified to replace hardcoded or mock data with real-time API calls to the backend, ensuring that the application now reflects live grading data. Additionally, backend controller actions were updated to return clean, structured JSON responses, and the data retrieval logic was centralized to improve maintainability and testability. &lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The previous implementation was designed for a Ruby-embedded front-end, where data was rendered server-side and injected directly into the view. We have since updated the APIs to return data in a format suitable for consumption by the React UI, typically as JSON objects. This change successfully decouples the front-end from the server-side rendering logic, enabling a more interactive and responsive user experience. By transitioning to a React-based interface, we now have improved control over UI state and better alignment with modern web development practices.&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
In this controller, we have updated the GET functions to remove the use of instance variables and instead return plain JSON objects using render json: in the response. This update was essential to align with the frontend architecture, which now relies on a React-based interface that expects structured data from the backend in JSON format rather than server-rendered templates. By returning JSON responses, we’ve established cleaner and more consistent API endpoints, improved the testability and debuggability of our backend logic, and created a more maintainable and decoupled integration between the frontend and backend systems. The following functions were updated as part of this integration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  def view_grading_report&lt;br /&gt;
    assignment_id = params[:id].to_i&lt;br /&gt;
    data = get_data_for_heat_map(assignment_id)&lt;br /&gt;
    &lt;br /&gt;
    render json: data, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
    &lt;br /&gt;
  def view_my_scores&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team_id = TeamsUser.team_id(participant.assignment_id, participant.user_id)&lt;br /&gt;
  &lt;br /&gt;
    questions = fetch_questionnaires_and_questions(assignment)&lt;br /&gt;
    pscore = fetch_participant_scores(participant, questions)&lt;br /&gt;
    topic_id = SignedUpTeam.find_topic_id_for_user(participant.assignment.id, participant.user_id)&lt;br /&gt;
    stage = participant.assignment.current_stage(topic_id)&lt;br /&gt;
    &lt;br /&gt;
    sum = SummaryHelper::Summary.new.summarize_reviews_by_reviewee(questions, assignment, team_id, 'http://peerlogic.csc.ncsu.edu/sum/v1.0/summary/8/lsa', session)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      topic_id: topic_id,&lt;br /&gt;
      stage: stage,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      summary: sum.summary,&lt;br /&gt;
      avg_scores_by_round: sum.avg_scores_by_round,&lt;br /&gt;
      avg_scores_by_criterion: sum.avg_scores_by_criterion&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def view_team&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    team_id = team.id&lt;br /&gt;
  &lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: assignment.id).map(&amp;amp;:questionnaire)&lt;br /&gt;
    questions = retrieve_questions(questionnaires, assignment.id)&lt;br /&gt;
    pscore = Response.participant_scores(participant, questions)&lt;br /&gt;
    vmlist = process_questionare_for_team(assignment, team_id,questionnaires, team, participant)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team: team,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      vmlist: vmlist&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These updates were important for the backend and ensured seamless communication with the React frontend. By removing instance variables and returning structured JSON responses, we eliminated dependencies on server-side rendering and enabled the frontend to dynamically manage and render data. This not only enhances performance and flexibility but also improves maintainability and scalability as the application evolves. Moreover, it allows the backend and frontend to evolve independently, supporting better separation of concerns and aligning with current best practices in full-stack web development.&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We have successfully reimplemented the previously pre-populated data with appropriate HTTP GET calls to the backend. This ensures that our application now reflects real-time data directly from the server, improving data accuracy and consistency across the UI. This update also enhances scalability and maintainability, as the frontend no longer depends on static content and can adapt to backend changes without manual intervention. This was the main focus of this project. &lt;br /&gt;
&lt;br /&gt;
All dummy data throughout these components has been successfully removed and replaced with real-time API integrations. This transition allows for a fully dynamic, data-driven React frontend that remains synchronized with backend updates and user interactions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Files and components that were updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' This component, loaded from App.tsx, initially used dummyAuthorFeedback data. Our goal was to replace this with an API call to retrieve real-time author feedback data from the backend. The updated implementation was reviewed to ensure proper API integration and dynamic rendering of review tables.&lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' Initially using dummy heatmap data, this component was updated to fetch live heatmap data via an API call. The review ensured that the component responds appropriately to data updates and correctly renders the heatmap.&lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:''' This component previously relied on static data for team-mates and author feedback. We mapped these to backend APIs. The review focused on validating the accuracy of the displayed statistics and their alignment with backend data.&lt;br /&gt;
&lt;br /&gt;
   '''ShowReview.tsx:''' This component was updated to dynamically display review content using data fetched from the backend instead of static placeholders. We reviewed this update to ensure it correctly loads the appropriate review details and handles edge cases like missing or malformed data.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Finally, we integrated all components with actual API calls, completing the transition from static content to dynamic, backend-driven data flow across the React frontend.&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
A key component of this project involved populating the necessary database tables that the grades_controller.rb relies on to serve real-time data to the frontend. This step was essential for replacing the previously hardcoded or pre-populated dummy data with dynamic, API-driven content. Below is a list of the database tables that were seeded with mock data specifically for development and testing purposes in this project:&lt;br /&gt;
&lt;br /&gt;
* roles&lt;br /&gt;
* institutions&lt;br /&gt;
* users&lt;br /&gt;
* assignments&lt;br /&gt;
* teams &lt;br /&gt;
* teams_users&lt;br /&gt;
* sign_up_topics&lt;br /&gt;
* signed_up_teams&lt;br /&gt;
* participants&lt;br /&gt;
* questionnaires&lt;br /&gt;
* questions &lt;br /&gt;
* assignment_questionaires&lt;br /&gt;
* response_maps&lt;br /&gt;
* responses&lt;br /&gt;
* score_views&lt;br /&gt;
* tag-prompts&lt;br /&gt;
* tag_prompt_deployments&lt;br /&gt;
&lt;br /&gt;
In order to correctly populate each database, we referenced the Expertiza Database Documentation to understand the schema, and then mapped out the relevant tables needed by grades_controller.rb. Then we populated them with mock data to support development and testing of the new API-driven frontend.&lt;br /&gt;
&lt;br /&gt;
==Data Flow Overview==&lt;br /&gt;
&lt;br /&gt;
The diagram from the implementation plan remained the same, illustrating the consistent data flow between the React frontend components and the grades_controller.rb backend during grading data retrieval.&lt;br /&gt;
&lt;br /&gt;
* The user (such as an instructor or student) interacts with the React-based grades interface—components like ReviewTable, RoundSelector, or Statistics.&lt;br /&gt;
&lt;br /&gt;
* In response to this interaction, the component initiates an API request to a specific endpoint in grades_controller.rb.&lt;br /&gt;
&lt;br /&gt;
* The controller action then queries the relevant backend models (such as Assignment, Team, and ReviewResponseMap) and constructs a structured JSON response.&lt;br /&gt;
&lt;br /&gt;
* This JSON data is returned to the frontend, where it is parsed by the corresponding React component.&lt;br /&gt;
&lt;br /&gt;
* Finally, the React components dynamically update the UI—populating tables, generating heatmaps, or displaying statistics—based on the data received.&lt;br /&gt;
&lt;br /&gt;
This architecture promotes a clear separation of concerns between frontend and backend layers, enabling more scalable development, easier debugging, and improved maintainability and testability across the application.&lt;br /&gt;
&lt;br /&gt;
==Adhering to Priciples==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
=Testing=&lt;br /&gt;
&lt;br /&gt;
==Testing Overview==&lt;br /&gt;
&lt;br /&gt;
After modifying several methods in grades_controller.rb to return JSON responses and support the new React-based frontend, we conducted comprehensive testing to ensure that both the backend logic and frontend integration functioned as intended. It was essential to validate not only that the backend endpoints behaved correctly in isolation, but also that the frontend components were able to successfully consume and render the data returned by the updated APIs.&lt;br /&gt;
&lt;br /&gt;
We retested all affected methods to verify that data was retrieved accurately, permission checks were enforced, and updates were correctly persisted. In addition to running automated RSpec tests, we manually tested the backend endpoints using authenticated curl commands. These terminal-based tests allowed us to simulate real API usage, verify response structures, and confirm compatibility with the frontend. This dual-layered testing approach ensured a smooth and reliable interaction between the React UI and the Rails backend.&lt;br /&gt;
&lt;br /&gt;
==Database Preparation==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, we populated the database with carefully designed mock data that simulates a variety of real-world grading scenarios. This approach ensured that our test environment closely mirrors actual usage patterns, allowing for more meaningful validation of the grades_controller.rb logic and its interactions with related models.&lt;br /&gt;
 &lt;br /&gt;
We created test scenarios that covered a range of use cases, including individual and team assignments, review rounds, and various submissions, to verify that each controller action behaves as expected under different conditions. By populating the relevant tables with representative data, we were able to rigorously test features like permission checks, grade updates, response mapping, and feedback rendering.&lt;br /&gt;
&lt;br /&gt;
The specific databases that were populated can be found in the Database section.&lt;br /&gt;
&lt;br /&gt;
[[File:Grades_Database.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==Backend Tests==&lt;br /&gt;
&lt;br /&gt;
After modifying several methods in grades_controller.rb to return JSON responses and integrate with the new React-based frontend, we conducted targeted RSpec tests to validate the backend functionality to ensure frontend compatibility. These tests ensured that each controller method operated correctly in isolation and that the frontend components could successfully consume the API responses as expected.&lt;br /&gt;
&lt;br /&gt;
RSpec tests were written for the following controller methods:&lt;br /&gt;
&lt;br /&gt;
* action_allowed?&lt;br /&gt;
* view_my_scores&lt;br /&gt;
* view_team&lt;br /&gt;
* edit_participant_scores&lt;br /&gt;
* update_participant_grade&lt;br /&gt;
* update_team&lt;br /&gt;
* instructor_review&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:rspec_grades.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==API Endpoint Tests==&lt;br /&gt;
&lt;br /&gt;
We used Postman to test our API endpoints during development and deployment. It allowed us to easily send HTTP requests and validate the structure and content of the responses. By simulating real client requests, we were able to verify authentication flows, check for correct status codes, and confirm that our endpoints returned the expected data, ensuring the backend was functioning as intended.&lt;br /&gt;
&lt;br /&gt;
=== view_grading_report ===&lt;br /&gt;
[[File:API1.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== view_my_scores ===&lt;br /&gt;
[[File:API2.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== view_team ===&lt;br /&gt;
[[File:API3.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UI and API Integration Tests==&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164562</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164562"/>
		<updated>2025-04-22T12:46:25Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* UI */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of this project is to integrate the frontend of the grades view page with the reimplemented '''''grades_controller.rb (E2510)''''' backend in Expertiza, ensuring a seamless connection between both layers. This integration involves refining the interaction between the UI and backend while adhering to best design principles such as modularity, maintainability, and scalability. The grades_controller.rb is responsible for managing grading functionality, allowing instructors to view and modify assignment grades while enabling students to access their evaluations. By following SOLID and DRY principles, this reimplementation enhances code clarity, reduces redundancy, and improves overall system efficiency.&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
The &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; is responsible for managing and delivering grading data to users in the Expertiza system. It enables instructors to view, calculate, and release grades to students, while also allowing students to view feedback and scores for assignments. The controller plays an important role in coordinating backend logic for reviews and grade visibility.&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
The previous implementation successfully created a functional frontend UI page in Expertiza, addressing design inconsistencies and improving usability. It introduced a visually cohesive interface with an intuitive layout, enhanced responsiveness, and improved information display, allowing users to navigate grading data more efficiently. However, the interface was populated using dummy data, limiting its practical use. This reimplemented UI will utilize real data from the database (that has been populated in this round), ensuring that grading information is dynamically retrieved and displayed accurately through JSON objects. Additionally, this phase will connect the redesigned frontend with some new components in the grades_controller.rb. Specifically, the GET functions in the grades_controller were reimplemented to return JSON objects (instead of instance variables) that could be accessed via an API call. Thus, this new implementation ensures seamless communication between the UI and backend while adhering to best design practices for maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
This project focuses on integrating the frontend of the grades view page with the reimplemented '''grades_controller.rb (E2510)''' backend in Expertiza. This integration requires modifications to both the frontend and backend to establish a seamless connection, ensuring that grading data is dynamically retrieved and displayed accurately. By adhering to best design principles such as modularity, maintainability, and scalability, the implementation will enhance system efficiency and long-term usability. Key improvements include replacing dummy data with real database values, refining data flow between the UI and backend, and optimizing API interactions for better performance. These enhancements will create a more intuitive and reliable grading system, providing a seamless experience for instructors and students while maintaining a well-structured and adaptable codebase for future development.&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
# '''Establish a Robust Connection Between the Frontend and Backend''': Ensure smooth data retrieval and updates between the grades view page and the backend by integrating dynamic data through API calls, replacing the current hardcoded dummy data.&lt;br /&gt;
# '''Define and Implement Clear API Endpoints''': Create well-structured API endpoints in grades_controller.rb for retrieving and displaying grades, ensuring they return appropriate data based on user roles (students, instructors, TAs) and maintain role-based access controls.&lt;br /&gt;
# '''Dynamic Data Integration''': Modify the frontend to consume real-time data fetched from the backend, ensuring an intuitive and responsive UI that reflects the actual grading information. &lt;br /&gt;
# '''Reimplement Frontend and Backend Components''': Reimplement both the frontend and backend as necessary to align with SOLID and DRY principles, ensuring modularity, maintainability, and scalability. This includes eliminating redundant logic and optimizing code for better readability.&lt;br /&gt;
# '''Implement Proper Permission Checks''': Ensure that only authorized users can access grade information by implementing robust privilege checks and ensuring that the data is securely accessible to students, instructors, and TAs based on their roles.&lt;br /&gt;
# '''Optimize Database Queries and API Responses''': Enhance the efficiency of database queries and API responses to reduce unnecessary load and ensure that data is retrieved and displayed promptly.&lt;br /&gt;
# '''Testing and Validation''': Implement comprehensive unit and integration tests to verify the correctness of data flow, UI interactions, and role-based access controls, ensuring that the system functions correctly and securely.&lt;br /&gt;
&lt;br /&gt;
=Reimplementation Plan=&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populated data with the appropriate HTTP GET and HTTP POST calls. This shift is necessary to ensure that our application reflects real-time data from the backend rather than relying on static or hardcoded values, which can quickly become outdated or inconsistent. It also enables better scalability and maintainability, as changes to the data only need to be made in the backend, without requiring manual updates in the frontend code.&lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
'''Author Feedback''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
'''Heatmap Data''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
'''Team-mate Data''':&lt;br /&gt;
   {&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The current implementation caters to the backend for a Ruby-embedded front-end, where data is rendered server-side and passed directly into the view. We need to update the APIs to return data in a format that can be consumed by the React UI, typically JSON. This shift is essential to decouple the front-end from the server-side rendering logic, allowing for a more interactive and dynamic user experience. By transitioning to a React-based interface, we gain better control over UI state and responsiveness, while also aligning with modern web development practices. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and instead return plain JSON objects using render json: in the response. This change is necessary to align with a frontend architecture that uses React or another JavaScript framework, which expects structured data from the backend in JSON format rather than relying on server-rendered templates. By shifting to JSON responses, we enable cleaner API endpoints, facilitate easier testing and debugging, and support a more maintainable, decoupled frontend-backend integration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
  1.1. Students&lt;br /&gt;
  1.2. Teams&lt;br /&gt;
  1.3. TA&lt;br /&gt;
  1.4. Instructir&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
  2.1 assignments&lt;br /&gt;
  2.2 assignment_questionnaire&lt;br /&gt;
  2.3 questionnaires&lt;br /&gt;
  2.4 participants&lt;br /&gt;
  2.5 signed_up_teams&lt;br /&gt;
  2.6 teams_users&lt;br /&gt;
  2.9 questions&lt;br /&gt;
  2.10 users&lt;br /&gt;
  2.11 teams&lt;br /&gt;
  2.12 sign_up_topics&lt;br /&gt;
  2.13 response_maps&lt;br /&gt;
  2.14 responses&lt;br /&gt;
  2.15 answers&lt;br /&gt;
  2.16 score_views&lt;br /&gt;
  2.17 tag_prompts&lt;br /&gt;
  2.18 tag_prompts_deployments&lt;br /&gt;
&lt;br /&gt;
== Data Flow Overview ==&lt;br /&gt;
The diagram below illustrates how data flows between the frontend React components and the grades_controller.rb backend during a typical grading data fetch operation.&lt;br /&gt;
&lt;br /&gt;
* The user (e.g., instructor or student) interacts with the React-based grades view (e.g., ReviewTable, RoundSelector, or Statistics).&lt;br /&gt;
* The component triggers an API request to a specific action in grades_controller.rb (e.g., GET /grades/:id/summary).&lt;br /&gt;
*The controller action queries the relevant models (e.g., Assignment, Team, ReviewResponseMap) and compiles a JSON response.&lt;br /&gt;
* The response is sent back to the frontend and parsed.&lt;br /&gt;
*The React components update the UI (tables, heatmaps, statistics) based on the received data.&lt;br /&gt;
&lt;br /&gt;
This architecture ensures a clean separation between frontend and backend logic, improving maintainability and testability.&lt;br /&gt;
[[File:Dataflow.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
The test plan for Phase 2 focuses on verifying the successful integration of the newly reimplemented &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the React-based UI components. We aim to ensure data is:&lt;br /&gt;
&lt;br /&gt;
* Correctly fetched from the backend  &lt;br /&gt;
* Appropriately displayed in the frontend  &lt;br /&gt;
* Functionally sound under both normal and edge-case scenarios&lt;br /&gt;
&lt;br /&gt;
== Tools and Frameworks ==&lt;br /&gt;
We plan to use the following tools and frameworks for testing:&lt;br /&gt;
&lt;br /&gt;
* '''Frontend''': Jest and React Testing Library for unit and integration tests&lt;br /&gt;
* '''Backend''': RSpec for controller and model tests&lt;br /&gt;
* '''Integration Testing''': Capybara and Selenium for simulating real user behavior&lt;br /&gt;
* '''Test Coverage''': SimpleCov&lt;br /&gt;
&lt;br /&gt;
== 1. UI Integration Tests ==&lt;br /&gt;
&lt;br /&gt;
These tests ensure the frontend correctly interacts with backend APIs and renders the data appropriately.&lt;br /&gt;
&lt;br /&gt;
=== ReviewTable Component ===&lt;br /&gt;
&lt;br /&gt;
* Validate that the component makes a successful API call to fetch author feedback  &lt;br /&gt;
* Ensure feedback is rendered in the correct table structure  &lt;br /&gt;
* Test loading state before data is fetched  &lt;br /&gt;
* Handle empty or malformed feedback responses gracefully  &lt;br /&gt;
&lt;br /&gt;
=== RoundSelector Component ===&lt;br /&gt;
&lt;br /&gt;
* Verify API call to fetch heatmap data is triggered on component load  &lt;br /&gt;
* Check that heatmap data is correctly visualized for different review rounds  &lt;br /&gt;
* Test behavior with no data, incomplete data, or delayed response  &lt;br /&gt;
&lt;br /&gt;
=== Statistics Component ===&lt;br /&gt;
&lt;br /&gt;
* Confirm it correctly fetches teammate evaluations and author feedback  &lt;br /&gt;
* Ensure charts or tables reflect the received backend data accurately  &lt;br /&gt;
* Test switching between different teams or assignments and verify correct display  &lt;br /&gt;
&lt;br /&gt;
=== General UI Considerations ===&lt;br /&gt;
&lt;br /&gt;
* Test frontend responsiveness to backend failures (500, 404, timeout)  &lt;br /&gt;
* Ensure authorization errors are handled and appropriate messages displayed  &lt;br /&gt;
&lt;br /&gt;
== 2. Backend API Tests ==&lt;br /&gt;
&lt;br /&gt;
While unit tests exist, integration-level tests will be added or updated to ensure UI compatibility.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
* Validate all &amp;lt;code&amp;gt;GET&amp;lt;/code&amp;gt; endpoints return properly structured JSON objects  &lt;br /&gt;
* Simulate various user roles (student, TA, instructor) and ensure access control  &lt;br /&gt;
* Include test cases for:&lt;br /&gt;
** No grades present  &lt;br /&gt;
** Partial data (e.g. missing feedback or evaluations)  &lt;br /&gt;
** Large number of records  &lt;br /&gt;
&lt;br /&gt;
=== Security &amp;amp; Permissions ===&lt;br /&gt;
&lt;br /&gt;
* Ensure students can only fetch their grades and feedback  &lt;br /&gt;
* Ensure TAs and instructors can access full assignment data  &lt;br /&gt;
* Test token/session-based access restrictions (if applicable)  &lt;br /&gt;
&lt;br /&gt;
== 3. Database Preparation ==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, seed data will simulate real-world usage and we will ensure that:&lt;br /&gt;
* Tests will use isolated fixtures or factories to ensure data consistency&lt;br /&gt;
* All database states will be reset before each test suite run&lt;br /&gt;
&lt;br /&gt;
=== Tables and Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;assignments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_participant&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;participants&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;questionnaires&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;questions&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_questionnaire&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;signed_up_teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;teams_users&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;late_policies&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
=== Scenarios ===&lt;br /&gt;
&lt;br /&gt;
* Single student assigned  &lt;br /&gt;
* Team assignments with/without feedback  &lt;br /&gt;
* Late submissions triggering late policies  &lt;br /&gt;
* Multiple review rounds per assignment&lt;br /&gt;
&lt;br /&gt;
== 4. Regression &amp;amp; CI Testing ==&lt;br /&gt;
&lt;br /&gt;
To ensure updates do not break existing functionality:&lt;br /&gt;
&lt;br /&gt;
* Re-run all existing unit tests  &lt;br /&gt;
* Include snapshot tests for frontend components  &lt;br /&gt;
* Use CI pipelines to automatically trigger tests on pull requests  &lt;br /&gt;
&lt;br /&gt;
== Test Plan Summary ==&lt;br /&gt;
&lt;br /&gt;
This test plan outlines the approach for integrating &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the frontend. By combining backend tests, UI integration checks, and realistic database scenarios, we aim to deliver a seamless user experience. The plan emphasizes early detection of issues and supports long-term maintainability through regression testing. As development progresses, the plan will be updated to cover new insights and edge cases.&lt;br /&gt;
&lt;br /&gt;
=Completed Reimplementation Details=&lt;br /&gt;
&lt;br /&gt;
This section outlines the changes that were actually implemented as part of the reimplementation effort. It provides a detailed breakdown of how the frontend was decoupled from the legacy Ruby-embedded views, and how dynamic data flow was established using API endpoints. Specific components were modified to replace hardcoded or mock data with real-time API calls to the backend, ensuring that the application now reflects live grading data. Additionally, backend controller actions were updated to return clean, structured JSON responses, and the data retrieval logic was centralized to improve maintainability and testability. &lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The previous implementation was designed for a Ruby-embedded front-end, where data was rendered server-side and injected directly into the view. We have since updated the APIs to return data in a format suitable for consumption by the React UI, typically as JSON objects. This change successfully decouples the front-end from the server-side rendering logic, enabling a more interactive and responsive user experience. By transitioning to a React-based interface, we now have improved control over UI state and better alignment with modern web development practices.&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
In this controller, we have updated the GET functions to remove the use of instance variables and instead return plain JSON objects using render json: in the response. This update was essential to align with the frontend architecture, which now relies on a React-based interface that expects structured data from the backend in JSON format rather than server-rendered templates. By returning JSON responses, we’ve established cleaner and more consistent API endpoints, improved the testability and debuggability of our backend logic, and created a more maintainable and decoupled integration between the frontend and backend systems. The following functions were updated as part of this integration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  def view_grading_report&lt;br /&gt;
    assignment_id = params[:id].to_i&lt;br /&gt;
    data = get_data_for_heat_map(assignment_id)&lt;br /&gt;
    &lt;br /&gt;
    render json: data, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
    &lt;br /&gt;
  def view_my_scores&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team_id = TeamsUser.team_id(participant.assignment_id, participant.user_id)&lt;br /&gt;
  &lt;br /&gt;
    questions = fetch_questionnaires_and_questions(assignment)&lt;br /&gt;
    pscore = fetch_participant_scores(participant, questions)&lt;br /&gt;
    topic_id = SignedUpTeam.find_topic_id_for_user(participant.assignment.id, participant.user_id)&lt;br /&gt;
    stage = participant.assignment.current_stage(topic_id)&lt;br /&gt;
    &lt;br /&gt;
    sum = SummaryHelper::Summary.new.summarize_reviews_by_reviewee(questions, assignment, team_id, 'http://peerlogic.csc.ncsu.edu/sum/v1.0/summary/8/lsa', session)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      topic_id: topic_id,&lt;br /&gt;
      stage: stage,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      summary: sum.summary,&lt;br /&gt;
      avg_scores_by_round: sum.avg_scores_by_round,&lt;br /&gt;
      avg_scores_by_criterion: sum.avg_scores_by_criterion&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def view_team&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    team_id = team.id&lt;br /&gt;
  &lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: assignment.id).map(&amp;amp;:questionnaire)&lt;br /&gt;
    questions = retrieve_questions(questionnaires, assignment.id)&lt;br /&gt;
    pscore = Response.participant_scores(participant, questions)&lt;br /&gt;
    vmlist = process_questionare_for_team(assignment, team_id,questionnaires, team, participant)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team: team,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      vmlist: vmlist&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These updates were important for the backend and ensured seamless communication with the React frontend. By removing instance variables and returning structured JSON responses, we eliminated dependencies on server-side rendering and enabled the frontend to dynamically manage and render data. This not only enhances performance and flexibility but also improves maintainability and scalability as the application evolves. Moreover, it allows the backend and frontend to evolve independently, supporting better separation of concerns and aligning with current best practices in full-stack web development.&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We have successfully reimplemented the previously pre-populated data with appropriate HTTP GET calls to the backend. This ensures that our application now reflects real-time data directly from the server, improving data accuracy and consistency across the UI. This update also enhances scalability and maintainability, as the frontend no longer depends on static content and can adapt to backend changes without manual intervention. This was the main focus of this project. &lt;br /&gt;
&lt;br /&gt;
All dummy data throughout these components has been successfully removed and replaced with real-time API integrations. This transition allows for a fully dynamic, data-driven React frontend that remains synchronized with backend updates and user interactions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Files and components that were updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' This component, loaded from App.tsx, initially used dummyAuthorFeedback data. Our goal was to replace this with an API call to retrieve real-time author feedback data from the backend. The updated implementation was reviewed to ensure proper API integration and dynamic rendering of review tables.&lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' Initially using dummy heatmap data, this component was updated to fetch live heatmap data via an API call. The review ensured that the component responds appropriately to data updates and correctly renders the heatmap.&lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:''' This component previously relied on static data for team-mates and author feedback. We mapped these to backend APIs. The review focused on validating the accuracy of the displayed statistics and their alignment with backend data.&lt;br /&gt;
&lt;br /&gt;
   '''ShowReview.tsx:''' This component was updated to dynamically display review content using data fetched from the backend instead of static placeholders. We reviewed this update to ensure it correctly loads the appropriate review details and handles edge cases like missing or malformed data.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Finally, we integrated all components with actual API calls, completing the transition from static content to dynamic, backend-driven data flow across the React frontend.&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
A key component of this project involved populating the necessary database tables that the grades_controller.rb relies on to serve real-time data to the frontend. This step was essential for replacing the previously hardcoded or pre-populated dummy data with dynamic, API-driven content. Below is a list of the database tables that were seeded with mock data specifically for development and testing purposes in this project:&lt;br /&gt;
&lt;br /&gt;
* roles&lt;br /&gt;
* institutions&lt;br /&gt;
* users&lt;br /&gt;
* assignments&lt;br /&gt;
* teams &lt;br /&gt;
* teams_users&lt;br /&gt;
* sign_up_topics&lt;br /&gt;
* signed_up_teams&lt;br /&gt;
* participants&lt;br /&gt;
* questionnaires&lt;br /&gt;
* questions &lt;br /&gt;
* assignment_questionaires&lt;br /&gt;
* response_maps&lt;br /&gt;
* responses&lt;br /&gt;
* score_views&lt;br /&gt;
* tag-prompts&lt;br /&gt;
* tag_prompt_deployments&lt;br /&gt;
&lt;br /&gt;
In order to correctly populate each database, we referenced the Expertiza Database Documentation to understand the schema, and then mapped out the relevant tables needed by grades_controller.rb. Then we populated them with mock data to support development and testing of the new API-driven frontend.&lt;br /&gt;
&lt;br /&gt;
==Data Flow Overview==&lt;br /&gt;
&lt;br /&gt;
The diagram from the implementation plan remained the same, illustrating the consistent data flow between the React frontend components and the grades_controller.rb backend during grading data retrieval.&lt;br /&gt;
&lt;br /&gt;
* The user (such as an instructor or student) interacts with the React-based grades interface—components like ReviewTable, RoundSelector, or Statistics.&lt;br /&gt;
&lt;br /&gt;
* In response to this interaction, the component initiates an API request to a specific endpoint in grades_controller.rb.&lt;br /&gt;
&lt;br /&gt;
* The controller action then queries the relevant backend models (such as Assignment, Team, and ReviewResponseMap) and constructs a structured JSON response.&lt;br /&gt;
&lt;br /&gt;
* This JSON data is returned to the frontend, where it is parsed by the corresponding React component.&lt;br /&gt;
&lt;br /&gt;
* Finally, the React components dynamically update the UI—populating tables, generating heatmaps, or displaying statistics—based on the data received.&lt;br /&gt;
&lt;br /&gt;
This architecture promotes a clear separation of concerns between frontend and backend layers, enabling more scalable development, easier debugging, and improved maintainability and testability across the application.&lt;br /&gt;
&lt;br /&gt;
==Adhering to Priciples==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
=Testing=&lt;br /&gt;
&lt;br /&gt;
==Testing Overview==&lt;br /&gt;
&lt;br /&gt;
After modifying several methods in grades_controller.rb to return JSON responses and support the new React-based frontend, we conducted comprehensive testing to ensure that both the backend logic and frontend integration functioned as intended. It was essential to validate not only that the backend endpoints behaved correctly in isolation, but also that the frontend components were able to successfully consume and render the data returned by the updated APIs.&lt;br /&gt;
&lt;br /&gt;
We retested all affected methods to verify that data was retrieved accurately, permission checks were enforced, and updates were correctly persisted. In addition to running automated RSpec tests, we manually tested the backend endpoints using authenticated curl commands. These terminal-based tests allowed us to simulate real API usage, verify response structures, and confirm compatibility with the frontend. This dual-layered testing approach ensured a smooth and reliable interaction between the React UI and the Rails backend.&lt;br /&gt;
&lt;br /&gt;
==Database Preparation==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, we populated the database with carefully designed mock data that simulates a variety of real-world grading scenarios. This approach ensured that our test environment closely mirrors actual usage patterns, allowing for more meaningful validation of the grades_controller.rb logic and its interactions with related models.&lt;br /&gt;
 &lt;br /&gt;
We created test scenarios that covered a range of use cases, including individual and team assignments, review rounds, and various submissions, to verify that each controller action behaves as expected under different conditions. By populating the relevant tables with representative data, we were able to rigorously test features like permission checks, grade updates, response mapping, and feedback rendering.&lt;br /&gt;
&lt;br /&gt;
The specific databases that were populated can be found in the Database section.&lt;br /&gt;
&lt;br /&gt;
[[File:Grades_Database.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==Backend Tests==&lt;br /&gt;
&lt;br /&gt;
After modifying several methods in grades_controller.rb to return JSON responses and integrate with the new React-based frontend, we conducted targeted RSpec tests to validate the backend functionality to ensure frontend compatibility. These tests ensured that each controller method operated correctly in isolation and that the frontend components could successfully consume the API responses as expected.&lt;br /&gt;
&lt;br /&gt;
RSpec tests were written for the following controller methods:&lt;br /&gt;
&lt;br /&gt;
* action_allowed?&lt;br /&gt;
* view_my_scores&lt;br /&gt;
* view_team&lt;br /&gt;
* edit_participant_scores&lt;br /&gt;
* update_participant_grade&lt;br /&gt;
* update_team&lt;br /&gt;
* instructor_review&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:rspec_grades.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==API Endpoint Tests==&lt;br /&gt;
&lt;br /&gt;
We used Postman to test our API endpoints during development and deployment. It allowed us to easily send HTTP requests and validate the structure and content of the responses. By simulating real client requests, we were able to verify authentication flows, check for correct status codes, and confirm that our endpoints returned the expected data, ensuring the backend was functioning as intended.&lt;br /&gt;
&lt;br /&gt;
=== view_grading_report ===&lt;br /&gt;
[[File:API1.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== view_my_scores ===&lt;br /&gt;
[[File:API2.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== view_team ===&lt;br /&gt;
[[File:API3.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UI and API Integration Tests==&lt;br /&gt;
&lt;br /&gt;
==Tables and Test Coverage==&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164561</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164561"/>
		<updated>2025-04-22T12:39:08Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* Data Flow Overview */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of this project is to integrate the frontend of the grades view page with the reimplemented '''''grades_controller.rb (E2510)''''' backend in Expertiza, ensuring a seamless connection between both layers. This integration involves refining the interaction between the UI and backend while adhering to best design principles such as modularity, maintainability, and scalability. The grades_controller.rb is responsible for managing grading functionality, allowing instructors to view and modify assignment grades while enabling students to access their evaluations. By following SOLID and DRY principles, this reimplementation enhances code clarity, reduces redundancy, and improves overall system efficiency.&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
The &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; is responsible for managing and delivering grading data to users in the Expertiza system. It enables instructors to view, calculate, and release grades to students, while also allowing students to view feedback and scores for assignments. The controller plays an important role in coordinating backend logic for reviews and grade visibility.&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
The previous implementation successfully created a functional frontend UI page in Expertiza, addressing design inconsistencies and improving usability. It introduced a visually cohesive interface with an intuitive layout, enhanced responsiveness, and improved information display, allowing users to navigate grading data more efficiently. However, the interface was populated using dummy data, limiting its practical use. This reimplemented UI will utilize real data from the database (that has been populated in this round), ensuring that grading information is dynamically retrieved and displayed accurately through JSON objects. Additionally, this phase will connect the redesigned frontend with some new components in the grades_controller.rb. Specifically, the GET functions in the grades_controller were reimplemented to return JSON objects (instead of instance variables) that could be accessed via an API call. Thus, this new implementation ensures seamless communication between the UI and backend while adhering to best design practices for maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
This project focuses on integrating the frontend of the grades view page with the reimplemented '''grades_controller.rb (E2510)''' backend in Expertiza. This integration requires modifications to both the frontend and backend to establish a seamless connection, ensuring that grading data is dynamically retrieved and displayed accurately. By adhering to best design principles such as modularity, maintainability, and scalability, the implementation will enhance system efficiency and long-term usability. Key improvements include replacing dummy data with real database values, refining data flow between the UI and backend, and optimizing API interactions for better performance. These enhancements will create a more intuitive and reliable grading system, providing a seamless experience for instructors and students while maintaining a well-structured and adaptable codebase for future development.&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
# '''Establish a Robust Connection Between the Frontend and Backend''': Ensure smooth data retrieval and updates between the grades view page and the backend by integrating dynamic data through API calls, replacing the current hardcoded dummy data.&lt;br /&gt;
# '''Define and Implement Clear API Endpoints''': Create well-structured API endpoints in grades_controller.rb for retrieving and displaying grades, ensuring they return appropriate data based on user roles (students, instructors, TAs) and maintain role-based access controls.&lt;br /&gt;
# '''Dynamic Data Integration''': Modify the frontend to consume real-time data fetched from the backend, ensuring an intuitive and responsive UI that reflects the actual grading information. &lt;br /&gt;
# '''Reimplement Frontend and Backend Components''': Reimplement both the frontend and backend as necessary to align with SOLID and DRY principles, ensuring modularity, maintainability, and scalability. This includes eliminating redundant logic and optimizing code for better readability.&lt;br /&gt;
# '''Implement Proper Permission Checks''': Ensure that only authorized users can access grade information by implementing robust privilege checks and ensuring that the data is securely accessible to students, instructors, and TAs based on their roles.&lt;br /&gt;
# '''Optimize Database Queries and API Responses''': Enhance the efficiency of database queries and API responses to reduce unnecessary load and ensure that data is retrieved and displayed promptly.&lt;br /&gt;
# '''Testing and Validation''': Implement comprehensive unit and integration tests to verify the correctness of data flow, UI interactions, and role-based access controls, ensuring that the system functions correctly and securely.&lt;br /&gt;
&lt;br /&gt;
=Reimplementation Plan=&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populated data with the appropriate HTTP GET and HTTP POST calls. This shift is necessary to ensure that our application reflects real-time data from the backend rather than relying on static or hardcoded values, which can quickly become outdated or inconsistent. It also enables better scalability and maintainability, as changes to the data only need to be made in the backend, without requiring manual updates in the frontend code.&lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
'''Author Feedback''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
'''Heatmap Data''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
'''Team-mate Data''':&lt;br /&gt;
   {&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The current implementation caters to the backend for a Ruby-embedded front-end, where data is rendered server-side and passed directly into the view. We need to update the APIs to return data in a format that can be consumed by the React UI, typically JSON. This shift is essential to decouple the front-end from the server-side rendering logic, allowing for a more interactive and dynamic user experience. By transitioning to a React-based interface, we gain better control over UI state and responsiveness, while also aligning with modern web development practices. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and instead return plain JSON objects using render json: in the response. This change is necessary to align with a frontend architecture that uses React or another JavaScript framework, which expects structured data from the backend in JSON format rather than relying on server-rendered templates. By shifting to JSON responses, we enable cleaner API endpoints, facilitate easier testing and debugging, and support a more maintainable, decoupled frontend-backend integration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
  1.1. Students&lt;br /&gt;
  1.2. Teams&lt;br /&gt;
  1.3. TA&lt;br /&gt;
  1.4. Instructir&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
  2.1 assignments&lt;br /&gt;
  2.2 assignment_questionnaire&lt;br /&gt;
  2.3 questionnaires&lt;br /&gt;
  2.4 participants&lt;br /&gt;
  2.5 signed_up_teams&lt;br /&gt;
  2.6 teams_users&lt;br /&gt;
  2.9 questions&lt;br /&gt;
  2.10 users&lt;br /&gt;
  2.11 teams&lt;br /&gt;
  2.12 sign_up_topics&lt;br /&gt;
  2.13 response_maps&lt;br /&gt;
  2.14 responses&lt;br /&gt;
  2.15 answers&lt;br /&gt;
  2.16 score_views&lt;br /&gt;
  2.17 tag_prompts&lt;br /&gt;
  2.18 tag_prompts_deployments&lt;br /&gt;
&lt;br /&gt;
== Data Flow Overview ==&lt;br /&gt;
The diagram below illustrates how data flows between the frontend React components and the grades_controller.rb backend during a typical grading data fetch operation.&lt;br /&gt;
&lt;br /&gt;
* The user (e.g., instructor or student) interacts with the React-based grades view (e.g., ReviewTable, RoundSelector, or Statistics).&lt;br /&gt;
* The component triggers an API request to a specific action in grades_controller.rb (e.g., GET /grades/:id/summary).&lt;br /&gt;
*The controller action queries the relevant models (e.g., Assignment, Team, ReviewResponseMap) and compiles a JSON response.&lt;br /&gt;
* The response is sent back to the frontend and parsed.&lt;br /&gt;
*The React components update the UI (tables, heatmaps, statistics) based on the received data.&lt;br /&gt;
&lt;br /&gt;
This architecture ensures a clean separation between frontend and backend logic, improving maintainability and testability.&lt;br /&gt;
[[File:Dataflow.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
The test plan for Phase 2 focuses on verifying the successful integration of the newly reimplemented &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the React-based UI components. We aim to ensure data is:&lt;br /&gt;
&lt;br /&gt;
* Correctly fetched from the backend  &lt;br /&gt;
* Appropriately displayed in the frontend  &lt;br /&gt;
* Functionally sound under both normal and edge-case scenarios&lt;br /&gt;
&lt;br /&gt;
== Tools and Frameworks ==&lt;br /&gt;
We plan to use the following tools and frameworks for testing:&lt;br /&gt;
&lt;br /&gt;
* '''Frontend''': Jest and React Testing Library for unit and integration tests&lt;br /&gt;
* '''Backend''': RSpec for controller and model tests&lt;br /&gt;
* '''Integration Testing''': Capybara and Selenium for simulating real user behavior&lt;br /&gt;
* '''Test Coverage''': SimpleCov&lt;br /&gt;
&lt;br /&gt;
== 1. UI Integration Tests ==&lt;br /&gt;
&lt;br /&gt;
These tests ensure the frontend correctly interacts with backend APIs and renders the data appropriately.&lt;br /&gt;
&lt;br /&gt;
=== ReviewTable Component ===&lt;br /&gt;
&lt;br /&gt;
* Validate that the component makes a successful API call to fetch author feedback  &lt;br /&gt;
* Ensure feedback is rendered in the correct table structure  &lt;br /&gt;
* Test loading state before data is fetched  &lt;br /&gt;
* Handle empty or malformed feedback responses gracefully  &lt;br /&gt;
&lt;br /&gt;
=== RoundSelector Component ===&lt;br /&gt;
&lt;br /&gt;
* Verify API call to fetch heatmap data is triggered on component load  &lt;br /&gt;
* Check that heatmap data is correctly visualized for different review rounds  &lt;br /&gt;
* Test behavior with no data, incomplete data, or delayed response  &lt;br /&gt;
&lt;br /&gt;
=== Statistics Component ===&lt;br /&gt;
&lt;br /&gt;
* Confirm it correctly fetches teammate evaluations and author feedback  &lt;br /&gt;
* Ensure charts or tables reflect the received backend data accurately  &lt;br /&gt;
* Test switching between different teams or assignments and verify correct display  &lt;br /&gt;
&lt;br /&gt;
=== General UI Considerations ===&lt;br /&gt;
&lt;br /&gt;
* Test frontend responsiveness to backend failures (500, 404, timeout)  &lt;br /&gt;
* Ensure authorization errors are handled and appropriate messages displayed  &lt;br /&gt;
&lt;br /&gt;
== 2. Backend API Tests ==&lt;br /&gt;
&lt;br /&gt;
While unit tests exist, integration-level tests will be added or updated to ensure UI compatibility.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
* Validate all &amp;lt;code&amp;gt;GET&amp;lt;/code&amp;gt; endpoints return properly structured JSON objects  &lt;br /&gt;
* Simulate various user roles (student, TA, instructor) and ensure access control  &lt;br /&gt;
* Include test cases for:&lt;br /&gt;
** No grades present  &lt;br /&gt;
** Partial data (e.g. missing feedback or evaluations)  &lt;br /&gt;
** Large number of records  &lt;br /&gt;
&lt;br /&gt;
=== Security &amp;amp; Permissions ===&lt;br /&gt;
&lt;br /&gt;
* Ensure students can only fetch their grades and feedback  &lt;br /&gt;
* Ensure TAs and instructors can access full assignment data  &lt;br /&gt;
* Test token/session-based access restrictions (if applicable)  &lt;br /&gt;
&lt;br /&gt;
== 3. Database Preparation ==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, seed data will simulate real-world usage and we will ensure that:&lt;br /&gt;
* Tests will use isolated fixtures or factories to ensure data consistency&lt;br /&gt;
* All database states will be reset before each test suite run&lt;br /&gt;
&lt;br /&gt;
=== Tables and Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;assignments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_participant&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;participants&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;questionnaires&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;questions&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_questionnaire&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;signed_up_teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;teams_users&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;late_policies&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
=== Scenarios ===&lt;br /&gt;
&lt;br /&gt;
* Single student assigned  &lt;br /&gt;
* Team assignments with/without feedback  &lt;br /&gt;
* Late submissions triggering late policies  &lt;br /&gt;
* Multiple review rounds per assignment&lt;br /&gt;
&lt;br /&gt;
== 4. Regression &amp;amp; CI Testing ==&lt;br /&gt;
&lt;br /&gt;
To ensure updates do not break existing functionality:&lt;br /&gt;
&lt;br /&gt;
* Re-run all existing unit tests  &lt;br /&gt;
* Include snapshot tests for frontend components  &lt;br /&gt;
* Use CI pipelines to automatically trigger tests on pull requests  &lt;br /&gt;
&lt;br /&gt;
== Test Plan Summary ==&lt;br /&gt;
&lt;br /&gt;
This test plan outlines the approach for integrating &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the frontend. By combining backend tests, UI integration checks, and realistic database scenarios, we aim to deliver a seamless user experience. The plan emphasizes early detection of issues and supports long-term maintainability through regression testing. As development progresses, the plan will be updated to cover new insights and edge cases.&lt;br /&gt;
&lt;br /&gt;
=Completed Reimplementation Details=&lt;br /&gt;
&lt;br /&gt;
This section outlines the changes that were actually implemented as part of the reimplementation effort. It provides a detailed breakdown of how the frontend was decoupled from the legacy Ruby-embedded views, and how dynamic data flow was established using API endpoints. Specific components were modified to replace hardcoded or mock data with real-time API calls to the backend, ensuring that the application now reflects live grading data. Additionally, backend controller actions were updated to return clean, structured JSON responses, and the data retrieval logic was centralized to improve maintainability and testability. &lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The previous implementation was designed for a Ruby-embedded front-end, where data was rendered server-side and injected directly into the view. We have since updated the APIs to return data in a format suitable for consumption by the React UI, typically as JSON objects. This change successfully decouples the front-end from the server-side rendering logic, enabling a more interactive and responsive user experience. By transitioning to a React-based interface, we now have improved control over UI state and better alignment with modern web development practices.&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
In this controller, we have updated the GET functions to remove the use of instance variables and instead return plain JSON objects using render json: in the response. This update was essential to align with the frontend architecture, which now relies on a React-based interface that expects structured data from the backend in JSON format rather than server-rendered templates. By returning JSON responses, we’ve established cleaner and more consistent API endpoints, improved the testability and debuggability of our backend logic, and created a more maintainable and decoupled integration between the frontend and backend systems. The following functions were updated as part of this integration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  def view_grading_report&lt;br /&gt;
    assignment_id = params[:id].to_i&lt;br /&gt;
    data = get_data_for_heat_map(assignment_id)&lt;br /&gt;
    &lt;br /&gt;
    render json: data, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
    &lt;br /&gt;
  def view_my_scores&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team_id = TeamsUser.team_id(participant.assignment_id, participant.user_id)&lt;br /&gt;
  &lt;br /&gt;
    questions = fetch_questionnaires_and_questions(assignment)&lt;br /&gt;
    pscore = fetch_participant_scores(participant, questions)&lt;br /&gt;
    topic_id = SignedUpTeam.find_topic_id_for_user(participant.assignment.id, participant.user_id)&lt;br /&gt;
    stage = participant.assignment.current_stage(topic_id)&lt;br /&gt;
    &lt;br /&gt;
    sum = SummaryHelper::Summary.new.summarize_reviews_by_reviewee(questions, assignment, team_id, 'http://peerlogic.csc.ncsu.edu/sum/v1.0/summary/8/lsa', session)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      topic_id: topic_id,&lt;br /&gt;
      stage: stage,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      summary: sum.summary,&lt;br /&gt;
      avg_scores_by_round: sum.avg_scores_by_round,&lt;br /&gt;
      avg_scores_by_criterion: sum.avg_scores_by_criterion&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def view_team&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    team_id = team.id&lt;br /&gt;
  &lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: assignment.id).map(&amp;amp;:questionnaire)&lt;br /&gt;
    questions = retrieve_questions(questionnaires, assignment.id)&lt;br /&gt;
    pscore = Response.participant_scores(participant, questions)&lt;br /&gt;
    vmlist = process_questionare_for_team(assignment, team_id,questionnaires, team, participant)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team: team,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      vmlist: vmlist&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These updates were important for the backend and ensured seamless communication with the React frontend. By removing instance variables and returning structured JSON responses, we eliminated dependencies on server-side rendering and enabled the frontend to dynamically manage and render data. This not only enhances performance and flexibility but also improves maintainability and scalability as the application evolves. Moreover, it allows the backend and frontend to evolve independently, supporting better separation of concerns and aligning with current best practices in full-stack web development.&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We have successfully  reimplemented the previously pre-populated data with appropriate HTTP GET calls to the backend. This ensures that our application now reflects real-time data directly from the server, improving data accuracy and consistency across the UI. This update also enhances scalability and maintainability, as the frontend no longer depends on static content and can adapt to backend changes without manual intervention.&lt;br /&gt;
&lt;br /&gt;
All dummy data throughout these components has been successfully removed and replaced with real-time API integrations. This transition allows for a fully dynamic, data-driven React frontend that remains synchronized with backend updates and user interactions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Files and components that were updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' &lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:'''&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
A key component of this project involved populating the necessary database tables that the grades_controller.rb relies on to serve real-time data to the frontend. This step was essential for replacing the previously hardcoded or pre-populated dummy data with dynamic, API-driven content. Below is a list of the database tables that were seeded with mock data specifically for development and testing purposes in this project:&lt;br /&gt;
&lt;br /&gt;
* roles&lt;br /&gt;
* institutions&lt;br /&gt;
* users&lt;br /&gt;
* assignments&lt;br /&gt;
* teams &lt;br /&gt;
* teams_users&lt;br /&gt;
* sign_up_topics&lt;br /&gt;
* signed_up_teams&lt;br /&gt;
* participants&lt;br /&gt;
* questionnaires&lt;br /&gt;
* questions &lt;br /&gt;
* assignment_questionaires&lt;br /&gt;
* response_maps&lt;br /&gt;
* responses&lt;br /&gt;
* score_views&lt;br /&gt;
* tag-prompts&lt;br /&gt;
* tag_prompt_deployments&lt;br /&gt;
&lt;br /&gt;
In order to correctly populate each database, we referenced the Expertiza Database Documentation to understand the schema, and then mapped out the relevant tables needed by grades_controller.rb. Then we populated them with mock data to support development and testing of the new API-driven frontend.&lt;br /&gt;
&lt;br /&gt;
==Data Flow Overview==&lt;br /&gt;
&lt;br /&gt;
The diagram from the implementation plan remained the same, illustrating the consistent data flow between the React frontend components and the grades_controller.rb backend during grading data retrieval.&lt;br /&gt;
&lt;br /&gt;
* The user (such as an instructor or student) interacts with the React-based grades interface—components like ReviewTable, RoundSelector, or Statistics.&lt;br /&gt;
&lt;br /&gt;
* In response to this interaction, the component initiates an API request to a specific endpoint in grades_controller.rb.&lt;br /&gt;
&lt;br /&gt;
* The controller action then queries the relevant backend models (such as Assignment, Team, and ReviewResponseMap) and constructs a structured JSON response.&lt;br /&gt;
&lt;br /&gt;
* This JSON data is returned to the frontend, where it is parsed by the corresponding React component.&lt;br /&gt;
&lt;br /&gt;
* Finally, the React components dynamically update the UI—populating tables, generating heatmaps, or displaying statistics—based on the data received.&lt;br /&gt;
&lt;br /&gt;
This architecture promotes a clear separation of concerns between frontend and backend layers, enabling more scalable development, easier debugging, and improved maintainability and testability across the application.&lt;br /&gt;
&lt;br /&gt;
==Adhering to Priciples==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
=Testing=&lt;br /&gt;
&lt;br /&gt;
==Testing Overview==&lt;br /&gt;
&lt;br /&gt;
After modifying several methods in grades_controller.rb to return JSON responses and support the new React-based frontend, we conducted comprehensive testing to ensure that both the backend logic and frontend integration functioned as intended. It was essential to validate not only that the backend endpoints behaved correctly in isolation, but also that the frontend components were able to successfully consume and render the data returned by the updated APIs.&lt;br /&gt;
&lt;br /&gt;
We retested all affected methods to verify that data was retrieved accurately, permission checks were enforced, and updates were correctly persisted. In addition to running automated RSpec tests, we manually tested the backend endpoints using authenticated curl commands. These terminal-based tests allowed us to simulate real API usage, verify response structures, and confirm compatibility with the frontend. This dual-layered testing approach ensured a smooth and reliable interaction between the React UI and the Rails backend.&lt;br /&gt;
&lt;br /&gt;
==Database Preparation==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, we populated the database with carefully designed mock data that simulates a variety of real-world grading scenarios. This approach ensured that our test environment closely mirrors actual usage patterns, allowing for more meaningful validation of the grades_controller.rb logic and its interactions with related models.&lt;br /&gt;
 &lt;br /&gt;
We created test scenarios that covered a range of use cases, including individual and team assignments, review rounds, and various submissions, to verify that each controller action behaves as expected under different conditions. By populating the relevant tables with representative data, we were able to rigorously test features like permission checks, grade updates, response mapping, and feedback rendering.&lt;br /&gt;
&lt;br /&gt;
The specific databases that were populated can be found in the Database section.&lt;br /&gt;
&lt;br /&gt;
[[File:Grades_Database.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==Backend Tests==&lt;br /&gt;
&lt;br /&gt;
After modifying several methods in grades_controller.rb to return JSON responses and integrate with the new React-based frontend, we conducted targeted RSpec tests to validate the backend functionality to ensure frontend compatibility. These tests ensured that each controller method operated correctly in isolation and that the frontend components could successfully consume the API responses as expected.&lt;br /&gt;
&lt;br /&gt;
RSpec tests were written for the following controller methods:&lt;br /&gt;
&lt;br /&gt;
* action_allowed?&lt;br /&gt;
* view_my_scores&lt;br /&gt;
* view_team&lt;br /&gt;
* edit_participant_scores&lt;br /&gt;
* update_participant_grade&lt;br /&gt;
* update_team&lt;br /&gt;
* instructor_review&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:rspec_grades.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==API Endpoint Tests==&lt;br /&gt;
&lt;br /&gt;
We used Postman to test our API endpoints during development and deployment. It allowed us to easily send HTTP requests and validate the structure and content of the responses. By simulating real client requests, we were able to verify authentication flows, check for correct status codes, and confirm that our endpoints returned the expected data, ensuring the backend was functioning as intended.&lt;br /&gt;
&lt;br /&gt;
=== view_grading_report ===&lt;br /&gt;
[[File:API1.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== view_my_scores ===&lt;br /&gt;
[[File:API2.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== view_team ===&lt;br /&gt;
[[File:API3.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UI and API Integration Tests==&lt;br /&gt;
&lt;br /&gt;
==Tables and Test Coverage==&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164250</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164250"/>
		<updated>2025-04-20T20:28:45Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* Completed Reimplementation Details */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of this project is to integrate the frontend of the grades view page with the reimplemented '''''grades_controller.rb (E2510)''''' backend in Expertiza, ensuring a seamless connection between both layers. This integration involves refining the interaction between the UI and backend while adhering to best design principles such as modularity, maintainability, and scalability. The grades_controller.rb is responsible for managing grading functionality, allowing instructors to view and modify assignment grades while enabling students to access their evaluations. By following SOLID and DRY principles, this reimplementation enhances code clarity, reduces redundancy, and improves overall system efficiency.&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
The &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; is responsible for managing and delivering grading data to users in the Expertiza system. It enables instructors to view, calculate, and release grades to students, while also allowing students to view feedback and scores for assignments. The controller plays an important role in coordinating backend logic for reviews and grade visibility.&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
The previous implementation successfully created a functional frontend UI page in Expertiza, addressing design inconsistencies and improving usability. It introduced a visually cohesive interface with an intuitive layout, enhanced responsiveness, and improved information display, allowing users to navigate grading data more efficiently. However, the interface was populated using dummy data, limiting its practical use. This reimplemented UI will utilize real data from the database (that has been populated in this round), ensuring that grading information is dynamically retrieved and displayed accurately through JSON objects. Additionally, this phase will connect the redesigned frontend with some new components in the grades_controller.rb. Specifically, the GET functions in the grades_controller were reimplemented to return JSON objects (instead of instance variables) that could be accessed via an API call. Thus, this new implementation ensures seamless communication between the UI and backend while adhering to best design practices for maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
This project focuses on integrating the frontend of the grades view page with the reimplemented '''grades_controller.rb (E2510)''' backend in Expertiza. This integration requires modifications to both the frontend and backend to establish a seamless connection, ensuring that grading data is dynamically retrieved and displayed accurately. By adhering to best design principles such as modularity, maintainability, and scalability, the implementation will enhance system efficiency and long-term usability. Key improvements include replacing dummy data with real database values, refining data flow between the UI and backend, and optimizing API interactions for better performance. These enhancements will create a more intuitive and reliable grading system, providing a seamless experience for instructors and students while maintaining a well-structured and adaptable codebase for future development.&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
# '''Establish a Robust Connection Between the Frontend and Backend''': Ensure smooth data retrieval and updates between the grades view page and the backend by integrating dynamic data through API calls, replacing the current hardcoded dummy data.&lt;br /&gt;
# '''Define and Implement Clear API Endpoints''': Create well-structured API endpoints in grades_controller.rb for retrieving and displaying grades, ensuring they return appropriate data based on user roles (students, instructors, TAs) and maintain role-based access controls.&lt;br /&gt;
# '''Dynamic Data Integration''': Modify the frontend to consume real-time data fetched from the backend, ensuring an intuitive and responsive UI that reflects the actual grading information. &lt;br /&gt;
# '''Reimplement Frontend and Backend Components''': Reimplement both the frontend and backend as necessary to align with SOLID and DRY principles, ensuring modularity, maintainability, and scalability. This includes eliminating redundant logic and optimizing code for better readability.&lt;br /&gt;
# '''Implement Proper Permission Checks''': Ensure that only authorized users can access grade information by implementing robust privilege checks and ensuring that the data is securely accessible to students, instructors, and TAs based on their roles.&lt;br /&gt;
# '''Optimize Database Queries and API Responses''': Enhance the efficiency of database queries and API responses to reduce unnecessary load and ensure that data is retrieved and displayed promptly.&lt;br /&gt;
# '''Testing and Validation''': Implement comprehensive unit and integration tests to verify the correctness of data flow, UI interactions, and role-based access controls, ensuring that the system functions correctly and securely.&lt;br /&gt;
&lt;br /&gt;
=Reimplementation Plan=&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populated data with the appropriate HTTP GET and HTTP POST calls. This shift is necessary to ensure that our application reflects real-time data from the backend rather than relying on static or hardcoded values, which can quickly become outdated or inconsistent. It also enables better scalability and maintainability, as changes to the data only need to be made in the backend, without requiring manual updates in the frontend code.&lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
'''Author Feedback''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
'''Heatmap Data''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
'''Team-mate Data''':&lt;br /&gt;
   {&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The current implementation caters to the backend for a Ruby-embedded front-end, where data is rendered server-side and passed directly into the view. We need to update the APIs to return data in a format that can be consumed by the React UI, typically JSON. This shift is essential to decouple the front-end from the server-side rendering logic, allowing for a more interactive and dynamic user experience. By transitioning to a React-based interface, we gain better control over UI state and responsiveness, while also aligning with modern web development practices. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and instead return plain JSON objects using render json: in the response. This change is necessary to align with a frontend architecture that uses React or another JavaScript framework, which expects structured data from the backend in JSON format rather than relying on server-rendered templates. By shifting to JSON responses, we enable cleaner API endpoints, facilitate easier testing and debugging, and support a more maintainable, decoupled frontend-backend integration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    # prepare feedback summaries&lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
  1.1. Students&lt;br /&gt;
  1.2. Teams&lt;br /&gt;
  1.3. TA&lt;br /&gt;
  1.4. Professor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
  2.1 assignments&lt;br /&gt;
  2.2 assignment_questionnaire&lt;br /&gt;
  2.3 questionnaires&lt;br /&gt;
  2.4 participant&lt;br /&gt;
  2.5 signed_up_teams&lt;br /&gt;
  2.6 teams_users&lt;br /&gt;
  2.7 due_dates&lt;br /&gt;
  2.8 late_policies&lt;br /&gt;
  2.9 questions&lt;br /&gt;
  2.10 review_scores&lt;br /&gt;
  2.11 review_grades&lt;br /&gt;
&lt;br /&gt;
== Data Flow Overview ==&lt;br /&gt;
The diagram below illustrates how data flows between the frontend React components and the grades_controller.rb backend during a typical grading data fetch operation.&lt;br /&gt;
&lt;br /&gt;
* The user (e.g., instructor or student) interacts with the React-based grades view (e.g., ReviewTable, RoundSelector, or Statistics).&lt;br /&gt;
* The component triggers an API request to a specific action in grades_controller.rb (e.g., GET /grades/:id/summary).&lt;br /&gt;
*The controller action queries the relevant models (e.g., Assignment, Team, ReviewResponseMap) and compiles a JSON response.&lt;br /&gt;
* The response is sent back to the frontend and parsed.&lt;br /&gt;
*The React components update the UI (tables, heatmaps, statistics) based on the received data.&lt;br /&gt;
&lt;br /&gt;
This architecture ensures a clean separation between frontend and backend logic, improving maintainability and testability.&lt;br /&gt;
[[File:Dataflow.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
The test plan for Phase 2 focuses on verifying the successful integration of the newly reimplemented &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the React-based UI components. We aim to ensure data is:&lt;br /&gt;
&lt;br /&gt;
* Correctly fetched from the backend  &lt;br /&gt;
* Appropriately displayed in the frontend  &lt;br /&gt;
* Functionally sound under both normal and edge-case scenarios&lt;br /&gt;
&lt;br /&gt;
== Tools and Frameworks ==&lt;br /&gt;
We plan to use the following tools and frameworks for testing:&lt;br /&gt;
&lt;br /&gt;
* '''Frontend''': Jest and React Testing Library for unit and integration tests&lt;br /&gt;
* '''Backend''': RSpec for controller and model tests&lt;br /&gt;
* '''Integration Testing''': Capybara and Selenium for simulating real user behavior&lt;br /&gt;
* '''Test Coverage''': SimpleCov&lt;br /&gt;
&lt;br /&gt;
== 1. UI Integration Tests ==&lt;br /&gt;
&lt;br /&gt;
These tests ensure the frontend correctly interacts with backend APIs and renders the data appropriately.&lt;br /&gt;
&lt;br /&gt;
=== ReviewTable Component ===&lt;br /&gt;
&lt;br /&gt;
* Validate that the component makes a successful API call to fetch author feedback  &lt;br /&gt;
* Ensure feedback is rendered in the correct table structure  &lt;br /&gt;
* Test loading state before data is fetched  &lt;br /&gt;
* Handle empty or malformed feedback responses gracefully  &lt;br /&gt;
&lt;br /&gt;
=== RoundSelector Component ===&lt;br /&gt;
&lt;br /&gt;
* Verify API call to fetch heatmap data is triggered on component load  &lt;br /&gt;
* Check that heatmap data is correctly visualized for different review rounds  &lt;br /&gt;
* Test behavior with no data, incomplete data, or delayed response  &lt;br /&gt;
&lt;br /&gt;
=== Statistics Component ===&lt;br /&gt;
&lt;br /&gt;
* Confirm it correctly fetches teammate evaluations and author feedback  &lt;br /&gt;
* Ensure charts or tables reflect the received backend data accurately  &lt;br /&gt;
* Test switching between different teams or assignments and verify correct display  &lt;br /&gt;
&lt;br /&gt;
=== General UI Considerations ===&lt;br /&gt;
&lt;br /&gt;
* Test frontend responsiveness to backend failures (500, 404, timeout)  &lt;br /&gt;
* Ensure authorization errors are handled and appropriate messages displayed  &lt;br /&gt;
&lt;br /&gt;
== 2. Backend API Tests ==&lt;br /&gt;
&lt;br /&gt;
While unit tests exist, integration-level tests will be added or updated to ensure UI compatibility.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
* Validate all &amp;lt;code&amp;gt;GET&amp;lt;/code&amp;gt; endpoints return properly structured JSON objects  &lt;br /&gt;
* Simulate various user roles (student, TA, instructor) and ensure access control  &lt;br /&gt;
* Include test cases for:&lt;br /&gt;
** No grades present  &lt;br /&gt;
** Partial data (e.g. missing feedback or evaluations)  &lt;br /&gt;
** Large number of records  &lt;br /&gt;
&lt;br /&gt;
=== Security &amp;amp; Permissions ===&lt;br /&gt;
&lt;br /&gt;
* Ensure students can only fetch their grades and feedback  &lt;br /&gt;
* Ensure TAs and instructors can access full assignment data  &lt;br /&gt;
* Test token/session-based access restrictions (if applicable)  &lt;br /&gt;
&lt;br /&gt;
== 3. Database Preparation ==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, seed data will simulate real-world usage and we will ensure that:&lt;br /&gt;
* Tests will use isolated fixtures or factories to ensure data consistency&lt;br /&gt;
* All database states will be reset before each test suite run&lt;br /&gt;
&lt;br /&gt;
=== Tables and Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;assignments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_participant&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;participants&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;questionnaires&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;questions&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_questionnaire&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;signed_up_teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;teams_users&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;late_policies&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
=== Scenarios ===&lt;br /&gt;
&lt;br /&gt;
* Single student assigned  &lt;br /&gt;
* Team assignments with/without feedback  &lt;br /&gt;
* Late submissions triggering late policies  &lt;br /&gt;
* Multiple review rounds per assignment&lt;br /&gt;
&lt;br /&gt;
== 4. Regression &amp;amp; CI Testing ==&lt;br /&gt;
&lt;br /&gt;
To ensure updates do not break existing functionality:&lt;br /&gt;
&lt;br /&gt;
* Re-run all existing unit tests  &lt;br /&gt;
* Include snapshot tests for frontend components  &lt;br /&gt;
* Use CI pipelines to automatically trigger tests on pull requests  &lt;br /&gt;
&lt;br /&gt;
== Test Plan Summary ==&lt;br /&gt;
&lt;br /&gt;
This test plan outlines the approach for integrating &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the frontend. By combining backend tests, UI integration checks, and realistic database scenarios, we aim to deliver a seamless user experience. The plan emphasizes early detection of issues and supports long-term maintainability through regression testing. As development progresses, the plan will be updated to cover new insights and edge cases.&lt;br /&gt;
&lt;br /&gt;
=Completed Reimplementation Details=&lt;br /&gt;
&lt;br /&gt;
This section outlines the changes that were actually implemented as part of the reimplementation effort. It provides a detailed breakdown of how the frontend was decoupled from the legacy Ruby-embedded views, and how dynamic data flow was established using API endpoints. Specific components were modified to replace hardcoded or mock data with real-time API calls to the backend, ensuring that the application now reflects live grading data. Additionally, backend controller actions were updated to return clean, structured JSON responses, and the data retrieval logic was centralized to improve maintainability and testability. &lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The previous implementation was designed for a Ruby-embedded front-end, where data was rendered server-side and injected directly into the view. We have since updated the APIs to return data in a format suitable for consumption by the React UI, typically as JSON objects. This change successfully decouples the front-end from the server-side rendering logic, enabling a more interactive and responsive user experience. By transitioning to a React-based interface, we now have improved control over UI state and better alignment with modern web development practices.&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
In this controller, we have updated the GET functions to remove the use of instance variables and instead return plain JSON objects using render json: in the response. This update was essential to align with the frontend architecture, which now relies on a React-based interface that expects structured data from the backend in JSON format rather than server-rendered templates. By returning JSON responses, we’ve established cleaner and more consistent API endpoints, improved the testability and debuggability of our backend logic, and created a more maintainable and decoupled integration between the frontend and backend systems. The following functions were updated as part of this integration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  def view_grading_report&lt;br /&gt;
    assignment_id = params[:id].to_i&lt;br /&gt;
    data = get_data_for_heat_map(assignment_id)&lt;br /&gt;
    &lt;br /&gt;
    render json: data, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
    &lt;br /&gt;
  def view_my_scores&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team_id = TeamsUser.team_id(participant.assignment_id, participant.user_id)&lt;br /&gt;
    # return if redirect_when_disallowed(participant)&lt;br /&gt;
    questions = fetch_questionnaires_and_questions(assignment)&lt;br /&gt;
    pscore = fetch_participant_scores(participant, questions)&lt;br /&gt;
    topic_id = SignedUpTeam.find_topic_id_for_user(participant.assignment.id, participant.user_id)&lt;br /&gt;
    stage = participant.assignment.current_stage(topic_id)&lt;br /&gt;
    # all_penalties = update_penalties(assignment)&lt;br /&gt;
    # Feedback Summary needs to be checked once&lt;br /&gt;
    # summary_ws_url = WEBSERVICE_CONFIG['summary_webservice_url']&lt;br /&gt;
    sum = SummaryHelper::Summary.new.summarize_reviews_by_reviewee(questions, assignment, team_id, 'http://peerlogic.csc.ncsu.edu/sum/v1.0/summary/8/lsa', session)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      topic_id: topic_id,&lt;br /&gt;
      stage: stage,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      summary: sum.summary,&lt;br /&gt;
      avg_scores_by_round: sum.avg_scores_by_round,&lt;br /&gt;
      avg_scores_by_criterion: sum.avg_scores_by_criterion&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def view_team&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    team_id = team.id&lt;br /&gt;
  &lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: assignment.id).map(&amp;amp;:questionnaire)&lt;br /&gt;
    questions = retrieve_questions(questionnaires, assignment.id)&lt;br /&gt;
    pscore = Response.participant_scores(participant, questions)&lt;br /&gt;
    vmlist = process_questionare_for_team(assignment, team_id,questionnaires, team, participant)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team: team,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      vmlist: vmlist&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These updates were important for the backend and ensured seamless communication with the React frontend. By removing instance variables and returning structured JSON responses, we eliminated dependencies on server-side rendering and enabled the frontend to dynamically manage and render data. This not only enhances performance and flexibility but also improves maintainability and scalability as the application evolves. Moreover, it allows the backend and frontend to evolve independently, supporting better separation of concerns and aligning with current best practices in full-stack web development.&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We have successfully  reimplemented the previously pre-populated data with appropriate HTTP GET calls to the backend. This ensures that our application now reflects real-time data directly from the server, improving data accuracy and consistency across the UI. This update also enhances scalability and maintainability, as the frontend no longer depends on static content and can adapt to backend changes without manual intervention.&lt;br /&gt;
&lt;br /&gt;
All dummy data throughout these components has been successfully removed and replaced with real-time API integrations. This transition allows for a fully dynamic, data-driven React frontend that remains synchronized with backend updates and user interactions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Files and components that were updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' &lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:'''&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
A key component of this project involved populating the necessary database tables that the grades_controller.rb relies on to serve real-time data to the frontend. This step was essential for replacing the previously hardcoded or pre-populated dummy data with dynamic, API-driven content. Below is a list of the database tables that were seeded with mock data specifically for development and testing purposes in this project:&lt;br /&gt;
&lt;br /&gt;
* roles&lt;br /&gt;
* institutions&lt;br /&gt;
* users&lt;br /&gt;
* assignments&lt;br /&gt;
* teams &lt;br /&gt;
* teams_users&lt;br /&gt;
* sign_up_topics&lt;br /&gt;
* signed_up_teams&lt;br /&gt;
* participants&lt;br /&gt;
* questionnaires&lt;br /&gt;
* questions &lt;br /&gt;
* assignment_questionaires&lt;br /&gt;
* response_maps&lt;br /&gt;
* responses&lt;br /&gt;
* score_views&lt;br /&gt;
* tag-prompts&lt;br /&gt;
* tag_prompt_deployments&lt;br /&gt;
&lt;br /&gt;
In order to correctly populate each database, we referenced the Expertiza Database Documentation to understand the schema, and then mapped out the relevant tables needed by grades_controller.rb. Then we populated them with mock data to support development and testing of the new API-driven frontend.&lt;br /&gt;
&lt;br /&gt;
==Data Flow Overview==&lt;br /&gt;
&lt;br /&gt;
The diagram below illustrates the data flow between React frontend components and the grades_controller.rb backend during a typical grading data retrieval process.&lt;br /&gt;
&lt;br /&gt;
* The user (such as an instructor or student) interacts with the React-based grades interface—components like ReviewTable, RoundSelector, or Statistics.&lt;br /&gt;
&lt;br /&gt;
* In response to this interaction, the component initiates an API request to a specific endpoint in grades_controller.rb.&lt;br /&gt;
&lt;br /&gt;
* The controller action then queries the relevant backend models (such as Assignment, Team, and ReviewResponseMap) and constructs a structured JSON response.&lt;br /&gt;
&lt;br /&gt;
* This JSON data is returned to the frontend, where it is parsed by the corresponding React component.&lt;br /&gt;
&lt;br /&gt;
* Finally, the React components dynamically update the UI—populating tables, generating heatmaps, or displaying statistics—based on the data received.&lt;br /&gt;
&lt;br /&gt;
This architecture promotes a clear separation of concerns between frontend and backend layers, enabling more scalable development, easier debugging, and improved maintainability and testability across the application.&lt;br /&gt;
&lt;br /&gt;
==Adhering to Priciples==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
=Testing=&lt;br /&gt;
&lt;br /&gt;
==Testing Overview==&lt;br /&gt;
&lt;br /&gt;
After modifying several methods in grades_controller.rb to return JSON responses and support the new React-based frontend, we conducted comprehensive testing to ensure that both the backend logic and frontend integration functioned as intended. It was essential to validate not only that the backend endpoints behaved correctly in isolation, but also that the frontend components were able to successfully consume and render the data returned by the updated APIs.&lt;br /&gt;
&lt;br /&gt;
We retested all affected methods to verify that data was retrieved accurately, permission checks were enforced, and updates were correctly persisted. In addition to running automated RSpec tests, we manually tested the backend endpoints using authenticated curl commands. These terminal-based tests allowed us to simulate real API usage, verify response structures, and confirm compatibility with the frontend. This dual-layered testing approach ensured a smooth and reliable interaction between the React UI and the Rails backend.&lt;br /&gt;
&lt;br /&gt;
==Database Preparation==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, we populated the database with carefully designed mock data that simulates a variety of real-world grading scenarios. This approach ensured that our test environment closely mirrors actual usage patterns, allowing for more meaningful validation of the grades_controller.rb logic and its interactions with related models.&lt;br /&gt;
 &lt;br /&gt;
We created test scenarios that covered a range of use cases, including individual and team assignments, review rounds, and various submissions, to verify that each controller action behaves as expected under different conditions. By populating the relevant tables with representative data, we were able to rigorously test features like permission checks, grade updates, response mapping, and feedback rendering.&lt;br /&gt;
&lt;br /&gt;
The specific databases that were populated can be found in the Database section.&lt;br /&gt;
&lt;br /&gt;
==Backend Tests==&lt;br /&gt;
&lt;br /&gt;
After modifying several methods in grades_controller.rb to return JSON responses and integrate with the new React-based frontend, we conducted targeted RSpec tests to validate both backend functionality and frontend compatibility. These tests ensured that each controller method operated correctly in isolation and that the frontend components could successfully consume the API responses as expected.&lt;br /&gt;
&lt;br /&gt;
RSpec tests were written for the following controller methods:&lt;br /&gt;
&lt;br /&gt;
* action_allowed?&lt;br /&gt;
* view_my_scores&lt;br /&gt;
* view_team&lt;br /&gt;
* edit_participant_scores&lt;br /&gt;
* update_participant_grade&lt;br /&gt;
* update_team&lt;br /&gt;
* instructor_review&lt;br /&gt;
&lt;br /&gt;
==API Endpoint (UI) Tests==&lt;br /&gt;
&lt;br /&gt;
==Tables and Test Coverage==&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164249</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164249"/>
		<updated>2025-04-20T20:28:28Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of this project is to integrate the frontend of the grades view page with the reimplemented '''''grades_controller.rb (E2510)''''' backend in Expertiza, ensuring a seamless connection between both layers. This integration involves refining the interaction between the UI and backend while adhering to best design principles such as modularity, maintainability, and scalability. The grades_controller.rb is responsible for managing grading functionality, allowing instructors to view and modify assignment grades while enabling students to access their evaluations. By following SOLID and DRY principles, this reimplementation enhances code clarity, reduces redundancy, and improves overall system efficiency.&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
The &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; is responsible for managing and delivering grading data to users in the Expertiza system. It enables instructors to view, calculate, and release grades to students, while also allowing students to view feedback and scores for assignments. The controller plays an important role in coordinating backend logic for reviews and grade visibility.&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
The previous implementation successfully created a functional frontend UI page in Expertiza, addressing design inconsistencies and improving usability. It introduced a visually cohesive interface with an intuitive layout, enhanced responsiveness, and improved information display, allowing users to navigate grading data more efficiently. However, the interface was populated using dummy data, limiting its practical use. This reimplemented UI will utilize real data from the database (that has been populated in this round), ensuring that grading information is dynamically retrieved and displayed accurately through JSON objects. Additionally, this phase will connect the redesigned frontend with some new components in the grades_controller.rb. Specifically, the GET functions in the grades_controller were reimplemented to return JSON objects (instead of instance variables) that could be accessed via an API call. Thus, this new implementation ensures seamless communication between the UI and backend while adhering to best design practices for maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
This project focuses on integrating the frontend of the grades view page with the reimplemented '''grades_controller.rb (E2510)''' backend in Expertiza. This integration requires modifications to both the frontend and backend to establish a seamless connection, ensuring that grading data is dynamically retrieved and displayed accurately. By adhering to best design principles such as modularity, maintainability, and scalability, the implementation will enhance system efficiency and long-term usability. Key improvements include replacing dummy data with real database values, refining data flow between the UI and backend, and optimizing API interactions for better performance. These enhancements will create a more intuitive and reliable grading system, providing a seamless experience for instructors and students while maintaining a well-structured and adaptable codebase for future development.&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
# '''Establish a Robust Connection Between the Frontend and Backend''': Ensure smooth data retrieval and updates between the grades view page and the backend by integrating dynamic data through API calls, replacing the current hardcoded dummy data.&lt;br /&gt;
# '''Define and Implement Clear API Endpoints''': Create well-structured API endpoints in grades_controller.rb for retrieving and displaying grades, ensuring they return appropriate data based on user roles (students, instructors, TAs) and maintain role-based access controls.&lt;br /&gt;
# '''Dynamic Data Integration''': Modify the frontend to consume real-time data fetched from the backend, ensuring an intuitive and responsive UI that reflects the actual grading information. &lt;br /&gt;
# '''Reimplement Frontend and Backend Components''': Reimplement both the frontend and backend as necessary to align with SOLID and DRY principles, ensuring modularity, maintainability, and scalability. This includes eliminating redundant logic and optimizing code for better readability.&lt;br /&gt;
# '''Implement Proper Permission Checks''': Ensure that only authorized users can access grade information by implementing robust privilege checks and ensuring that the data is securely accessible to students, instructors, and TAs based on their roles.&lt;br /&gt;
# '''Optimize Database Queries and API Responses''': Enhance the efficiency of database queries and API responses to reduce unnecessary load and ensure that data is retrieved and displayed promptly.&lt;br /&gt;
# '''Testing and Validation''': Implement comprehensive unit and integration tests to verify the correctness of data flow, UI interactions, and role-based access controls, ensuring that the system functions correctly and securely.&lt;br /&gt;
&lt;br /&gt;
=Reimplementation Plan=&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populated data with the appropriate HTTP GET and HTTP POST calls. This shift is necessary to ensure that our application reflects real-time data from the backend rather than relying on static or hardcoded values, which can quickly become outdated or inconsistent. It also enables better scalability and maintainability, as changes to the data only need to be made in the backend, without requiring manual updates in the frontend code.&lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
'''Author Feedback''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
'''Heatmap Data''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
'''Team-mate Data''':&lt;br /&gt;
   {&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The current implementation caters to the backend for a Ruby-embedded front-end, where data is rendered server-side and passed directly into the view. We need to update the APIs to return data in a format that can be consumed by the React UI, typically JSON. This shift is essential to decouple the front-end from the server-side rendering logic, allowing for a more interactive and dynamic user experience. By transitioning to a React-based interface, we gain better control over UI state and responsiveness, while also aligning with modern web development practices. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and instead return plain JSON objects using render json: in the response. This change is necessary to align with a frontend architecture that uses React or another JavaScript framework, which expects structured data from the backend in JSON format rather than relying on server-rendered templates. By shifting to JSON responses, we enable cleaner API endpoints, facilitate easier testing and debugging, and support a more maintainable, decoupled frontend-backend integration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    # prepare feedback summaries&lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
  1.1. Students&lt;br /&gt;
  1.2. Teams&lt;br /&gt;
  1.3. TA&lt;br /&gt;
  1.4. Professor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
  2.1 assignments&lt;br /&gt;
  2.2 assignment_questionnaire&lt;br /&gt;
  2.3 questionnaires&lt;br /&gt;
  2.4 participant&lt;br /&gt;
  2.5 signed_up_teams&lt;br /&gt;
  2.6 teams_users&lt;br /&gt;
  2.7 due_dates&lt;br /&gt;
  2.8 late_policies&lt;br /&gt;
  2.9 questions&lt;br /&gt;
  2.10 review_scores&lt;br /&gt;
  2.11 review_grades&lt;br /&gt;
&lt;br /&gt;
== Data Flow Overview ==&lt;br /&gt;
The diagram below illustrates how data flows between the frontend React components and the grades_controller.rb backend during a typical grading data fetch operation.&lt;br /&gt;
&lt;br /&gt;
* The user (e.g., instructor or student) interacts with the React-based grades view (e.g., ReviewTable, RoundSelector, or Statistics).&lt;br /&gt;
* The component triggers an API request to a specific action in grades_controller.rb (e.g., GET /grades/:id/summary).&lt;br /&gt;
*The controller action queries the relevant models (e.g., Assignment, Team, ReviewResponseMap) and compiles a JSON response.&lt;br /&gt;
* The response is sent back to the frontend and parsed.&lt;br /&gt;
*The React components update the UI (tables, heatmaps, statistics) based on the received data.&lt;br /&gt;
&lt;br /&gt;
This architecture ensures a clean separation between frontend and backend logic, improving maintainability and testability.&lt;br /&gt;
[[File:Dataflow.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
The test plan for Phase 2 focuses on verifying the successful integration of the newly reimplemented &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the React-based UI components. We aim to ensure data is:&lt;br /&gt;
&lt;br /&gt;
* Correctly fetched from the backend  &lt;br /&gt;
* Appropriately displayed in the frontend  &lt;br /&gt;
* Functionally sound under both normal and edge-case scenarios&lt;br /&gt;
&lt;br /&gt;
== Tools and Frameworks ==&lt;br /&gt;
We plan to use the following tools and frameworks for testing:&lt;br /&gt;
&lt;br /&gt;
* '''Frontend''': Jest and React Testing Library for unit and integration tests&lt;br /&gt;
* '''Backend''': RSpec for controller and model tests&lt;br /&gt;
* '''Integration Testing''': Capybara and Selenium for simulating real user behavior&lt;br /&gt;
* '''Test Coverage''': SimpleCov&lt;br /&gt;
&lt;br /&gt;
== 1. UI Integration Tests ==&lt;br /&gt;
&lt;br /&gt;
These tests ensure the frontend correctly interacts with backend APIs and renders the data appropriately.&lt;br /&gt;
&lt;br /&gt;
=== ReviewTable Component ===&lt;br /&gt;
&lt;br /&gt;
* Validate that the component makes a successful API call to fetch author feedback  &lt;br /&gt;
* Ensure feedback is rendered in the correct table structure  &lt;br /&gt;
* Test loading state before data is fetched  &lt;br /&gt;
* Handle empty or malformed feedback responses gracefully  &lt;br /&gt;
&lt;br /&gt;
=== RoundSelector Component ===&lt;br /&gt;
&lt;br /&gt;
* Verify API call to fetch heatmap data is triggered on component load  &lt;br /&gt;
* Check that heatmap data is correctly visualized for different review rounds  &lt;br /&gt;
* Test behavior with no data, incomplete data, or delayed response  &lt;br /&gt;
&lt;br /&gt;
=== Statistics Component ===&lt;br /&gt;
&lt;br /&gt;
* Confirm it correctly fetches teammate evaluations and author feedback  &lt;br /&gt;
* Ensure charts or tables reflect the received backend data accurately  &lt;br /&gt;
* Test switching between different teams or assignments and verify correct display  &lt;br /&gt;
&lt;br /&gt;
=== General UI Considerations ===&lt;br /&gt;
&lt;br /&gt;
* Test frontend responsiveness to backend failures (500, 404, timeout)  &lt;br /&gt;
* Ensure authorization errors are handled and appropriate messages displayed  &lt;br /&gt;
&lt;br /&gt;
== 2. Backend API Tests ==&lt;br /&gt;
&lt;br /&gt;
While unit tests exist, integration-level tests will be added or updated to ensure UI compatibility.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
* Validate all &amp;lt;code&amp;gt;GET&amp;lt;/code&amp;gt; endpoints return properly structured JSON objects  &lt;br /&gt;
* Simulate various user roles (student, TA, instructor) and ensure access control  &lt;br /&gt;
* Include test cases for:&lt;br /&gt;
** No grades present  &lt;br /&gt;
** Partial data (e.g. missing feedback or evaluations)  &lt;br /&gt;
** Large number of records  &lt;br /&gt;
&lt;br /&gt;
=== Security &amp;amp; Permissions ===&lt;br /&gt;
&lt;br /&gt;
* Ensure students can only fetch their grades and feedback  &lt;br /&gt;
* Ensure TAs and instructors can access full assignment data  &lt;br /&gt;
* Test token/session-based access restrictions (if applicable)  &lt;br /&gt;
&lt;br /&gt;
== 3. Database Preparation ==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, seed data will simulate real-world usage and we will ensure that:&lt;br /&gt;
* Tests will use isolated fixtures or factories to ensure data consistency&lt;br /&gt;
* All database states will be reset before each test suite run&lt;br /&gt;
&lt;br /&gt;
=== Tables and Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;assignments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_participant&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;participants&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;questionnaires&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;questions&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_questionnaire&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;signed_up_teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;teams_users&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;late_policies&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
=== Scenarios ===&lt;br /&gt;
&lt;br /&gt;
* Single student assigned  &lt;br /&gt;
* Team assignments with/without feedback  &lt;br /&gt;
* Late submissions triggering late policies  &lt;br /&gt;
* Multiple review rounds per assignment&lt;br /&gt;
&lt;br /&gt;
== 4. Regression &amp;amp; CI Testing ==&lt;br /&gt;
&lt;br /&gt;
To ensure updates do not break existing functionality:&lt;br /&gt;
&lt;br /&gt;
* Re-run all existing unit tests  &lt;br /&gt;
* Include snapshot tests for frontend components  &lt;br /&gt;
* Use CI pipelines to automatically trigger tests on pull requests  &lt;br /&gt;
&lt;br /&gt;
== Test Plan Summary ==&lt;br /&gt;
&lt;br /&gt;
This test plan outlines the approach for integrating &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the frontend. By combining backend tests, UI integration checks, and realistic database scenarios, we aim to deliver a seamless user experience. The plan emphasizes early detection of issues and supports long-term maintainability through regression testing. As development progresses, the plan will be updated to cover new insights and edge cases.&lt;br /&gt;
&lt;br /&gt;
=Completed Reimplementation Details=&lt;br /&gt;
&lt;br /&gt;
This section outlines the changes that were actually implemented as part of the reimplementation effort. It provides a detailed breakdown of how the frontend was decoupled from the legacy Ruby-embedded views, and how dynamic data flow was established using API endpoints. Specific components were modified to replace hardcoded or mock data with real-time API calls to the backend, ensuring that the application now reflects live grading data. Additionally, backend controller actions were updated to return clean, structured JSON responses, and the data retrieval logic was centralized to improve maintainability and testability. &lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The previous implementation was designed for a Ruby-embedded front-end, where data was rendered server-side and injected directly into the view. We have since updated the APIs to return data in a format suitable for consumption by the React UI, typically as JSON objects. This change successfully decouples the front-end from the server-side rendering logic, enabling a more interactive and responsive user experience. By transitioning to a React-based interface, we now have improved control over UI state and better alignment with modern web development practices.&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
In this controller, we have updated the GET functions to remove the use of instance variables and instead return plain JSON objects using render json: in the response. This update was essential to align with the frontend architecture, which now relies on a React-based interface that expects structured data from the backend in JSON format rather than server-rendered templates. By returning JSON responses, we’ve established cleaner and more consistent API endpoints, improved the testability and debuggability of our backend logic, and created a more maintainable and decoupled integration between the frontend and backend systems. The following functions were updated as part of this integration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  def view_grading_report&lt;br /&gt;
    assignment_id = params[:id].to_i&lt;br /&gt;
    data = get_data_for_heat_map(assignment_id)&lt;br /&gt;
    &lt;br /&gt;
    render json: data, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
    &lt;br /&gt;
  def view_my_scores&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team_id = TeamsUser.team_id(participant.assignment_id, participant.user_id)&lt;br /&gt;
    # return if redirect_when_disallowed(participant)&lt;br /&gt;
    questions = fetch_questionnaires_and_questions(assignment)&lt;br /&gt;
    pscore = fetch_participant_scores(participant, questions)&lt;br /&gt;
    topic_id = SignedUpTeam.find_topic_id_for_user(participant.assignment.id, participant.user_id)&lt;br /&gt;
    stage = participant.assignment.current_stage(topic_id)&lt;br /&gt;
    # all_penalties = update_penalties(assignment)&lt;br /&gt;
    # Feedback Summary needs to be checked once&lt;br /&gt;
    # summary_ws_url = WEBSERVICE_CONFIG['summary_webservice_url']&lt;br /&gt;
    sum = SummaryHelper::Summary.new.summarize_reviews_by_reviewee(questions, assignment, team_id, 'http://peerlogic.csc.ncsu.edu/sum/v1.0/summary/8/lsa', session)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      topic_id: topic_id,&lt;br /&gt;
      stage: stage,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      summary: sum.summary,&lt;br /&gt;
      avg_scores_by_round: sum.avg_scores_by_round,&lt;br /&gt;
      avg_scores_by_criterion: sum.avg_scores_by_criterion&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def view_team&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    team_id = team.id&lt;br /&gt;
  &lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: assignment.id).map(&amp;amp;:questionnaire)&lt;br /&gt;
    questions = retrieve_questions(questionnaires, assignment.id)&lt;br /&gt;
    pscore = Response.participant_scores(participant, questions)&lt;br /&gt;
    vmlist = process_questionare_for_team(assignment, team_id,questionnaires, team, participant)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team: team,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      vmlist: vmlist&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These updates were important for the backend and ensured seamless communication with the React frontend. By removing instance variables and returning structured JSON responses, we eliminated dependencies on server-side rendering and enabled the frontend to dynamically manage and render data. This not only enhances performance and flexibility but also improves maintainability and scalability as the application evolves. Moreover, it allows the backend and frontend to evolve independently, supporting better separation of concerns and aligning with current best practices in full-stack web development.&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We have successfully  reimplemented the previously pre-populated data with appropriate HTTP GET calls to the backend. This ensures that our application now reflects real-time data directly from the server, improving data accuracy and consistency across the UI. This update also enhances scalability and maintainability, as the frontend no longer depends on static content and can adapt to backend changes without manual intervention.&lt;br /&gt;
&lt;br /&gt;
All dummy data throughout these components has been successfully removed and replaced with real-time API integrations. This transition allows for a fully dynamic, data-driven React frontend that remains synchronized with backend updates and user interactions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Files and components that were updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' &lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:'''&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
A key component of this project involved populating the necessary database tables that the grades_controller.rb relies on to serve real-time data to the frontend. This step was essential for replacing the previously hardcoded or pre-populated dummy data with dynamic, API-driven content. Below is a list of the database tables that were seeded with mock data specifically for development and testing purposes in this project:&lt;br /&gt;
&lt;br /&gt;
* roles&lt;br /&gt;
* institutions&lt;br /&gt;
* users&lt;br /&gt;
* assignments&lt;br /&gt;
* teams &lt;br /&gt;
* teams_users&lt;br /&gt;
* sign_up_topics&lt;br /&gt;
* signed_up_teams&lt;br /&gt;
* participants&lt;br /&gt;
* questionnaires&lt;br /&gt;
* questions &lt;br /&gt;
* assignment_questionaires&lt;br /&gt;
* response_maps&lt;br /&gt;
* responses&lt;br /&gt;
* score_views&lt;br /&gt;
* tag-prompts&lt;br /&gt;
* tag_prompt_deployments&lt;br /&gt;
&lt;br /&gt;
In order to correctly populate each database, we referenced the Expertiza Database Documentation to understand the schema, and then mapped out the relevant tables needed by grades_controller.rb. Then we populated them with mock data to support development and testing of the new API-driven frontend.&lt;br /&gt;
&lt;br /&gt;
==Data Flow Overview==&lt;br /&gt;
&lt;br /&gt;
The diagram below illustrates the data flow between React frontend components and the grades_controller.rb backend during a typical grading data retrieval process.&lt;br /&gt;
&lt;br /&gt;
* The user (such as an instructor or student) interacts with the React-based grades interface—components like ReviewTable, RoundSelector, or Statistics.&lt;br /&gt;
&lt;br /&gt;
* In response to this interaction, the component initiates an API request to a specific endpoint in grades_controller.rb.&lt;br /&gt;
&lt;br /&gt;
* The controller action then queries the relevant backend models (such as Assignment, Team, and ReviewResponseMap) and constructs a structured JSON response.&lt;br /&gt;
&lt;br /&gt;
* This JSON data is returned to the frontend, where it is parsed by the corresponding React component.&lt;br /&gt;
&lt;br /&gt;
* Finally, the React components dynamically update the UI—populating tables, generating heatmaps, or displaying statistics—based on the data received.&lt;br /&gt;
&lt;br /&gt;
This architecture promotes a clear separation of concerns between frontend and backend layers, enabling more scalable development, easier debugging, and improved maintainability and testability across the application.&lt;br /&gt;
&lt;br /&gt;
=Testing=&lt;br /&gt;
&lt;br /&gt;
==Testing Overview==&lt;br /&gt;
&lt;br /&gt;
After modifying several methods in grades_controller.rb to return JSON responses and support the new React-based frontend, we conducted comprehensive testing to ensure that both the backend logic and frontend integration functioned as intended. It was essential to validate not only that the backend endpoints behaved correctly in isolation, but also that the frontend components were able to successfully consume and render the data returned by the updated APIs.&lt;br /&gt;
&lt;br /&gt;
We retested all affected methods to verify that data was retrieved accurately, permission checks were enforced, and updates were correctly persisted. In addition to running automated RSpec tests, we manually tested the backend endpoints using authenticated curl commands. These terminal-based tests allowed us to simulate real API usage, verify response structures, and confirm compatibility with the frontend. This dual-layered testing approach ensured a smooth and reliable interaction between the React UI and the Rails backend.&lt;br /&gt;
&lt;br /&gt;
==Database Preparation==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, we populated the database with carefully designed mock data that simulates a variety of real-world grading scenarios. This approach ensured that our test environment closely mirrors actual usage patterns, allowing for more meaningful validation of the grades_controller.rb logic and its interactions with related models.&lt;br /&gt;
 &lt;br /&gt;
We created test scenarios that covered a range of use cases, including individual and team assignments, review rounds, and various submissions, to verify that each controller action behaves as expected under different conditions. By populating the relevant tables with representative data, we were able to rigorously test features like permission checks, grade updates, response mapping, and feedback rendering.&lt;br /&gt;
&lt;br /&gt;
The specific databases that were populated can be found in the Database section.&lt;br /&gt;
&lt;br /&gt;
==Backend Tests==&lt;br /&gt;
&lt;br /&gt;
After modifying several methods in grades_controller.rb to return JSON responses and integrate with the new React-based frontend, we conducted targeted RSpec tests to validate both backend functionality and frontend compatibility. These tests ensured that each controller method operated correctly in isolation and that the frontend components could successfully consume the API responses as expected.&lt;br /&gt;
&lt;br /&gt;
RSpec tests were written for the following controller methods:&lt;br /&gt;
&lt;br /&gt;
* action_allowed?&lt;br /&gt;
* view_my_scores&lt;br /&gt;
* view_team&lt;br /&gt;
* edit_participant_scores&lt;br /&gt;
* update_participant_grade&lt;br /&gt;
* update_team&lt;br /&gt;
* instructor_review&lt;br /&gt;
&lt;br /&gt;
==API Endpoint (UI) Tests==&lt;br /&gt;
&lt;br /&gt;
==Tables and Test Coverage==&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164248</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164248"/>
		<updated>2025-04-20T20:27:49Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* Backend API Tests */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of this project is to integrate the frontend of the grades view page with the reimplemented '''''grades_controller.rb (E2510)''''' backend in Expertiza, ensuring a seamless connection between both layers. This integration involves refining the interaction between the UI and backend while adhering to best design principles such as modularity, maintainability, and scalability. The grades_controller.rb is responsible for managing grading functionality, allowing instructors to view and modify assignment grades while enabling students to access their evaluations. By following SOLID and DRY principles, this reimplementation enhances code clarity, reduces redundancy, and improves overall system efficiency.&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
The &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; is responsible for managing and delivering grading data to users in the Expertiza system. It enables instructors to view, calculate, and release grades to students, while also allowing students to view feedback and scores for assignments. The controller plays an important role in coordinating backend logic for reviews and grade visibility.&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
The previous implementation successfully created a functional frontend UI page in Expertiza, addressing design inconsistencies and improving usability. It introduced a visually cohesive interface with an intuitive layout, enhanced responsiveness, and improved information display, allowing users to navigate grading data more efficiently. However, the interface was populated using dummy data, limiting its practical use. This reimplemented UI will utilize real data from the database (that has been populated in this round), ensuring that grading information is dynamically retrieved and displayed accurately through JSON objects. Additionally, this phase will connect the redesigned frontend with some new components in the grades_controller.rb. Specifically, the GET functions in the grades_controller were reimplemented to return JSON objects (instead of instance variables) that could be accessed via an API call. Thus, this new implementation ensures seamless communication between the UI and backend while adhering to best design practices for maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
This project focuses on integrating the frontend of the grades view page with the reimplemented '''grades_controller.rb (E2510)''' backend in Expertiza. This integration requires modifications to both the frontend and backend to establish a seamless connection, ensuring that grading data is dynamically retrieved and displayed accurately. By adhering to best design principles such as modularity, maintainability, and scalability, the implementation will enhance system efficiency and long-term usability. Key improvements include replacing dummy data with real database values, refining data flow between the UI and backend, and optimizing API interactions for better performance. These enhancements will create a more intuitive and reliable grading system, providing a seamless experience for instructors and students while maintaining a well-structured and adaptable codebase for future development.&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
# '''Establish a Robust Connection Between the Frontend and Backend''': Ensure smooth data retrieval and updates between the grades view page and the backend by integrating dynamic data through API calls, replacing the current hardcoded dummy data.&lt;br /&gt;
# '''Define and Implement Clear API Endpoints''': Create well-structured API endpoints in grades_controller.rb for retrieving and displaying grades, ensuring they return appropriate data based on user roles (students, instructors, TAs) and maintain role-based access controls.&lt;br /&gt;
# '''Dynamic Data Integration''': Modify the frontend to consume real-time data fetched from the backend, ensuring an intuitive and responsive UI that reflects the actual grading information. &lt;br /&gt;
# '''Reimplement Frontend and Backend Components''': Reimplement both the frontend and backend as necessary to align with SOLID and DRY principles, ensuring modularity, maintainability, and scalability. This includes eliminating redundant logic and optimizing code for better readability.&lt;br /&gt;
# '''Implement Proper Permission Checks''': Ensure that only authorized users can access grade information by implementing robust privilege checks and ensuring that the data is securely accessible to students, instructors, and TAs based on their roles.&lt;br /&gt;
# '''Optimize Database Queries and API Responses''': Enhance the efficiency of database queries and API responses to reduce unnecessary load and ensure that data is retrieved and displayed promptly.&lt;br /&gt;
# '''Testing and Validation''': Implement comprehensive unit and integration tests to verify the correctness of data flow, UI interactions, and role-based access controls, ensuring that the system functions correctly and securely.&lt;br /&gt;
&lt;br /&gt;
=Reimplementation Plan=&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populated data with the appropriate HTTP GET and HTTP POST calls. This shift is necessary to ensure that our application reflects real-time data from the backend rather than relying on static or hardcoded values, which can quickly become outdated or inconsistent. It also enables better scalability and maintainability, as changes to the data only need to be made in the backend, without requiring manual updates in the frontend code.&lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
'''Author Feedback''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
'''Heatmap Data''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
'''Team-mate Data''':&lt;br /&gt;
   {&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The current implementation caters to the backend for a Ruby-embedded front-end, where data is rendered server-side and passed directly into the view. We need to update the APIs to return data in a format that can be consumed by the React UI, typically JSON. This shift is essential to decouple the front-end from the server-side rendering logic, allowing for a more interactive and dynamic user experience. By transitioning to a React-based interface, we gain better control over UI state and responsiveness, while also aligning with modern web development practices. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and instead return plain JSON objects using render json: in the response. This change is necessary to align with a frontend architecture that uses React or another JavaScript framework, which expects structured data from the backend in JSON format rather than relying on server-rendered templates. By shifting to JSON responses, we enable cleaner API endpoints, facilitate easier testing and debugging, and support a more maintainable, decoupled frontend-backend integration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    # prepare feedback summaries&lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
  1.1. Students&lt;br /&gt;
  1.2. Teams&lt;br /&gt;
  1.3. TA&lt;br /&gt;
  1.4. Professor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
  2.1 assignments&lt;br /&gt;
  2.2 assignment_questionnaire&lt;br /&gt;
  2.3 questionnaires&lt;br /&gt;
  2.4 participant&lt;br /&gt;
  2.5 signed_up_teams&lt;br /&gt;
  2.6 teams_users&lt;br /&gt;
  2.7 due_dates&lt;br /&gt;
  2.8 late_policies&lt;br /&gt;
  2.9 questions&lt;br /&gt;
  2.10 review_scores&lt;br /&gt;
  2.11 review_grades&lt;br /&gt;
&lt;br /&gt;
== Data Flow Overview ==&lt;br /&gt;
The diagram below illustrates how data flows between the frontend React components and the grades_controller.rb backend during a typical grading data fetch operation.&lt;br /&gt;
&lt;br /&gt;
* The user (e.g., instructor or student) interacts with the React-based grades view (e.g., ReviewTable, RoundSelector, or Statistics).&lt;br /&gt;
* The component triggers an API request to a specific action in grades_controller.rb (e.g., GET /grades/:id/summary).&lt;br /&gt;
*The controller action queries the relevant models (e.g., Assignment, Team, ReviewResponseMap) and compiles a JSON response.&lt;br /&gt;
* The response is sent back to the frontend and parsed.&lt;br /&gt;
*The React components update the UI (tables, heatmaps, statistics) based on the received data.&lt;br /&gt;
&lt;br /&gt;
This architecture ensures a clean separation between frontend and backend logic, improving maintainability and testability.&lt;br /&gt;
[[File:Dataflow.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
The test plan for Phase 2 focuses on verifying the successful integration of the newly reimplemented &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the React-based UI components. We aim to ensure data is:&lt;br /&gt;
&lt;br /&gt;
* Correctly fetched from the backend  &lt;br /&gt;
* Appropriately displayed in the frontend  &lt;br /&gt;
* Functionally sound under both normal and edge-case scenarios&lt;br /&gt;
&lt;br /&gt;
== Tools and Frameworks ==&lt;br /&gt;
We plan to use the following tools and frameworks for testing:&lt;br /&gt;
&lt;br /&gt;
* '''Frontend''': Jest and React Testing Library for unit and integration tests&lt;br /&gt;
* '''Backend''': RSpec for controller and model tests&lt;br /&gt;
* '''Integration Testing''': Capybara and Selenium for simulating real user behavior&lt;br /&gt;
* '''Test Coverage''': SimpleCov&lt;br /&gt;
&lt;br /&gt;
== 1. UI Integration Tests ==&lt;br /&gt;
&lt;br /&gt;
These tests ensure the frontend correctly interacts with backend APIs and renders the data appropriately.&lt;br /&gt;
&lt;br /&gt;
=== ReviewTable Component ===&lt;br /&gt;
&lt;br /&gt;
* Validate that the component makes a successful API call to fetch author feedback  &lt;br /&gt;
* Ensure feedback is rendered in the correct table structure  &lt;br /&gt;
* Test loading state before data is fetched  &lt;br /&gt;
* Handle empty or malformed feedback responses gracefully  &lt;br /&gt;
&lt;br /&gt;
=== RoundSelector Component ===&lt;br /&gt;
&lt;br /&gt;
* Verify API call to fetch heatmap data is triggered on component load  &lt;br /&gt;
* Check that heatmap data is correctly visualized for different review rounds  &lt;br /&gt;
* Test behavior with no data, incomplete data, or delayed response  &lt;br /&gt;
&lt;br /&gt;
=== Statistics Component ===&lt;br /&gt;
&lt;br /&gt;
* Confirm it correctly fetches teammate evaluations and author feedback  &lt;br /&gt;
* Ensure charts or tables reflect the received backend data accurately  &lt;br /&gt;
* Test switching between different teams or assignments and verify correct display  &lt;br /&gt;
&lt;br /&gt;
=== General UI Considerations ===&lt;br /&gt;
&lt;br /&gt;
* Test frontend responsiveness to backend failures (500, 404, timeout)  &lt;br /&gt;
* Ensure authorization errors are handled and appropriate messages displayed  &lt;br /&gt;
&lt;br /&gt;
== 2. Backend API Tests ==&lt;br /&gt;
&lt;br /&gt;
While unit tests exist, integration-level tests will be added or updated to ensure UI compatibility.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
* Validate all &amp;lt;code&amp;gt;GET&amp;lt;/code&amp;gt; endpoints return properly structured JSON objects  &lt;br /&gt;
* Simulate various user roles (student, TA, instructor) and ensure access control  &lt;br /&gt;
* Include test cases for:&lt;br /&gt;
** No grades present  &lt;br /&gt;
** Partial data (e.g. missing feedback or evaluations)  &lt;br /&gt;
** Large number of records  &lt;br /&gt;
&lt;br /&gt;
=== Security &amp;amp; Permissions ===&lt;br /&gt;
&lt;br /&gt;
* Ensure students can only fetch their grades and feedback  &lt;br /&gt;
* Ensure TAs and instructors can access full assignment data  &lt;br /&gt;
* Test token/session-based access restrictions (if applicable)  &lt;br /&gt;
&lt;br /&gt;
== 3. Database Preparation ==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, seed data will simulate real-world usage and we will ensure that:&lt;br /&gt;
* Tests will use isolated fixtures or factories to ensure data consistency&lt;br /&gt;
* All database states will be reset before each test suite run&lt;br /&gt;
&lt;br /&gt;
=== Tables and Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;assignments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_participant&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;participants&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;questionnaires&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;questions&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_questionnaire&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;signed_up_teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;teams_users&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;late_policies&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
=== Scenarios ===&lt;br /&gt;
&lt;br /&gt;
* Single student assigned  &lt;br /&gt;
* Team assignments with/without feedback  &lt;br /&gt;
* Late submissions triggering late policies  &lt;br /&gt;
* Multiple review rounds per assignment&lt;br /&gt;
&lt;br /&gt;
== 4. Regression &amp;amp; CI Testing ==&lt;br /&gt;
&lt;br /&gt;
To ensure updates do not break existing functionality:&lt;br /&gt;
&lt;br /&gt;
* Re-run all existing unit tests  &lt;br /&gt;
* Include snapshot tests for frontend components  &lt;br /&gt;
* Use CI pipelines to automatically trigger tests on pull requests  &lt;br /&gt;
&lt;br /&gt;
== Test Plan Summary ==&lt;br /&gt;
&lt;br /&gt;
This test plan outlines the approach for integrating &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the frontend. By combining backend tests, UI integration checks, and realistic database scenarios, we aim to deliver a seamless user experience. The plan emphasizes early detection of issues and supports long-term maintainability through regression testing. As development progresses, the plan will be updated to cover new insights and edge cases.&lt;br /&gt;
&lt;br /&gt;
=Completed Reimplementation Details=&lt;br /&gt;
&lt;br /&gt;
This section outlines the changes that were actually implemented as part of the reimplementation effort. It provides a detailed breakdown of how the frontend was decoupled from the legacy Ruby-embedded views, and how dynamic data flow was established using API endpoints. Specific components were modified to replace hardcoded or mock data with real-time API calls to the backend, ensuring that the application now reflects live grading data. Additionally, backend controller actions were updated to return clean, structured JSON responses, and the data retrieval logic was centralized to improve maintainability and testability. &lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The previous implementation was designed for a Ruby-embedded front-end, where data was rendered server-side and injected directly into the view. We have since updated the APIs to return data in a format suitable for consumption by the React UI, typically as JSON objects. This change successfully decouples the front-end from the server-side rendering logic, enabling a more interactive and responsive user experience. By transitioning to a React-based interface, we now have improved control over UI state and better alignment with modern web development practices.&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
In this controller, we have updated the GET functions to remove the use of instance variables and instead return plain JSON objects using render json: in the response. This update was essential to align with the frontend architecture, which now relies on a React-based interface that expects structured data from the backend in JSON format rather than server-rendered templates. By returning JSON responses, we’ve established cleaner and more consistent API endpoints, improved the testability and debuggability of our backend logic, and created a more maintainable and decoupled integration between the frontend and backend systems. The following functions were updated as part of this integration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  def view_grading_report&lt;br /&gt;
    assignment_id = params[:id].to_i&lt;br /&gt;
    data = get_data_for_heat_map(assignment_id)&lt;br /&gt;
    &lt;br /&gt;
    render json: data, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
    &lt;br /&gt;
  def view_my_scores&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team_id = TeamsUser.team_id(participant.assignment_id, participant.user_id)&lt;br /&gt;
    # return if redirect_when_disallowed(participant)&lt;br /&gt;
    questions = fetch_questionnaires_and_questions(assignment)&lt;br /&gt;
    pscore = fetch_participant_scores(participant, questions)&lt;br /&gt;
    topic_id = SignedUpTeam.find_topic_id_for_user(participant.assignment.id, participant.user_id)&lt;br /&gt;
    stage = participant.assignment.current_stage(topic_id)&lt;br /&gt;
    # all_penalties = update_penalties(assignment)&lt;br /&gt;
    # Feedback Summary needs to be checked once&lt;br /&gt;
    # summary_ws_url = WEBSERVICE_CONFIG['summary_webservice_url']&lt;br /&gt;
    sum = SummaryHelper::Summary.new.summarize_reviews_by_reviewee(questions, assignment, team_id, 'http://peerlogic.csc.ncsu.edu/sum/v1.0/summary/8/lsa', session)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      topic_id: topic_id,&lt;br /&gt;
      stage: stage,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      summary: sum.summary,&lt;br /&gt;
      avg_scores_by_round: sum.avg_scores_by_round,&lt;br /&gt;
      avg_scores_by_criterion: sum.avg_scores_by_criterion&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def view_team&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    team_id = team.id&lt;br /&gt;
  &lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: assignment.id).map(&amp;amp;:questionnaire)&lt;br /&gt;
    questions = retrieve_questions(questionnaires, assignment.id)&lt;br /&gt;
    pscore = Response.participant_scores(participant, questions)&lt;br /&gt;
    vmlist = process_questionare_for_team(assignment, team_id,questionnaires, team, participant)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team: team,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      vmlist: vmlist&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These updates were important for the backend and ensured seamless communication with the React frontend. By removing instance variables and returning structured JSON responses, we eliminated dependencies on server-side rendering and enabled the frontend to dynamically manage and render data. This not only enhances performance and flexibility but also improves maintainability and scalability as the application evolves. Moreover, it allows the backend and frontend to evolve independently, supporting better separation of concerns and aligning with current best practices in full-stack web development.&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We have successfully  reimplemented the previously pre-populated data with appropriate HTTP GET calls to the backend. This ensures that our application now reflects real-time data directly from the server, improving data accuracy and consistency across the UI. This update also enhances scalability and maintainability, as the frontend no longer depends on static content and can adapt to backend changes without manual intervention.&lt;br /&gt;
&lt;br /&gt;
All dummy data throughout these components has been successfully removed and replaced with real-time API integrations. This transition allows for a fully dynamic, data-driven React frontend that remains synchronized with backend updates and user interactions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Files and components that were updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' &lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:'''&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
A key component of this project involved populating the necessary database tables that the grades_controller.rb relies on to serve real-time data to the frontend. This step was essential for replacing the previously hardcoded or pre-populated dummy data with dynamic, API-driven content. Below is a list of the database tables that were seeded with mock data specifically for development and testing purposes in this project:&lt;br /&gt;
&lt;br /&gt;
* roles&lt;br /&gt;
* institutions&lt;br /&gt;
* users&lt;br /&gt;
* assignments&lt;br /&gt;
* teams &lt;br /&gt;
* teams_users&lt;br /&gt;
* sign_up_topics&lt;br /&gt;
* signed_up_teams&lt;br /&gt;
* participants&lt;br /&gt;
* questionnaires&lt;br /&gt;
* questions &lt;br /&gt;
* assignment_questionaires&lt;br /&gt;
* response_maps&lt;br /&gt;
* responses&lt;br /&gt;
* score_views&lt;br /&gt;
* tag-prompts&lt;br /&gt;
* tag_prompt_deployments&lt;br /&gt;
&lt;br /&gt;
In order to correctly populate each database, we referenced the Expertiza Database Documentation to understand the schema, and then mapped out the relevant tables needed by grades_controller.rb. Then we populated them with mock data to support development and testing of the new API-driven frontend.&lt;br /&gt;
&lt;br /&gt;
==Data Flow Overview==&lt;br /&gt;
&lt;br /&gt;
The diagram below illustrates the data flow between React frontend components and the grades_controller.rb backend during a typical grading data retrieval process.&lt;br /&gt;
&lt;br /&gt;
* The user (such as an instructor or student) interacts with the React-based grades interface—components like ReviewTable, RoundSelector, or Statistics.&lt;br /&gt;
&lt;br /&gt;
* In response to this interaction, the component initiates an API request to a specific endpoint in grades_controller.rb.&lt;br /&gt;
&lt;br /&gt;
* The controller action then queries the relevant backend models (such as Assignment, Team, and ReviewResponseMap) and constructs a structured JSON response.&lt;br /&gt;
&lt;br /&gt;
* This JSON data is returned to the frontend, where it is parsed by the corresponding React component.&lt;br /&gt;
&lt;br /&gt;
* Finally, the React components dynamically update the UI—populating tables, generating heatmaps, or displaying statistics—based on the data received.&lt;br /&gt;
&lt;br /&gt;
This architecture promotes a clear separation of concerns between frontend and backend layers, enabling more scalable development, easier debugging, and improved maintainability and testability across the application.&lt;br /&gt;
&lt;br /&gt;
=Testing=&lt;br /&gt;
&lt;br /&gt;
==Testing Overview==&lt;br /&gt;
&lt;br /&gt;
After modifying several methods in grades_controller.rb to return JSON responses and support the new React-based frontend, we conducted comprehensive testing to ensure that both the backend logic and frontend integration functioned as intended. It was essential to validate not only that the backend endpoints behaved correctly in isolation, but also that the frontend components were able to successfully consume and render the data returned by the updated APIs.&lt;br /&gt;
&lt;br /&gt;
We retested all affected methods to verify that data was retrieved accurately, permission checks were enforced, and updates were correctly persisted. In addition to running automated RSpec tests, we manually tested the backend endpoints using authenticated curl commands. These terminal-based tests allowed us to simulate real API usage, verify response structures, and confirm compatibility with the frontend. This dual-layered testing approach ensured a smooth and reliable interaction between the React UI and the Rails backend.&lt;br /&gt;
&lt;br /&gt;
==Database Preparation==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, we populated the database with carefully designed mock data that simulates a variety of real-world grading scenarios. This approach ensured that our test environment closely mirrors actual usage patterns, allowing for more meaningful validation of the grades_controller.rb logic and its interactions with related models.&lt;br /&gt;
 &lt;br /&gt;
We created test scenarios that covered a range of use cases, including individual and team assignments, review rounds, and various submissions, to verify that each controller action behaves as expected under different conditions. By populating the relevant tables with representative data, we were able to rigorously test features like permission checks, grade updates, response mapping, and feedback rendering.&lt;br /&gt;
&lt;br /&gt;
The specific databases that were populated can be found in the Database section.&lt;br /&gt;
&lt;br /&gt;
==Backend Tests==&lt;br /&gt;
&lt;br /&gt;
After modifying several methods in grades_controller.rb to return JSON responses and integrate with the new React-based frontend, we conducted targeted RSpec tests to validate both backend functionality and frontend compatibility. These tests ensured that each controller method operated correctly in isolation and that the frontend components could successfully consume the API responses as expected.&lt;br /&gt;
&lt;br /&gt;
RSpec tests were written for the following controller methods:&lt;br /&gt;
&lt;br /&gt;
* action_allowed?&lt;br /&gt;
* view_my_scores&lt;br /&gt;
* view_team&lt;br /&gt;
* edit_participant_scores&lt;br /&gt;
* update_participant_grade&lt;br /&gt;
* update_team&lt;br /&gt;
* instructor_review&lt;br /&gt;
&lt;br /&gt;
==API Endpoint (UI) Tests==&lt;br /&gt;
&lt;br /&gt;
==Tables and Test Coverage==&lt;br /&gt;
&lt;br /&gt;
==Adhering to Priciples==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164247</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164247"/>
		<updated>2025-04-20T20:19:32Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* UI Tests */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of this project is to integrate the frontend of the grades view page with the reimplemented '''''grades_controller.rb (E2510)''''' backend in Expertiza, ensuring a seamless connection between both layers. This integration involves refining the interaction between the UI and backend while adhering to best design principles such as modularity, maintainability, and scalability. The grades_controller.rb is responsible for managing grading functionality, allowing instructors to view and modify assignment grades while enabling students to access their evaluations. By following SOLID and DRY principles, this reimplementation enhances code clarity, reduces redundancy, and improves overall system efficiency.&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
The &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; is responsible for managing and delivering grading data to users in the Expertiza system. It enables instructors to view, calculate, and release grades to students, while also allowing students to view feedback and scores for assignments. The controller plays an important role in coordinating backend logic for reviews and grade visibility.&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
The previous implementation successfully created a functional frontend UI page in Expertiza, addressing design inconsistencies and improving usability. It introduced a visually cohesive interface with an intuitive layout, enhanced responsiveness, and improved information display, allowing users to navigate grading data more efficiently. However, the interface was populated using dummy data, limiting its practical use. This reimplemented UI will utilize real data from the database (that has been populated in this round), ensuring that grading information is dynamically retrieved and displayed accurately through JSON objects. Additionally, this phase will connect the redesigned frontend with some new components in the grades_controller.rb. Specifically, the GET functions in the grades_controller were reimplemented to return JSON objects (instead of instance variables) that could be accessed via an API call. Thus, this new implementation ensures seamless communication between the UI and backend while adhering to best design practices for maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
This project focuses on integrating the frontend of the grades view page with the reimplemented '''grades_controller.rb (E2510)''' backend in Expertiza. This integration requires modifications to both the frontend and backend to establish a seamless connection, ensuring that grading data is dynamically retrieved and displayed accurately. By adhering to best design principles such as modularity, maintainability, and scalability, the implementation will enhance system efficiency and long-term usability. Key improvements include replacing dummy data with real database values, refining data flow between the UI and backend, and optimizing API interactions for better performance. These enhancements will create a more intuitive and reliable grading system, providing a seamless experience for instructors and students while maintaining a well-structured and adaptable codebase for future development.&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
# '''Establish a Robust Connection Between the Frontend and Backend''': Ensure smooth data retrieval and updates between the grades view page and the backend by integrating dynamic data through API calls, replacing the current hardcoded dummy data.&lt;br /&gt;
# '''Define and Implement Clear API Endpoints''': Create well-structured API endpoints in grades_controller.rb for retrieving and displaying grades, ensuring they return appropriate data based on user roles (students, instructors, TAs) and maintain role-based access controls.&lt;br /&gt;
# '''Dynamic Data Integration''': Modify the frontend to consume real-time data fetched from the backend, ensuring an intuitive and responsive UI that reflects the actual grading information. &lt;br /&gt;
# '''Reimplement Frontend and Backend Components''': Reimplement both the frontend and backend as necessary to align with SOLID and DRY principles, ensuring modularity, maintainability, and scalability. This includes eliminating redundant logic and optimizing code for better readability.&lt;br /&gt;
# '''Implement Proper Permission Checks''': Ensure that only authorized users can access grade information by implementing robust privilege checks and ensuring that the data is securely accessible to students, instructors, and TAs based on their roles.&lt;br /&gt;
# '''Optimize Database Queries and API Responses''': Enhance the efficiency of database queries and API responses to reduce unnecessary load and ensure that data is retrieved and displayed promptly.&lt;br /&gt;
# '''Testing and Validation''': Implement comprehensive unit and integration tests to verify the correctness of data flow, UI interactions, and role-based access controls, ensuring that the system functions correctly and securely.&lt;br /&gt;
&lt;br /&gt;
=Reimplementation Plan=&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populated data with the appropriate HTTP GET and HTTP POST calls. This shift is necessary to ensure that our application reflects real-time data from the backend rather than relying on static or hardcoded values, which can quickly become outdated or inconsistent. It also enables better scalability and maintainability, as changes to the data only need to be made in the backend, without requiring manual updates in the frontend code.&lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
'''Author Feedback''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
'''Heatmap Data''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
'''Team-mate Data''':&lt;br /&gt;
   {&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The current implementation caters to the backend for a Ruby-embedded front-end, where data is rendered server-side and passed directly into the view. We need to update the APIs to return data in a format that can be consumed by the React UI, typically JSON. This shift is essential to decouple the front-end from the server-side rendering logic, allowing for a more interactive and dynamic user experience. By transitioning to a React-based interface, we gain better control over UI state and responsiveness, while also aligning with modern web development practices. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and instead return plain JSON objects using render json: in the response. This change is necessary to align with a frontend architecture that uses React or another JavaScript framework, which expects structured data from the backend in JSON format rather than relying on server-rendered templates. By shifting to JSON responses, we enable cleaner API endpoints, facilitate easier testing and debugging, and support a more maintainable, decoupled frontend-backend integration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    # prepare feedback summaries&lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
  1.1. Students&lt;br /&gt;
  1.2. Teams&lt;br /&gt;
  1.3. TA&lt;br /&gt;
  1.4. Professor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
  2.1 assignments&lt;br /&gt;
  2.2 assignment_questionnaire&lt;br /&gt;
  2.3 questionnaires&lt;br /&gt;
  2.4 participant&lt;br /&gt;
  2.5 signed_up_teams&lt;br /&gt;
  2.6 teams_users&lt;br /&gt;
  2.7 due_dates&lt;br /&gt;
  2.8 late_policies&lt;br /&gt;
  2.9 questions&lt;br /&gt;
  2.10 review_scores&lt;br /&gt;
  2.11 review_grades&lt;br /&gt;
&lt;br /&gt;
== Data Flow Overview ==&lt;br /&gt;
The diagram below illustrates how data flows between the frontend React components and the grades_controller.rb backend during a typical grading data fetch operation.&lt;br /&gt;
&lt;br /&gt;
* The user (e.g., instructor or student) interacts with the React-based grades view (e.g., ReviewTable, RoundSelector, or Statistics).&lt;br /&gt;
* The component triggers an API request to a specific action in grades_controller.rb (e.g., GET /grades/:id/summary).&lt;br /&gt;
*The controller action queries the relevant models (e.g., Assignment, Team, ReviewResponseMap) and compiles a JSON response.&lt;br /&gt;
* The response is sent back to the frontend and parsed.&lt;br /&gt;
*The React components update the UI (tables, heatmaps, statistics) based on the received data.&lt;br /&gt;
&lt;br /&gt;
This architecture ensures a clean separation between frontend and backend logic, improving maintainability and testability.&lt;br /&gt;
[[File:Dataflow.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
The test plan for Phase 2 focuses on verifying the successful integration of the newly reimplemented &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the React-based UI components. We aim to ensure data is:&lt;br /&gt;
&lt;br /&gt;
* Correctly fetched from the backend  &lt;br /&gt;
* Appropriately displayed in the frontend  &lt;br /&gt;
* Functionally sound under both normal and edge-case scenarios&lt;br /&gt;
&lt;br /&gt;
== Tools and Frameworks ==&lt;br /&gt;
We plan to use the following tools and frameworks for testing:&lt;br /&gt;
&lt;br /&gt;
* '''Frontend''': Jest and React Testing Library for unit and integration tests&lt;br /&gt;
* '''Backend''': RSpec for controller and model tests&lt;br /&gt;
* '''Integration Testing''': Capybara and Selenium for simulating real user behavior&lt;br /&gt;
* '''Test Coverage''': SimpleCov&lt;br /&gt;
&lt;br /&gt;
== 1. UI Integration Tests ==&lt;br /&gt;
&lt;br /&gt;
These tests ensure the frontend correctly interacts with backend APIs and renders the data appropriately.&lt;br /&gt;
&lt;br /&gt;
=== ReviewTable Component ===&lt;br /&gt;
&lt;br /&gt;
* Validate that the component makes a successful API call to fetch author feedback  &lt;br /&gt;
* Ensure feedback is rendered in the correct table structure  &lt;br /&gt;
* Test loading state before data is fetched  &lt;br /&gt;
* Handle empty or malformed feedback responses gracefully  &lt;br /&gt;
&lt;br /&gt;
=== RoundSelector Component ===&lt;br /&gt;
&lt;br /&gt;
* Verify API call to fetch heatmap data is triggered on component load  &lt;br /&gt;
* Check that heatmap data is correctly visualized for different review rounds  &lt;br /&gt;
* Test behavior with no data, incomplete data, or delayed response  &lt;br /&gt;
&lt;br /&gt;
=== Statistics Component ===&lt;br /&gt;
&lt;br /&gt;
* Confirm it correctly fetches teammate evaluations and author feedback  &lt;br /&gt;
* Ensure charts or tables reflect the received backend data accurately  &lt;br /&gt;
* Test switching between different teams or assignments and verify correct display  &lt;br /&gt;
&lt;br /&gt;
=== General UI Considerations ===&lt;br /&gt;
&lt;br /&gt;
* Test frontend responsiveness to backend failures (500, 404, timeout)  &lt;br /&gt;
* Ensure authorization errors are handled and appropriate messages displayed  &lt;br /&gt;
&lt;br /&gt;
== 2. Backend API Tests ==&lt;br /&gt;
&lt;br /&gt;
While unit tests exist, integration-level tests will be added or updated to ensure UI compatibility.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
* Validate all &amp;lt;code&amp;gt;GET&amp;lt;/code&amp;gt; endpoints return properly structured JSON objects  &lt;br /&gt;
* Simulate various user roles (student, TA, instructor) and ensure access control  &lt;br /&gt;
* Include test cases for:&lt;br /&gt;
** No grades present  &lt;br /&gt;
** Partial data (e.g. missing feedback or evaluations)  &lt;br /&gt;
** Large number of records  &lt;br /&gt;
&lt;br /&gt;
=== Security &amp;amp; Permissions ===&lt;br /&gt;
&lt;br /&gt;
* Ensure students can only fetch their grades and feedback  &lt;br /&gt;
* Ensure TAs and instructors can access full assignment data  &lt;br /&gt;
* Test token/session-based access restrictions (if applicable)  &lt;br /&gt;
&lt;br /&gt;
== 3. Database Preparation ==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, seed data will simulate real-world usage and we will ensure that:&lt;br /&gt;
* Tests will use isolated fixtures or factories to ensure data consistency&lt;br /&gt;
* All database states will be reset before each test suite run&lt;br /&gt;
&lt;br /&gt;
=== Tables and Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;assignments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_participant&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;participants&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;questionnaires&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;questions&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_questionnaire&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;signed_up_teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;teams_users&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;late_policies&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
=== Scenarios ===&lt;br /&gt;
&lt;br /&gt;
* Single student assigned  &lt;br /&gt;
* Team assignments with/without feedback  &lt;br /&gt;
* Late submissions triggering late policies  &lt;br /&gt;
* Multiple review rounds per assignment&lt;br /&gt;
&lt;br /&gt;
== 4. Regression &amp;amp; CI Testing ==&lt;br /&gt;
&lt;br /&gt;
To ensure updates do not break existing functionality:&lt;br /&gt;
&lt;br /&gt;
* Re-run all existing unit tests  &lt;br /&gt;
* Include snapshot tests for frontend components  &lt;br /&gt;
* Use CI pipelines to automatically trigger tests on pull requests  &lt;br /&gt;
&lt;br /&gt;
== Test Plan Summary ==&lt;br /&gt;
&lt;br /&gt;
This test plan outlines the approach for integrating &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the frontend. By combining backend tests, UI integration checks, and realistic database scenarios, we aim to deliver a seamless user experience. The plan emphasizes early detection of issues and supports long-term maintainability through regression testing. As development progresses, the plan will be updated to cover new insights and edge cases.&lt;br /&gt;
&lt;br /&gt;
=Completed Reimplementation Details=&lt;br /&gt;
&lt;br /&gt;
This section outlines the changes that were actually implemented as part of the reimplementation effort. It provides a detailed breakdown of how the frontend was decoupled from the legacy Ruby-embedded views, and how dynamic data flow was established using API endpoints. Specific components were modified to replace hardcoded or mock data with real-time API calls to the backend, ensuring that the application now reflects live grading data. Additionally, backend controller actions were updated to return clean, structured JSON responses, and the data retrieval logic was centralized to improve maintainability and testability. &lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The previous implementation was designed for a Ruby-embedded front-end, where data was rendered server-side and injected directly into the view. We have since updated the APIs to return data in a format suitable for consumption by the React UI, typically as JSON objects. This change successfully decouples the front-end from the server-side rendering logic, enabling a more interactive and responsive user experience. By transitioning to a React-based interface, we now have improved control over UI state and better alignment with modern web development practices.&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
In this controller, we have updated the GET functions to remove the use of instance variables and instead return plain JSON objects using render json: in the response. This update was essential to align with the frontend architecture, which now relies on a React-based interface that expects structured data from the backend in JSON format rather than server-rendered templates. By returning JSON responses, we’ve established cleaner and more consistent API endpoints, improved the testability and debuggability of our backend logic, and created a more maintainable and decoupled integration between the frontend and backend systems. The following functions were updated as part of this integration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  def view_grading_report&lt;br /&gt;
    assignment_id = params[:id].to_i&lt;br /&gt;
    data = get_data_for_heat_map(assignment_id)&lt;br /&gt;
    &lt;br /&gt;
    render json: data, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
    &lt;br /&gt;
  def view_my_scores&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team_id = TeamsUser.team_id(participant.assignment_id, participant.user_id)&lt;br /&gt;
    # return if redirect_when_disallowed(participant)&lt;br /&gt;
    questions = fetch_questionnaires_and_questions(assignment)&lt;br /&gt;
    pscore = fetch_participant_scores(participant, questions)&lt;br /&gt;
    topic_id = SignedUpTeam.find_topic_id_for_user(participant.assignment.id, participant.user_id)&lt;br /&gt;
    stage = participant.assignment.current_stage(topic_id)&lt;br /&gt;
    # all_penalties = update_penalties(assignment)&lt;br /&gt;
    # Feedback Summary needs to be checked once&lt;br /&gt;
    # summary_ws_url = WEBSERVICE_CONFIG['summary_webservice_url']&lt;br /&gt;
    sum = SummaryHelper::Summary.new.summarize_reviews_by_reviewee(questions, assignment, team_id, 'http://peerlogic.csc.ncsu.edu/sum/v1.0/summary/8/lsa', session)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      topic_id: topic_id,&lt;br /&gt;
      stage: stage,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      summary: sum.summary,&lt;br /&gt;
      avg_scores_by_round: sum.avg_scores_by_round,&lt;br /&gt;
      avg_scores_by_criterion: sum.avg_scores_by_criterion&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def view_team&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    team_id = team.id&lt;br /&gt;
  &lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: assignment.id).map(&amp;amp;:questionnaire)&lt;br /&gt;
    questions = retrieve_questions(questionnaires, assignment.id)&lt;br /&gt;
    pscore = Response.participant_scores(participant, questions)&lt;br /&gt;
    vmlist = process_questionare_for_team(assignment, team_id,questionnaires, team, participant)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team: team,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      vmlist: vmlist&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These updates were important for the backend and ensured seamless communication with the React frontend. By removing instance variables and returning structured JSON responses, we eliminated dependencies on server-side rendering and enabled the frontend to dynamically manage and render data. This not only enhances performance and flexibility but also improves maintainability and scalability as the application evolves. Moreover, it allows the backend and frontend to evolve independently, supporting better separation of concerns and aligning with current best practices in full-stack web development.&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We have successfully  reimplemented the previously pre-populated data with appropriate HTTP GET calls to the backend. This ensures that our application now reflects real-time data directly from the server, improving data accuracy and consistency across the UI. This update also enhances scalability and maintainability, as the frontend no longer depends on static content and can adapt to backend changes without manual intervention.&lt;br /&gt;
&lt;br /&gt;
All dummy data throughout these components has been successfully removed and replaced with real-time API integrations. This transition allows for a fully dynamic, data-driven React frontend that remains synchronized with backend updates and user interactions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Files and components that were updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' &lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:'''&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
A key component of this project involved populating the necessary database tables that the grades_controller.rb relies on to serve real-time data to the frontend. This step was essential for replacing the previously hardcoded or pre-populated dummy data with dynamic, API-driven content. Below is a list of the database tables that were seeded with mock data specifically for development and testing purposes in this project:&lt;br /&gt;
&lt;br /&gt;
* roles&lt;br /&gt;
* institutions&lt;br /&gt;
* users&lt;br /&gt;
* assignments&lt;br /&gt;
* teams &lt;br /&gt;
* teams_users&lt;br /&gt;
* sign_up_topics&lt;br /&gt;
* signed_up_teams&lt;br /&gt;
* participants&lt;br /&gt;
* questionnaires&lt;br /&gt;
* questions &lt;br /&gt;
* assignment_questionaires&lt;br /&gt;
* response_maps&lt;br /&gt;
* responses&lt;br /&gt;
* score_views&lt;br /&gt;
* tag-prompts&lt;br /&gt;
* tag_prompt_deployments&lt;br /&gt;
&lt;br /&gt;
In order to correctly populate each database, we referenced the Expertiza Database Documentation to understand the schema, and then mapped out the relevant tables needed by grades_controller.rb. Then we populated them with mock data to support development and testing of the new API-driven frontend.&lt;br /&gt;
&lt;br /&gt;
==Data Flow Overview==&lt;br /&gt;
&lt;br /&gt;
The diagram below illustrates the data flow between React frontend components and the grades_controller.rb backend during a typical grading data retrieval process.&lt;br /&gt;
&lt;br /&gt;
* The user (such as an instructor or student) interacts with the React-based grades interface—components like ReviewTable, RoundSelector, or Statistics.&lt;br /&gt;
&lt;br /&gt;
* In response to this interaction, the component initiates an API request to a specific endpoint in grades_controller.rb.&lt;br /&gt;
&lt;br /&gt;
* The controller action then queries the relevant backend models (such as Assignment, Team, and ReviewResponseMap) and constructs a structured JSON response.&lt;br /&gt;
&lt;br /&gt;
* This JSON data is returned to the frontend, where it is parsed by the corresponding React component.&lt;br /&gt;
&lt;br /&gt;
* Finally, the React components dynamically update the UI—populating tables, generating heatmaps, or displaying statistics—based on the data received.&lt;br /&gt;
&lt;br /&gt;
This architecture promotes a clear separation of concerns between frontend and backend layers, enabling more scalable development, easier debugging, and improved maintainability and testability across the application.&lt;br /&gt;
&lt;br /&gt;
=Testing=&lt;br /&gt;
&lt;br /&gt;
==Testing Overview==&lt;br /&gt;
&lt;br /&gt;
After modifying several methods in grades_controller.rb to return JSON responses and support the new React-based frontend, we conducted comprehensive testing to ensure that both the backend logic and frontend integration functioned as intended. It was essential to validate not only that the backend endpoints behaved correctly in isolation, but also that the frontend components were able to successfully consume and render the data returned by the updated APIs.&lt;br /&gt;
&lt;br /&gt;
We retested all affected methods to verify that data was retrieved accurately, permission checks were enforced, and updates were correctly persisted. In addition to running automated RSpec tests, we manually tested the backend endpoints using authenticated curl commands. These terminal-based tests allowed us to simulate real API usage, verify response structures, and confirm compatibility with the frontend. This dual-layered testing approach ensured a smooth and reliable interaction between the React UI and the Rails backend.&lt;br /&gt;
&lt;br /&gt;
==Database Preparation==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, we populated the database with carefully designed mock data that simulates a variety of real-world grading scenarios. This approach ensured that our test environment closely mirrors actual usage patterns, allowing for more meaningful validation of the grades_controller.rb logic and its interactions with related models.&lt;br /&gt;
 &lt;br /&gt;
We created test scenarios that covered a range of use cases, including individual and team assignments, review rounds, and various submissions, to verify that each controller action behaves as expected under different conditions. By populating the relevant tables with representative data, we were able to rigorously test features like permission checks, grade updates, response mapping, and feedback rendering.&lt;br /&gt;
&lt;br /&gt;
The specific databases that were populated can be found in the Database section.&lt;br /&gt;
&lt;br /&gt;
==Backend Tests==&lt;br /&gt;
&lt;br /&gt;
After modifying several methods in grades_controller.rb to return JSON responses and integrate with the new React-based frontend, we conducted targeted RSpec tests to validate both backend functionality and frontend compatibility. These tests ensured that each controller method operated correctly in isolation and that the frontend components could successfully consume the API responses as expected.&lt;br /&gt;
&lt;br /&gt;
RSpec tests were written for the following controller methods:&lt;br /&gt;
&lt;br /&gt;
* action_allowed?&lt;br /&gt;
* view_my_scores&lt;br /&gt;
* view_team&lt;br /&gt;
* edit_participant_scores&lt;br /&gt;
* update_participant_grade&lt;br /&gt;
* update_team&lt;br /&gt;
* instructor_review&lt;br /&gt;
&lt;br /&gt;
==Backend API Tests==&lt;br /&gt;
&lt;br /&gt;
==Tables and Test Coverage==&lt;br /&gt;
&lt;br /&gt;
==Adhering to Priciples==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164246</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164246"/>
		<updated>2025-04-20T20:15:29Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* Database Preparation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of this project is to integrate the frontend of the grades view page with the reimplemented '''''grades_controller.rb (E2510)''''' backend in Expertiza, ensuring a seamless connection between both layers. This integration involves refining the interaction between the UI and backend while adhering to best design principles such as modularity, maintainability, and scalability. The grades_controller.rb is responsible for managing grading functionality, allowing instructors to view and modify assignment grades while enabling students to access their evaluations. By following SOLID and DRY principles, this reimplementation enhances code clarity, reduces redundancy, and improves overall system efficiency.&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
The &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; is responsible for managing and delivering grading data to users in the Expertiza system. It enables instructors to view, calculate, and release grades to students, while also allowing students to view feedback and scores for assignments. The controller plays an important role in coordinating backend logic for reviews and grade visibility.&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
The previous implementation successfully created a functional frontend UI page in Expertiza, addressing design inconsistencies and improving usability. It introduced a visually cohesive interface with an intuitive layout, enhanced responsiveness, and improved information display, allowing users to navigate grading data more efficiently. However, the interface was populated using dummy data, limiting its practical use. This reimplemented UI will utilize real data from the database (that has been populated in this round), ensuring that grading information is dynamically retrieved and displayed accurately through JSON objects. Additionally, this phase will connect the redesigned frontend with some new components in the grades_controller.rb. Specifically, the GET functions in the grades_controller were reimplemented to return JSON objects (instead of instance variables) that could be accessed via an API call. Thus, this new implementation ensures seamless communication between the UI and backend while adhering to best design practices for maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
This project focuses on integrating the frontend of the grades view page with the reimplemented '''grades_controller.rb (E2510)''' backend in Expertiza. This integration requires modifications to both the frontend and backend to establish a seamless connection, ensuring that grading data is dynamically retrieved and displayed accurately. By adhering to best design principles such as modularity, maintainability, and scalability, the implementation will enhance system efficiency and long-term usability. Key improvements include replacing dummy data with real database values, refining data flow between the UI and backend, and optimizing API interactions for better performance. These enhancements will create a more intuitive and reliable grading system, providing a seamless experience for instructors and students while maintaining a well-structured and adaptable codebase for future development.&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
# '''Establish a Robust Connection Between the Frontend and Backend''': Ensure smooth data retrieval and updates between the grades view page and the backend by integrating dynamic data through API calls, replacing the current hardcoded dummy data.&lt;br /&gt;
# '''Define and Implement Clear API Endpoints''': Create well-structured API endpoints in grades_controller.rb for retrieving and displaying grades, ensuring they return appropriate data based on user roles (students, instructors, TAs) and maintain role-based access controls.&lt;br /&gt;
# '''Dynamic Data Integration''': Modify the frontend to consume real-time data fetched from the backend, ensuring an intuitive and responsive UI that reflects the actual grading information. &lt;br /&gt;
# '''Reimplement Frontend and Backend Components''': Reimplement both the frontend and backend as necessary to align with SOLID and DRY principles, ensuring modularity, maintainability, and scalability. This includes eliminating redundant logic and optimizing code for better readability.&lt;br /&gt;
# '''Implement Proper Permission Checks''': Ensure that only authorized users can access grade information by implementing robust privilege checks and ensuring that the data is securely accessible to students, instructors, and TAs based on their roles.&lt;br /&gt;
# '''Optimize Database Queries and API Responses''': Enhance the efficiency of database queries and API responses to reduce unnecessary load and ensure that data is retrieved and displayed promptly.&lt;br /&gt;
# '''Testing and Validation''': Implement comprehensive unit and integration tests to verify the correctness of data flow, UI interactions, and role-based access controls, ensuring that the system functions correctly and securely.&lt;br /&gt;
&lt;br /&gt;
=Reimplementation Plan=&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populated data with the appropriate HTTP GET and HTTP POST calls. This shift is necessary to ensure that our application reflects real-time data from the backend rather than relying on static or hardcoded values, which can quickly become outdated or inconsistent. It also enables better scalability and maintainability, as changes to the data only need to be made in the backend, without requiring manual updates in the frontend code.&lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
'''Author Feedback''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
'''Heatmap Data''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
'''Team-mate Data''':&lt;br /&gt;
   {&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The current implementation caters to the backend for a Ruby-embedded front-end, where data is rendered server-side and passed directly into the view. We need to update the APIs to return data in a format that can be consumed by the React UI, typically JSON. This shift is essential to decouple the front-end from the server-side rendering logic, allowing for a more interactive and dynamic user experience. By transitioning to a React-based interface, we gain better control over UI state and responsiveness, while also aligning with modern web development practices. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and instead return plain JSON objects using render json: in the response. This change is necessary to align with a frontend architecture that uses React or another JavaScript framework, which expects structured data from the backend in JSON format rather than relying on server-rendered templates. By shifting to JSON responses, we enable cleaner API endpoints, facilitate easier testing and debugging, and support a more maintainable, decoupled frontend-backend integration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    # prepare feedback summaries&lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
  1.1. Students&lt;br /&gt;
  1.2. Teams&lt;br /&gt;
  1.3. TA&lt;br /&gt;
  1.4. Professor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
  2.1 assignments&lt;br /&gt;
  2.2 assignment_questionnaire&lt;br /&gt;
  2.3 questionnaires&lt;br /&gt;
  2.4 participant&lt;br /&gt;
  2.5 signed_up_teams&lt;br /&gt;
  2.6 teams_users&lt;br /&gt;
  2.7 due_dates&lt;br /&gt;
  2.8 late_policies&lt;br /&gt;
  2.9 questions&lt;br /&gt;
  2.10 review_scores&lt;br /&gt;
  2.11 review_grades&lt;br /&gt;
&lt;br /&gt;
== Data Flow Overview ==&lt;br /&gt;
The diagram below illustrates how data flows between the frontend React components and the grades_controller.rb backend during a typical grading data fetch operation.&lt;br /&gt;
&lt;br /&gt;
* The user (e.g., instructor or student) interacts with the React-based grades view (e.g., ReviewTable, RoundSelector, or Statistics).&lt;br /&gt;
* The component triggers an API request to a specific action in grades_controller.rb (e.g., GET /grades/:id/summary).&lt;br /&gt;
*The controller action queries the relevant models (e.g., Assignment, Team, ReviewResponseMap) and compiles a JSON response.&lt;br /&gt;
* The response is sent back to the frontend and parsed.&lt;br /&gt;
*The React components update the UI (tables, heatmaps, statistics) based on the received data.&lt;br /&gt;
&lt;br /&gt;
This architecture ensures a clean separation between frontend and backend logic, improving maintainability and testability.&lt;br /&gt;
[[File:Dataflow.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
The test plan for Phase 2 focuses on verifying the successful integration of the newly reimplemented &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the React-based UI components. We aim to ensure data is:&lt;br /&gt;
&lt;br /&gt;
* Correctly fetched from the backend  &lt;br /&gt;
* Appropriately displayed in the frontend  &lt;br /&gt;
* Functionally sound under both normal and edge-case scenarios&lt;br /&gt;
&lt;br /&gt;
== Tools and Frameworks ==&lt;br /&gt;
We plan to use the following tools and frameworks for testing:&lt;br /&gt;
&lt;br /&gt;
* '''Frontend''': Jest and React Testing Library for unit and integration tests&lt;br /&gt;
* '''Backend''': RSpec for controller and model tests&lt;br /&gt;
* '''Integration Testing''': Capybara and Selenium for simulating real user behavior&lt;br /&gt;
* '''Test Coverage''': SimpleCov&lt;br /&gt;
&lt;br /&gt;
== 1. UI Integration Tests ==&lt;br /&gt;
&lt;br /&gt;
These tests ensure the frontend correctly interacts with backend APIs and renders the data appropriately.&lt;br /&gt;
&lt;br /&gt;
=== ReviewTable Component ===&lt;br /&gt;
&lt;br /&gt;
* Validate that the component makes a successful API call to fetch author feedback  &lt;br /&gt;
* Ensure feedback is rendered in the correct table structure  &lt;br /&gt;
* Test loading state before data is fetched  &lt;br /&gt;
* Handle empty or malformed feedback responses gracefully  &lt;br /&gt;
&lt;br /&gt;
=== RoundSelector Component ===&lt;br /&gt;
&lt;br /&gt;
* Verify API call to fetch heatmap data is triggered on component load  &lt;br /&gt;
* Check that heatmap data is correctly visualized for different review rounds  &lt;br /&gt;
* Test behavior with no data, incomplete data, or delayed response  &lt;br /&gt;
&lt;br /&gt;
=== Statistics Component ===&lt;br /&gt;
&lt;br /&gt;
* Confirm it correctly fetches teammate evaluations and author feedback  &lt;br /&gt;
* Ensure charts or tables reflect the received backend data accurately  &lt;br /&gt;
* Test switching between different teams or assignments and verify correct display  &lt;br /&gt;
&lt;br /&gt;
=== General UI Considerations ===&lt;br /&gt;
&lt;br /&gt;
* Test frontend responsiveness to backend failures (500, 404, timeout)  &lt;br /&gt;
* Ensure authorization errors are handled and appropriate messages displayed  &lt;br /&gt;
&lt;br /&gt;
== 2. Backend API Tests ==&lt;br /&gt;
&lt;br /&gt;
While unit tests exist, integration-level tests will be added or updated to ensure UI compatibility.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
* Validate all &amp;lt;code&amp;gt;GET&amp;lt;/code&amp;gt; endpoints return properly structured JSON objects  &lt;br /&gt;
* Simulate various user roles (student, TA, instructor) and ensure access control  &lt;br /&gt;
* Include test cases for:&lt;br /&gt;
** No grades present  &lt;br /&gt;
** Partial data (e.g. missing feedback or evaluations)  &lt;br /&gt;
** Large number of records  &lt;br /&gt;
&lt;br /&gt;
=== Security &amp;amp; Permissions ===&lt;br /&gt;
&lt;br /&gt;
* Ensure students can only fetch their grades and feedback  &lt;br /&gt;
* Ensure TAs and instructors can access full assignment data  &lt;br /&gt;
* Test token/session-based access restrictions (if applicable)  &lt;br /&gt;
&lt;br /&gt;
== 3. Database Preparation ==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, seed data will simulate real-world usage and we will ensure that:&lt;br /&gt;
* Tests will use isolated fixtures or factories to ensure data consistency&lt;br /&gt;
* All database states will be reset before each test suite run&lt;br /&gt;
&lt;br /&gt;
=== Tables and Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;assignments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_participant&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;participants&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;questionnaires&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;questions&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_questionnaire&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;signed_up_teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;teams_users&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;late_policies&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
=== Scenarios ===&lt;br /&gt;
&lt;br /&gt;
* Single student assigned  &lt;br /&gt;
* Team assignments with/without feedback  &lt;br /&gt;
* Late submissions triggering late policies  &lt;br /&gt;
* Multiple review rounds per assignment&lt;br /&gt;
&lt;br /&gt;
== 4. Regression &amp;amp; CI Testing ==&lt;br /&gt;
&lt;br /&gt;
To ensure updates do not break existing functionality:&lt;br /&gt;
&lt;br /&gt;
* Re-run all existing unit tests  &lt;br /&gt;
* Include snapshot tests for frontend components  &lt;br /&gt;
* Use CI pipelines to automatically trigger tests on pull requests  &lt;br /&gt;
&lt;br /&gt;
== Test Plan Summary ==&lt;br /&gt;
&lt;br /&gt;
This test plan outlines the approach for integrating &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the frontend. By combining backend tests, UI integration checks, and realistic database scenarios, we aim to deliver a seamless user experience. The plan emphasizes early detection of issues and supports long-term maintainability through regression testing. As development progresses, the plan will be updated to cover new insights and edge cases.&lt;br /&gt;
&lt;br /&gt;
=Completed Reimplementation Details=&lt;br /&gt;
&lt;br /&gt;
This section outlines the changes that were actually implemented as part of the reimplementation effort. It provides a detailed breakdown of how the frontend was decoupled from the legacy Ruby-embedded views, and how dynamic data flow was established using API endpoints. Specific components were modified to replace hardcoded or mock data with real-time API calls to the backend, ensuring that the application now reflects live grading data. Additionally, backend controller actions were updated to return clean, structured JSON responses, and the data retrieval logic was centralized to improve maintainability and testability. &lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The previous implementation was designed for a Ruby-embedded front-end, where data was rendered server-side and injected directly into the view. We have since updated the APIs to return data in a format suitable for consumption by the React UI, typically as JSON objects. This change successfully decouples the front-end from the server-side rendering logic, enabling a more interactive and responsive user experience. By transitioning to a React-based interface, we now have improved control over UI state and better alignment with modern web development practices.&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
In this controller, we have updated the GET functions to remove the use of instance variables and instead return plain JSON objects using render json: in the response. This update was essential to align with the frontend architecture, which now relies on a React-based interface that expects structured data from the backend in JSON format rather than server-rendered templates. By returning JSON responses, we’ve established cleaner and more consistent API endpoints, improved the testability and debuggability of our backend logic, and created a more maintainable and decoupled integration between the frontend and backend systems. The following functions were updated as part of this integration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  def view_grading_report&lt;br /&gt;
    assignment_id = params[:id].to_i&lt;br /&gt;
    data = get_data_for_heat_map(assignment_id)&lt;br /&gt;
    &lt;br /&gt;
    render json: data, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
    &lt;br /&gt;
  def view_my_scores&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team_id = TeamsUser.team_id(participant.assignment_id, participant.user_id)&lt;br /&gt;
    # return if redirect_when_disallowed(participant)&lt;br /&gt;
    questions = fetch_questionnaires_and_questions(assignment)&lt;br /&gt;
    pscore = fetch_participant_scores(participant, questions)&lt;br /&gt;
    topic_id = SignedUpTeam.find_topic_id_for_user(participant.assignment.id, participant.user_id)&lt;br /&gt;
    stage = participant.assignment.current_stage(topic_id)&lt;br /&gt;
    # all_penalties = update_penalties(assignment)&lt;br /&gt;
    # Feedback Summary needs to be checked once&lt;br /&gt;
    # summary_ws_url = WEBSERVICE_CONFIG['summary_webservice_url']&lt;br /&gt;
    sum = SummaryHelper::Summary.new.summarize_reviews_by_reviewee(questions, assignment, team_id, 'http://peerlogic.csc.ncsu.edu/sum/v1.0/summary/8/lsa', session)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      topic_id: topic_id,&lt;br /&gt;
      stage: stage,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      summary: sum.summary,&lt;br /&gt;
      avg_scores_by_round: sum.avg_scores_by_round,&lt;br /&gt;
      avg_scores_by_criterion: sum.avg_scores_by_criterion&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def view_team&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    team_id = team.id&lt;br /&gt;
  &lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: assignment.id).map(&amp;amp;:questionnaire)&lt;br /&gt;
    questions = retrieve_questions(questionnaires, assignment.id)&lt;br /&gt;
    pscore = Response.participant_scores(participant, questions)&lt;br /&gt;
    vmlist = process_questionare_for_team(assignment, team_id,questionnaires, team, participant)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team: team,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      vmlist: vmlist&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These updates were important for the backend and ensured seamless communication with the React frontend. By removing instance variables and returning structured JSON responses, we eliminated dependencies on server-side rendering and enabled the frontend to dynamically manage and render data. This not only enhances performance and flexibility but also improves maintainability and scalability as the application evolves. Moreover, it allows the backend and frontend to evolve independently, supporting better separation of concerns and aligning with current best practices in full-stack web development.&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We have successfully  reimplemented the previously pre-populated data with appropriate HTTP GET calls to the backend. This ensures that our application now reflects real-time data directly from the server, improving data accuracy and consistency across the UI. This update also enhances scalability and maintainability, as the frontend no longer depends on static content and can adapt to backend changes without manual intervention.&lt;br /&gt;
&lt;br /&gt;
All dummy data throughout these components has been successfully removed and replaced with real-time API integrations. This transition allows for a fully dynamic, data-driven React frontend that remains synchronized with backend updates and user interactions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Files and components that were updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' &lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:'''&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
A key component of this project involved populating the necessary database tables that the grades_controller.rb relies on to serve real-time data to the frontend. This step was essential for replacing the previously hardcoded or pre-populated dummy data with dynamic, API-driven content. Below is a list of the database tables that were seeded with mock data specifically for development and testing purposes in this project:&lt;br /&gt;
&lt;br /&gt;
* roles&lt;br /&gt;
* institutions&lt;br /&gt;
* users&lt;br /&gt;
* assignments&lt;br /&gt;
* teams &lt;br /&gt;
* teams_users&lt;br /&gt;
* sign_up_topics&lt;br /&gt;
* signed_up_teams&lt;br /&gt;
* participants&lt;br /&gt;
* questionnaires&lt;br /&gt;
* questions &lt;br /&gt;
* assignment_questionaires&lt;br /&gt;
* response_maps&lt;br /&gt;
* responses&lt;br /&gt;
* score_views&lt;br /&gt;
* tag-prompts&lt;br /&gt;
* tag_prompt_deployments&lt;br /&gt;
&lt;br /&gt;
In order to correctly populate each database, we referenced the Expertiza Database Documentation to understand the schema, and then mapped out the relevant tables needed by grades_controller.rb. Then we populated them with mock data to support development and testing of the new API-driven frontend.&lt;br /&gt;
&lt;br /&gt;
==Data Flow Overview==&lt;br /&gt;
&lt;br /&gt;
The diagram below illustrates the data flow between React frontend components and the grades_controller.rb backend during a typical grading data retrieval process.&lt;br /&gt;
&lt;br /&gt;
* The user (such as an instructor or student) interacts with the React-based grades interface—components like ReviewTable, RoundSelector, or Statistics.&lt;br /&gt;
&lt;br /&gt;
* In response to this interaction, the component initiates an API request to a specific endpoint in grades_controller.rb.&lt;br /&gt;
&lt;br /&gt;
* The controller action then queries the relevant backend models (such as Assignment, Team, and ReviewResponseMap) and constructs a structured JSON response.&lt;br /&gt;
&lt;br /&gt;
* This JSON data is returned to the frontend, where it is parsed by the corresponding React component.&lt;br /&gt;
&lt;br /&gt;
* Finally, the React components dynamically update the UI—populating tables, generating heatmaps, or displaying statistics—based on the data received.&lt;br /&gt;
&lt;br /&gt;
This architecture promotes a clear separation of concerns between frontend and backend layers, enabling more scalable development, easier debugging, and improved maintainability and testability across the application.&lt;br /&gt;
&lt;br /&gt;
=Testing=&lt;br /&gt;
&lt;br /&gt;
==Testing Overview==&lt;br /&gt;
&lt;br /&gt;
After modifying several methods in grades_controller.rb to return JSON responses and support the new React-based frontend, we conducted comprehensive testing to ensure that both the backend logic and frontend integration functioned as intended. It was essential to validate not only that the backend endpoints behaved correctly in isolation, but also that the frontend components were able to successfully consume and render the data returned by the updated APIs.&lt;br /&gt;
&lt;br /&gt;
We retested all affected methods to verify that data was retrieved accurately, permission checks were enforced, and updates were correctly persisted. In addition to running automated RSpec tests, we manually tested the backend endpoints using authenticated curl commands. These terminal-based tests allowed us to simulate real API usage, verify response structures, and confirm compatibility with the frontend. This dual-layered testing approach ensured a smooth and reliable interaction between the React UI and the Rails backend.&lt;br /&gt;
&lt;br /&gt;
==Database Preparation==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, we populated the database with carefully designed mock data that simulates a variety of real-world grading scenarios. This approach ensured that our test environment closely mirrors actual usage patterns, allowing for more meaningful validation of the grades_controller.rb logic and its interactions with related models.&lt;br /&gt;
 &lt;br /&gt;
We created test scenarios that covered a range of use cases, including individual and team assignments, review rounds, and various submissions, to verify that each controller action behaves as expected under different conditions. By populating the relevant tables with representative data, we were able to rigorously test features like permission checks, grade updates, response mapping, and feedback rendering.&lt;br /&gt;
&lt;br /&gt;
The specific databases that were populated can be found in the Database section.&lt;br /&gt;
&lt;br /&gt;
==UI Tests==&lt;br /&gt;
&lt;br /&gt;
==Backend API Tests==&lt;br /&gt;
&lt;br /&gt;
==Tables and Test Coverage==&lt;br /&gt;
&lt;br /&gt;
==Adhering to Priciples==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164245</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164245"/>
		<updated>2025-04-20T20:12:01Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* Testing Overview */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of this project is to integrate the frontend of the grades view page with the reimplemented '''''grades_controller.rb (E2510)''''' backend in Expertiza, ensuring a seamless connection between both layers. This integration involves refining the interaction between the UI and backend while adhering to best design principles such as modularity, maintainability, and scalability. The grades_controller.rb is responsible for managing grading functionality, allowing instructors to view and modify assignment grades while enabling students to access their evaluations. By following SOLID and DRY principles, this reimplementation enhances code clarity, reduces redundancy, and improves overall system efficiency.&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
The &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; is responsible for managing and delivering grading data to users in the Expertiza system. It enables instructors to view, calculate, and release grades to students, while also allowing students to view feedback and scores for assignments. The controller plays an important role in coordinating backend logic for reviews and grade visibility.&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
The previous implementation successfully created a functional frontend UI page in Expertiza, addressing design inconsistencies and improving usability. It introduced a visually cohesive interface with an intuitive layout, enhanced responsiveness, and improved information display, allowing users to navigate grading data more efficiently. However, the interface was populated using dummy data, limiting its practical use. This reimplemented UI will utilize real data from the database (that has been populated in this round), ensuring that grading information is dynamically retrieved and displayed accurately through JSON objects. Additionally, this phase will connect the redesigned frontend with some new components in the grades_controller.rb. Specifically, the GET functions in the grades_controller were reimplemented to return JSON objects (instead of instance variables) that could be accessed via an API call. Thus, this new implementation ensures seamless communication between the UI and backend while adhering to best design practices for maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
This project focuses on integrating the frontend of the grades view page with the reimplemented '''grades_controller.rb (E2510)''' backend in Expertiza. This integration requires modifications to both the frontend and backend to establish a seamless connection, ensuring that grading data is dynamically retrieved and displayed accurately. By adhering to best design principles such as modularity, maintainability, and scalability, the implementation will enhance system efficiency and long-term usability. Key improvements include replacing dummy data with real database values, refining data flow between the UI and backend, and optimizing API interactions for better performance. These enhancements will create a more intuitive and reliable grading system, providing a seamless experience for instructors and students while maintaining a well-structured and adaptable codebase for future development.&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
# '''Establish a Robust Connection Between the Frontend and Backend''': Ensure smooth data retrieval and updates between the grades view page and the backend by integrating dynamic data through API calls, replacing the current hardcoded dummy data.&lt;br /&gt;
# '''Define and Implement Clear API Endpoints''': Create well-structured API endpoints in grades_controller.rb for retrieving and displaying grades, ensuring they return appropriate data based on user roles (students, instructors, TAs) and maintain role-based access controls.&lt;br /&gt;
# '''Dynamic Data Integration''': Modify the frontend to consume real-time data fetched from the backend, ensuring an intuitive and responsive UI that reflects the actual grading information. &lt;br /&gt;
# '''Reimplement Frontend and Backend Components''': Reimplement both the frontend and backend as necessary to align with SOLID and DRY principles, ensuring modularity, maintainability, and scalability. This includes eliminating redundant logic and optimizing code for better readability.&lt;br /&gt;
# '''Implement Proper Permission Checks''': Ensure that only authorized users can access grade information by implementing robust privilege checks and ensuring that the data is securely accessible to students, instructors, and TAs based on their roles.&lt;br /&gt;
# '''Optimize Database Queries and API Responses''': Enhance the efficiency of database queries and API responses to reduce unnecessary load and ensure that data is retrieved and displayed promptly.&lt;br /&gt;
# '''Testing and Validation''': Implement comprehensive unit and integration tests to verify the correctness of data flow, UI interactions, and role-based access controls, ensuring that the system functions correctly and securely.&lt;br /&gt;
&lt;br /&gt;
=Reimplementation Plan=&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populated data with the appropriate HTTP GET and HTTP POST calls. This shift is necessary to ensure that our application reflects real-time data from the backend rather than relying on static or hardcoded values, which can quickly become outdated or inconsistent. It also enables better scalability and maintainability, as changes to the data only need to be made in the backend, without requiring manual updates in the frontend code.&lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
'''Author Feedback''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
'''Heatmap Data''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
'''Team-mate Data''':&lt;br /&gt;
   {&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The current implementation caters to the backend for a Ruby-embedded front-end, where data is rendered server-side and passed directly into the view. We need to update the APIs to return data in a format that can be consumed by the React UI, typically JSON. This shift is essential to decouple the front-end from the server-side rendering logic, allowing for a more interactive and dynamic user experience. By transitioning to a React-based interface, we gain better control over UI state and responsiveness, while also aligning with modern web development practices. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and instead return plain JSON objects using render json: in the response. This change is necessary to align with a frontend architecture that uses React or another JavaScript framework, which expects structured data from the backend in JSON format rather than relying on server-rendered templates. By shifting to JSON responses, we enable cleaner API endpoints, facilitate easier testing and debugging, and support a more maintainable, decoupled frontend-backend integration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    # prepare feedback summaries&lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
  1.1. Students&lt;br /&gt;
  1.2. Teams&lt;br /&gt;
  1.3. TA&lt;br /&gt;
  1.4. Professor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
  2.1 assignments&lt;br /&gt;
  2.2 assignment_questionnaire&lt;br /&gt;
  2.3 questionnaires&lt;br /&gt;
  2.4 participant&lt;br /&gt;
  2.5 signed_up_teams&lt;br /&gt;
  2.6 teams_users&lt;br /&gt;
  2.7 due_dates&lt;br /&gt;
  2.8 late_policies&lt;br /&gt;
  2.9 questions&lt;br /&gt;
  2.10 review_scores&lt;br /&gt;
  2.11 review_grades&lt;br /&gt;
&lt;br /&gt;
== Data Flow Overview ==&lt;br /&gt;
The diagram below illustrates how data flows between the frontend React components and the grades_controller.rb backend during a typical grading data fetch operation.&lt;br /&gt;
&lt;br /&gt;
* The user (e.g., instructor or student) interacts with the React-based grades view (e.g., ReviewTable, RoundSelector, or Statistics).&lt;br /&gt;
* The component triggers an API request to a specific action in grades_controller.rb (e.g., GET /grades/:id/summary).&lt;br /&gt;
*The controller action queries the relevant models (e.g., Assignment, Team, ReviewResponseMap) and compiles a JSON response.&lt;br /&gt;
* The response is sent back to the frontend and parsed.&lt;br /&gt;
*The React components update the UI (tables, heatmaps, statistics) based on the received data.&lt;br /&gt;
&lt;br /&gt;
This architecture ensures a clean separation between frontend and backend logic, improving maintainability and testability.&lt;br /&gt;
[[File:Dataflow.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
The test plan for Phase 2 focuses on verifying the successful integration of the newly reimplemented &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the React-based UI components. We aim to ensure data is:&lt;br /&gt;
&lt;br /&gt;
* Correctly fetched from the backend  &lt;br /&gt;
* Appropriately displayed in the frontend  &lt;br /&gt;
* Functionally sound under both normal and edge-case scenarios&lt;br /&gt;
&lt;br /&gt;
== Tools and Frameworks ==&lt;br /&gt;
We plan to use the following tools and frameworks for testing:&lt;br /&gt;
&lt;br /&gt;
* '''Frontend''': Jest and React Testing Library for unit and integration tests&lt;br /&gt;
* '''Backend''': RSpec for controller and model tests&lt;br /&gt;
* '''Integration Testing''': Capybara and Selenium for simulating real user behavior&lt;br /&gt;
* '''Test Coverage''': SimpleCov&lt;br /&gt;
&lt;br /&gt;
== 1. UI Integration Tests ==&lt;br /&gt;
&lt;br /&gt;
These tests ensure the frontend correctly interacts with backend APIs and renders the data appropriately.&lt;br /&gt;
&lt;br /&gt;
=== ReviewTable Component ===&lt;br /&gt;
&lt;br /&gt;
* Validate that the component makes a successful API call to fetch author feedback  &lt;br /&gt;
* Ensure feedback is rendered in the correct table structure  &lt;br /&gt;
* Test loading state before data is fetched  &lt;br /&gt;
* Handle empty or malformed feedback responses gracefully  &lt;br /&gt;
&lt;br /&gt;
=== RoundSelector Component ===&lt;br /&gt;
&lt;br /&gt;
* Verify API call to fetch heatmap data is triggered on component load  &lt;br /&gt;
* Check that heatmap data is correctly visualized for different review rounds  &lt;br /&gt;
* Test behavior with no data, incomplete data, or delayed response  &lt;br /&gt;
&lt;br /&gt;
=== Statistics Component ===&lt;br /&gt;
&lt;br /&gt;
* Confirm it correctly fetches teammate evaluations and author feedback  &lt;br /&gt;
* Ensure charts or tables reflect the received backend data accurately  &lt;br /&gt;
* Test switching between different teams or assignments and verify correct display  &lt;br /&gt;
&lt;br /&gt;
=== General UI Considerations ===&lt;br /&gt;
&lt;br /&gt;
* Test frontend responsiveness to backend failures (500, 404, timeout)  &lt;br /&gt;
* Ensure authorization errors are handled and appropriate messages displayed  &lt;br /&gt;
&lt;br /&gt;
== 2. Backend API Tests ==&lt;br /&gt;
&lt;br /&gt;
While unit tests exist, integration-level tests will be added or updated to ensure UI compatibility.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
* Validate all &amp;lt;code&amp;gt;GET&amp;lt;/code&amp;gt; endpoints return properly structured JSON objects  &lt;br /&gt;
* Simulate various user roles (student, TA, instructor) and ensure access control  &lt;br /&gt;
* Include test cases for:&lt;br /&gt;
** No grades present  &lt;br /&gt;
** Partial data (e.g. missing feedback or evaluations)  &lt;br /&gt;
** Large number of records  &lt;br /&gt;
&lt;br /&gt;
=== Security &amp;amp; Permissions ===&lt;br /&gt;
&lt;br /&gt;
* Ensure students can only fetch their grades and feedback  &lt;br /&gt;
* Ensure TAs and instructors can access full assignment data  &lt;br /&gt;
* Test token/session-based access restrictions (if applicable)  &lt;br /&gt;
&lt;br /&gt;
== 3. Database Preparation ==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, seed data will simulate real-world usage and we will ensure that:&lt;br /&gt;
* Tests will use isolated fixtures or factories to ensure data consistency&lt;br /&gt;
* All database states will be reset before each test suite run&lt;br /&gt;
&lt;br /&gt;
=== Tables and Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;assignments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_participant&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;participants&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;questionnaires&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;questions&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_questionnaire&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;signed_up_teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;teams_users&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;late_policies&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
=== Scenarios ===&lt;br /&gt;
&lt;br /&gt;
* Single student assigned  &lt;br /&gt;
* Team assignments with/without feedback  &lt;br /&gt;
* Late submissions triggering late policies  &lt;br /&gt;
* Multiple review rounds per assignment&lt;br /&gt;
&lt;br /&gt;
== 4. Regression &amp;amp; CI Testing ==&lt;br /&gt;
&lt;br /&gt;
To ensure updates do not break existing functionality:&lt;br /&gt;
&lt;br /&gt;
* Re-run all existing unit tests  &lt;br /&gt;
* Include snapshot tests for frontend components  &lt;br /&gt;
* Use CI pipelines to automatically trigger tests on pull requests  &lt;br /&gt;
&lt;br /&gt;
== Test Plan Summary ==&lt;br /&gt;
&lt;br /&gt;
This test plan outlines the approach for integrating &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the frontend. By combining backend tests, UI integration checks, and realistic database scenarios, we aim to deliver a seamless user experience. The plan emphasizes early detection of issues and supports long-term maintainability through regression testing. As development progresses, the plan will be updated to cover new insights and edge cases.&lt;br /&gt;
&lt;br /&gt;
=Completed Reimplementation Details=&lt;br /&gt;
&lt;br /&gt;
This section outlines the changes that were actually implemented as part of the reimplementation effort. It provides a detailed breakdown of how the frontend was decoupled from the legacy Ruby-embedded views, and how dynamic data flow was established using API endpoints. Specific components were modified to replace hardcoded or mock data with real-time API calls to the backend, ensuring that the application now reflects live grading data. Additionally, backend controller actions were updated to return clean, structured JSON responses, and the data retrieval logic was centralized to improve maintainability and testability. &lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The previous implementation was designed for a Ruby-embedded front-end, where data was rendered server-side and injected directly into the view. We have since updated the APIs to return data in a format suitable for consumption by the React UI, typically as JSON objects. This change successfully decouples the front-end from the server-side rendering logic, enabling a more interactive and responsive user experience. By transitioning to a React-based interface, we now have improved control over UI state and better alignment with modern web development practices.&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
In this controller, we have updated the GET functions to remove the use of instance variables and instead return plain JSON objects using render json: in the response. This update was essential to align with the frontend architecture, which now relies on a React-based interface that expects structured data from the backend in JSON format rather than server-rendered templates. By returning JSON responses, we’ve established cleaner and more consistent API endpoints, improved the testability and debuggability of our backend logic, and created a more maintainable and decoupled integration between the frontend and backend systems. The following functions were updated as part of this integration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  def view_grading_report&lt;br /&gt;
    assignment_id = params[:id].to_i&lt;br /&gt;
    data = get_data_for_heat_map(assignment_id)&lt;br /&gt;
    &lt;br /&gt;
    render json: data, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
    &lt;br /&gt;
  def view_my_scores&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team_id = TeamsUser.team_id(participant.assignment_id, participant.user_id)&lt;br /&gt;
    # return if redirect_when_disallowed(participant)&lt;br /&gt;
    questions = fetch_questionnaires_and_questions(assignment)&lt;br /&gt;
    pscore = fetch_participant_scores(participant, questions)&lt;br /&gt;
    topic_id = SignedUpTeam.find_topic_id_for_user(participant.assignment.id, participant.user_id)&lt;br /&gt;
    stage = participant.assignment.current_stage(topic_id)&lt;br /&gt;
    # all_penalties = update_penalties(assignment)&lt;br /&gt;
    # Feedback Summary needs to be checked once&lt;br /&gt;
    # summary_ws_url = WEBSERVICE_CONFIG['summary_webservice_url']&lt;br /&gt;
    sum = SummaryHelper::Summary.new.summarize_reviews_by_reviewee(questions, assignment, team_id, 'http://peerlogic.csc.ncsu.edu/sum/v1.0/summary/8/lsa', session)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      topic_id: topic_id,&lt;br /&gt;
      stage: stage,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      summary: sum.summary,&lt;br /&gt;
      avg_scores_by_round: sum.avg_scores_by_round,&lt;br /&gt;
      avg_scores_by_criterion: sum.avg_scores_by_criterion&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def view_team&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    team_id = team.id&lt;br /&gt;
  &lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: assignment.id).map(&amp;amp;:questionnaire)&lt;br /&gt;
    questions = retrieve_questions(questionnaires, assignment.id)&lt;br /&gt;
    pscore = Response.participant_scores(participant, questions)&lt;br /&gt;
    vmlist = process_questionare_for_team(assignment, team_id,questionnaires, team, participant)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team: team,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      vmlist: vmlist&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These updates were important for the backend and ensured seamless communication with the React frontend. By removing instance variables and returning structured JSON responses, we eliminated dependencies on server-side rendering and enabled the frontend to dynamically manage and render data. This not only enhances performance and flexibility but also improves maintainability and scalability as the application evolves. Moreover, it allows the backend and frontend to evolve independently, supporting better separation of concerns and aligning with current best practices in full-stack web development.&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We have successfully  reimplemented the previously pre-populated data with appropriate HTTP GET calls to the backend. This ensures that our application now reflects real-time data directly from the server, improving data accuracy and consistency across the UI. This update also enhances scalability and maintainability, as the frontend no longer depends on static content and can adapt to backend changes without manual intervention.&lt;br /&gt;
&lt;br /&gt;
All dummy data throughout these components has been successfully removed and replaced with real-time API integrations. This transition allows for a fully dynamic, data-driven React frontend that remains synchronized with backend updates and user interactions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Files and components that were updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' &lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:'''&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
A key component of this project involved populating the necessary database tables that the grades_controller.rb relies on to serve real-time data to the frontend. This step was essential for replacing the previously hardcoded or pre-populated dummy data with dynamic, API-driven content. Below is a list of the database tables that were seeded with mock data specifically for development and testing purposes in this project:&lt;br /&gt;
&lt;br /&gt;
* roles&lt;br /&gt;
* institutions&lt;br /&gt;
* users&lt;br /&gt;
* assignments&lt;br /&gt;
* teams &lt;br /&gt;
* teams_users&lt;br /&gt;
* sign_up_topics&lt;br /&gt;
* signed_up_teams&lt;br /&gt;
* participants&lt;br /&gt;
* questionnaires&lt;br /&gt;
* questions &lt;br /&gt;
* assignment_questionaires&lt;br /&gt;
* response_maps&lt;br /&gt;
* responses&lt;br /&gt;
* score_views&lt;br /&gt;
* tag-prompts&lt;br /&gt;
* tag_prompt_deployments&lt;br /&gt;
&lt;br /&gt;
In order to correctly populate each database, we referenced the Expertiza Database Documentation to understand the schema, and then mapped out the relevant tables needed by grades_controller.rb. Then we populated them with mock data to support development and testing of the new API-driven frontend.&lt;br /&gt;
&lt;br /&gt;
==Data Flow Overview==&lt;br /&gt;
&lt;br /&gt;
The diagram below illustrates the data flow between React frontend components and the grades_controller.rb backend during a typical grading data retrieval process.&lt;br /&gt;
&lt;br /&gt;
* The user (such as an instructor or student) interacts with the React-based grades interface—components like ReviewTable, RoundSelector, or Statistics.&lt;br /&gt;
&lt;br /&gt;
* In response to this interaction, the component initiates an API request to a specific endpoint in grades_controller.rb.&lt;br /&gt;
&lt;br /&gt;
* The controller action then queries the relevant backend models (such as Assignment, Team, and ReviewResponseMap) and constructs a structured JSON response.&lt;br /&gt;
&lt;br /&gt;
* This JSON data is returned to the frontend, where it is parsed by the corresponding React component.&lt;br /&gt;
&lt;br /&gt;
* Finally, the React components dynamically update the UI—populating tables, generating heatmaps, or displaying statistics—based on the data received.&lt;br /&gt;
&lt;br /&gt;
This architecture promotes a clear separation of concerns between frontend and backend layers, enabling more scalable development, easier debugging, and improved maintainability and testability across the application.&lt;br /&gt;
&lt;br /&gt;
=Testing=&lt;br /&gt;
&lt;br /&gt;
==Testing Overview==&lt;br /&gt;
&lt;br /&gt;
After modifying several methods in grades_controller.rb to return JSON responses and support the new React-based frontend, we conducted comprehensive testing to ensure that both the backend logic and frontend integration functioned as intended. It was essential to validate not only that the backend endpoints behaved correctly in isolation, but also that the frontend components were able to successfully consume and render the data returned by the updated APIs.&lt;br /&gt;
&lt;br /&gt;
We retested all affected methods to verify that data was retrieved accurately, permission checks were enforced, and updates were correctly persisted. In addition to running automated RSpec tests, we manually tested the backend endpoints using authenticated curl commands. These terminal-based tests allowed us to simulate real API usage, verify response structures, and confirm compatibility with the frontend. This dual-layered testing approach ensured a smooth and reliable interaction between the React UI and the Rails backend.&lt;br /&gt;
&lt;br /&gt;
==Database Preparation==&lt;br /&gt;
&lt;br /&gt;
==UI Tests==&lt;br /&gt;
&lt;br /&gt;
==Backend API Tests==&lt;br /&gt;
&lt;br /&gt;
==Tables and Test Coverage==&lt;br /&gt;
&lt;br /&gt;
==Adhering to Priciples==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164231</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164231"/>
		<updated>2025-04-20T19:16:57Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* Specific Objectives */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of this project is to integrate the frontend of the grades view page with the reimplemented '''''grades_controller.rb (E2510)''''' backend in Expertiza, ensuring a seamless connection between both layers. This integration involves refining the interaction between the UI and backend while adhering to best design principles such as modularity, maintainability, and scalability. The grades_controller.rb is responsible for managing grading functionality, allowing instructors to view and modify assignment grades while enabling students to access their evaluations. By following SOLID and DRY principles, this reimplementation enhances code clarity, reduces redundancy, and improves overall system efficiency.&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
The &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; is responsible for managing and delivering grading data to users in the Expertiza system. It enables instructors to view, calculate, and release grades to students, while also allowing students to view feedback and scores for assignments. The controller plays an important role in coordinating backend logic for reviews and grade visibility.&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
The previous implementation successfully created a functional frontend UI page in Expertiza, addressing design inconsistencies and improving usability. It introduced a visually cohesive interface with an intuitive layout, enhanced responsiveness, and improved information display, allowing users to navigate grading data more efficiently. However, the interface was populated using dummy data, limiting its practical use. This reimplemented UI will utilize real data from the database (that has been populated in this round), ensuring that grading information is dynamically retrieved and displayed accurately through JSON objects. Additionally, this phase will connect the redesigned frontend with some new components in the grades_controller.rb. Specifically, the GET functions in the grades_controller were reimplemented to return JSON objects (instead of instance variables) that could be accessed via an API call. Thus, this new implementation ensures seamless communication between the UI and backend while adhering to best design practices for maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
This project focuses on integrating the frontend of the grades view page with the reimplemented '''grades_controller.rb (E2510)''' backend in Expertiza. This integration requires modifications to both the frontend and backend to establish a seamless connection, ensuring that grading data is dynamically retrieved and displayed accurately. By adhering to best design principles such as modularity, maintainability, and scalability, the implementation will enhance system efficiency and long-term usability. Key improvements include replacing dummy data with real database values, refining data flow between the UI and backend, and optimizing API interactions for better performance. These enhancements will create a more intuitive and reliable grading system, providing a seamless experience for instructors and students while maintaining a well-structured and adaptable codebase for future development.&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
# '''Establish a Robust Connection Between the Frontend and Backend''': Ensure smooth data retrieval and updates between the grades view page and the backend by integrating dynamic data through API calls, replacing the current hardcoded dummy data.&lt;br /&gt;
# '''Define and Implement Clear API Endpoints''': Create well-structured API endpoints in grades_controller.rb for retrieving and displaying grades, ensuring they return appropriate data based on user roles (students, instructors, TAs) and maintain role-based access controls.&lt;br /&gt;
# '''Dynamic Data Integration''': Modify the frontend to consume real-time data fetched from the backend, ensuring an intuitive and responsive UI that reflects the actual grading information. &lt;br /&gt;
# '''Reimplement Frontend and Backend Components''': Reimplement both the frontend and backend as necessary to align with SOLID and DRY principles, ensuring modularity, maintainability, and scalability. This includes eliminating redundant logic and optimizing code for better readability.&lt;br /&gt;
# '''Implement Proper Permission Checks''': Ensure that only authorized users can access grade information by implementing robust privilege checks and ensuring that the data is securely accessible to students, instructors, and TAs based on their roles.&lt;br /&gt;
# '''Optimize Database Queries and API Responses''': Enhance the efficiency of database queries and API responses to reduce unnecessary load and ensure that data is retrieved and displayed promptly.&lt;br /&gt;
# '''Testing and Validation''': Implement comprehensive unit and integration tests to verify the correctness of data flow, UI interactions, and role-based access controls, ensuring that the system functions correctly and securely.&lt;br /&gt;
&lt;br /&gt;
=Reimplementation Plan=&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populated data with the appropriate HTTP GET and HTTP POST calls. This shift is necessary to ensure that our application reflects real-time data from the backend rather than relying on static or hardcoded values, which can quickly become outdated or inconsistent. It also enables better scalability and maintainability, as changes to the data only need to be made in the backend, without requiring manual updates in the frontend code.&lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
'''Author Feedback''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
'''Heatmap Data''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
'''Team-mate Data''':&lt;br /&gt;
   {&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The current implementation caters to the backend for a Ruby-embedded front-end, where data is rendered server-side and passed directly into the view. We need to update the APIs to return data in a format that can be consumed by the React UI, typically JSON. This shift is essential to decouple the front-end from the server-side rendering logic, allowing for a more interactive and dynamic user experience. By transitioning to a React-based interface, we gain better control over UI state and responsiveness, while also aligning with modern web development practices. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and instead return plain JSON objects using render json: in the response. This change is necessary to align with a frontend architecture that uses React or another JavaScript framework, which expects structured data from the backend in JSON format rather than relying on server-rendered templates. By shifting to JSON responses, we enable cleaner API endpoints, facilitate easier testing and debugging, and support a more maintainable, decoupled frontend-backend integration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    # prepare feedback summaries&lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
  1.1. Students&lt;br /&gt;
  1.2. Teams&lt;br /&gt;
  1.3. TA&lt;br /&gt;
  1.4. Professor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
  2.1 assignments&lt;br /&gt;
  2.2 assignment_questionnaire&lt;br /&gt;
  2.3 questionnaires&lt;br /&gt;
  2.4 participant&lt;br /&gt;
  2.5 signed_up_teams&lt;br /&gt;
  2.6 teams_users&lt;br /&gt;
  2.7 due_dates&lt;br /&gt;
  2.8 late_policies&lt;br /&gt;
  2.9 questions&lt;br /&gt;
  2.10 review_scores&lt;br /&gt;
  2.11 review_grades&lt;br /&gt;
&lt;br /&gt;
== Data Flow Overview ==&lt;br /&gt;
The diagram below illustrates how data flows between the frontend React components and the grades_controller.rb backend during a typical grading data fetch operation.&lt;br /&gt;
&lt;br /&gt;
* The user (e.g., instructor or student) interacts with the React-based grades view (e.g., ReviewTable, RoundSelector, or Statistics).&lt;br /&gt;
* The component triggers an API request to a specific action in grades_controller.rb (e.g., GET /grades/:id/summary).&lt;br /&gt;
*The controller action queries the relevant models (e.g., Assignment, Team, ReviewResponseMap) and compiles a JSON response.&lt;br /&gt;
* The response is sent back to the frontend and parsed.&lt;br /&gt;
*The React components update the UI (tables, heatmaps, statistics) based on the received data.&lt;br /&gt;
&lt;br /&gt;
This architecture ensures a clean separation between frontend and backend logic, improving maintainability and testability.&lt;br /&gt;
[[File:Dataflow.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
The test plan for Phase 2 focuses on verifying the successful integration of the newly reimplemented &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the React-based UI components. We aim to ensure data is:&lt;br /&gt;
&lt;br /&gt;
* Correctly fetched from the backend  &lt;br /&gt;
* Appropriately displayed in the frontend  &lt;br /&gt;
* Functionally sound under both normal and edge-case scenarios&lt;br /&gt;
&lt;br /&gt;
== Tools and Frameworks ==&lt;br /&gt;
We plan to use the following tools and frameworks for testing:&lt;br /&gt;
&lt;br /&gt;
* '''Frontend''': Jest and React Testing Library for unit and integration tests&lt;br /&gt;
* '''Backend''': RSpec for controller and model tests&lt;br /&gt;
* '''Integration Testing''': Capybara and Selenium for simulating real user behavior&lt;br /&gt;
* '''Test Coverage''': SimpleCov&lt;br /&gt;
&lt;br /&gt;
== 1. UI Integration Tests ==&lt;br /&gt;
&lt;br /&gt;
These tests ensure the frontend correctly interacts with backend APIs and renders the data appropriately.&lt;br /&gt;
&lt;br /&gt;
=== ReviewTable Component ===&lt;br /&gt;
&lt;br /&gt;
* Validate that the component makes a successful API call to fetch author feedback  &lt;br /&gt;
* Ensure feedback is rendered in the correct table structure  &lt;br /&gt;
* Test loading state before data is fetched  &lt;br /&gt;
* Handle empty or malformed feedback responses gracefully  &lt;br /&gt;
&lt;br /&gt;
=== RoundSelector Component ===&lt;br /&gt;
&lt;br /&gt;
* Verify API call to fetch heatmap data is triggered on component load  &lt;br /&gt;
* Check that heatmap data is correctly visualized for different review rounds  &lt;br /&gt;
* Test behavior with no data, incomplete data, or delayed response  &lt;br /&gt;
&lt;br /&gt;
=== Statistics Component ===&lt;br /&gt;
&lt;br /&gt;
* Confirm it correctly fetches teammate evaluations and author feedback  &lt;br /&gt;
* Ensure charts or tables reflect the received backend data accurately  &lt;br /&gt;
* Test switching between different teams or assignments and verify correct display  &lt;br /&gt;
&lt;br /&gt;
=== General UI Considerations ===&lt;br /&gt;
&lt;br /&gt;
* Test frontend responsiveness to backend failures (500, 404, timeout)  &lt;br /&gt;
* Ensure authorization errors are handled and appropriate messages displayed  &lt;br /&gt;
&lt;br /&gt;
== 2. Backend API Tests ==&lt;br /&gt;
&lt;br /&gt;
While unit tests exist, integration-level tests will be added or updated to ensure UI compatibility.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
* Validate all &amp;lt;code&amp;gt;GET&amp;lt;/code&amp;gt; endpoints return properly structured JSON objects  &lt;br /&gt;
* Simulate various user roles (student, TA, instructor) and ensure access control  &lt;br /&gt;
* Include test cases for:&lt;br /&gt;
** No grades present  &lt;br /&gt;
** Partial data (e.g. missing feedback or evaluations)  &lt;br /&gt;
** Large number of records  &lt;br /&gt;
&lt;br /&gt;
=== Security &amp;amp; Permissions ===&lt;br /&gt;
&lt;br /&gt;
* Ensure students can only fetch their grades and feedback  &lt;br /&gt;
* Ensure TAs and instructors can access full assignment data  &lt;br /&gt;
* Test token/session-based access restrictions (if applicable)  &lt;br /&gt;
&lt;br /&gt;
== 3. Database Preparation ==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, seed data will simulate real-world usage and we will ensure that:&lt;br /&gt;
* Tests will use isolated fixtures or factories to ensure data consistency&lt;br /&gt;
* All database states will be reset before each test suite run&lt;br /&gt;
&lt;br /&gt;
=== Tables and Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;assignments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_participant&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;participants&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;questionnaires&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;questions&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_questionnaire&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;signed_up_teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;teams_users&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;late_policies&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
=== Scenarios ===&lt;br /&gt;
&lt;br /&gt;
* Single student assigned  &lt;br /&gt;
* Team assignments with/without feedback  &lt;br /&gt;
* Late submissions triggering late policies  &lt;br /&gt;
* Multiple review rounds per assignment&lt;br /&gt;
&lt;br /&gt;
== 4. Regression &amp;amp; CI Testing ==&lt;br /&gt;
&lt;br /&gt;
To ensure updates do not break existing functionality:&lt;br /&gt;
&lt;br /&gt;
* Re-run all existing unit tests  &lt;br /&gt;
* Include snapshot tests for frontend components  &lt;br /&gt;
* Use CI pipelines to automatically trigger tests on pull requests  &lt;br /&gt;
&lt;br /&gt;
== Test Plan Summary ==&lt;br /&gt;
&lt;br /&gt;
This test plan outlines the approach for integrating &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the frontend. By combining backend tests, UI integration checks, and realistic database scenarios, we aim to deliver a seamless user experience. The plan emphasizes early detection of issues and supports long-term maintainability through regression testing. As development progresses, the plan will be updated to cover new insights and edge cases.&lt;br /&gt;
&lt;br /&gt;
=Completed Reimplementation Details=&lt;br /&gt;
&lt;br /&gt;
This section outlines the changes that were actually implemented as part of the reimplementation effort. It provides a detailed breakdown of how the frontend was decoupled from the legacy Ruby-embedded views, and how dynamic data flow was established using API endpoints. Specific components were modified to replace hardcoded or mock data with real-time API calls to the backend, ensuring that the application now reflects live grading data. Additionally, backend controller actions were updated to return clean, structured JSON responses, and the data retrieval logic was centralized to improve maintainability and testability. &lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The previous implementation was designed for a Ruby-embedded front-end, where data was rendered server-side and injected directly into the view. We have since updated the APIs to return data in a format suitable for consumption by the React UI, typically as JSON objects. This change successfully decouples the front-end from the server-side rendering logic, enabling a more interactive and responsive user experience. By transitioning to a React-based interface, we now have improved control over UI state and better alignment with modern web development practices.&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
In this controller, we have updated the GET functions to remove the use of instance variables and instead return plain JSON objects using render json: in the response. This update was essential to align with the frontend architecture, which now relies on a React-based interface that expects structured data from the backend in JSON format rather than server-rendered templates. By returning JSON responses, we’ve established cleaner and more consistent API endpoints, improved the testability and debuggability of our backend logic, and created a more maintainable and decoupled integration between the frontend and backend systems. The following functions were updated as part of this integration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  def view_grading_report&lt;br /&gt;
    assignment_id = params[:id].to_i&lt;br /&gt;
    data = get_data_for_heat_map(assignment_id)&lt;br /&gt;
    &lt;br /&gt;
    render json: data, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
    &lt;br /&gt;
  def view_my_scores&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team_id = TeamsUser.team_id(participant.assignment_id, participant.user_id)&lt;br /&gt;
    # return if redirect_when_disallowed(participant)&lt;br /&gt;
    questions = fetch_questionnaires_and_questions(assignment)&lt;br /&gt;
    pscore = fetch_participant_scores(participant, questions)&lt;br /&gt;
    topic_id = SignedUpTeam.find_topic_id_for_user(participant.assignment.id, participant.user_id)&lt;br /&gt;
    stage = participant.assignment.current_stage(topic_id)&lt;br /&gt;
    # all_penalties = update_penalties(assignment)&lt;br /&gt;
    # Feedback Summary needs to be checked once&lt;br /&gt;
    # summary_ws_url = WEBSERVICE_CONFIG['summary_webservice_url']&lt;br /&gt;
    sum = SummaryHelper::Summary.new.summarize_reviews_by_reviewee(questions, assignment, team_id, 'http://peerlogic.csc.ncsu.edu/sum/v1.0/summary/8/lsa', session)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      topic_id: topic_id,&lt;br /&gt;
      stage: stage,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      summary: sum.summary,&lt;br /&gt;
      avg_scores_by_round: sum.avg_scores_by_round,&lt;br /&gt;
      avg_scores_by_criterion: sum.avg_scores_by_criterion&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def view_team&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    team_id = team.id&lt;br /&gt;
  &lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: assignment.id).map(&amp;amp;:questionnaire)&lt;br /&gt;
    questions = retrieve_questions(questionnaires, assignment.id)&lt;br /&gt;
    pscore = Response.participant_scores(participant, questions)&lt;br /&gt;
    vmlist = process_questionare_for_team(assignment, team_id,questionnaires, team, participant)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team: team,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      vmlist: vmlist&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These updates were important for the backend and ensured seamless communication with the React frontend. By removing instance variables and returning structured JSON responses, we eliminated dependencies on server-side rendering and enabled the frontend to dynamically manage and render data. This not only enhances performance and flexibility but also improves maintainability and scalability as the application evolves. Moreover, it allows the backend and frontend to evolve independently, supporting better separation of concerns and aligning with current best practices in full-stack web development.&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We have successfully  reimplemented the previously pre-populated data with appropriate HTTP GET calls to the backend. This ensures that our application now reflects real-time data directly from the server, improving data accuracy and consistency across the UI. This update also enhances scalability and maintainability, as the frontend no longer depends on static content and can adapt to backend changes without manual intervention.&lt;br /&gt;
&lt;br /&gt;
All dummy data throughout these components has been successfully removed and replaced with real-time API integrations. This transition allows for a fully dynamic, data-driven React frontend that remains synchronized with backend updates and user interactions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Files and components that were updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' &lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:'''&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
A key component of this project involved populating the necessary database tables that the grades_controller.rb relies on to serve real-time data to the frontend. This step was essential for replacing the previously hardcoded or pre-populated dummy data with dynamic, API-driven content. Below is a list of the database tables that were seeded with mock data specifically for development and testing purposes in this project:&lt;br /&gt;
&lt;br /&gt;
* roles&lt;br /&gt;
* institutions&lt;br /&gt;
* users&lt;br /&gt;
* assignments&lt;br /&gt;
* teams &lt;br /&gt;
* teams_users&lt;br /&gt;
* sign_up_topics&lt;br /&gt;
* signed_up_teams&lt;br /&gt;
* participants&lt;br /&gt;
* questionnaires&lt;br /&gt;
* questions &lt;br /&gt;
* assignment_questionaires&lt;br /&gt;
* response_maps&lt;br /&gt;
* responses&lt;br /&gt;
* score_views&lt;br /&gt;
* tag-prompts&lt;br /&gt;
* tag_prompt_deployments&lt;br /&gt;
&lt;br /&gt;
In order to correctly populate each database, we referenced the Expertiza Database Documentation to understand the schema, and then mapped out the relevant tables needed by grades_controller.rb. Then we populated them with mock data to support development and testing of the new API-driven frontend.&lt;br /&gt;
&lt;br /&gt;
==Data Flow Overview==&lt;br /&gt;
&lt;br /&gt;
The diagram below illustrates the data flow between React frontend components and the grades_controller.rb backend during a typical grading data retrieval process.&lt;br /&gt;
&lt;br /&gt;
* The user (such as an instructor or student) interacts with the React-based grades interface—components like ReviewTable, RoundSelector, or Statistics.&lt;br /&gt;
&lt;br /&gt;
* In response to this interaction, the component initiates an API request to a specific endpoint in grades_controller.rb.&lt;br /&gt;
&lt;br /&gt;
* The controller action then queries the relevant backend models (such as Assignment, Team, and ReviewResponseMap) and constructs a structured JSON response.&lt;br /&gt;
&lt;br /&gt;
* This JSON data is returned to the frontend, where it is parsed by the corresponding React component.&lt;br /&gt;
&lt;br /&gt;
* Finally, the React components dynamically update the UI—populating tables, generating heatmaps, or displaying statistics—based on the data received.&lt;br /&gt;
&lt;br /&gt;
This architecture promotes a clear separation of concerns between frontend and backend layers, enabling more scalable development, easier debugging, and improved maintainability and testability across the application.&lt;br /&gt;
&lt;br /&gt;
=Testing=&lt;br /&gt;
&lt;br /&gt;
==Testing Overview==&lt;br /&gt;
&lt;br /&gt;
==Database Preparation==&lt;br /&gt;
&lt;br /&gt;
==UI Tests==&lt;br /&gt;
&lt;br /&gt;
==Backend API Tests==&lt;br /&gt;
&lt;br /&gt;
==Tables and Test Coverage==&lt;br /&gt;
&lt;br /&gt;
==Adhering to Priciples==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164230</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164230"/>
		<updated>2025-04-20T19:14:52Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* Links */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of this project is to integrate the frontend of the grades view page with the reimplemented '''''grades_controller.rb (E2510)''''' backend in Expertiza, ensuring a seamless connection between both layers. This integration involves refining the interaction between the UI and backend while adhering to best design principles such as modularity, maintainability, and scalability. The grades_controller.rb is responsible for managing grading functionality, allowing instructors to view and modify assignment grades while enabling students to access their evaluations. By following SOLID and DRY principles, this reimplementation enhances code clarity, reduces redundancy, and improves overall system efficiency.&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
The &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; is responsible for managing and delivering grading data to users in the Expertiza system. It enables instructors to view, calculate, and release grades to students, while also allowing students to view feedback and scores for assignments. The controller plays an important role in coordinating backend logic for reviews and grade visibility.&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
The previous implementation successfully created a functional frontend UI page in Expertiza, addressing design inconsistencies and improving usability. It introduced a visually cohesive interface with an intuitive layout, enhanced responsiveness, and improved information display, allowing users to navigate grading data more efficiently. However, the interface was populated using dummy data, limiting its practical use. This reimplemented UI will utilize real data from the database (that has been populated in this round), ensuring that grading information is dynamically retrieved and displayed accurately through JSON objects. Additionally, this phase will connect the redesigned frontend with some new components in the grades_controller.rb. Specifically, the GET functions in the grades_controller were reimplemented to return JSON objects (instead of instance variables) that could be accessed via an API call. Thus, this new implementation ensures seamless communication between the UI and backend while adhering to best design practices for maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
This project focuses on integrating the frontend of the grades view page with the reimplemented '''grades_controller.rb (E2510)''' backend in Expertiza. This integration requires modifications to both the frontend and backend to establish a seamless connection, ensuring that grading data is dynamically retrieved and displayed accurately. By adhering to best design principles such as modularity, maintainability, and scalability, the implementation will enhance system efficiency and long-term usability. Key improvements include replacing dummy data with real database values, refining data flow between the UI and backend, and optimizing API interactions for better performance. These enhancements will create a more intuitive and reliable grading system, providing a seamless experience for instructors and students while maintaining a well-structured and adaptable codebase for future development.&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
# '''Establish a Robust Connection Between the Frontend and Backend''': Ensure smooth data retrieval and updates between the grades view page and the backend by integrating dynamic data through API calls, replacing the current hardcoded dummy data.&lt;br /&gt;
# '''Define and Implement Clear API Endpoints''': Create well-structured API endpoints in grades_controller.rb for retrieving and displaying grades, ensuring they return appropriate data based on user roles (students, instructors, TAs) and maintain role-based access controls.&lt;br /&gt;
# '''Dynamic Data Integration''': Modify the frontend to consume real-time data fetched from the backend, ensuring an intuitive and responsive UI that reflects the actual grading information. &lt;br /&gt;
# '''Refactor Frontend and Backend Components''': Refactor both the frontend and backend as necessary to align with SOLID and DRY principles, ensuring modularity, maintainability, and scalability. This includes eliminating redundant logic and optimizing code for better readability.&lt;br /&gt;
# '''Implement Proper Permission Checks''': Ensure that only authorized users can access grade information by implementing robust privilege checks and ensuring that the data is securely accessible to students, instructors, and TAs based on their roles.&lt;br /&gt;
# '''Optimize Database Queries and API Responses''': Enhance the efficiency of database queries and API responses to reduce unnecessary load and ensure that data is retrieved and displayed promptly.&lt;br /&gt;
# '''Testing and Validation''': Implement comprehensive unit and integration tests to verify the correctness of data flow, UI interactions, and role-based access controls, ensuring that the system functions correctly and securely.&lt;br /&gt;
&lt;br /&gt;
=Reimplementation Plan=&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populated data with the appropriate HTTP GET and HTTP POST calls. This shift is necessary to ensure that our application reflects real-time data from the backend rather than relying on static or hardcoded values, which can quickly become outdated or inconsistent. It also enables better scalability and maintainability, as changes to the data only need to be made in the backend, without requiring manual updates in the frontend code.&lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
'''Author Feedback''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
'''Heatmap Data''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
'''Team-mate Data''':&lt;br /&gt;
   {&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The current implementation caters to the backend for a Ruby-embedded front-end, where data is rendered server-side and passed directly into the view. We need to update the APIs to return data in a format that can be consumed by the React UI, typically JSON. This shift is essential to decouple the front-end from the server-side rendering logic, allowing for a more interactive and dynamic user experience. By transitioning to a React-based interface, we gain better control over UI state and responsiveness, while also aligning with modern web development practices. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and instead return plain JSON objects using render json: in the response. This change is necessary to align with a frontend architecture that uses React or another JavaScript framework, which expects structured data from the backend in JSON format rather than relying on server-rendered templates. By shifting to JSON responses, we enable cleaner API endpoints, facilitate easier testing and debugging, and support a more maintainable, decoupled frontend-backend integration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    # prepare feedback summaries&lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
  1.1. Students&lt;br /&gt;
  1.2. Teams&lt;br /&gt;
  1.3. TA&lt;br /&gt;
  1.4. Professor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
  2.1 assignments&lt;br /&gt;
  2.2 assignment_questionnaire&lt;br /&gt;
  2.3 questionnaires&lt;br /&gt;
  2.4 participant&lt;br /&gt;
  2.5 signed_up_teams&lt;br /&gt;
  2.6 teams_users&lt;br /&gt;
  2.7 due_dates&lt;br /&gt;
  2.8 late_policies&lt;br /&gt;
  2.9 questions&lt;br /&gt;
  2.10 review_scores&lt;br /&gt;
  2.11 review_grades&lt;br /&gt;
&lt;br /&gt;
== Data Flow Overview ==&lt;br /&gt;
The diagram below illustrates how data flows between the frontend React components and the grades_controller.rb backend during a typical grading data fetch operation.&lt;br /&gt;
&lt;br /&gt;
* The user (e.g., instructor or student) interacts with the React-based grades view (e.g., ReviewTable, RoundSelector, or Statistics).&lt;br /&gt;
* The component triggers an API request to a specific action in grades_controller.rb (e.g., GET /grades/:id/summary).&lt;br /&gt;
*The controller action queries the relevant models (e.g., Assignment, Team, ReviewResponseMap) and compiles a JSON response.&lt;br /&gt;
* The response is sent back to the frontend and parsed.&lt;br /&gt;
*The React components update the UI (tables, heatmaps, statistics) based on the received data.&lt;br /&gt;
&lt;br /&gt;
This architecture ensures a clean separation between frontend and backend logic, improving maintainability and testability.&lt;br /&gt;
[[File:Dataflow.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
The test plan for Phase 2 focuses on verifying the successful integration of the newly reimplemented &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the React-based UI components. We aim to ensure data is:&lt;br /&gt;
&lt;br /&gt;
* Correctly fetched from the backend  &lt;br /&gt;
* Appropriately displayed in the frontend  &lt;br /&gt;
* Functionally sound under both normal and edge-case scenarios&lt;br /&gt;
&lt;br /&gt;
== Tools and Frameworks ==&lt;br /&gt;
We plan to use the following tools and frameworks for testing:&lt;br /&gt;
&lt;br /&gt;
* '''Frontend''': Jest and React Testing Library for unit and integration tests&lt;br /&gt;
* '''Backend''': RSpec for controller and model tests&lt;br /&gt;
* '''Integration Testing''': Capybara and Selenium for simulating real user behavior&lt;br /&gt;
* '''Test Coverage''': SimpleCov&lt;br /&gt;
&lt;br /&gt;
== 1. UI Integration Tests ==&lt;br /&gt;
&lt;br /&gt;
These tests ensure the frontend correctly interacts with backend APIs and renders the data appropriately.&lt;br /&gt;
&lt;br /&gt;
=== ReviewTable Component ===&lt;br /&gt;
&lt;br /&gt;
* Validate that the component makes a successful API call to fetch author feedback  &lt;br /&gt;
* Ensure feedback is rendered in the correct table structure  &lt;br /&gt;
* Test loading state before data is fetched  &lt;br /&gt;
* Handle empty or malformed feedback responses gracefully  &lt;br /&gt;
&lt;br /&gt;
=== RoundSelector Component ===&lt;br /&gt;
&lt;br /&gt;
* Verify API call to fetch heatmap data is triggered on component load  &lt;br /&gt;
* Check that heatmap data is correctly visualized for different review rounds  &lt;br /&gt;
* Test behavior with no data, incomplete data, or delayed response  &lt;br /&gt;
&lt;br /&gt;
=== Statistics Component ===&lt;br /&gt;
&lt;br /&gt;
* Confirm it correctly fetches teammate evaluations and author feedback  &lt;br /&gt;
* Ensure charts or tables reflect the received backend data accurately  &lt;br /&gt;
* Test switching between different teams or assignments and verify correct display  &lt;br /&gt;
&lt;br /&gt;
=== General UI Considerations ===&lt;br /&gt;
&lt;br /&gt;
* Test frontend responsiveness to backend failures (500, 404, timeout)  &lt;br /&gt;
* Ensure authorization errors are handled and appropriate messages displayed  &lt;br /&gt;
&lt;br /&gt;
== 2. Backend API Tests ==&lt;br /&gt;
&lt;br /&gt;
While unit tests exist, integration-level tests will be added or updated to ensure UI compatibility.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
* Validate all &amp;lt;code&amp;gt;GET&amp;lt;/code&amp;gt; endpoints return properly structured JSON objects  &lt;br /&gt;
* Simulate various user roles (student, TA, instructor) and ensure access control  &lt;br /&gt;
* Include test cases for:&lt;br /&gt;
** No grades present  &lt;br /&gt;
** Partial data (e.g. missing feedback or evaluations)  &lt;br /&gt;
** Large number of records  &lt;br /&gt;
&lt;br /&gt;
=== Security &amp;amp; Permissions ===&lt;br /&gt;
&lt;br /&gt;
* Ensure students can only fetch their grades and feedback  &lt;br /&gt;
* Ensure TAs and instructors can access full assignment data  &lt;br /&gt;
* Test token/session-based access restrictions (if applicable)  &lt;br /&gt;
&lt;br /&gt;
== 3. Database Preparation ==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, seed data will simulate real-world usage and we will ensure that:&lt;br /&gt;
* Tests will use isolated fixtures or factories to ensure data consistency&lt;br /&gt;
* All database states will be reset before each test suite run&lt;br /&gt;
&lt;br /&gt;
=== Tables and Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;assignments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_participant&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;participants&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;questionnaires&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;questions&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_questionnaire&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;signed_up_teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;teams_users&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;late_policies&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
=== Scenarios ===&lt;br /&gt;
&lt;br /&gt;
* Single student assigned  &lt;br /&gt;
* Team assignments with/without feedback  &lt;br /&gt;
* Late submissions triggering late policies  &lt;br /&gt;
* Multiple review rounds per assignment&lt;br /&gt;
&lt;br /&gt;
== 4. Regression &amp;amp; CI Testing ==&lt;br /&gt;
&lt;br /&gt;
To ensure updates do not break existing functionality:&lt;br /&gt;
&lt;br /&gt;
* Re-run all existing unit tests  &lt;br /&gt;
* Include snapshot tests for frontend components  &lt;br /&gt;
* Use CI pipelines to automatically trigger tests on pull requests  &lt;br /&gt;
&lt;br /&gt;
== Test Plan Summary ==&lt;br /&gt;
&lt;br /&gt;
This test plan outlines the approach for integrating &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the frontend. By combining backend tests, UI integration checks, and realistic database scenarios, we aim to deliver a seamless user experience. The plan emphasizes early detection of issues and supports long-term maintainability through regression testing. As development progresses, the plan will be updated to cover new insights and edge cases.&lt;br /&gt;
&lt;br /&gt;
=Completed Reimplementation Details=&lt;br /&gt;
&lt;br /&gt;
This section outlines the changes that were actually implemented as part of the reimplementation effort. It provides a detailed breakdown of how the frontend was decoupled from the legacy Ruby-embedded views, and how dynamic data flow was established using API endpoints. Specific components were modified to replace hardcoded or mock data with real-time API calls to the backend, ensuring that the application now reflects live grading data. Additionally, backend controller actions were updated to return clean, structured JSON responses, and the data retrieval logic was centralized to improve maintainability and testability. &lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The previous implementation was designed for a Ruby-embedded front-end, where data was rendered server-side and injected directly into the view. We have since updated the APIs to return data in a format suitable for consumption by the React UI, typically as JSON objects. This change successfully decouples the front-end from the server-side rendering logic, enabling a more interactive and responsive user experience. By transitioning to a React-based interface, we now have improved control over UI state and better alignment with modern web development practices.&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
In this controller, we have updated the GET functions to remove the use of instance variables and instead return plain JSON objects using render json: in the response. This update was essential to align with the frontend architecture, which now relies on a React-based interface that expects structured data from the backend in JSON format rather than server-rendered templates. By returning JSON responses, we’ve established cleaner and more consistent API endpoints, improved the testability and debuggability of our backend logic, and created a more maintainable and decoupled integration between the frontend and backend systems. The following functions were updated as part of this integration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  def view_grading_report&lt;br /&gt;
    assignment_id = params[:id].to_i&lt;br /&gt;
    data = get_data_for_heat_map(assignment_id)&lt;br /&gt;
    &lt;br /&gt;
    render json: data, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
    &lt;br /&gt;
  def view_my_scores&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team_id = TeamsUser.team_id(participant.assignment_id, participant.user_id)&lt;br /&gt;
    # return if redirect_when_disallowed(participant)&lt;br /&gt;
    questions = fetch_questionnaires_and_questions(assignment)&lt;br /&gt;
    pscore = fetch_participant_scores(participant, questions)&lt;br /&gt;
    topic_id = SignedUpTeam.find_topic_id_for_user(participant.assignment.id, participant.user_id)&lt;br /&gt;
    stage = participant.assignment.current_stage(topic_id)&lt;br /&gt;
    # all_penalties = update_penalties(assignment)&lt;br /&gt;
    # Feedback Summary needs to be checked once&lt;br /&gt;
    # summary_ws_url = WEBSERVICE_CONFIG['summary_webservice_url']&lt;br /&gt;
    sum = SummaryHelper::Summary.new.summarize_reviews_by_reviewee(questions, assignment, team_id, 'http://peerlogic.csc.ncsu.edu/sum/v1.0/summary/8/lsa', session)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      topic_id: topic_id,&lt;br /&gt;
      stage: stage,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      summary: sum.summary,&lt;br /&gt;
      avg_scores_by_round: sum.avg_scores_by_round,&lt;br /&gt;
      avg_scores_by_criterion: sum.avg_scores_by_criterion&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def view_team&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    team_id = team.id&lt;br /&gt;
  &lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: assignment.id).map(&amp;amp;:questionnaire)&lt;br /&gt;
    questions = retrieve_questions(questionnaires, assignment.id)&lt;br /&gt;
    pscore = Response.participant_scores(participant, questions)&lt;br /&gt;
    vmlist = process_questionare_for_team(assignment, team_id,questionnaires, team, participant)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team: team,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      vmlist: vmlist&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These updates were important for the backend and ensured seamless communication with the React frontend. By removing instance variables and returning structured JSON responses, we eliminated dependencies on server-side rendering and enabled the frontend to dynamically manage and render data. This not only enhances performance and flexibility but also improves maintainability and scalability as the application evolves. Moreover, it allows the backend and frontend to evolve independently, supporting better separation of concerns and aligning with current best practices in full-stack web development.&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We have successfully  reimplemented the previously pre-populated data with appropriate HTTP GET calls to the backend. This ensures that our application now reflects real-time data directly from the server, improving data accuracy and consistency across the UI. This update also enhances scalability and maintainability, as the frontend no longer depends on static content and can adapt to backend changes without manual intervention.&lt;br /&gt;
&lt;br /&gt;
All dummy data throughout these components has been successfully removed and replaced with real-time API integrations. This transition allows for a fully dynamic, data-driven React frontend that remains synchronized with backend updates and user interactions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Files and components that were updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' &lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:'''&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
A key component of this project involved populating the necessary database tables that the grades_controller.rb relies on to serve real-time data to the frontend. This step was essential for replacing the previously hardcoded or pre-populated dummy data with dynamic, API-driven content. Below is a list of the database tables that were seeded with mock data specifically for development and testing purposes in this project:&lt;br /&gt;
&lt;br /&gt;
* roles&lt;br /&gt;
* institutions&lt;br /&gt;
* users&lt;br /&gt;
* assignments&lt;br /&gt;
* teams &lt;br /&gt;
* teams_users&lt;br /&gt;
* sign_up_topics&lt;br /&gt;
* signed_up_teams&lt;br /&gt;
* participants&lt;br /&gt;
* questionnaires&lt;br /&gt;
* questions &lt;br /&gt;
* assignment_questionaires&lt;br /&gt;
* response_maps&lt;br /&gt;
* responses&lt;br /&gt;
* score_views&lt;br /&gt;
* tag-prompts&lt;br /&gt;
* tag_prompt_deployments&lt;br /&gt;
&lt;br /&gt;
In order to correctly populate each database, we referenced the Expertiza Database Documentation to understand the schema, and then mapped out the relevant tables needed by grades_controller.rb. Then we populated them with mock data to support development and testing of the new API-driven frontend.&lt;br /&gt;
&lt;br /&gt;
==Data Flow Overview==&lt;br /&gt;
&lt;br /&gt;
The diagram below illustrates the data flow between React frontend components and the grades_controller.rb backend during a typical grading data retrieval process.&lt;br /&gt;
&lt;br /&gt;
* The user (such as an instructor or student) interacts with the React-based grades interface—components like ReviewTable, RoundSelector, or Statistics.&lt;br /&gt;
&lt;br /&gt;
* In response to this interaction, the component initiates an API request to a specific endpoint in grades_controller.rb.&lt;br /&gt;
&lt;br /&gt;
* The controller action then queries the relevant backend models (such as Assignment, Team, and ReviewResponseMap) and constructs a structured JSON response.&lt;br /&gt;
&lt;br /&gt;
* This JSON data is returned to the frontend, where it is parsed by the corresponding React component.&lt;br /&gt;
&lt;br /&gt;
* Finally, the React components dynamically update the UI—populating tables, generating heatmaps, or displaying statistics—based on the data received.&lt;br /&gt;
&lt;br /&gt;
This architecture promotes a clear separation of concerns between frontend and backend layers, enabling more scalable development, easier debugging, and improved maintainability and testability across the application.&lt;br /&gt;
&lt;br /&gt;
=Testing=&lt;br /&gt;
&lt;br /&gt;
==Testing Overview==&lt;br /&gt;
&lt;br /&gt;
==Database Preparation==&lt;br /&gt;
&lt;br /&gt;
==UI Tests==&lt;br /&gt;
&lt;br /&gt;
==Backend API Tests==&lt;br /&gt;
&lt;br /&gt;
==Tables and Test Coverage==&lt;br /&gt;
&lt;br /&gt;
==Adhering to Priciples==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164229</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164229"/>
		<updated>2025-04-20T19:14:41Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of this project is to integrate the frontend of the grades view page with the reimplemented '''''grades_controller.rb (E2510)''''' backend in Expertiza, ensuring a seamless connection between both layers. This integration involves refining the interaction between the UI and backend while adhering to best design principles such as modularity, maintainability, and scalability. The grades_controller.rb is responsible for managing grading functionality, allowing instructors to view and modify assignment grades while enabling students to access their evaluations. By following SOLID and DRY principles, this reimplementation enhances code clarity, reduces redundancy, and improves overall system efficiency.&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
The &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; is responsible for managing and delivering grading data to users in the Expertiza system. It enables instructors to view, calculate, and release grades to students, while also allowing students to view feedback and scores for assignments. The controller plays an important role in coordinating backend logic for reviews and grade visibility.&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
The previous implementation successfully created a functional frontend UI page in Expertiza, addressing design inconsistencies and improving usability. It introduced a visually cohesive interface with an intuitive layout, enhanced responsiveness, and improved information display, allowing users to navigate grading data more efficiently. However, the interface was populated using dummy data, limiting its practical use. This reimplemented UI will utilize real data from the database (that has been populated in this round), ensuring that grading information is dynamically retrieved and displayed accurately through JSON objects. Additionally, this phase will connect the redesigned frontend with some new components in the grades_controller.rb. Specifically, the GET functions in the grades_controller were reimplemented to return JSON objects (instead of instance variables) that could be accessed via an API call. Thus, this new implementation ensures seamless communication between the UI and backend while adhering to best design practices for maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
This project focuses on integrating the frontend of the grades view page with the reimplemented '''grades_controller.rb (E2510)''' backend in Expertiza. This integration requires modifications to both the frontend and backend to establish a seamless connection, ensuring that grading data is dynamically retrieved and displayed accurately. By adhering to best design principles such as modularity, maintainability, and scalability, the implementation will enhance system efficiency and long-term usability. Key improvements include replacing dummy data with real database values, refining data flow between the UI and backend, and optimizing API interactions for better performance. These enhancements will create a more intuitive and reliable grading system, providing a seamless experience for instructors and students while maintaining a well-structured and adaptable codebase for future development.&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
# '''Establish a Robust Connection Between the Frontend and Backend''': Ensure smooth data retrieval and updates between the grades view page and the backend by integrating dynamic data through API calls, replacing the current hardcoded dummy data.&lt;br /&gt;
# '''Define and Implement Clear API Endpoints''': Create well-structured API endpoints in grades_controller.rb for retrieving and displaying grades, ensuring they return appropriate data based on user roles (students, instructors, TAs) and maintain role-based access controls.&lt;br /&gt;
# '''Dynamic Data Integration''': Modify the frontend to consume real-time data fetched from the backend, ensuring an intuitive and responsive UI that reflects the actual grading information. &lt;br /&gt;
# '''Refactor Frontend and Backend Components''': Refactor both the frontend and backend as necessary to align with SOLID and DRY principles, ensuring modularity, maintainability, and scalability. This includes eliminating redundant logic and optimizing code for better readability.&lt;br /&gt;
# '''Implement Proper Permission Checks''': Ensure that only authorized users can access grade information by implementing robust privilege checks and ensuring that the data is securely accessible to students, instructors, and TAs based on their roles.&lt;br /&gt;
# '''Optimize Database Queries and API Responses''': Enhance the efficiency of database queries and API responses to reduce unnecessary load and ensure that data is retrieved and displayed promptly.&lt;br /&gt;
# '''Testing and Validation''': Implement comprehensive unit and integration tests to verify the correctness of data flow, UI interactions, and role-based access controls, ensuring that the system functions correctly and securely.&lt;br /&gt;
&lt;br /&gt;
=Reimplementation Plan=&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populated data with the appropriate HTTP GET and HTTP POST calls. This shift is necessary to ensure that our application reflects real-time data from the backend rather than relying on static or hardcoded values, which can quickly become outdated or inconsistent. It also enables better scalability and maintainability, as changes to the data only need to be made in the backend, without requiring manual updates in the frontend code.&lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
'''Author Feedback''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
'''Heatmap Data''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
'''Team-mate Data''':&lt;br /&gt;
   {&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The current implementation caters to the backend for a Ruby-embedded front-end, where data is rendered server-side and passed directly into the view. We need to update the APIs to return data in a format that can be consumed by the React UI, typically JSON. This shift is essential to decouple the front-end from the server-side rendering logic, allowing for a more interactive and dynamic user experience. By transitioning to a React-based interface, we gain better control over UI state and responsiveness, while also aligning with modern web development practices. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and instead return plain JSON objects using render json: in the response. This change is necessary to align with a frontend architecture that uses React or another JavaScript framework, which expects structured data from the backend in JSON format rather than relying on server-rendered templates. By shifting to JSON responses, we enable cleaner API endpoints, facilitate easier testing and debugging, and support a more maintainable, decoupled frontend-backend integration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    # prepare feedback summaries&lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
  1.1. Students&lt;br /&gt;
  1.2. Teams&lt;br /&gt;
  1.3. TA&lt;br /&gt;
  1.4. Professor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
  2.1 assignments&lt;br /&gt;
  2.2 assignment_questionnaire&lt;br /&gt;
  2.3 questionnaires&lt;br /&gt;
  2.4 participant&lt;br /&gt;
  2.5 signed_up_teams&lt;br /&gt;
  2.6 teams_users&lt;br /&gt;
  2.7 due_dates&lt;br /&gt;
  2.8 late_policies&lt;br /&gt;
  2.9 questions&lt;br /&gt;
  2.10 review_scores&lt;br /&gt;
  2.11 review_grades&lt;br /&gt;
&lt;br /&gt;
== Data Flow Overview ==&lt;br /&gt;
The diagram below illustrates how data flows between the frontend React components and the grades_controller.rb backend during a typical grading data fetch operation.&lt;br /&gt;
&lt;br /&gt;
* The user (e.g., instructor or student) interacts with the React-based grades view (e.g., ReviewTable, RoundSelector, or Statistics).&lt;br /&gt;
* The component triggers an API request to a specific action in grades_controller.rb (e.g., GET /grades/:id/summary).&lt;br /&gt;
*The controller action queries the relevant models (e.g., Assignment, Team, ReviewResponseMap) and compiles a JSON response.&lt;br /&gt;
* The response is sent back to the frontend and parsed.&lt;br /&gt;
*The React components update the UI (tables, heatmaps, statistics) based on the received data.&lt;br /&gt;
&lt;br /&gt;
This architecture ensures a clean separation between frontend and backend logic, improving maintainability and testability.&lt;br /&gt;
[[File:Dataflow.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
The test plan for Phase 2 focuses on verifying the successful integration of the newly reimplemented &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the React-based UI components. We aim to ensure data is:&lt;br /&gt;
&lt;br /&gt;
* Correctly fetched from the backend  &lt;br /&gt;
* Appropriately displayed in the frontend  &lt;br /&gt;
* Functionally sound under both normal and edge-case scenarios&lt;br /&gt;
&lt;br /&gt;
== Tools and Frameworks ==&lt;br /&gt;
We plan to use the following tools and frameworks for testing:&lt;br /&gt;
&lt;br /&gt;
* '''Frontend''': Jest and React Testing Library for unit and integration tests&lt;br /&gt;
* '''Backend''': RSpec for controller and model tests&lt;br /&gt;
* '''Integration Testing''': Capybara and Selenium for simulating real user behavior&lt;br /&gt;
* '''Test Coverage''': SimpleCov&lt;br /&gt;
&lt;br /&gt;
== 1. UI Integration Tests ==&lt;br /&gt;
&lt;br /&gt;
These tests ensure the frontend correctly interacts with backend APIs and renders the data appropriately.&lt;br /&gt;
&lt;br /&gt;
=== ReviewTable Component ===&lt;br /&gt;
&lt;br /&gt;
* Validate that the component makes a successful API call to fetch author feedback  &lt;br /&gt;
* Ensure feedback is rendered in the correct table structure  &lt;br /&gt;
* Test loading state before data is fetched  &lt;br /&gt;
* Handle empty or malformed feedback responses gracefully  &lt;br /&gt;
&lt;br /&gt;
=== RoundSelector Component ===&lt;br /&gt;
&lt;br /&gt;
* Verify API call to fetch heatmap data is triggered on component load  &lt;br /&gt;
* Check that heatmap data is correctly visualized for different review rounds  &lt;br /&gt;
* Test behavior with no data, incomplete data, or delayed response  &lt;br /&gt;
&lt;br /&gt;
=== Statistics Component ===&lt;br /&gt;
&lt;br /&gt;
* Confirm it correctly fetches teammate evaluations and author feedback  &lt;br /&gt;
* Ensure charts or tables reflect the received backend data accurately  &lt;br /&gt;
* Test switching between different teams or assignments and verify correct display  &lt;br /&gt;
&lt;br /&gt;
=== General UI Considerations ===&lt;br /&gt;
&lt;br /&gt;
* Test frontend responsiveness to backend failures (500, 404, timeout)  &lt;br /&gt;
* Ensure authorization errors are handled and appropriate messages displayed  &lt;br /&gt;
&lt;br /&gt;
== 2. Backend API Tests ==&lt;br /&gt;
&lt;br /&gt;
While unit tests exist, integration-level tests will be added or updated to ensure UI compatibility.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
* Validate all &amp;lt;code&amp;gt;GET&amp;lt;/code&amp;gt; endpoints return properly structured JSON objects  &lt;br /&gt;
* Simulate various user roles (student, TA, instructor) and ensure access control  &lt;br /&gt;
* Include test cases for:&lt;br /&gt;
** No grades present  &lt;br /&gt;
** Partial data (e.g. missing feedback or evaluations)  &lt;br /&gt;
** Large number of records  &lt;br /&gt;
&lt;br /&gt;
=== Security &amp;amp; Permissions ===&lt;br /&gt;
&lt;br /&gt;
* Ensure students can only fetch their grades and feedback  &lt;br /&gt;
* Ensure TAs and instructors can access full assignment data  &lt;br /&gt;
* Test token/session-based access restrictions (if applicable)  &lt;br /&gt;
&lt;br /&gt;
== 3. Database Preparation ==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, seed data will simulate real-world usage and we will ensure that:&lt;br /&gt;
* Tests will use isolated fixtures or factories to ensure data consistency&lt;br /&gt;
* All database states will be reset before each test suite run&lt;br /&gt;
&lt;br /&gt;
=== Tables and Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;assignments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_participant&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;participants&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;questionnaires&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;questions&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_questionnaire&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;signed_up_teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;teams_users&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;late_policies&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
=== Scenarios ===&lt;br /&gt;
&lt;br /&gt;
* Single student assigned  &lt;br /&gt;
* Team assignments with/without feedback  &lt;br /&gt;
* Late submissions triggering late policies  &lt;br /&gt;
* Multiple review rounds per assignment&lt;br /&gt;
&lt;br /&gt;
== 4. Regression &amp;amp; CI Testing ==&lt;br /&gt;
&lt;br /&gt;
To ensure updates do not break existing functionality:&lt;br /&gt;
&lt;br /&gt;
* Re-run all existing unit tests  &lt;br /&gt;
* Include snapshot tests for frontend components  &lt;br /&gt;
* Use CI pipelines to automatically trigger tests on pull requests  &lt;br /&gt;
&lt;br /&gt;
== Test Plan Summary ==&lt;br /&gt;
&lt;br /&gt;
This test plan outlines the approach for integrating &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the frontend. By combining backend tests, UI integration checks, and realistic database scenarios, we aim to deliver a seamless user experience. The plan emphasizes early detection of issues and supports long-term maintainability through regression testing. As development progresses, the plan will be updated to cover new insights and edge cases.&lt;br /&gt;
&lt;br /&gt;
=Completed Reimplementation Details=&lt;br /&gt;
&lt;br /&gt;
This section outlines the changes that were actually implemented as part of the reimplementation effort. It provides a detailed breakdown of how the frontend was decoupled from the legacy Ruby-embedded views, and how dynamic data flow was established using API endpoints. Specific components were modified to replace hardcoded or mock data with real-time API calls to the backend, ensuring that the application now reflects live grading data. Additionally, backend controller actions were updated to return clean, structured JSON responses, and the data retrieval logic was centralized to improve maintainability and testability. &lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The previous implementation was designed for a Ruby-embedded front-end, where data was rendered server-side and injected directly into the view. We have since updated the APIs to return data in a format suitable for consumption by the React UI, typically as JSON objects. This change successfully decouples the front-end from the server-side rendering logic, enabling a more interactive and responsive user experience. By transitioning to a React-based interface, we now have improved control over UI state and better alignment with modern web development practices.&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
In this controller, we have updated the GET functions to remove the use of instance variables and instead return plain JSON objects using render json: in the response. This update was essential to align with the frontend architecture, which now relies on a React-based interface that expects structured data from the backend in JSON format rather than server-rendered templates. By returning JSON responses, we’ve established cleaner and more consistent API endpoints, improved the testability and debuggability of our backend logic, and created a more maintainable and decoupled integration between the frontend and backend systems. The following functions were updated as part of this integration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  def view_grading_report&lt;br /&gt;
    assignment_id = params[:id].to_i&lt;br /&gt;
    data = get_data_for_heat_map(assignment_id)&lt;br /&gt;
    &lt;br /&gt;
    render json: data, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
    &lt;br /&gt;
  def view_my_scores&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team_id = TeamsUser.team_id(participant.assignment_id, participant.user_id)&lt;br /&gt;
    # return if redirect_when_disallowed(participant)&lt;br /&gt;
    questions = fetch_questionnaires_and_questions(assignment)&lt;br /&gt;
    pscore = fetch_participant_scores(participant, questions)&lt;br /&gt;
    topic_id = SignedUpTeam.find_topic_id_for_user(participant.assignment.id, participant.user_id)&lt;br /&gt;
    stage = participant.assignment.current_stage(topic_id)&lt;br /&gt;
    # all_penalties = update_penalties(assignment)&lt;br /&gt;
    # Feedback Summary needs to be checked once&lt;br /&gt;
    # summary_ws_url = WEBSERVICE_CONFIG['summary_webservice_url']&lt;br /&gt;
    sum = SummaryHelper::Summary.new.summarize_reviews_by_reviewee(questions, assignment, team_id, 'http://peerlogic.csc.ncsu.edu/sum/v1.0/summary/8/lsa', session)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      topic_id: topic_id,&lt;br /&gt;
      stage: stage,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      summary: sum.summary,&lt;br /&gt;
      avg_scores_by_round: sum.avg_scores_by_round,&lt;br /&gt;
      avg_scores_by_criterion: sum.avg_scores_by_criterion&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def view_team&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    team_id = team.id&lt;br /&gt;
  &lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: assignment.id).map(&amp;amp;:questionnaire)&lt;br /&gt;
    questions = retrieve_questions(questionnaires, assignment.id)&lt;br /&gt;
    pscore = Response.participant_scores(participant, questions)&lt;br /&gt;
    vmlist = process_questionare_for_team(assignment, team_id,questionnaires, team, participant)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team: team,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      vmlist: vmlist&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These updates were important for the backend and ensured seamless communication with the React frontend. By removing instance variables and returning structured JSON responses, we eliminated dependencies on server-side rendering and enabled the frontend to dynamically manage and render data. This not only enhances performance and flexibility but also improves maintainability and scalability as the application evolves. Moreover, it allows the backend and frontend to evolve independently, supporting better separation of concerns and aligning with current best practices in full-stack web development.&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We have successfully  reimplemented the previously pre-populated data with appropriate HTTP GET calls to the backend. This ensures that our application now reflects real-time data directly from the server, improving data accuracy and consistency across the UI. This update also enhances scalability and maintainability, as the frontend no longer depends on static content and can adapt to backend changes without manual intervention.&lt;br /&gt;
&lt;br /&gt;
All dummy data throughout these components has been successfully removed and replaced with real-time API integrations. This transition allows for a fully dynamic, data-driven React frontend that remains synchronized with backend updates and user interactions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Files and components that were updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' &lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:'''&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
A key component of this project involved populating the necessary database tables that the grades_controller.rb relies on to serve real-time data to the frontend. This step was essential for replacing the previously hardcoded or pre-populated dummy data with dynamic, API-driven content. Below is a list of the database tables that were seeded with mock data specifically for development and testing purposes in this project:&lt;br /&gt;
&lt;br /&gt;
* roles&lt;br /&gt;
* institutions&lt;br /&gt;
* users&lt;br /&gt;
* assignments&lt;br /&gt;
* teams &lt;br /&gt;
* teams_users&lt;br /&gt;
* sign_up_topics&lt;br /&gt;
* signed_up_teams&lt;br /&gt;
* participants&lt;br /&gt;
* questionnaires&lt;br /&gt;
* questions &lt;br /&gt;
* assignment_questionaires&lt;br /&gt;
* response_maps&lt;br /&gt;
* responses&lt;br /&gt;
* score_views&lt;br /&gt;
* tag-prompts&lt;br /&gt;
* tag_prompt_deployments&lt;br /&gt;
&lt;br /&gt;
In order to correctly populate each database, we referenced the Expertiza Database Documentation to understand the schema, and then mapped out the relevant tables needed by grades_controller.rb. Then we populated them with mock data to support development and testing of the new API-driven frontend.&lt;br /&gt;
&lt;br /&gt;
==Data Flow Overview==&lt;br /&gt;
&lt;br /&gt;
The diagram below illustrates the data flow between React frontend components and the grades_controller.rb backend during a typical grading data retrieval process.&lt;br /&gt;
&lt;br /&gt;
* The user (such as an instructor or student) interacts with the React-based grades interface—components like ReviewTable, RoundSelector, or Statistics.&lt;br /&gt;
&lt;br /&gt;
* In response to this interaction, the component initiates an API request to a specific endpoint in grades_controller.rb.&lt;br /&gt;
&lt;br /&gt;
* The controller action then queries the relevant backend models (such as Assignment, Team, and ReviewResponseMap) and constructs a structured JSON response.&lt;br /&gt;
&lt;br /&gt;
* This JSON data is returned to the frontend, where it is parsed by the corresponding React component.&lt;br /&gt;
&lt;br /&gt;
* Finally, the React components dynamically update the UI—populating tables, generating heatmaps, or displaying statistics—based on the data received.&lt;br /&gt;
&lt;br /&gt;
This architecture promotes a clear separation of concerns between frontend and backend layers, enabling more scalable development, easier debugging, and improved maintainability and testability across the application.&lt;br /&gt;
&lt;br /&gt;
=Testing=&lt;br /&gt;
&lt;br /&gt;
==Testing Overview==&lt;br /&gt;
&lt;br /&gt;
==Database Preparation==&lt;br /&gt;
&lt;br /&gt;
==UI Tests==&lt;br /&gt;
&lt;br /&gt;
==Backend API Tests==&lt;br /&gt;
&lt;br /&gt;
==Tables and Test Coverage==&lt;br /&gt;
&lt;br /&gt;
==Adhering to Priciples==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164228</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164228"/>
		<updated>2025-04-20T19:12:23Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* Database */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of this project is to integrate the frontend of the grades view page with the reimplemented '''''grades_controller.rb (E2510)''''' backend in Expertiza, ensuring a seamless connection between both layers. This integration involves refining the interaction between the UI and backend while adhering to best design principles such as modularity, maintainability, and scalability. The grades_controller.rb is responsible for managing grading functionality, allowing instructors to view and modify assignment grades while enabling students to access their evaluations. By following SOLID and DRY principles, this reimplementation enhances code clarity, reduces redundancy, and improves overall system efficiency.&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
The &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; is responsible for managing and delivering grading data to users in the Expertiza system. It enables instructors to view, calculate, and release grades to students, while also allowing students to view feedback and scores for assignments. The controller plays an important role in coordinating backend logic for reviews and grade visibility.&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
The previous implementation successfully created a functional frontend UI page in Expertiza, addressing design inconsistencies and improving usability. It introduced a visually cohesive interface with an intuitive layout, enhanced responsiveness, and improved information display, allowing users to navigate grading data more efficiently. However, the interface was populated using dummy data, limiting its practical use. This reimplemented UI will utilize real data from the database (that has been populated in this round), ensuring that grading information is dynamically retrieved and displayed accurately through JSON objects. Additionally, this phase will connect the redesigned frontend with some new components in the grades_controller.rb. Specifically, the GET functions in the grades_controller were reimplemented to return JSON objects (instead of instance variables) that could be accessed via an API call. Thus, this new implementation ensures seamless communication between the UI and backend while adhering to best design practices for maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
This project focuses on integrating the frontend of the grades view page with the reimplemented '''grades_controller.rb (E2510)''' backend in Expertiza. This integration requires modifications to both the frontend and backend to establish a seamless connection, ensuring that grading data is dynamically retrieved and displayed accurately. By adhering to best design principles such as modularity, maintainability, and scalability, the implementation will enhance system efficiency and long-term usability. Key improvements include replacing dummy data with real database values, refining data flow between the UI and backend, and optimizing API interactions for better performance. These enhancements will create a more intuitive and reliable grading system, providing a seamless experience for instructors and students while maintaining a well-structured and adaptable codebase for future development.&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
# '''Establish a Robust Connection Between the Frontend and Backend''': Ensure smooth data retrieval and updates between the grades view page and the backend by integrating dynamic data through API calls, replacing the current hardcoded dummy data.&lt;br /&gt;
# '''Define and Implement Clear API Endpoints''': Create well-structured API endpoints in grades_controller.rb for retrieving and displaying grades, ensuring they return appropriate data based on user roles (students, instructors, TAs) and maintain role-based access controls.&lt;br /&gt;
# '''Dynamic Data Integration''': Modify the frontend to consume real-time data fetched from the backend, ensuring an intuitive and responsive UI that reflects the actual grading information. &lt;br /&gt;
# '''Refactor Frontend and Backend Components''': Refactor both the frontend and backend as necessary to align with SOLID and DRY principles, ensuring modularity, maintainability, and scalability. This includes eliminating redundant logic and optimizing code for better readability.&lt;br /&gt;
# '''Implement Proper Permission Checks''': Ensure that only authorized users can access grade information by implementing robust privilege checks and ensuring that the data is securely accessible to students, instructors, and TAs based on their roles.&lt;br /&gt;
# '''Optimize Database Queries and API Responses''': Enhance the efficiency of database queries and API responses to reduce unnecessary load and ensure that data is retrieved and displayed promptly.&lt;br /&gt;
# '''Testing and Validation''': Implement comprehensive unit and integration tests to verify the correctness of data flow, UI interactions, and role-based access controls, ensuring that the system functions correctly and securely.&lt;br /&gt;
&lt;br /&gt;
=Reimplementation Plan=&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populated data with the appropriate HTTP GET and HTTP POST calls. This shift is necessary to ensure that our application reflects real-time data from the backend rather than relying on static or hardcoded values, which can quickly become outdated or inconsistent. It also enables better scalability and maintainability, as changes to the data only need to be made in the backend, without requiring manual updates in the frontend code.&lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
'''Author Feedback''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
'''Heatmap Data''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
'''Team-mate Data''':&lt;br /&gt;
   {&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The current implementation caters to the backend for a Ruby-embedded front-end, where data is rendered server-side and passed directly into the view. We need to update the APIs to return data in a format that can be consumed by the React UI, typically JSON. This shift is essential to decouple the front-end from the server-side rendering logic, allowing for a more interactive and dynamic user experience. By transitioning to a React-based interface, we gain better control over UI state and responsiveness, while also aligning with modern web development practices. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and instead return plain JSON objects using render json: in the response. This change is necessary to align with a frontend architecture that uses React or another JavaScript framework, which expects structured data from the backend in JSON format rather than relying on server-rendered templates. By shifting to JSON responses, we enable cleaner API endpoints, facilitate easier testing and debugging, and support a more maintainable, decoupled frontend-backend integration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    # prepare feedback summaries&lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
  1.1. Students&lt;br /&gt;
  1.2. Teams&lt;br /&gt;
  1.3. TA&lt;br /&gt;
  1.4. Professor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
  2.1 assignments&lt;br /&gt;
  2.2 assignment_questionnaire&lt;br /&gt;
  2.3 questionnaires&lt;br /&gt;
  2.4 participant&lt;br /&gt;
  2.5 signed_up_teams&lt;br /&gt;
  2.6 teams_users&lt;br /&gt;
  2.7 due_dates&lt;br /&gt;
  2.8 late_policies&lt;br /&gt;
  2.9 questions&lt;br /&gt;
  2.10 review_scores&lt;br /&gt;
  2.11 review_grades&lt;br /&gt;
&lt;br /&gt;
== Data Flow Overview ==&lt;br /&gt;
The diagram below illustrates how data flows between the frontend React components and the grades_controller.rb backend during a typical grading data fetch operation.&lt;br /&gt;
&lt;br /&gt;
* The user (e.g., instructor or student) interacts with the React-based grades view (e.g., ReviewTable, RoundSelector, or Statistics).&lt;br /&gt;
* The component triggers an API request to a specific action in grades_controller.rb (e.g., GET /grades/:id/summary).&lt;br /&gt;
*The controller action queries the relevant models (e.g., Assignment, Team, ReviewResponseMap) and compiles a JSON response.&lt;br /&gt;
* The response is sent back to the frontend and parsed.&lt;br /&gt;
*The React components update the UI (tables, heatmaps, statistics) based on the received data.&lt;br /&gt;
&lt;br /&gt;
This architecture ensures a clean separation between frontend and backend logic, improving maintainability and testability.&lt;br /&gt;
[[File:Dataflow.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
The test plan for Phase 2 focuses on verifying the successful integration of the newly reimplemented &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the React-based UI components. We aim to ensure data is:&lt;br /&gt;
&lt;br /&gt;
* Correctly fetched from the backend  &lt;br /&gt;
* Appropriately displayed in the frontend  &lt;br /&gt;
* Functionally sound under both normal and edge-case scenarios&lt;br /&gt;
&lt;br /&gt;
== Tools and Frameworks ==&lt;br /&gt;
We plan to use the following tools and frameworks for testing:&lt;br /&gt;
&lt;br /&gt;
* '''Frontend''': Jest and React Testing Library for unit and integration tests&lt;br /&gt;
* '''Backend''': RSpec for controller and model tests&lt;br /&gt;
* '''Integration Testing''': Capybara and Selenium for simulating real user behavior&lt;br /&gt;
* '''Test Coverage''': SimpleCov&lt;br /&gt;
&lt;br /&gt;
== 1. UI Integration Tests ==&lt;br /&gt;
&lt;br /&gt;
These tests ensure the frontend correctly interacts with backend APIs and renders the data appropriately.&lt;br /&gt;
&lt;br /&gt;
=== ReviewTable Component ===&lt;br /&gt;
&lt;br /&gt;
* Validate that the component makes a successful API call to fetch author feedback  &lt;br /&gt;
* Ensure feedback is rendered in the correct table structure  &lt;br /&gt;
* Test loading state before data is fetched  &lt;br /&gt;
* Handle empty or malformed feedback responses gracefully  &lt;br /&gt;
&lt;br /&gt;
=== RoundSelector Component ===&lt;br /&gt;
&lt;br /&gt;
* Verify API call to fetch heatmap data is triggered on component load  &lt;br /&gt;
* Check that heatmap data is correctly visualized for different review rounds  &lt;br /&gt;
* Test behavior with no data, incomplete data, or delayed response  &lt;br /&gt;
&lt;br /&gt;
=== Statistics Component ===&lt;br /&gt;
&lt;br /&gt;
* Confirm it correctly fetches teammate evaluations and author feedback  &lt;br /&gt;
* Ensure charts or tables reflect the received backend data accurately  &lt;br /&gt;
* Test switching between different teams or assignments and verify correct display  &lt;br /&gt;
&lt;br /&gt;
=== General UI Considerations ===&lt;br /&gt;
&lt;br /&gt;
* Test frontend responsiveness to backend failures (500, 404, timeout)  &lt;br /&gt;
* Ensure authorization errors are handled and appropriate messages displayed  &lt;br /&gt;
&lt;br /&gt;
== 2. Backend API Tests ==&lt;br /&gt;
&lt;br /&gt;
While unit tests exist, integration-level tests will be added or updated to ensure UI compatibility.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
* Validate all &amp;lt;code&amp;gt;GET&amp;lt;/code&amp;gt; endpoints return properly structured JSON objects  &lt;br /&gt;
* Simulate various user roles (student, TA, instructor) and ensure access control  &lt;br /&gt;
* Include test cases for:&lt;br /&gt;
** No grades present  &lt;br /&gt;
** Partial data (e.g. missing feedback or evaluations)  &lt;br /&gt;
** Large number of records  &lt;br /&gt;
&lt;br /&gt;
=== Security &amp;amp; Permissions ===&lt;br /&gt;
&lt;br /&gt;
* Ensure students can only fetch their grades and feedback  &lt;br /&gt;
* Ensure TAs and instructors can access full assignment data  &lt;br /&gt;
* Test token/session-based access restrictions (if applicable)  &lt;br /&gt;
&lt;br /&gt;
== 3. Database Preparation ==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, seed data will simulate real-world usage and we will ensure that:&lt;br /&gt;
* Tests will use isolated fixtures or factories to ensure data consistency&lt;br /&gt;
* All database states will be reset before each test suite run&lt;br /&gt;
&lt;br /&gt;
=== Tables and Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;assignments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_participant&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;participants&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;questionnaires&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;questions&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_questionnaire&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;signed_up_teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;teams_users&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;late_policies&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
=== Scenarios ===&lt;br /&gt;
&lt;br /&gt;
* Single student assigned  &lt;br /&gt;
* Team assignments with/without feedback  &lt;br /&gt;
* Late submissions triggering late policies  &lt;br /&gt;
* Multiple review rounds per assignment&lt;br /&gt;
&lt;br /&gt;
== 4. Regression &amp;amp; CI Testing ==&lt;br /&gt;
&lt;br /&gt;
To ensure updates do not break existing functionality:&lt;br /&gt;
&lt;br /&gt;
* Re-run all existing unit tests  &lt;br /&gt;
* Include snapshot tests for frontend components  &lt;br /&gt;
* Use CI pipelines to automatically trigger tests on pull requests  &lt;br /&gt;
&lt;br /&gt;
== Test Plan Summary ==&lt;br /&gt;
&lt;br /&gt;
This test plan outlines the approach for integrating &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the frontend. By combining backend tests, UI integration checks, and realistic database scenarios, we aim to deliver a seamless user experience. The plan emphasizes early detection of issues and supports long-term maintainability through regression testing. As development progresses, the plan will be updated to cover new insights and edge cases.&lt;br /&gt;
&lt;br /&gt;
=Completed Reimplementation Details=&lt;br /&gt;
&lt;br /&gt;
This section outlines the changes that were actually implemented as part of the reimplementation effort. It provides a detailed breakdown of how the frontend was decoupled from the legacy Ruby-embedded views, and how dynamic data flow was established using API endpoints. Specific components were modified to replace hardcoded or mock data with real-time API calls to the backend, ensuring that the application now reflects live grading data. Additionally, backend controller actions were updated to return clean, structured JSON responses, and the data retrieval logic was centralized to improve maintainability and testability. &lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The previous implementation was designed for a Ruby-embedded front-end, where data was rendered server-side and injected directly into the view. We have since updated the APIs to return data in a format suitable for consumption by the React UI, typically as JSON objects. This change successfully decouples the front-end from the server-side rendering logic, enabling a more interactive and responsive user experience. By transitioning to a React-based interface, we now have improved control over UI state and better alignment with modern web development practices.&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
In this controller, we have updated the GET functions to remove the use of instance variables and instead return plain JSON objects using render json: in the response. This update was essential to align with the frontend architecture, which now relies on a React-based interface that expects structured data from the backend in JSON format rather than server-rendered templates. By returning JSON responses, we’ve established cleaner and more consistent API endpoints, improved the testability and debuggability of our backend logic, and created a more maintainable and decoupled integration between the frontend and backend systems. The following functions were updated as part of this integration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  def view_grading_report&lt;br /&gt;
    assignment_id = params[:id].to_i&lt;br /&gt;
    data = get_data_for_heat_map(assignment_id)&lt;br /&gt;
    &lt;br /&gt;
    render json: data, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
    &lt;br /&gt;
  def view_my_scores&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team_id = TeamsUser.team_id(participant.assignment_id, participant.user_id)&lt;br /&gt;
    # return if redirect_when_disallowed(participant)&lt;br /&gt;
    questions = fetch_questionnaires_and_questions(assignment)&lt;br /&gt;
    pscore = fetch_participant_scores(participant, questions)&lt;br /&gt;
    topic_id = SignedUpTeam.find_topic_id_for_user(participant.assignment.id, participant.user_id)&lt;br /&gt;
    stage = participant.assignment.current_stage(topic_id)&lt;br /&gt;
    # all_penalties = update_penalties(assignment)&lt;br /&gt;
    # Feedback Summary needs to be checked once&lt;br /&gt;
    # summary_ws_url = WEBSERVICE_CONFIG['summary_webservice_url']&lt;br /&gt;
    sum = SummaryHelper::Summary.new.summarize_reviews_by_reviewee(questions, assignment, team_id, 'http://peerlogic.csc.ncsu.edu/sum/v1.0/summary/8/lsa', session)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      topic_id: topic_id,&lt;br /&gt;
      stage: stage,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      summary: sum.summary,&lt;br /&gt;
      avg_scores_by_round: sum.avg_scores_by_round,&lt;br /&gt;
      avg_scores_by_criterion: sum.avg_scores_by_criterion&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def view_team&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    team_id = team.id&lt;br /&gt;
  &lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: assignment.id).map(&amp;amp;:questionnaire)&lt;br /&gt;
    questions = retrieve_questions(questionnaires, assignment.id)&lt;br /&gt;
    pscore = Response.participant_scores(participant, questions)&lt;br /&gt;
    vmlist = process_questionare_for_team(assignment, team_id,questionnaires, team, participant)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team: team,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      vmlist: vmlist&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These updates were important for the backend and ensured seamless communication with the React frontend. By removing instance variables and returning structured JSON responses, we eliminated dependencies on server-side rendering and enabled the frontend to dynamically manage and render data. This not only enhances performance and flexibility but also improves maintainability and scalability as the application evolves. Moreover, it allows the backend and frontend to evolve independently, supporting better separation of concerns and aligning with current best practices in full-stack web development.&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We have successfully  reimplemented the previously pre-populated data with appropriate HTTP GET calls to the backend. This ensures that our application now reflects real-time data directly from the server, improving data accuracy and consistency across the UI. This update also enhances scalability and maintainability, as the frontend no longer depends on static content and can adapt to backend changes without manual intervention.&lt;br /&gt;
&lt;br /&gt;
All dummy data throughout these components has been successfully removed and replaced with real-time API integrations. This transition allows for a fully dynamic, data-driven React frontend that remains synchronized with backend updates and user interactions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Files and components that were updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' &lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:'''&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
A key component of this project involved populating the necessary database tables that the grades_controller.rb relies on to serve real-time data to the frontend. This step was essential for replacing the previously hardcoded or pre-populated dummy data with dynamic, API-driven content. Below is a list of the database tables that were seeded with mock data specifically for development and testing purposes in this project:&lt;br /&gt;
&lt;br /&gt;
* roles&lt;br /&gt;
* institutions&lt;br /&gt;
* users&lt;br /&gt;
* assignments&lt;br /&gt;
* teams &lt;br /&gt;
* teams_users&lt;br /&gt;
* sign_up_topics&lt;br /&gt;
* signed_up_teams&lt;br /&gt;
* participants&lt;br /&gt;
* questionnaires&lt;br /&gt;
* questions &lt;br /&gt;
* assignment_questionaires&lt;br /&gt;
* response_maps&lt;br /&gt;
* responses&lt;br /&gt;
* score_views&lt;br /&gt;
* tag-prompts&lt;br /&gt;
* tag_prompt_deployments&lt;br /&gt;
&lt;br /&gt;
In order to correctly populate each database, we referenced the Expertiza Database Documentation to understand the schema, and then mapped out the relevant tables needed by grades_controller.rb. Then we populated them with mock data to support development and testing of the new API-driven frontend.&lt;br /&gt;
&lt;br /&gt;
==Data Flow Overview==&lt;br /&gt;
&lt;br /&gt;
The diagram below illustrates the data flow between React frontend components and the grades_controller.rb backend during a typical grading data retrieval process.&lt;br /&gt;
&lt;br /&gt;
* The user (such as an instructor or student) interacts with the React-based grades interface—components like ReviewTable, RoundSelector, or Statistics.&lt;br /&gt;
&lt;br /&gt;
* In response to this interaction, the component initiates an API request to a specific endpoint in grades_controller.rb.&lt;br /&gt;
&lt;br /&gt;
* The controller action then queries the relevant backend models (such as Assignment, Team, and ReviewResponseMap) and constructs a structured JSON response.&lt;br /&gt;
&lt;br /&gt;
* This JSON data is returned to the frontend, where it is parsed by the corresponding React component.&lt;br /&gt;
&lt;br /&gt;
* Finally, the React components dynamically update the UI—populating tables, generating heatmaps, or displaying statistics—based on the data received.&lt;br /&gt;
&lt;br /&gt;
This architecture promotes a clear separation of concerns between frontend and backend layers, enabling more scalable development, easier debugging, and improved maintainability and testability across the application.&lt;br /&gt;
&lt;br /&gt;
=Testing=&lt;br /&gt;
&lt;br /&gt;
==Testing Overview==&lt;br /&gt;
&lt;br /&gt;
==Database Preparation==&lt;br /&gt;
&lt;br /&gt;
==UI Tests==&lt;br /&gt;
&lt;br /&gt;
==Backend API Tests==&lt;br /&gt;
&lt;br /&gt;
==Tables and Test Coverage==&lt;br /&gt;
&lt;br /&gt;
==Adhering to Priciples==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164227</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164227"/>
		<updated>2025-04-20T19:08:12Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* Database */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of this project is to integrate the frontend of the grades view page with the reimplemented '''''grades_controller.rb (E2510)''''' backend in Expertiza, ensuring a seamless connection between both layers. This integration involves refining the interaction between the UI and backend while adhering to best design principles such as modularity, maintainability, and scalability. The grades_controller.rb is responsible for managing grading functionality, allowing instructors to view and modify assignment grades while enabling students to access their evaluations. By following SOLID and DRY principles, this reimplementation enhances code clarity, reduces redundancy, and improves overall system efficiency.&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
The &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; is responsible for managing and delivering grading data to users in the Expertiza system. It enables instructors to view, calculate, and release grades to students, while also allowing students to view feedback and scores for assignments. The controller plays an important role in coordinating backend logic for reviews and grade visibility.&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
The previous implementation successfully created a functional frontend UI page in Expertiza, addressing design inconsistencies and improving usability. It introduced a visually cohesive interface with an intuitive layout, enhanced responsiveness, and improved information display, allowing users to navigate grading data more efficiently. However, the interface was populated using dummy data, limiting its practical use. This reimplemented UI will utilize real data from the database (that has been populated in this round), ensuring that grading information is dynamically retrieved and displayed accurately through JSON objects. Additionally, this phase will connect the redesigned frontend with some new components in the grades_controller.rb. Specifically, the GET functions in the grades_controller were reimplemented to return JSON objects (instead of instance variables) that could be accessed via an API call. Thus, this new implementation ensures seamless communication between the UI and backend while adhering to best design practices for maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
This project focuses on integrating the frontend of the grades view page with the reimplemented '''grades_controller.rb (E2510)''' backend in Expertiza. This integration requires modifications to both the frontend and backend to establish a seamless connection, ensuring that grading data is dynamically retrieved and displayed accurately. By adhering to best design principles such as modularity, maintainability, and scalability, the implementation will enhance system efficiency and long-term usability. Key improvements include replacing dummy data with real database values, refining data flow between the UI and backend, and optimizing API interactions for better performance. These enhancements will create a more intuitive and reliable grading system, providing a seamless experience for instructors and students while maintaining a well-structured and adaptable codebase for future development.&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
# '''Establish a Robust Connection Between the Frontend and Backend''': Ensure smooth data retrieval and updates between the grades view page and the backend by integrating dynamic data through API calls, replacing the current hardcoded dummy data.&lt;br /&gt;
# '''Define and Implement Clear API Endpoints''': Create well-structured API endpoints in grades_controller.rb for retrieving and displaying grades, ensuring they return appropriate data based on user roles (students, instructors, TAs) and maintain role-based access controls.&lt;br /&gt;
# '''Dynamic Data Integration''': Modify the frontend to consume real-time data fetched from the backend, ensuring an intuitive and responsive UI that reflects the actual grading information. &lt;br /&gt;
# '''Refactor Frontend and Backend Components''': Refactor both the frontend and backend as necessary to align with SOLID and DRY principles, ensuring modularity, maintainability, and scalability. This includes eliminating redundant logic and optimizing code for better readability.&lt;br /&gt;
# '''Implement Proper Permission Checks''': Ensure that only authorized users can access grade information by implementing robust privilege checks and ensuring that the data is securely accessible to students, instructors, and TAs based on their roles.&lt;br /&gt;
# '''Optimize Database Queries and API Responses''': Enhance the efficiency of database queries and API responses to reduce unnecessary load and ensure that data is retrieved and displayed promptly.&lt;br /&gt;
# '''Testing and Validation''': Implement comprehensive unit and integration tests to verify the correctness of data flow, UI interactions, and role-based access controls, ensuring that the system functions correctly and securely.&lt;br /&gt;
&lt;br /&gt;
=Reimplementation Plan=&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populated data with the appropriate HTTP GET and HTTP POST calls. This shift is necessary to ensure that our application reflects real-time data from the backend rather than relying on static or hardcoded values, which can quickly become outdated or inconsistent. It also enables better scalability and maintainability, as changes to the data only need to be made in the backend, without requiring manual updates in the frontend code.&lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
'''Author Feedback''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
'''Heatmap Data''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
'''Team-mate Data''':&lt;br /&gt;
   {&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The current implementation caters to the backend for a Ruby-embedded front-end, where data is rendered server-side and passed directly into the view. We need to update the APIs to return data in a format that can be consumed by the React UI, typically JSON. This shift is essential to decouple the front-end from the server-side rendering logic, allowing for a more interactive and dynamic user experience. By transitioning to a React-based interface, we gain better control over UI state and responsiveness, while also aligning with modern web development practices. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and instead return plain JSON objects using render json: in the response. This change is necessary to align with a frontend architecture that uses React or another JavaScript framework, which expects structured data from the backend in JSON format rather than relying on server-rendered templates. By shifting to JSON responses, we enable cleaner API endpoints, facilitate easier testing and debugging, and support a more maintainable, decoupled frontend-backend integration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    # prepare feedback summaries&lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
  1.1. Students&lt;br /&gt;
  1.2. Teams&lt;br /&gt;
  1.3. TA&lt;br /&gt;
  1.4. Professor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
  2.1 assignments&lt;br /&gt;
  2.2 assignment_questionnaire&lt;br /&gt;
  2.3 questionnaires&lt;br /&gt;
  2.4 participant&lt;br /&gt;
  2.5 signed_up_teams&lt;br /&gt;
  2.6 teams_users&lt;br /&gt;
  2.7 due_dates&lt;br /&gt;
  2.8 late_policies&lt;br /&gt;
  2.9 questions&lt;br /&gt;
  2.10 review_scores&lt;br /&gt;
  2.11 review_grades&lt;br /&gt;
&lt;br /&gt;
== Data Flow Overview ==&lt;br /&gt;
The diagram below illustrates how data flows between the frontend React components and the grades_controller.rb backend during a typical grading data fetch operation.&lt;br /&gt;
&lt;br /&gt;
* The user (e.g., instructor or student) interacts with the React-based grades view (e.g., ReviewTable, RoundSelector, or Statistics).&lt;br /&gt;
* The component triggers an API request to a specific action in grades_controller.rb (e.g., GET /grades/:id/summary).&lt;br /&gt;
*The controller action queries the relevant models (e.g., Assignment, Team, ReviewResponseMap) and compiles a JSON response.&lt;br /&gt;
* The response is sent back to the frontend and parsed.&lt;br /&gt;
*The React components update the UI (tables, heatmaps, statistics) based on the received data.&lt;br /&gt;
&lt;br /&gt;
This architecture ensures a clean separation between frontend and backend logic, improving maintainability and testability.&lt;br /&gt;
[[File:Dataflow.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
The test plan for Phase 2 focuses on verifying the successful integration of the newly reimplemented &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the React-based UI components. We aim to ensure data is:&lt;br /&gt;
&lt;br /&gt;
* Correctly fetched from the backend  &lt;br /&gt;
* Appropriately displayed in the frontend  &lt;br /&gt;
* Functionally sound under both normal and edge-case scenarios&lt;br /&gt;
&lt;br /&gt;
== Tools and Frameworks ==&lt;br /&gt;
We plan to use the following tools and frameworks for testing:&lt;br /&gt;
&lt;br /&gt;
* '''Frontend''': Jest and React Testing Library for unit and integration tests&lt;br /&gt;
* '''Backend''': RSpec for controller and model tests&lt;br /&gt;
* '''Integration Testing''': Capybara and Selenium for simulating real user behavior&lt;br /&gt;
* '''Test Coverage''': SimpleCov&lt;br /&gt;
&lt;br /&gt;
== 1. UI Integration Tests ==&lt;br /&gt;
&lt;br /&gt;
These tests ensure the frontend correctly interacts with backend APIs and renders the data appropriately.&lt;br /&gt;
&lt;br /&gt;
=== ReviewTable Component ===&lt;br /&gt;
&lt;br /&gt;
* Validate that the component makes a successful API call to fetch author feedback  &lt;br /&gt;
* Ensure feedback is rendered in the correct table structure  &lt;br /&gt;
* Test loading state before data is fetched  &lt;br /&gt;
* Handle empty or malformed feedback responses gracefully  &lt;br /&gt;
&lt;br /&gt;
=== RoundSelector Component ===&lt;br /&gt;
&lt;br /&gt;
* Verify API call to fetch heatmap data is triggered on component load  &lt;br /&gt;
* Check that heatmap data is correctly visualized for different review rounds  &lt;br /&gt;
* Test behavior with no data, incomplete data, or delayed response  &lt;br /&gt;
&lt;br /&gt;
=== Statistics Component ===&lt;br /&gt;
&lt;br /&gt;
* Confirm it correctly fetches teammate evaluations and author feedback  &lt;br /&gt;
* Ensure charts or tables reflect the received backend data accurately  &lt;br /&gt;
* Test switching between different teams or assignments and verify correct display  &lt;br /&gt;
&lt;br /&gt;
=== General UI Considerations ===&lt;br /&gt;
&lt;br /&gt;
* Test frontend responsiveness to backend failures (500, 404, timeout)  &lt;br /&gt;
* Ensure authorization errors are handled and appropriate messages displayed  &lt;br /&gt;
&lt;br /&gt;
== 2. Backend API Tests ==&lt;br /&gt;
&lt;br /&gt;
While unit tests exist, integration-level tests will be added or updated to ensure UI compatibility.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
* Validate all &amp;lt;code&amp;gt;GET&amp;lt;/code&amp;gt; endpoints return properly structured JSON objects  &lt;br /&gt;
* Simulate various user roles (student, TA, instructor) and ensure access control  &lt;br /&gt;
* Include test cases for:&lt;br /&gt;
** No grades present  &lt;br /&gt;
** Partial data (e.g. missing feedback or evaluations)  &lt;br /&gt;
** Large number of records  &lt;br /&gt;
&lt;br /&gt;
=== Security &amp;amp; Permissions ===&lt;br /&gt;
&lt;br /&gt;
* Ensure students can only fetch their grades and feedback  &lt;br /&gt;
* Ensure TAs and instructors can access full assignment data  &lt;br /&gt;
* Test token/session-based access restrictions (if applicable)  &lt;br /&gt;
&lt;br /&gt;
== 3. Database Preparation ==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, seed data will simulate real-world usage and we will ensure that:&lt;br /&gt;
* Tests will use isolated fixtures or factories to ensure data consistency&lt;br /&gt;
* All database states will be reset before each test suite run&lt;br /&gt;
&lt;br /&gt;
=== Tables and Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;assignments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_participant&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;participants&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;questionnaires&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;questions&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_questionnaire&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;signed_up_teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;teams_users&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;late_policies&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
=== Scenarios ===&lt;br /&gt;
&lt;br /&gt;
* Single student assigned  &lt;br /&gt;
* Team assignments with/without feedback  &lt;br /&gt;
* Late submissions triggering late policies  &lt;br /&gt;
* Multiple review rounds per assignment&lt;br /&gt;
&lt;br /&gt;
== 4. Regression &amp;amp; CI Testing ==&lt;br /&gt;
&lt;br /&gt;
To ensure updates do not break existing functionality:&lt;br /&gt;
&lt;br /&gt;
* Re-run all existing unit tests  &lt;br /&gt;
* Include snapshot tests for frontend components  &lt;br /&gt;
* Use CI pipelines to automatically trigger tests on pull requests  &lt;br /&gt;
&lt;br /&gt;
== Test Plan Summary ==&lt;br /&gt;
&lt;br /&gt;
This test plan outlines the approach for integrating &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the frontend. By combining backend tests, UI integration checks, and realistic database scenarios, we aim to deliver a seamless user experience. The plan emphasizes early detection of issues and supports long-term maintainability through regression testing. As development progresses, the plan will be updated to cover new insights and edge cases.&lt;br /&gt;
&lt;br /&gt;
=Completed Reimplementation Details=&lt;br /&gt;
&lt;br /&gt;
This section outlines the changes that were actually implemented as part of the reimplementation effort. It provides a detailed breakdown of how the frontend was decoupled from the legacy Ruby-embedded views, and how dynamic data flow was established using API endpoints. Specific components were modified to replace hardcoded or mock data with real-time API calls to the backend, ensuring that the application now reflects live grading data. Additionally, backend controller actions were updated to return clean, structured JSON responses, and the data retrieval logic was centralized to improve maintainability and testability. &lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The previous implementation was designed for a Ruby-embedded front-end, where data was rendered server-side and injected directly into the view. We have since updated the APIs to return data in a format suitable for consumption by the React UI, typically as JSON objects. This change successfully decouples the front-end from the server-side rendering logic, enabling a more interactive and responsive user experience. By transitioning to a React-based interface, we now have improved control over UI state and better alignment with modern web development practices.&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
In this controller, we have updated the GET functions to remove the use of instance variables and instead return plain JSON objects using render json: in the response. This update was essential to align with the frontend architecture, which now relies on a React-based interface that expects structured data from the backend in JSON format rather than server-rendered templates. By returning JSON responses, we’ve established cleaner and more consistent API endpoints, improved the testability and debuggability of our backend logic, and created a more maintainable and decoupled integration between the frontend and backend systems. The following functions were updated as part of this integration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  def view_grading_report&lt;br /&gt;
    assignment_id = params[:id].to_i&lt;br /&gt;
    data = get_data_for_heat_map(assignment_id)&lt;br /&gt;
    &lt;br /&gt;
    render json: data, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
    &lt;br /&gt;
  def view_my_scores&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team_id = TeamsUser.team_id(participant.assignment_id, participant.user_id)&lt;br /&gt;
    # return if redirect_when_disallowed(participant)&lt;br /&gt;
    questions = fetch_questionnaires_and_questions(assignment)&lt;br /&gt;
    pscore = fetch_participant_scores(participant, questions)&lt;br /&gt;
    topic_id = SignedUpTeam.find_topic_id_for_user(participant.assignment.id, participant.user_id)&lt;br /&gt;
    stage = participant.assignment.current_stage(topic_id)&lt;br /&gt;
    # all_penalties = update_penalties(assignment)&lt;br /&gt;
    # Feedback Summary needs to be checked once&lt;br /&gt;
    # summary_ws_url = WEBSERVICE_CONFIG['summary_webservice_url']&lt;br /&gt;
    sum = SummaryHelper::Summary.new.summarize_reviews_by_reviewee(questions, assignment, team_id, 'http://peerlogic.csc.ncsu.edu/sum/v1.0/summary/8/lsa', session)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      topic_id: topic_id,&lt;br /&gt;
      stage: stage,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      summary: sum.summary,&lt;br /&gt;
      avg_scores_by_round: sum.avg_scores_by_round,&lt;br /&gt;
      avg_scores_by_criterion: sum.avg_scores_by_criterion&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def view_team&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    team_id = team.id&lt;br /&gt;
  &lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: assignment.id).map(&amp;amp;:questionnaire)&lt;br /&gt;
    questions = retrieve_questions(questionnaires, assignment.id)&lt;br /&gt;
    pscore = Response.participant_scores(participant, questions)&lt;br /&gt;
    vmlist = process_questionare_for_team(assignment, team_id,questionnaires, team, participant)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team: team,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      vmlist: vmlist&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These updates were important for the backend and ensured seamless communication with the React frontend. By removing instance variables and returning structured JSON responses, we eliminated dependencies on server-side rendering and enabled the frontend to dynamically manage and render data. This not only enhances performance and flexibility but also improves maintainability and scalability as the application evolves. Moreover, it allows the backend and frontend to evolve independently, supporting better separation of concerns and aligning with current best practices in full-stack web development.&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We have successfully  reimplemented the previously pre-populated data with appropriate HTTP GET calls to the backend. This ensures that our application now reflects real-time data directly from the server, improving data accuracy and consistency across the UI. This update also enhances scalability and maintainability, as the frontend no longer depends on static content and can adapt to backend changes without manual intervention.&lt;br /&gt;
&lt;br /&gt;
All dummy data throughout these components has been successfully removed and replaced with real-time API integrations. This transition allows for a fully dynamic, data-driven React frontend that remains synchronized with backend updates and user interactions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Files and components that were updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' &lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:'''&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
A key component of this project involved populating the necessary database tables that the grades_controller.rb relies on to serve real-time data to the frontend. This step was essential for replacing the previously hardcoded or pre-populated dummy data with dynamic, API-driven content. Below is a list of the database tables that were seeded with mock data specifically for development and testing purposes in this project:&lt;br /&gt;
&lt;br /&gt;
* roles&lt;br /&gt;
* institutions&lt;br /&gt;
* users&lt;br /&gt;
* assignments&lt;br /&gt;
* teams &lt;br /&gt;
* teams_users&lt;br /&gt;
* sign_up_topics&lt;br /&gt;
* signed_up_teams&lt;br /&gt;
* participants&lt;br /&gt;
* questionnaires&lt;br /&gt;
* questions &lt;br /&gt;
* assignment_questionaires&lt;br /&gt;
* response_maps&lt;br /&gt;
* responses&lt;br /&gt;
* score_views&lt;br /&gt;
* tag-prompts&lt;br /&gt;
* tag_prompt_deployments&lt;br /&gt;
&lt;br /&gt;
==Data Flow Overview==&lt;br /&gt;
&lt;br /&gt;
The diagram below illustrates the data flow between React frontend components and the grades_controller.rb backend during a typical grading data retrieval process.&lt;br /&gt;
&lt;br /&gt;
* The user (such as an instructor or student) interacts with the React-based grades interface—components like ReviewTable, RoundSelector, or Statistics.&lt;br /&gt;
&lt;br /&gt;
* In response to this interaction, the component initiates an API request to a specific endpoint in grades_controller.rb.&lt;br /&gt;
&lt;br /&gt;
* The controller action then queries the relevant backend models (such as Assignment, Team, and ReviewResponseMap) and constructs a structured JSON response.&lt;br /&gt;
&lt;br /&gt;
* This JSON data is returned to the frontend, where it is parsed by the corresponding React component.&lt;br /&gt;
&lt;br /&gt;
* Finally, the React components dynamically update the UI—populating tables, generating heatmaps, or displaying statistics—based on the data received.&lt;br /&gt;
&lt;br /&gt;
This architecture promotes a clear separation of concerns between frontend and backend layers, enabling more scalable development, easier debugging, and improved maintainability and testability across the application.&lt;br /&gt;
&lt;br /&gt;
=Testing=&lt;br /&gt;
&lt;br /&gt;
==Testing Overview==&lt;br /&gt;
&lt;br /&gt;
==Database Preparation==&lt;br /&gt;
&lt;br /&gt;
==UI Tests==&lt;br /&gt;
&lt;br /&gt;
==Backend API Tests==&lt;br /&gt;
&lt;br /&gt;
==Tables and Test Coverage==&lt;br /&gt;
&lt;br /&gt;
==Adhering to Priciples==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164226</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164226"/>
		<updated>2025-04-20T18:54:34Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* Completed Reimplementation Details */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of this project is to integrate the frontend of the grades view page with the reimplemented '''''grades_controller.rb (E2510)''''' backend in Expertiza, ensuring a seamless connection between both layers. This integration involves refining the interaction between the UI and backend while adhering to best design principles such as modularity, maintainability, and scalability. The grades_controller.rb is responsible for managing grading functionality, allowing instructors to view and modify assignment grades while enabling students to access their evaluations. By following SOLID and DRY principles, this reimplementation enhances code clarity, reduces redundancy, and improves overall system efficiency.&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
The &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; is responsible for managing and delivering grading data to users in the Expertiza system. It enables instructors to view, calculate, and release grades to students, while also allowing students to view feedback and scores for assignments. The controller plays an important role in coordinating backend logic for reviews and grade visibility.&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
The previous implementation successfully created a functional frontend UI page in Expertiza, addressing design inconsistencies and improving usability. It introduced a visually cohesive interface with an intuitive layout, enhanced responsiveness, and improved information display, allowing users to navigate grading data more efficiently. However, the interface was populated using dummy data, limiting its practical use. This reimplemented UI will utilize real data from the database (that has been populated in this round), ensuring that grading information is dynamically retrieved and displayed accurately through JSON objects. Additionally, this phase will connect the redesigned frontend with some new components in the grades_controller.rb. Specifically, the GET functions in the grades_controller were reimplemented to return JSON objects (instead of instance variables) that could be accessed via an API call. Thus, this new implementation ensures seamless communication between the UI and backend while adhering to best design practices for maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
This project focuses on integrating the frontend of the grades view page with the reimplemented '''grades_controller.rb (E2510)''' backend in Expertiza. This integration requires modifications to both the frontend and backend to establish a seamless connection, ensuring that grading data is dynamically retrieved and displayed accurately. By adhering to best design principles such as modularity, maintainability, and scalability, the implementation will enhance system efficiency and long-term usability. Key improvements include replacing dummy data with real database values, refining data flow between the UI and backend, and optimizing API interactions for better performance. These enhancements will create a more intuitive and reliable grading system, providing a seamless experience for instructors and students while maintaining a well-structured and adaptable codebase for future development.&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
# '''Establish a Robust Connection Between the Frontend and Backend''': Ensure smooth data retrieval and updates between the grades view page and the backend by integrating dynamic data through API calls, replacing the current hardcoded dummy data.&lt;br /&gt;
# '''Define and Implement Clear API Endpoints''': Create well-structured API endpoints in grades_controller.rb for retrieving and displaying grades, ensuring they return appropriate data based on user roles (students, instructors, TAs) and maintain role-based access controls.&lt;br /&gt;
# '''Dynamic Data Integration''': Modify the frontend to consume real-time data fetched from the backend, ensuring an intuitive and responsive UI that reflects the actual grading information. &lt;br /&gt;
# '''Refactor Frontend and Backend Components''': Refactor both the frontend and backend as necessary to align with SOLID and DRY principles, ensuring modularity, maintainability, and scalability. This includes eliminating redundant logic and optimizing code for better readability.&lt;br /&gt;
# '''Implement Proper Permission Checks''': Ensure that only authorized users can access grade information by implementing robust privilege checks and ensuring that the data is securely accessible to students, instructors, and TAs based on their roles.&lt;br /&gt;
# '''Optimize Database Queries and API Responses''': Enhance the efficiency of database queries and API responses to reduce unnecessary load and ensure that data is retrieved and displayed promptly.&lt;br /&gt;
# '''Testing and Validation''': Implement comprehensive unit and integration tests to verify the correctness of data flow, UI interactions, and role-based access controls, ensuring that the system functions correctly and securely.&lt;br /&gt;
&lt;br /&gt;
=Reimplementation Plan=&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populated data with the appropriate HTTP GET and HTTP POST calls. This shift is necessary to ensure that our application reflects real-time data from the backend rather than relying on static or hardcoded values, which can quickly become outdated or inconsistent. It also enables better scalability and maintainability, as changes to the data only need to be made in the backend, without requiring manual updates in the frontend code.&lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
'''Author Feedback''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
'''Heatmap Data''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
'''Team-mate Data''':&lt;br /&gt;
   {&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The current implementation caters to the backend for a Ruby-embedded front-end, where data is rendered server-side and passed directly into the view. We need to update the APIs to return data in a format that can be consumed by the React UI, typically JSON. This shift is essential to decouple the front-end from the server-side rendering logic, allowing for a more interactive and dynamic user experience. By transitioning to a React-based interface, we gain better control over UI state and responsiveness, while also aligning with modern web development practices. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and instead return plain JSON objects using render json: in the response. This change is necessary to align with a frontend architecture that uses React or another JavaScript framework, which expects structured data from the backend in JSON format rather than relying on server-rendered templates. By shifting to JSON responses, we enable cleaner API endpoints, facilitate easier testing and debugging, and support a more maintainable, decoupled frontend-backend integration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    # prepare feedback summaries&lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
  1.1. Students&lt;br /&gt;
  1.2. Teams&lt;br /&gt;
  1.3. TA&lt;br /&gt;
  1.4. Professor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
  2.1 assignments&lt;br /&gt;
  2.2 assignment_questionnaire&lt;br /&gt;
  2.3 questionnaires&lt;br /&gt;
  2.4 participant&lt;br /&gt;
  2.5 signed_up_teams&lt;br /&gt;
  2.6 teams_users&lt;br /&gt;
  2.7 due_dates&lt;br /&gt;
  2.8 late_policies&lt;br /&gt;
  2.9 questions&lt;br /&gt;
  2.10 review_scores&lt;br /&gt;
  2.11 review_grades&lt;br /&gt;
&lt;br /&gt;
== Data Flow Overview ==&lt;br /&gt;
The diagram below illustrates how data flows between the frontend React components and the grades_controller.rb backend during a typical grading data fetch operation.&lt;br /&gt;
&lt;br /&gt;
* The user (e.g., instructor or student) interacts with the React-based grades view (e.g., ReviewTable, RoundSelector, or Statistics).&lt;br /&gt;
* The component triggers an API request to a specific action in grades_controller.rb (e.g., GET /grades/:id/summary).&lt;br /&gt;
*The controller action queries the relevant models (e.g., Assignment, Team, ReviewResponseMap) and compiles a JSON response.&lt;br /&gt;
* The response is sent back to the frontend and parsed.&lt;br /&gt;
*The React components update the UI (tables, heatmaps, statistics) based on the received data.&lt;br /&gt;
&lt;br /&gt;
This architecture ensures a clean separation between frontend and backend logic, improving maintainability and testability.&lt;br /&gt;
[[File:Dataflow.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
The test plan for Phase 2 focuses on verifying the successful integration of the newly reimplemented &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the React-based UI components. We aim to ensure data is:&lt;br /&gt;
&lt;br /&gt;
* Correctly fetched from the backend  &lt;br /&gt;
* Appropriately displayed in the frontend  &lt;br /&gt;
* Functionally sound under both normal and edge-case scenarios&lt;br /&gt;
&lt;br /&gt;
== Tools and Frameworks ==&lt;br /&gt;
We plan to use the following tools and frameworks for testing:&lt;br /&gt;
&lt;br /&gt;
* '''Frontend''': Jest and React Testing Library for unit and integration tests&lt;br /&gt;
* '''Backend''': RSpec for controller and model tests&lt;br /&gt;
* '''Integration Testing''': Capybara and Selenium for simulating real user behavior&lt;br /&gt;
* '''Test Coverage''': SimpleCov&lt;br /&gt;
&lt;br /&gt;
== 1. UI Integration Tests ==&lt;br /&gt;
&lt;br /&gt;
These tests ensure the frontend correctly interacts with backend APIs and renders the data appropriately.&lt;br /&gt;
&lt;br /&gt;
=== ReviewTable Component ===&lt;br /&gt;
&lt;br /&gt;
* Validate that the component makes a successful API call to fetch author feedback  &lt;br /&gt;
* Ensure feedback is rendered in the correct table structure  &lt;br /&gt;
* Test loading state before data is fetched  &lt;br /&gt;
* Handle empty or malformed feedback responses gracefully  &lt;br /&gt;
&lt;br /&gt;
=== RoundSelector Component ===&lt;br /&gt;
&lt;br /&gt;
* Verify API call to fetch heatmap data is triggered on component load  &lt;br /&gt;
* Check that heatmap data is correctly visualized for different review rounds  &lt;br /&gt;
* Test behavior with no data, incomplete data, or delayed response  &lt;br /&gt;
&lt;br /&gt;
=== Statistics Component ===&lt;br /&gt;
&lt;br /&gt;
* Confirm it correctly fetches teammate evaluations and author feedback  &lt;br /&gt;
* Ensure charts or tables reflect the received backend data accurately  &lt;br /&gt;
* Test switching between different teams or assignments and verify correct display  &lt;br /&gt;
&lt;br /&gt;
=== General UI Considerations ===&lt;br /&gt;
&lt;br /&gt;
* Test frontend responsiveness to backend failures (500, 404, timeout)  &lt;br /&gt;
* Ensure authorization errors are handled and appropriate messages displayed  &lt;br /&gt;
&lt;br /&gt;
== 2. Backend API Tests ==&lt;br /&gt;
&lt;br /&gt;
While unit tests exist, integration-level tests will be added or updated to ensure UI compatibility.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
* Validate all &amp;lt;code&amp;gt;GET&amp;lt;/code&amp;gt; endpoints return properly structured JSON objects  &lt;br /&gt;
* Simulate various user roles (student, TA, instructor) and ensure access control  &lt;br /&gt;
* Include test cases for:&lt;br /&gt;
** No grades present  &lt;br /&gt;
** Partial data (e.g. missing feedback or evaluations)  &lt;br /&gt;
** Large number of records  &lt;br /&gt;
&lt;br /&gt;
=== Security &amp;amp; Permissions ===&lt;br /&gt;
&lt;br /&gt;
* Ensure students can only fetch their grades and feedback  &lt;br /&gt;
* Ensure TAs and instructors can access full assignment data  &lt;br /&gt;
* Test token/session-based access restrictions (if applicable)  &lt;br /&gt;
&lt;br /&gt;
== 3. Database Preparation ==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, seed data will simulate real-world usage and we will ensure that:&lt;br /&gt;
* Tests will use isolated fixtures or factories to ensure data consistency&lt;br /&gt;
* All database states will be reset before each test suite run&lt;br /&gt;
&lt;br /&gt;
=== Tables and Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;assignments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_participant&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;participants&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;questionnaires&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;questions&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_questionnaire&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;signed_up_teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;teams_users&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;late_policies&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
=== Scenarios ===&lt;br /&gt;
&lt;br /&gt;
* Single student assigned  &lt;br /&gt;
* Team assignments with/without feedback  &lt;br /&gt;
* Late submissions triggering late policies  &lt;br /&gt;
* Multiple review rounds per assignment&lt;br /&gt;
&lt;br /&gt;
== 4. Regression &amp;amp; CI Testing ==&lt;br /&gt;
&lt;br /&gt;
To ensure updates do not break existing functionality:&lt;br /&gt;
&lt;br /&gt;
* Re-run all existing unit tests  &lt;br /&gt;
* Include snapshot tests for frontend components  &lt;br /&gt;
* Use CI pipelines to automatically trigger tests on pull requests  &lt;br /&gt;
&lt;br /&gt;
== Test Plan Summary ==&lt;br /&gt;
&lt;br /&gt;
This test plan outlines the approach for integrating &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the frontend. By combining backend tests, UI integration checks, and realistic database scenarios, we aim to deliver a seamless user experience. The plan emphasizes early detection of issues and supports long-term maintainability through regression testing. As development progresses, the plan will be updated to cover new insights and edge cases.&lt;br /&gt;
&lt;br /&gt;
=Completed Reimplementation Details=&lt;br /&gt;
&lt;br /&gt;
This section outlines the changes that were actually implemented as part of the reimplementation effort. It provides a detailed breakdown of how the frontend was decoupled from the legacy Ruby-embedded views, and how dynamic data flow was established using API endpoints. Specific components were modified to replace hardcoded or mock data with real-time API calls to the backend, ensuring that the application now reflects live grading data. Additionally, backend controller actions were updated to return clean, structured JSON responses, and the data retrieval logic was centralized to improve maintainability and testability. &lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The previous implementation was designed for a Ruby-embedded front-end, where data was rendered server-side and injected directly into the view. We have since updated the APIs to return data in a format suitable for consumption by the React UI, typically as JSON objects. This change successfully decouples the front-end from the server-side rendering logic, enabling a more interactive and responsive user experience. By transitioning to a React-based interface, we now have improved control over UI state and better alignment with modern web development practices.&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
In this controller, we have updated the GET functions to remove the use of instance variables and instead return plain JSON objects using render json: in the response. This update was essential to align with the frontend architecture, which now relies on a React-based interface that expects structured data from the backend in JSON format rather than server-rendered templates. By returning JSON responses, we’ve established cleaner and more consistent API endpoints, improved the testability and debuggability of our backend logic, and created a more maintainable and decoupled integration between the frontend and backend systems. The following functions were updated as part of this integration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  def view_grading_report&lt;br /&gt;
    assignment_id = params[:id].to_i&lt;br /&gt;
    data = get_data_for_heat_map(assignment_id)&lt;br /&gt;
    &lt;br /&gt;
    render json: data, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
    &lt;br /&gt;
  def view_my_scores&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team_id = TeamsUser.team_id(participant.assignment_id, participant.user_id)&lt;br /&gt;
    # return if redirect_when_disallowed(participant)&lt;br /&gt;
    questions = fetch_questionnaires_and_questions(assignment)&lt;br /&gt;
    pscore = fetch_participant_scores(participant, questions)&lt;br /&gt;
    topic_id = SignedUpTeam.find_topic_id_for_user(participant.assignment.id, participant.user_id)&lt;br /&gt;
    stage = participant.assignment.current_stage(topic_id)&lt;br /&gt;
    # all_penalties = update_penalties(assignment)&lt;br /&gt;
    # Feedback Summary needs to be checked once&lt;br /&gt;
    # summary_ws_url = WEBSERVICE_CONFIG['summary_webservice_url']&lt;br /&gt;
    sum = SummaryHelper::Summary.new.summarize_reviews_by_reviewee(questions, assignment, team_id, 'http://peerlogic.csc.ncsu.edu/sum/v1.0/summary/8/lsa', session)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      topic_id: topic_id,&lt;br /&gt;
      stage: stage,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      summary: sum.summary,&lt;br /&gt;
      avg_scores_by_round: sum.avg_scores_by_round,&lt;br /&gt;
      avg_scores_by_criterion: sum.avg_scores_by_criterion&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def view_team&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    team_id = team.id&lt;br /&gt;
  &lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: assignment.id).map(&amp;amp;:questionnaire)&lt;br /&gt;
    questions = retrieve_questions(questionnaires, assignment.id)&lt;br /&gt;
    pscore = Response.participant_scores(participant, questions)&lt;br /&gt;
    vmlist = process_questionare_for_team(assignment, team_id,questionnaires, team, participant)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team: team,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      vmlist: vmlist&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These updates were important for the backend and ensured seamless communication with the React frontend. By removing instance variables and returning structured JSON responses, we eliminated dependencies on server-side rendering and enabled the frontend to dynamically manage and render data. This not only enhances performance and flexibility but also improves maintainability and scalability as the application evolves. Moreover, it allows the backend and frontend to evolve independently, supporting better separation of concerns and aligning with current best practices in full-stack web development.&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We have successfully  reimplemented the previously pre-populated data with appropriate HTTP GET calls to the backend. This ensures that our application now reflects real-time data directly from the server, improving data accuracy and consistency across the UI. This update also enhances scalability and maintainability, as the frontend no longer depends on static content and can adapt to backend changes without manual intervention.&lt;br /&gt;
&lt;br /&gt;
All dummy data throughout these components has been successfully removed and replaced with real-time API integrations. This transition allows for a fully dynamic, data-driven React frontend that remains synchronized with backend updates and user interactions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Files and components that were updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' &lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:'''&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
==Data Flow Overview==&lt;br /&gt;
&lt;br /&gt;
The diagram below illustrates the data flow between React frontend components and the grades_controller.rb backend during a typical grading data retrieval process.&lt;br /&gt;
&lt;br /&gt;
* The user (such as an instructor or student) interacts with the React-based grades interface—components like ReviewTable, RoundSelector, or Statistics.&lt;br /&gt;
&lt;br /&gt;
* In response to this interaction, the component initiates an API request to a specific endpoint in grades_controller.rb.&lt;br /&gt;
&lt;br /&gt;
* The controller action then queries the relevant backend models (such as Assignment, Team, and ReviewResponseMap) and constructs a structured JSON response.&lt;br /&gt;
&lt;br /&gt;
* This JSON data is returned to the frontend, where it is parsed by the corresponding React component.&lt;br /&gt;
&lt;br /&gt;
* Finally, the React components dynamically update the UI—populating tables, generating heatmaps, or displaying statistics—based on the data received.&lt;br /&gt;
&lt;br /&gt;
This architecture promotes a clear separation of concerns between frontend and backend layers, enabling more scalable development, easier debugging, and improved maintainability and testability across the application.&lt;br /&gt;
&lt;br /&gt;
=Testing=&lt;br /&gt;
&lt;br /&gt;
==Testing Overview==&lt;br /&gt;
&lt;br /&gt;
==Database Preparation==&lt;br /&gt;
&lt;br /&gt;
==UI Tests==&lt;br /&gt;
&lt;br /&gt;
==Backend API Tests==&lt;br /&gt;
&lt;br /&gt;
==Tables and Test Coverage==&lt;br /&gt;
&lt;br /&gt;
==Adhering to Priciples==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164225</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164225"/>
		<updated>2025-04-20T18:42:05Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* Data Flow Overview */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of this project is to integrate the frontend of the grades view page with the reimplemented '''''grades_controller.rb (E2510)''''' backend in Expertiza, ensuring a seamless connection between both layers. This integration involves refining the interaction between the UI and backend while adhering to best design principles such as modularity, maintainability, and scalability. The grades_controller.rb is responsible for managing grading functionality, allowing instructors to view and modify assignment grades while enabling students to access their evaluations. By following SOLID and DRY principles, this reimplementation enhances code clarity, reduces redundancy, and improves overall system efficiency.&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
The &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; is responsible for managing and delivering grading data to users in the Expertiza system. It enables instructors to view, calculate, and release grades to students, while also allowing students to view feedback and scores for assignments. The controller plays an important role in coordinating backend logic for reviews and grade visibility.&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
The previous implementation successfully created a functional frontend UI page in Expertiza, addressing design inconsistencies and improving usability. It introduced a visually cohesive interface with an intuitive layout, enhanced responsiveness, and improved information display, allowing users to navigate grading data more efficiently. However, the interface was populated using dummy data, limiting its practical use. This reimplemented UI will utilize real data from the database (that has been populated in this round), ensuring that grading information is dynamically retrieved and displayed accurately through JSON objects. Additionally, this phase will connect the redesigned frontend with some new components in the grades_controller.rb. Specifically, the GET functions in the grades_controller were reimplemented to return JSON objects (instead of instance variables) that could be accessed via an API call. Thus, this new implementation ensures seamless communication between the UI and backend while adhering to best design practices for maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
This project focuses on integrating the frontend of the grades view page with the reimplemented '''grades_controller.rb (E2510)''' backend in Expertiza. This integration requires modifications to both the frontend and backend to establish a seamless connection, ensuring that grading data is dynamically retrieved and displayed accurately. By adhering to best design principles such as modularity, maintainability, and scalability, the implementation will enhance system efficiency and long-term usability. Key improvements include replacing dummy data with real database values, refining data flow between the UI and backend, and optimizing API interactions for better performance. These enhancements will create a more intuitive and reliable grading system, providing a seamless experience for instructors and students while maintaining a well-structured and adaptable codebase for future development.&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
# '''Establish a Robust Connection Between the Frontend and Backend''': Ensure smooth data retrieval and updates between the grades view page and the backend by integrating dynamic data through API calls, replacing the current hardcoded dummy data.&lt;br /&gt;
# '''Define and Implement Clear API Endpoints''': Create well-structured API endpoints in grades_controller.rb for retrieving and displaying grades, ensuring they return appropriate data based on user roles (students, instructors, TAs) and maintain role-based access controls.&lt;br /&gt;
# '''Dynamic Data Integration''': Modify the frontend to consume real-time data fetched from the backend, ensuring an intuitive and responsive UI that reflects the actual grading information. &lt;br /&gt;
# '''Refactor Frontend and Backend Components''': Refactor both the frontend and backend as necessary to align with SOLID and DRY principles, ensuring modularity, maintainability, and scalability. This includes eliminating redundant logic and optimizing code for better readability.&lt;br /&gt;
# '''Implement Proper Permission Checks''': Ensure that only authorized users can access grade information by implementing robust privilege checks and ensuring that the data is securely accessible to students, instructors, and TAs based on their roles.&lt;br /&gt;
# '''Optimize Database Queries and API Responses''': Enhance the efficiency of database queries and API responses to reduce unnecessary load and ensure that data is retrieved and displayed promptly.&lt;br /&gt;
# '''Testing and Validation''': Implement comprehensive unit and integration tests to verify the correctness of data flow, UI interactions, and role-based access controls, ensuring that the system functions correctly and securely.&lt;br /&gt;
&lt;br /&gt;
=Reimplementation Plan=&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populated data with the appropriate HTTP GET and HTTP POST calls. This shift is necessary to ensure that our application reflects real-time data from the backend rather than relying on static or hardcoded values, which can quickly become outdated or inconsistent. It also enables better scalability and maintainability, as changes to the data only need to be made in the backend, without requiring manual updates in the frontend code.&lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
'''Author Feedback''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
'''Heatmap Data''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
'''Team-mate Data''':&lt;br /&gt;
   {&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The current implementation caters to the backend for a Ruby-embedded front-end, where data is rendered server-side and passed directly into the view. We need to update the APIs to return data in a format that can be consumed by the React UI, typically JSON. This shift is essential to decouple the front-end from the server-side rendering logic, allowing for a more interactive and dynamic user experience. By transitioning to a React-based interface, we gain better control over UI state and responsiveness, while also aligning with modern web development practices. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and instead return plain JSON objects using render json: in the response. This change is necessary to align with a frontend architecture that uses React or another JavaScript framework, which expects structured data from the backend in JSON format rather than relying on server-rendered templates. By shifting to JSON responses, we enable cleaner API endpoints, facilitate easier testing and debugging, and support a more maintainable, decoupled frontend-backend integration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    # prepare feedback summaries&lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
  1.1. Students&lt;br /&gt;
  1.2. Teams&lt;br /&gt;
  1.3. TA&lt;br /&gt;
  1.4. Professor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
  2.1 assignments&lt;br /&gt;
  2.2 assignment_questionnaire&lt;br /&gt;
  2.3 questionnaires&lt;br /&gt;
  2.4 participant&lt;br /&gt;
  2.5 signed_up_teams&lt;br /&gt;
  2.6 teams_users&lt;br /&gt;
  2.7 due_dates&lt;br /&gt;
  2.8 late_policies&lt;br /&gt;
  2.9 questions&lt;br /&gt;
  2.10 review_scores&lt;br /&gt;
  2.11 review_grades&lt;br /&gt;
&lt;br /&gt;
== Data Flow Overview ==&lt;br /&gt;
The diagram below illustrates how data flows between the frontend React components and the grades_controller.rb backend during a typical grading data fetch operation.&lt;br /&gt;
&lt;br /&gt;
* The user (e.g., instructor or student) interacts with the React-based grades view (e.g., ReviewTable, RoundSelector, or Statistics).&lt;br /&gt;
* The component triggers an API request to a specific action in grades_controller.rb (e.g., GET /grades/:id/summary).&lt;br /&gt;
*The controller action queries the relevant models (e.g., Assignment, Team, ReviewResponseMap) and compiles a JSON response.&lt;br /&gt;
* The response is sent back to the frontend and parsed.&lt;br /&gt;
*The React components update the UI (tables, heatmaps, statistics) based on the received data.&lt;br /&gt;
&lt;br /&gt;
This architecture ensures a clean separation between frontend and backend logic, improving maintainability and testability.&lt;br /&gt;
[[File:Dataflow.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
The test plan for Phase 2 focuses on verifying the successful integration of the newly reimplemented &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the React-based UI components. We aim to ensure data is:&lt;br /&gt;
&lt;br /&gt;
* Correctly fetched from the backend  &lt;br /&gt;
* Appropriately displayed in the frontend  &lt;br /&gt;
* Functionally sound under both normal and edge-case scenarios&lt;br /&gt;
&lt;br /&gt;
== Tools and Frameworks ==&lt;br /&gt;
We plan to use the following tools and frameworks for testing:&lt;br /&gt;
&lt;br /&gt;
* '''Frontend''': Jest and React Testing Library for unit and integration tests&lt;br /&gt;
* '''Backend''': RSpec for controller and model tests&lt;br /&gt;
* '''Integration Testing''': Capybara and Selenium for simulating real user behavior&lt;br /&gt;
* '''Test Coverage''': SimpleCov&lt;br /&gt;
&lt;br /&gt;
== 1. UI Integration Tests ==&lt;br /&gt;
&lt;br /&gt;
These tests ensure the frontend correctly interacts with backend APIs and renders the data appropriately.&lt;br /&gt;
&lt;br /&gt;
=== ReviewTable Component ===&lt;br /&gt;
&lt;br /&gt;
* Validate that the component makes a successful API call to fetch author feedback  &lt;br /&gt;
* Ensure feedback is rendered in the correct table structure  &lt;br /&gt;
* Test loading state before data is fetched  &lt;br /&gt;
* Handle empty or malformed feedback responses gracefully  &lt;br /&gt;
&lt;br /&gt;
=== RoundSelector Component ===&lt;br /&gt;
&lt;br /&gt;
* Verify API call to fetch heatmap data is triggered on component load  &lt;br /&gt;
* Check that heatmap data is correctly visualized for different review rounds  &lt;br /&gt;
* Test behavior with no data, incomplete data, or delayed response  &lt;br /&gt;
&lt;br /&gt;
=== Statistics Component ===&lt;br /&gt;
&lt;br /&gt;
* Confirm it correctly fetches teammate evaluations and author feedback  &lt;br /&gt;
* Ensure charts or tables reflect the received backend data accurately  &lt;br /&gt;
* Test switching between different teams or assignments and verify correct display  &lt;br /&gt;
&lt;br /&gt;
=== General UI Considerations ===&lt;br /&gt;
&lt;br /&gt;
* Test frontend responsiveness to backend failures (500, 404, timeout)  &lt;br /&gt;
* Ensure authorization errors are handled and appropriate messages displayed  &lt;br /&gt;
&lt;br /&gt;
== 2. Backend API Tests ==&lt;br /&gt;
&lt;br /&gt;
While unit tests exist, integration-level tests will be added or updated to ensure UI compatibility.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
* Validate all &amp;lt;code&amp;gt;GET&amp;lt;/code&amp;gt; endpoints return properly structured JSON objects  &lt;br /&gt;
* Simulate various user roles (student, TA, instructor) and ensure access control  &lt;br /&gt;
* Include test cases for:&lt;br /&gt;
** No grades present  &lt;br /&gt;
** Partial data (e.g. missing feedback or evaluations)  &lt;br /&gt;
** Large number of records  &lt;br /&gt;
&lt;br /&gt;
=== Security &amp;amp; Permissions ===&lt;br /&gt;
&lt;br /&gt;
* Ensure students can only fetch their grades and feedback  &lt;br /&gt;
* Ensure TAs and instructors can access full assignment data  &lt;br /&gt;
* Test token/session-based access restrictions (if applicable)  &lt;br /&gt;
&lt;br /&gt;
== 3. Database Preparation ==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, seed data will simulate real-world usage and we will ensure that:&lt;br /&gt;
* Tests will use isolated fixtures or factories to ensure data consistency&lt;br /&gt;
* All database states will be reset before each test suite run&lt;br /&gt;
&lt;br /&gt;
=== Tables and Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;assignments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_participant&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;participants&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;questionnaires&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;questions&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_questionnaire&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;signed_up_teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;teams_users&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;late_policies&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
=== Scenarios ===&lt;br /&gt;
&lt;br /&gt;
* Single student assigned  &lt;br /&gt;
* Team assignments with/without feedback  &lt;br /&gt;
* Late submissions triggering late policies  &lt;br /&gt;
* Multiple review rounds per assignment&lt;br /&gt;
&lt;br /&gt;
== 4. Regression &amp;amp; CI Testing ==&lt;br /&gt;
&lt;br /&gt;
To ensure updates do not break existing functionality:&lt;br /&gt;
&lt;br /&gt;
* Re-run all existing unit tests  &lt;br /&gt;
* Include snapshot tests for frontend components  &lt;br /&gt;
* Use CI pipelines to automatically trigger tests on pull requests  &lt;br /&gt;
&lt;br /&gt;
== Test Plan Summary ==&lt;br /&gt;
&lt;br /&gt;
This test plan outlines the approach for integrating &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the frontend. By combining backend tests, UI integration checks, and realistic database scenarios, we aim to deliver a seamless user experience. The plan emphasizes early detection of issues and supports long-term maintainability through regression testing. As development progresses, the plan will be updated to cover new insights and edge cases.&lt;br /&gt;
&lt;br /&gt;
=Completed Reimplementation Details=&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The previous implementation was designed for a Ruby-embedded front-end, where data was rendered server-side and injected directly into the view. We have since updated the APIs to return data in a format suitable for consumption by the React UI, typically as JSON objects. This change successfully decouples the front-end from the server-side rendering logic, enabling a more interactive and responsive user experience. By transitioning to a React-based interface, we now have improved control over UI state and better alignment with modern web development practices.&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
In this controller, we have updated the GET functions to remove the use of instance variables and instead return plain JSON objects using render json: in the response. This update was essential to align with the frontend architecture, which now relies on a React-based interface that expects structured data from the backend in JSON format rather than server-rendered templates. By returning JSON responses, we’ve established cleaner and more consistent API endpoints, improved the testability and debuggability of our backend logic, and created a more maintainable and decoupled integration between the frontend and backend systems. The following functions were updated as part of this integration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  def view_grading_report&lt;br /&gt;
    assignment_id = params[:id].to_i&lt;br /&gt;
    data = get_data_for_heat_map(assignment_id)&lt;br /&gt;
    &lt;br /&gt;
    render json: data, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
    &lt;br /&gt;
  def view_my_scores&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team_id = TeamsUser.team_id(participant.assignment_id, participant.user_id)&lt;br /&gt;
    # return if redirect_when_disallowed(participant)&lt;br /&gt;
    questions = fetch_questionnaires_and_questions(assignment)&lt;br /&gt;
    pscore = fetch_participant_scores(participant, questions)&lt;br /&gt;
    topic_id = SignedUpTeam.find_topic_id_for_user(participant.assignment.id, participant.user_id)&lt;br /&gt;
    stage = participant.assignment.current_stage(topic_id)&lt;br /&gt;
    # all_penalties = update_penalties(assignment)&lt;br /&gt;
    # Feedback Summary needs to be checked once&lt;br /&gt;
    # summary_ws_url = WEBSERVICE_CONFIG['summary_webservice_url']&lt;br /&gt;
    sum = SummaryHelper::Summary.new.summarize_reviews_by_reviewee(questions, assignment, team_id, 'http://peerlogic.csc.ncsu.edu/sum/v1.0/summary/8/lsa', session)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      topic_id: topic_id,&lt;br /&gt;
      stage: stage,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      summary: sum.summary,&lt;br /&gt;
      avg_scores_by_round: sum.avg_scores_by_round,&lt;br /&gt;
      avg_scores_by_criterion: sum.avg_scores_by_criterion&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def view_team&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    team_id = team.id&lt;br /&gt;
  &lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: assignment.id).map(&amp;amp;:questionnaire)&lt;br /&gt;
    questions = retrieve_questions(questionnaires, assignment.id)&lt;br /&gt;
    pscore = Response.participant_scores(participant, questions)&lt;br /&gt;
    vmlist = process_questionare_for_team(assignment, team_id,questionnaires, team, participant)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team: team,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      vmlist: vmlist&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These updates were important for the backend and ensured seamless communication with the React frontend. By removing instance variables and returning structured JSON responses, we eliminated dependencies on server-side rendering and enabled the frontend to dynamically manage and render data. This not only enhances performance and flexibility but also improves maintainability and scalability as the application evolves. Moreover, it allows the backend and frontend to evolve independently, supporting better separation of concerns and aligning with current best practices in full-stack web development.&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We have successfully  reimplemented the previously pre-populated data with appropriate HTTP GET calls to the backend. This ensures that our application now reflects real-time data directly from the server, improving data accuracy and consistency across the UI. This update also enhances scalability and maintainability, as the frontend no longer depends on static content and can adapt to backend changes without manual intervention.&lt;br /&gt;
&lt;br /&gt;
All dummy data throughout these components has been successfully removed and replaced with real-time API integrations. This transition allows for a fully dynamic, data-driven React frontend that remains synchronized with backend updates and user interactions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Files and components that were updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' &lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:'''&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
==Data Flow Overview==&lt;br /&gt;
&lt;br /&gt;
The diagram below illustrates the data flow between React frontend components and the grades_controller.rb backend during a typical grading data retrieval process.&lt;br /&gt;
&lt;br /&gt;
* The user (such as an instructor or student) interacts with the React-based grades interface—components like ReviewTable, RoundSelector, or Statistics.&lt;br /&gt;
&lt;br /&gt;
* In response to this interaction, the component initiates an API request to a specific endpoint in grades_controller.rb.&lt;br /&gt;
&lt;br /&gt;
* The controller action then queries the relevant backend models (such as Assignment, Team, and ReviewResponseMap) and constructs a structured JSON response.&lt;br /&gt;
&lt;br /&gt;
* This JSON data is returned to the frontend, where it is parsed by the corresponding React component.&lt;br /&gt;
&lt;br /&gt;
* Finally, the React components dynamically update the UI—populating tables, generating heatmaps, or displaying statistics—based on the data received.&lt;br /&gt;
&lt;br /&gt;
This architecture promotes a clear separation of concerns between frontend and backend layers, enabling more scalable development, easier debugging, and improved maintainability and testability across the application.&lt;br /&gt;
&lt;br /&gt;
=Testing=&lt;br /&gt;
&lt;br /&gt;
==Testing Overview==&lt;br /&gt;
&lt;br /&gt;
==Database Preparation==&lt;br /&gt;
&lt;br /&gt;
==UI Tests==&lt;br /&gt;
&lt;br /&gt;
==Backend API Tests==&lt;br /&gt;
&lt;br /&gt;
==Tables and Test Coverage==&lt;br /&gt;
&lt;br /&gt;
==Adhering to Priciples==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164224</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164224"/>
		<updated>2025-04-20T18:37:09Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* UI */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of this project is to integrate the frontend of the grades view page with the reimplemented '''''grades_controller.rb (E2510)''''' backend in Expertiza, ensuring a seamless connection between both layers. This integration involves refining the interaction between the UI and backend while adhering to best design principles such as modularity, maintainability, and scalability. The grades_controller.rb is responsible for managing grading functionality, allowing instructors to view and modify assignment grades while enabling students to access their evaluations. By following SOLID and DRY principles, this reimplementation enhances code clarity, reduces redundancy, and improves overall system efficiency.&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
The &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; is responsible for managing and delivering grading data to users in the Expertiza system. It enables instructors to view, calculate, and release grades to students, while also allowing students to view feedback and scores for assignments. The controller plays an important role in coordinating backend logic for reviews and grade visibility.&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
The previous implementation successfully created a functional frontend UI page in Expertiza, addressing design inconsistencies and improving usability. It introduced a visually cohesive interface with an intuitive layout, enhanced responsiveness, and improved information display, allowing users to navigate grading data more efficiently. However, the interface was populated using dummy data, limiting its practical use. This reimplemented UI will utilize real data from the database (that has been populated in this round), ensuring that grading information is dynamically retrieved and displayed accurately through JSON objects. Additionally, this phase will connect the redesigned frontend with some new components in the grades_controller.rb. Specifically, the GET functions in the grades_controller were reimplemented to return JSON objects (instead of instance variables) that could be accessed via an API call. Thus, this new implementation ensures seamless communication between the UI and backend while adhering to best design practices for maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
This project focuses on integrating the frontend of the grades view page with the reimplemented '''grades_controller.rb (E2510)''' backend in Expertiza. This integration requires modifications to both the frontend and backend to establish a seamless connection, ensuring that grading data is dynamically retrieved and displayed accurately. By adhering to best design principles such as modularity, maintainability, and scalability, the implementation will enhance system efficiency and long-term usability. Key improvements include replacing dummy data with real database values, refining data flow between the UI and backend, and optimizing API interactions for better performance. These enhancements will create a more intuitive and reliable grading system, providing a seamless experience for instructors and students while maintaining a well-structured and adaptable codebase for future development.&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
# '''Establish a Robust Connection Between the Frontend and Backend''': Ensure smooth data retrieval and updates between the grades view page and the backend by integrating dynamic data through API calls, replacing the current hardcoded dummy data.&lt;br /&gt;
# '''Define and Implement Clear API Endpoints''': Create well-structured API endpoints in grades_controller.rb for retrieving and displaying grades, ensuring they return appropriate data based on user roles (students, instructors, TAs) and maintain role-based access controls.&lt;br /&gt;
# '''Dynamic Data Integration''': Modify the frontend to consume real-time data fetched from the backend, ensuring an intuitive and responsive UI that reflects the actual grading information. &lt;br /&gt;
# '''Refactor Frontend and Backend Components''': Refactor both the frontend and backend as necessary to align with SOLID and DRY principles, ensuring modularity, maintainability, and scalability. This includes eliminating redundant logic and optimizing code for better readability.&lt;br /&gt;
# '''Implement Proper Permission Checks''': Ensure that only authorized users can access grade information by implementing robust privilege checks and ensuring that the data is securely accessible to students, instructors, and TAs based on their roles.&lt;br /&gt;
# '''Optimize Database Queries and API Responses''': Enhance the efficiency of database queries and API responses to reduce unnecessary load and ensure that data is retrieved and displayed promptly.&lt;br /&gt;
# '''Testing and Validation''': Implement comprehensive unit and integration tests to verify the correctness of data flow, UI interactions, and role-based access controls, ensuring that the system functions correctly and securely.&lt;br /&gt;
&lt;br /&gt;
=Reimplementation Plan=&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populated data with the appropriate HTTP GET and HTTP POST calls. This shift is necessary to ensure that our application reflects real-time data from the backend rather than relying on static or hardcoded values, which can quickly become outdated or inconsistent. It also enables better scalability and maintainability, as changes to the data only need to be made in the backend, without requiring manual updates in the frontend code.&lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
'''Author Feedback''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
'''Heatmap Data''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
'''Team-mate Data''':&lt;br /&gt;
   {&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The current implementation caters to the backend for a Ruby-embedded front-end, where data is rendered server-side and passed directly into the view. We need to update the APIs to return data in a format that can be consumed by the React UI, typically JSON. This shift is essential to decouple the front-end from the server-side rendering logic, allowing for a more interactive and dynamic user experience. By transitioning to a React-based interface, we gain better control over UI state and responsiveness, while also aligning with modern web development practices. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and instead return plain JSON objects using render json: in the response. This change is necessary to align with a frontend architecture that uses React or another JavaScript framework, which expects structured data from the backend in JSON format rather than relying on server-rendered templates. By shifting to JSON responses, we enable cleaner API endpoints, facilitate easier testing and debugging, and support a more maintainable, decoupled frontend-backend integration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    # prepare feedback summaries&lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
  1.1. Students&lt;br /&gt;
  1.2. Teams&lt;br /&gt;
  1.3. TA&lt;br /&gt;
  1.4. Professor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
  2.1 assignments&lt;br /&gt;
  2.2 assignment_questionnaire&lt;br /&gt;
  2.3 questionnaires&lt;br /&gt;
  2.4 participant&lt;br /&gt;
  2.5 signed_up_teams&lt;br /&gt;
  2.6 teams_users&lt;br /&gt;
  2.7 due_dates&lt;br /&gt;
  2.8 late_policies&lt;br /&gt;
  2.9 questions&lt;br /&gt;
  2.10 review_scores&lt;br /&gt;
  2.11 review_grades&lt;br /&gt;
&lt;br /&gt;
== Data Flow Overview ==&lt;br /&gt;
The diagram below illustrates how data flows between the frontend React components and the grades_controller.rb backend during a typical grading data fetch operation.&lt;br /&gt;
&lt;br /&gt;
* The user (e.g., instructor or student) interacts with the React-based grades view (e.g., ReviewTable, RoundSelector, or Statistics).&lt;br /&gt;
* The component triggers an API request to a specific action in grades_controller.rb (e.g., GET /grades/:id/summary).&lt;br /&gt;
*The controller action queries the relevant models (e.g., Assignment, Team, ReviewResponseMap) and compiles a JSON response.&lt;br /&gt;
* The response is sent back to the frontend and parsed.&lt;br /&gt;
*The React components update the UI (tables, heatmaps, statistics) based on the received data.&lt;br /&gt;
&lt;br /&gt;
This architecture ensures a clean separation between frontend and backend logic, improving maintainability and testability.&lt;br /&gt;
[[File:Dataflow.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
The test plan for Phase 2 focuses on verifying the successful integration of the newly reimplemented &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the React-based UI components. We aim to ensure data is:&lt;br /&gt;
&lt;br /&gt;
* Correctly fetched from the backend  &lt;br /&gt;
* Appropriately displayed in the frontend  &lt;br /&gt;
* Functionally sound under both normal and edge-case scenarios&lt;br /&gt;
&lt;br /&gt;
== Tools and Frameworks ==&lt;br /&gt;
We plan to use the following tools and frameworks for testing:&lt;br /&gt;
&lt;br /&gt;
* '''Frontend''': Jest and React Testing Library for unit and integration tests&lt;br /&gt;
* '''Backend''': RSpec for controller and model tests&lt;br /&gt;
* '''Integration Testing''': Capybara and Selenium for simulating real user behavior&lt;br /&gt;
* '''Test Coverage''': SimpleCov&lt;br /&gt;
&lt;br /&gt;
== 1. UI Integration Tests ==&lt;br /&gt;
&lt;br /&gt;
These tests ensure the frontend correctly interacts with backend APIs and renders the data appropriately.&lt;br /&gt;
&lt;br /&gt;
=== ReviewTable Component ===&lt;br /&gt;
&lt;br /&gt;
* Validate that the component makes a successful API call to fetch author feedback  &lt;br /&gt;
* Ensure feedback is rendered in the correct table structure  &lt;br /&gt;
* Test loading state before data is fetched  &lt;br /&gt;
* Handle empty or malformed feedback responses gracefully  &lt;br /&gt;
&lt;br /&gt;
=== RoundSelector Component ===&lt;br /&gt;
&lt;br /&gt;
* Verify API call to fetch heatmap data is triggered on component load  &lt;br /&gt;
* Check that heatmap data is correctly visualized for different review rounds  &lt;br /&gt;
* Test behavior with no data, incomplete data, or delayed response  &lt;br /&gt;
&lt;br /&gt;
=== Statistics Component ===&lt;br /&gt;
&lt;br /&gt;
* Confirm it correctly fetches teammate evaluations and author feedback  &lt;br /&gt;
* Ensure charts or tables reflect the received backend data accurately  &lt;br /&gt;
* Test switching between different teams or assignments and verify correct display  &lt;br /&gt;
&lt;br /&gt;
=== General UI Considerations ===&lt;br /&gt;
&lt;br /&gt;
* Test frontend responsiveness to backend failures (500, 404, timeout)  &lt;br /&gt;
* Ensure authorization errors are handled and appropriate messages displayed  &lt;br /&gt;
&lt;br /&gt;
== 2. Backend API Tests ==&lt;br /&gt;
&lt;br /&gt;
While unit tests exist, integration-level tests will be added or updated to ensure UI compatibility.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
* Validate all &amp;lt;code&amp;gt;GET&amp;lt;/code&amp;gt; endpoints return properly structured JSON objects  &lt;br /&gt;
* Simulate various user roles (student, TA, instructor) and ensure access control  &lt;br /&gt;
* Include test cases for:&lt;br /&gt;
** No grades present  &lt;br /&gt;
** Partial data (e.g. missing feedback or evaluations)  &lt;br /&gt;
** Large number of records  &lt;br /&gt;
&lt;br /&gt;
=== Security &amp;amp; Permissions ===&lt;br /&gt;
&lt;br /&gt;
* Ensure students can only fetch their grades and feedback  &lt;br /&gt;
* Ensure TAs and instructors can access full assignment data  &lt;br /&gt;
* Test token/session-based access restrictions (if applicable)  &lt;br /&gt;
&lt;br /&gt;
== 3. Database Preparation ==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, seed data will simulate real-world usage and we will ensure that:&lt;br /&gt;
* Tests will use isolated fixtures or factories to ensure data consistency&lt;br /&gt;
* All database states will be reset before each test suite run&lt;br /&gt;
&lt;br /&gt;
=== Tables and Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;assignments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_participant&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;participants&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;questionnaires&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;questions&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_questionnaire&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;signed_up_teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;teams_users&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;late_policies&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
=== Scenarios ===&lt;br /&gt;
&lt;br /&gt;
* Single student assigned  &lt;br /&gt;
* Team assignments with/without feedback  &lt;br /&gt;
* Late submissions triggering late policies  &lt;br /&gt;
* Multiple review rounds per assignment&lt;br /&gt;
&lt;br /&gt;
== 4. Regression &amp;amp; CI Testing ==&lt;br /&gt;
&lt;br /&gt;
To ensure updates do not break existing functionality:&lt;br /&gt;
&lt;br /&gt;
* Re-run all existing unit tests  &lt;br /&gt;
* Include snapshot tests for frontend components  &lt;br /&gt;
* Use CI pipelines to automatically trigger tests on pull requests  &lt;br /&gt;
&lt;br /&gt;
== Test Plan Summary ==&lt;br /&gt;
&lt;br /&gt;
This test plan outlines the approach for integrating &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the frontend. By combining backend tests, UI integration checks, and realistic database scenarios, we aim to deliver a seamless user experience. The plan emphasizes early detection of issues and supports long-term maintainability through regression testing. As development progresses, the plan will be updated to cover new insights and edge cases.&lt;br /&gt;
&lt;br /&gt;
=Completed Reimplementation Details=&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The previous implementation was designed for a Ruby-embedded front-end, where data was rendered server-side and injected directly into the view. We have since updated the APIs to return data in a format suitable for consumption by the React UI, typically as JSON objects. This change successfully decouples the front-end from the server-side rendering logic, enabling a more interactive and responsive user experience. By transitioning to a React-based interface, we now have improved control over UI state and better alignment with modern web development practices.&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
In this controller, we have updated the GET functions to remove the use of instance variables and instead return plain JSON objects using render json: in the response. This update was essential to align with the frontend architecture, which now relies on a React-based interface that expects structured data from the backend in JSON format rather than server-rendered templates. By returning JSON responses, we’ve established cleaner and more consistent API endpoints, improved the testability and debuggability of our backend logic, and created a more maintainable and decoupled integration between the frontend and backend systems. The following functions were updated as part of this integration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  def view_grading_report&lt;br /&gt;
    assignment_id = params[:id].to_i&lt;br /&gt;
    data = get_data_for_heat_map(assignment_id)&lt;br /&gt;
    &lt;br /&gt;
    render json: data, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
    &lt;br /&gt;
  def view_my_scores&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team_id = TeamsUser.team_id(participant.assignment_id, participant.user_id)&lt;br /&gt;
    # return if redirect_when_disallowed(participant)&lt;br /&gt;
    questions = fetch_questionnaires_and_questions(assignment)&lt;br /&gt;
    pscore = fetch_participant_scores(participant, questions)&lt;br /&gt;
    topic_id = SignedUpTeam.find_topic_id_for_user(participant.assignment.id, participant.user_id)&lt;br /&gt;
    stage = participant.assignment.current_stage(topic_id)&lt;br /&gt;
    # all_penalties = update_penalties(assignment)&lt;br /&gt;
    # Feedback Summary needs to be checked once&lt;br /&gt;
    # summary_ws_url = WEBSERVICE_CONFIG['summary_webservice_url']&lt;br /&gt;
    sum = SummaryHelper::Summary.new.summarize_reviews_by_reviewee(questions, assignment, team_id, 'http://peerlogic.csc.ncsu.edu/sum/v1.0/summary/8/lsa', session)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      topic_id: topic_id,&lt;br /&gt;
      stage: stage,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      summary: sum.summary,&lt;br /&gt;
      avg_scores_by_round: sum.avg_scores_by_round,&lt;br /&gt;
      avg_scores_by_criterion: sum.avg_scores_by_criterion&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def view_team&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    team_id = team.id&lt;br /&gt;
  &lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: assignment.id).map(&amp;amp;:questionnaire)&lt;br /&gt;
    questions = retrieve_questions(questionnaires, assignment.id)&lt;br /&gt;
    pscore = Response.participant_scores(participant, questions)&lt;br /&gt;
    vmlist = process_questionare_for_team(assignment, team_id,questionnaires, team, participant)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team: team,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      vmlist: vmlist&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These updates were important for the backend and ensured seamless communication with the React frontend. By removing instance variables and returning structured JSON responses, we eliminated dependencies on server-side rendering and enabled the frontend to dynamically manage and render data. This not only enhances performance and flexibility but also improves maintainability and scalability as the application evolves. Moreover, it allows the backend and frontend to evolve independently, supporting better separation of concerns and aligning with current best practices in full-stack web development.&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We have successfully  reimplemented the previously pre-populated data with appropriate HTTP GET calls to the backend. This ensures that our application now reflects real-time data directly from the server, improving data accuracy and consistency across the UI. This update also enhances scalability and maintainability, as the frontend no longer depends on static content and can adapt to backend changes without manual intervention.&lt;br /&gt;
&lt;br /&gt;
All dummy data throughout these components has been successfully removed and replaced with real-time API integrations. This transition allows for a fully dynamic, data-driven React frontend that remains synchronized with backend updates and user interactions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Files and components that were updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' &lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:'''&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
==Data Flow Overview==&lt;br /&gt;
&lt;br /&gt;
=Testing=&lt;br /&gt;
&lt;br /&gt;
==Testing Overview==&lt;br /&gt;
&lt;br /&gt;
==Database Preparation==&lt;br /&gt;
&lt;br /&gt;
==UI Tests==&lt;br /&gt;
&lt;br /&gt;
==Backend API Tests==&lt;br /&gt;
&lt;br /&gt;
==Tables and Test Coverage==&lt;br /&gt;
&lt;br /&gt;
==Adhering to Priciples==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164223</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164223"/>
		<updated>2025-04-20T18:28:48Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of this project is to integrate the frontend of the grades view page with the reimplemented '''''grades_controller.rb (E2510)''''' backend in Expertiza, ensuring a seamless connection between both layers. This integration involves refining the interaction between the UI and backend while adhering to best design principles such as modularity, maintainability, and scalability. The grades_controller.rb is responsible for managing grading functionality, allowing instructors to view and modify assignment grades while enabling students to access their evaluations. By following SOLID and DRY principles, this reimplementation enhances code clarity, reduces redundancy, and improves overall system efficiency.&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
The &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; is responsible for managing and delivering grading data to users in the Expertiza system. It enables instructors to view, calculate, and release grades to students, while also allowing students to view feedback and scores for assignments. The controller plays an important role in coordinating backend logic for reviews and grade visibility.&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
The previous implementation successfully created a functional frontend UI page in Expertiza, addressing design inconsistencies and improving usability. It introduced a visually cohesive interface with an intuitive layout, enhanced responsiveness, and improved information display, allowing users to navigate grading data more efficiently. However, the interface was populated using dummy data, limiting its practical use. This reimplemented UI will utilize real data from the database (that has been populated in this round), ensuring that grading information is dynamically retrieved and displayed accurately through JSON objects. Additionally, this phase will connect the redesigned frontend with some new components in the grades_controller.rb. Specifically, the GET functions in the grades_controller were reimplemented to return JSON objects (instead of instance variables) that could be accessed via an API call. Thus, this new implementation ensures seamless communication between the UI and backend while adhering to best design practices for maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
This project focuses on integrating the frontend of the grades view page with the reimplemented '''grades_controller.rb (E2510)''' backend in Expertiza. This integration requires modifications to both the frontend and backend to establish a seamless connection, ensuring that grading data is dynamically retrieved and displayed accurately. By adhering to best design principles such as modularity, maintainability, and scalability, the implementation will enhance system efficiency and long-term usability. Key improvements include replacing dummy data with real database values, refining data flow between the UI and backend, and optimizing API interactions for better performance. These enhancements will create a more intuitive and reliable grading system, providing a seamless experience for instructors and students while maintaining a well-structured and adaptable codebase for future development.&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
# '''Establish a Robust Connection Between the Frontend and Backend''': Ensure smooth data retrieval and updates between the grades view page and the backend by integrating dynamic data through API calls, replacing the current hardcoded dummy data.&lt;br /&gt;
# '''Define and Implement Clear API Endpoints''': Create well-structured API endpoints in grades_controller.rb for retrieving and displaying grades, ensuring they return appropriate data based on user roles (students, instructors, TAs) and maintain role-based access controls.&lt;br /&gt;
# '''Dynamic Data Integration''': Modify the frontend to consume real-time data fetched from the backend, ensuring an intuitive and responsive UI that reflects the actual grading information. &lt;br /&gt;
# '''Refactor Frontend and Backend Components''': Refactor both the frontend and backend as necessary to align with SOLID and DRY principles, ensuring modularity, maintainability, and scalability. This includes eliminating redundant logic and optimizing code for better readability.&lt;br /&gt;
# '''Implement Proper Permission Checks''': Ensure that only authorized users can access grade information by implementing robust privilege checks and ensuring that the data is securely accessible to students, instructors, and TAs based on their roles.&lt;br /&gt;
# '''Optimize Database Queries and API Responses''': Enhance the efficiency of database queries and API responses to reduce unnecessary load and ensure that data is retrieved and displayed promptly.&lt;br /&gt;
# '''Testing and Validation''': Implement comprehensive unit and integration tests to verify the correctness of data flow, UI interactions, and role-based access controls, ensuring that the system functions correctly and securely.&lt;br /&gt;
&lt;br /&gt;
=Reimplementation Plan=&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populated data with the appropriate HTTP GET and HTTP POST calls. This shift is necessary to ensure that our application reflects real-time data from the backend rather than relying on static or hardcoded values, which can quickly become outdated or inconsistent. It also enables better scalability and maintainability, as changes to the data only need to be made in the backend, without requiring manual updates in the frontend code.&lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
'''Author Feedback''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
'''Heatmap Data''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
'''Team-mate Data''':&lt;br /&gt;
   {&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The current implementation caters to the backend for a Ruby-embedded front-end, where data is rendered server-side and passed directly into the view. We need to update the APIs to return data in a format that can be consumed by the React UI, typically JSON. This shift is essential to decouple the front-end from the server-side rendering logic, allowing for a more interactive and dynamic user experience. By transitioning to a React-based interface, we gain better control over UI state and responsiveness, while also aligning with modern web development practices. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and instead return plain JSON objects using render json: in the response. This change is necessary to align with a frontend architecture that uses React or another JavaScript framework, which expects structured data from the backend in JSON format rather than relying on server-rendered templates. By shifting to JSON responses, we enable cleaner API endpoints, facilitate easier testing and debugging, and support a more maintainable, decoupled frontend-backend integration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    # prepare feedback summaries&lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
  1.1. Students&lt;br /&gt;
  1.2. Teams&lt;br /&gt;
  1.3. TA&lt;br /&gt;
  1.4. Professor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
  2.1 assignments&lt;br /&gt;
  2.2 assignment_questionnaire&lt;br /&gt;
  2.3 questionnaires&lt;br /&gt;
  2.4 participant&lt;br /&gt;
  2.5 signed_up_teams&lt;br /&gt;
  2.6 teams_users&lt;br /&gt;
  2.7 due_dates&lt;br /&gt;
  2.8 late_policies&lt;br /&gt;
  2.9 questions&lt;br /&gt;
  2.10 review_scores&lt;br /&gt;
  2.11 review_grades&lt;br /&gt;
&lt;br /&gt;
== Data Flow Overview ==&lt;br /&gt;
The diagram below illustrates how data flows between the frontend React components and the grades_controller.rb backend during a typical grading data fetch operation.&lt;br /&gt;
&lt;br /&gt;
* The user (e.g., instructor or student) interacts with the React-based grades view (e.g., ReviewTable, RoundSelector, or Statistics).&lt;br /&gt;
* The component triggers an API request to a specific action in grades_controller.rb (e.g., GET /grades/:id/summary).&lt;br /&gt;
*The controller action queries the relevant models (e.g., Assignment, Team, ReviewResponseMap) and compiles a JSON response.&lt;br /&gt;
* The response is sent back to the frontend and parsed.&lt;br /&gt;
*The React components update the UI (tables, heatmaps, statistics) based on the received data.&lt;br /&gt;
&lt;br /&gt;
This architecture ensures a clean separation between frontend and backend logic, improving maintainability and testability.&lt;br /&gt;
[[File:Dataflow.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
The test plan for Phase 2 focuses on verifying the successful integration of the newly reimplemented &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the React-based UI components. We aim to ensure data is:&lt;br /&gt;
&lt;br /&gt;
* Correctly fetched from the backend  &lt;br /&gt;
* Appropriately displayed in the frontend  &lt;br /&gt;
* Functionally sound under both normal and edge-case scenarios&lt;br /&gt;
&lt;br /&gt;
== Tools and Frameworks ==&lt;br /&gt;
We plan to use the following tools and frameworks for testing:&lt;br /&gt;
&lt;br /&gt;
* '''Frontend''': Jest and React Testing Library for unit and integration tests&lt;br /&gt;
* '''Backend''': RSpec for controller and model tests&lt;br /&gt;
* '''Integration Testing''': Capybara and Selenium for simulating real user behavior&lt;br /&gt;
* '''Test Coverage''': SimpleCov&lt;br /&gt;
&lt;br /&gt;
== 1. UI Integration Tests ==&lt;br /&gt;
&lt;br /&gt;
These tests ensure the frontend correctly interacts with backend APIs and renders the data appropriately.&lt;br /&gt;
&lt;br /&gt;
=== ReviewTable Component ===&lt;br /&gt;
&lt;br /&gt;
* Validate that the component makes a successful API call to fetch author feedback  &lt;br /&gt;
* Ensure feedback is rendered in the correct table structure  &lt;br /&gt;
* Test loading state before data is fetched  &lt;br /&gt;
* Handle empty or malformed feedback responses gracefully  &lt;br /&gt;
&lt;br /&gt;
=== RoundSelector Component ===&lt;br /&gt;
&lt;br /&gt;
* Verify API call to fetch heatmap data is triggered on component load  &lt;br /&gt;
* Check that heatmap data is correctly visualized for different review rounds  &lt;br /&gt;
* Test behavior with no data, incomplete data, or delayed response  &lt;br /&gt;
&lt;br /&gt;
=== Statistics Component ===&lt;br /&gt;
&lt;br /&gt;
* Confirm it correctly fetches teammate evaluations and author feedback  &lt;br /&gt;
* Ensure charts or tables reflect the received backend data accurately  &lt;br /&gt;
* Test switching between different teams or assignments and verify correct display  &lt;br /&gt;
&lt;br /&gt;
=== General UI Considerations ===&lt;br /&gt;
&lt;br /&gt;
* Test frontend responsiveness to backend failures (500, 404, timeout)  &lt;br /&gt;
* Ensure authorization errors are handled and appropriate messages displayed  &lt;br /&gt;
&lt;br /&gt;
== 2. Backend API Tests ==&lt;br /&gt;
&lt;br /&gt;
While unit tests exist, integration-level tests will be added or updated to ensure UI compatibility.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
* Validate all &amp;lt;code&amp;gt;GET&amp;lt;/code&amp;gt; endpoints return properly structured JSON objects  &lt;br /&gt;
* Simulate various user roles (student, TA, instructor) and ensure access control  &lt;br /&gt;
* Include test cases for:&lt;br /&gt;
** No grades present  &lt;br /&gt;
** Partial data (e.g. missing feedback or evaluations)  &lt;br /&gt;
** Large number of records  &lt;br /&gt;
&lt;br /&gt;
=== Security &amp;amp; Permissions ===&lt;br /&gt;
&lt;br /&gt;
* Ensure students can only fetch their grades and feedback  &lt;br /&gt;
* Ensure TAs and instructors can access full assignment data  &lt;br /&gt;
* Test token/session-based access restrictions (if applicable)  &lt;br /&gt;
&lt;br /&gt;
== 3. Database Preparation ==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, seed data will simulate real-world usage and we will ensure that:&lt;br /&gt;
* Tests will use isolated fixtures or factories to ensure data consistency&lt;br /&gt;
* All database states will be reset before each test suite run&lt;br /&gt;
&lt;br /&gt;
=== Tables and Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;assignments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_participant&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;participants&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;questionnaires&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;questions&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_questionnaire&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;signed_up_teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;teams_users&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;late_policies&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
=== Scenarios ===&lt;br /&gt;
&lt;br /&gt;
* Single student assigned  &lt;br /&gt;
* Team assignments with/without feedback  &lt;br /&gt;
* Late submissions triggering late policies  &lt;br /&gt;
* Multiple review rounds per assignment&lt;br /&gt;
&lt;br /&gt;
== 4. Regression &amp;amp; CI Testing ==&lt;br /&gt;
&lt;br /&gt;
To ensure updates do not break existing functionality:&lt;br /&gt;
&lt;br /&gt;
* Re-run all existing unit tests  &lt;br /&gt;
* Include snapshot tests for frontend components  &lt;br /&gt;
* Use CI pipelines to automatically trigger tests on pull requests  &lt;br /&gt;
&lt;br /&gt;
== Test Plan Summary ==&lt;br /&gt;
&lt;br /&gt;
This test plan outlines the approach for integrating &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the frontend. By combining backend tests, UI integration checks, and realistic database scenarios, we aim to deliver a seamless user experience. The plan emphasizes early detection of issues and supports long-term maintainability through regression testing. As development progresses, the plan will be updated to cover new insights and edge cases.&lt;br /&gt;
&lt;br /&gt;
=Completed Reimplementation Details=&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The previous implementation was designed for a Ruby-embedded front-end, where data was rendered server-side and injected directly into the view. We have since updated the APIs to return data in a format suitable for consumption by the React UI, typically as JSON objects. This change successfully decouples the front-end from the server-side rendering logic, enabling a more interactive and responsive user experience. By transitioning to a React-based interface, we now have improved control over UI state and better alignment with modern web development practices.&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
In this controller, we have updated the GET functions to remove the use of instance variables and instead return plain JSON objects using render json: in the response. This update was essential to align with the frontend architecture, which now relies on a React-based interface that expects structured data from the backend in JSON format rather than server-rendered templates. By returning JSON responses, we’ve established cleaner and more consistent API endpoints, improved the testability and debuggability of our backend logic, and created a more maintainable and decoupled integration between the frontend and backend systems. The following functions were updated as part of this integration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  def view_grading_report&lt;br /&gt;
    assignment_id = params[:id].to_i&lt;br /&gt;
    data = get_data_for_heat_map(assignment_id)&lt;br /&gt;
    &lt;br /&gt;
    render json: data, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
    &lt;br /&gt;
  def view_my_scores&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team_id = TeamsUser.team_id(participant.assignment_id, participant.user_id)&lt;br /&gt;
    # return if redirect_when_disallowed(participant)&lt;br /&gt;
    questions = fetch_questionnaires_and_questions(assignment)&lt;br /&gt;
    pscore = fetch_participant_scores(participant, questions)&lt;br /&gt;
    topic_id = SignedUpTeam.find_topic_id_for_user(participant.assignment.id, participant.user_id)&lt;br /&gt;
    stage = participant.assignment.current_stage(topic_id)&lt;br /&gt;
    # all_penalties = update_penalties(assignment)&lt;br /&gt;
    # Feedback Summary needs to be checked once&lt;br /&gt;
    # summary_ws_url = WEBSERVICE_CONFIG['summary_webservice_url']&lt;br /&gt;
    sum = SummaryHelper::Summary.new.summarize_reviews_by_reviewee(questions, assignment, team_id, 'http://peerlogic.csc.ncsu.edu/sum/v1.0/summary/8/lsa', session)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      topic_id: topic_id,&lt;br /&gt;
      stage: stage,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      summary: sum.summary,&lt;br /&gt;
      avg_scores_by_round: sum.avg_scores_by_round,&lt;br /&gt;
      avg_scores_by_criterion: sum.avg_scores_by_criterion&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def view_team&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    team_id = team.id&lt;br /&gt;
  &lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: assignment.id).map(&amp;amp;:questionnaire)&lt;br /&gt;
    questions = retrieve_questions(questionnaires, assignment.id)&lt;br /&gt;
    pscore = Response.participant_scores(participant, questions)&lt;br /&gt;
    vmlist = process_questionare_for_team(assignment, team_id,questionnaires, team, participant)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team: team,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      vmlist: vmlist&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These updates were important for the backend and ensured seamless communication with the React frontend. By removing instance variables and returning structured JSON responses, we eliminated dependencies on server-side rendering and enabled the frontend to dynamically manage and render data. This not only enhances performance and flexibility but also improves maintainability and scalability as the application evolves. Moreover, it allows the backend and frontend to evolve independently, supporting better separation of concerns and aligning with current best practices in full-stack web development.&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
==Data Flow Overview==&lt;br /&gt;
&lt;br /&gt;
=Testing=&lt;br /&gt;
&lt;br /&gt;
==Testing Overview==&lt;br /&gt;
&lt;br /&gt;
==Database Preparation==&lt;br /&gt;
&lt;br /&gt;
==UI Tests==&lt;br /&gt;
&lt;br /&gt;
==Backend API Tests==&lt;br /&gt;
&lt;br /&gt;
==Tables and Test Coverage==&lt;br /&gt;
&lt;br /&gt;
==Adhering to Priciples==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164222</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164222"/>
		<updated>2025-04-20T18:26:57Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of this project is to integrate the frontend of the grades view page with the reimplemented '''''grades_controller.rb (E2510)''''' backend in Expertiza, ensuring a seamless connection between both layers. This integration involves refining the interaction between the UI and backend while adhering to best design principles such as modularity, maintainability, and scalability. The grades_controller.rb is responsible for managing grading functionality, allowing instructors to view and modify assignment grades while enabling students to access their evaluations. By following SOLID and DRY principles, this reimplementation enhances code clarity, reduces redundancy, and improves overall system efficiency.&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
The &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; is responsible for managing and delivering grading data to users in the Expertiza system. It enables instructors to view, calculate, and release grades to students, while also allowing students to view feedback and scores for assignments. The controller plays an important role in coordinating backend logic for reviews and grade visibility.&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
The previous implementation successfully created a functional frontend UI page in Expertiza, addressing design inconsistencies and improving usability. It introduced a visually cohesive interface with an intuitive layout, enhanced responsiveness, and improved information display, allowing users to navigate grading data more efficiently. However, the interface was populated using dummy data, limiting its practical use. This reimplemented UI will utilize real data from the database (that has been populated in this round), ensuring that grading information is dynamically retrieved and displayed accurately through JSON objects. Additionally, this phase will connect the redesigned frontend with some new components in the grades_controller.rb. Specifically, the GET functions in the grades_controller were reimplemented to return JSON objects (instead of instance variables) that could be accessed via an API call. Thus, this new implementation ensures seamless communication between the UI and backend while adhering to best design practices for maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
This project focuses on integrating the frontend of the grades view page with the reimplemented '''grades_controller.rb (E2510)''' backend in Expertiza. This integration requires modifications to both the frontend and backend to establish a seamless connection, ensuring that grading data is dynamically retrieved and displayed accurately. By adhering to best design principles such as modularity, maintainability, and scalability, the implementation will enhance system efficiency and long-term usability. Key improvements include replacing dummy data with real database values, refining data flow between the UI and backend, and optimizing API interactions for better performance. These enhancements will create a more intuitive and reliable grading system, providing a seamless experience for instructors and students while maintaining a well-structured and adaptable codebase for future development.&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
# '''Establish a Robust Connection Between the Frontend and Backend''': Ensure smooth data retrieval and updates between the grades view page and the backend by integrating dynamic data through API calls, replacing the current hardcoded dummy data.&lt;br /&gt;
# '''Define and Implement Clear API Endpoints''': Create well-structured API endpoints in grades_controller.rb for retrieving and displaying grades, ensuring they return appropriate data based on user roles (students, instructors, TAs) and maintain role-based access controls.&lt;br /&gt;
# '''Dynamic Data Integration''': Modify the frontend to consume real-time data fetched from the backend, ensuring an intuitive and responsive UI that reflects the actual grading information. &lt;br /&gt;
# '''Refactor Frontend and Backend Components''': Refactor both the frontend and backend as necessary to align with SOLID and DRY principles, ensuring modularity, maintainability, and scalability. This includes eliminating redundant logic and optimizing code for better readability.&lt;br /&gt;
# '''Implement Proper Permission Checks''': Ensure that only authorized users can access grade information by implementing robust privilege checks and ensuring that the data is securely accessible to students, instructors, and TAs based on their roles.&lt;br /&gt;
# '''Optimize Database Queries and API Responses''': Enhance the efficiency of database queries and API responses to reduce unnecessary load and ensure that data is retrieved and displayed promptly.&lt;br /&gt;
# '''Testing and Validation''': Implement comprehensive unit and integration tests to verify the correctness of data flow, UI interactions, and role-based access controls, ensuring that the system functions correctly and securely.&lt;br /&gt;
&lt;br /&gt;
=Reimplementation Plan=&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populated data with the appropriate HTTP GET and HTTP POST calls. This shift is necessary to ensure that our application reflects real-time data from the backend rather than relying on static or hardcoded values, which can quickly become outdated or inconsistent. It also enables better scalability and maintainability, as changes to the data only need to be made in the backend, without requiring manual updates in the frontend code.&lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
'''Author Feedback''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
'''Heatmap Data''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
'''Team-mate Data''':&lt;br /&gt;
   {&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The current implementation caters to the backend for a Ruby-embedded front-end, where data is rendered server-side and passed directly into the view. We need to update the APIs to return data in a format that can be consumed by the React UI, typically JSON. This shift is essential to decouple the front-end from the server-side rendering logic, allowing for a more interactive and dynamic user experience. By transitioning to a React-based interface, we gain better control over UI state and responsiveness, while also aligning with modern web development practices. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and instead return plain JSON objects using render json: in the response. This change is necessary to align with a frontend architecture that uses React or another JavaScript framework, which expects structured data from the backend in JSON format rather than relying on server-rendered templates. By shifting to JSON responses, we enable cleaner API endpoints, facilitate easier testing and debugging, and support a more maintainable, decoupled frontend-backend integration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    # prepare feedback summaries&lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
  1.1. Students&lt;br /&gt;
  1.2. Teams&lt;br /&gt;
  1.3. TA&lt;br /&gt;
  1.4. Professor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
  2.1 assignments&lt;br /&gt;
  2.2 assignment_questionnaire&lt;br /&gt;
  2.3 questionnaires&lt;br /&gt;
  2.4 participant&lt;br /&gt;
  2.5 signed_up_teams&lt;br /&gt;
  2.6 teams_users&lt;br /&gt;
  2.7 due_dates&lt;br /&gt;
  2.8 late_policies&lt;br /&gt;
  2.9 questions&lt;br /&gt;
  2.10 review_scores&lt;br /&gt;
  2.11 review_grades&lt;br /&gt;
&lt;br /&gt;
== Data Flow Overview ==&lt;br /&gt;
The diagram below illustrates how data flows between the frontend React components and the grades_controller.rb backend during a typical grading data fetch operation.&lt;br /&gt;
&lt;br /&gt;
* The user (e.g., instructor or student) interacts with the React-based grades view (e.g., ReviewTable, RoundSelector, or Statistics).&lt;br /&gt;
* The component triggers an API request to a specific action in grades_controller.rb (e.g., GET /grades/:id/summary).&lt;br /&gt;
*The controller action queries the relevant models (e.g., Assignment, Team, ReviewResponseMap) and compiles a JSON response.&lt;br /&gt;
* The response is sent back to the frontend and parsed.&lt;br /&gt;
*The React components update the UI (tables, heatmaps, statistics) based on the received data.&lt;br /&gt;
&lt;br /&gt;
This architecture ensures a clean separation between frontend and backend logic, improving maintainability and testability.&lt;br /&gt;
[[File:Dataflow.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
The test plan for Phase 2 focuses on verifying the successful integration of the newly reimplemented &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the React-based UI components. We aim to ensure data is:&lt;br /&gt;
&lt;br /&gt;
* Correctly fetched from the backend  &lt;br /&gt;
* Appropriately displayed in the frontend  &lt;br /&gt;
* Functionally sound under both normal and edge-case scenarios&lt;br /&gt;
&lt;br /&gt;
== Tools and Frameworks ==&lt;br /&gt;
We plan to use the following tools and frameworks for testing:&lt;br /&gt;
&lt;br /&gt;
* '''Frontend''': Jest and React Testing Library for unit and integration tests&lt;br /&gt;
* '''Backend''': RSpec for controller and model tests&lt;br /&gt;
* '''Integration Testing''': Capybara and Selenium for simulating real user behavior&lt;br /&gt;
* '''Test Coverage''': SimpleCov&lt;br /&gt;
&lt;br /&gt;
== 1. UI Integration Tests ==&lt;br /&gt;
&lt;br /&gt;
These tests ensure the frontend correctly interacts with backend APIs and renders the data appropriately.&lt;br /&gt;
&lt;br /&gt;
=== ReviewTable Component ===&lt;br /&gt;
&lt;br /&gt;
* Validate that the component makes a successful API call to fetch author feedback  &lt;br /&gt;
* Ensure feedback is rendered in the correct table structure  &lt;br /&gt;
* Test loading state before data is fetched  &lt;br /&gt;
* Handle empty or malformed feedback responses gracefully  &lt;br /&gt;
&lt;br /&gt;
=== RoundSelector Component ===&lt;br /&gt;
&lt;br /&gt;
* Verify API call to fetch heatmap data is triggered on component load  &lt;br /&gt;
* Check that heatmap data is correctly visualized for different review rounds  &lt;br /&gt;
* Test behavior with no data, incomplete data, or delayed response  &lt;br /&gt;
&lt;br /&gt;
=== Statistics Component ===&lt;br /&gt;
&lt;br /&gt;
* Confirm it correctly fetches teammate evaluations and author feedback  &lt;br /&gt;
* Ensure charts or tables reflect the received backend data accurately  &lt;br /&gt;
* Test switching between different teams or assignments and verify correct display  &lt;br /&gt;
&lt;br /&gt;
=== General UI Considerations ===&lt;br /&gt;
&lt;br /&gt;
* Test frontend responsiveness to backend failures (500, 404, timeout)  &lt;br /&gt;
* Ensure authorization errors are handled and appropriate messages displayed  &lt;br /&gt;
&lt;br /&gt;
== 2. Backend API Tests ==&lt;br /&gt;
&lt;br /&gt;
While unit tests exist, integration-level tests will be added or updated to ensure UI compatibility.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
* Validate all &amp;lt;code&amp;gt;GET&amp;lt;/code&amp;gt; endpoints return properly structured JSON objects  &lt;br /&gt;
* Simulate various user roles (student, TA, instructor) and ensure access control  &lt;br /&gt;
* Include test cases for:&lt;br /&gt;
** No grades present  &lt;br /&gt;
** Partial data (e.g. missing feedback or evaluations)  &lt;br /&gt;
** Large number of records  &lt;br /&gt;
&lt;br /&gt;
=== Security &amp;amp; Permissions ===&lt;br /&gt;
&lt;br /&gt;
* Ensure students can only fetch their grades and feedback  &lt;br /&gt;
* Ensure TAs and instructors can access full assignment data  &lt;br /&gt;
* Test token/session-based access restrictions (if applicable)  &lt;br /&gt;
&lt;br /&gt;
== 3. Database Preparation ==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, seed data will simulate real-world usage and we will ensure that:&lt;br /&gt;
* Tests will use isolated fixtures or factories to ensure data consistency&lt;br /&gt;
* All database states will be reset before each test suite run&lt;br /&gt;
&lt;br /&gt;
=== Tables and Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;assignments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_participant&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;participants&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;questionnaires&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;questions&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_questionnaire&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;signed_up_teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;teams_users&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;late_policies&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
=== Scenarios ===&lt;br /&gt;
&lt;br /&gt;
* Single student assigned  &lt;br /&gt;
* Team assignments with/without feedback  &lt;br /&gt;
* Late submissions triggering late policies  &lt;br /&gt;
* Multiple review rounds per assignment&lt;br /&gt;
&lt;br /&gt;
== 4. Regression &amp;amp; CI Testing ==&lt;br /&gt;
&lt;br /&gt;
To ensure updates do not break existing functionality:&lt;br /&gt;
&lt;br /&gt;
* Re-run all existing unit tests  &lt;br /&gt;
* Include snapshot tests for frontend components  &lt;br /&gt;
* Use CI pipelines to automatically trigger tests on pull requests  &lt;br /&gt;
&lt;br /&gt;
== Test Plan Summary ==&lt;br /&gt;
&lt;br /&gt;
This test plan outlines the approach for integrating &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the frontend. By combining backend tests, UI integration checks, and realistic database scenarios, we aim to deliver a seamless user experience. The plan emphasizes early detection of issues and supports long-term maintainability through regression testing. As development progresses, the plan will be updated to cover new insights and edge cases.&lt;br /&gt;
&lt;br /&gt;
=Completed Reimplementation Details=&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The previous implementation was designed for a Ruby-embedded front-end, where data was rendered server-side and injected directly into the view. We have since updated the APIs to return data in a format suitable for consumption by the React UI, typically as JSON objects. This change successfully decouples the front-end from the server-side rendering logic, enabling a more interactive and responsive user experience. By transitioning to a React-based interface, we now have improved control over UI state and better alignment with modern web development practices.&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
In this controller, we have updated the GET functions to remove the use of instance variables and instead return plain JSON objects using render json: in the response. This update was essential to align with the frontend architecture, which now relies on a React-based interface that expects structured data from the backend in JSON format rather than server-rendered templates. By returning JSON responses, we’ve established cleaner and more consistent API endpoints, improved the testability and debuggability of our backend logic, and created a more maintainable and decoupled integration between the frontend and backend systems. The following functions were updated as part of this integration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  def view_grading_report&lt;br /&gt;
    assignment_id = params[:id].to_i&lt;br /&gt;
    data = get_data_for_heat_map(assignment_id)&lt;br /&gt;
    &lt;br /&gt;
    render json: data, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
    &lt;br /&gt;
  def view_my_scores&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team_id = TeamsUser.team_id(participant.assignment_id, participant.user_id)&lt;br /&gt;
    # return if redirect_when_disallowed(participant)&lt;br /&gt;
    questions = fetch_questionnaires_and_questions(assignment)&lt;br /&gt;
    pscore = fetch_participant_scores(participant, questions)&lt;br /&gt;
    topic_id = SignedUpTeam.find_topic_id_for_user(participant.assignment.id, participant.user_id)&lt;br /&gt;
    stage = participant.assignment.current_stage(topic_id)&lt;br /&gt;
    # all_penalties = update_penalties(assignment)&lt;br /&gt;
    # Feedback Summary needs to be checked once&lt;br /&gt;
    # summary_ws_url = WEBSERVICE_CONFIG['summary_webservice_url']&lt;br /&gt;
    sum = SummaryHelper::Summary.new.summarize_reviews_by_reviewee(questions, assignment, team_id, 'http://peerlogic.csc.ncsu.edu/sum/v1.0/summary/8/lsa', session)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      topic_id: topic_id,&lt;br /&gt;
      stage: stage,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      summary: sum.summary,&lt;br /&gt;
      avg_scores_by_round: sum.avg_scores_by_round,&lt;br /&gt;
      avg_scores_by_criterion: sum.avg_scores_by_criterion&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def view_team&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    team_id = team.id&lt;br /&gt;
  &lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: assignment.id).map(&amp;amp;:questionnaire)&lt;br /&gt;
    questions = retrieve_questions(questionnaires, assignment.id)&lt;br /&gt;
    pscore = Response.participant_scores(participant, questions)&lt;br /&gt;
    vmlist = process_questionare_for_team(assignment, team_id,questionnaires, team, participant)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team: team,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      vmlist: vmlist&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These updates were important for the backend and ensured seamless communication with the React frontend. By removing instance variables and returning structured JSON responses, we eliminated dependencies on server-side rendering and enabled the frontend to dynamically manage and render data. This not only enhances performance and flexibility but also improves maintainability and scalability as the application evolves. Moreover, it allows the backend and frontend to evolve independently, supporting better separation of concerns and aligning with current best practices in full-stack web development.&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
==Data Flow Overview==&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
Overview:&lt;br /&gt;
&lt;br /&gt;
===UI Tests===&lt;br /&gt;
&lt;br /&gt;
===Backend API Tests===&lt;br /&gt;
&lt;br /&gt;
2.5	Test Plan&lt;br /&gt;
2.6	Tools and Frameworks&lt;br /&gt;
2.7	1. UI Integration Tests&lt;br /&gt;
2.7.1	ReviewTable Component&lt;br /&gt;
2.7.2	RoundSelector Component&lt;br /&gt;
2.7.3	Statistics Component&lt;br /&gt;
2.7.4	General UI Considerations&lt;br /&gt;
2.8	2. Backend API Tests&lt;br /&gt;
2.8.1	grades_controller.rb&lt;br /&gt;
2.8.2	Security &amp;amp; Permissions&lt;br /&gt;
2.9	3. Database Preparation&lt;br /&gt;
2.9.1	Tables and Test Coverage&lt;br /&gt;
2.9.2	Scenarios&lt;br /&gt;
2.10	4. Regression &amp;amp; CI Testing&lt;br /&gt;
2.11	Test Plan Summary&lt;br /&gt;
&lt;br /&gt;
==Adhering to Priciples==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164221</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164221"/>
		<updated>2025-04-20T18:24:49Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of this project is to integrate the frontend of the grades view page with the reimplemented '''''grades_controller.rb (E2510)''''' backend in Expertiza, ensuring a seamless connection between both layers. This integration involves refining the interaction between the UI and backend while adhering to best design principles such as modularity, maintainability, and scalability. The grades_controller.rb is responsible for managing grading functionality, allowing instructors to view and modify assignment grades while enabling students to access their evaluations. By following SOLID and DRY principles, this reimplementation enhances code clarity, reduces redundancy, and improves overall system efficiency.&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
The &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; is responsible for managing and delivering grading data to users in the Expertiza system. It enables instructors to view, calculate, and release grades to students, while also allowing students to view feedback and scores for assignments. The controller plays an important role in coordinating backend logic for reviews and grade visibility.&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
The previous implementation successfully created a functional frontend UI page in Expertiza, addressing design inconsistencies and improving usability. It introduced a visually cohesive interface with an intuitive layout, enhanced responsiveness, and improved information display, allowing users to navigate grading data more efficiently. However, the interface was populated using dummy data, limiting its practical use. This reimplemented UI will utilize real data from the database (that has been populated in this round), ensuring that grading information is dynamically retrieved and displayed accurately through JSON objects. Additionally, this phase will connect the redesigned frontend with some new components in the grades_controller.rb. Specifically, the GET functions in the grades_controller were reimplemented to return JSON objects (instead of instance variables) that could be accessed via an API call. Thus, this new implementation ensures seamless communication between the UI and backend while adhering to best design practices for maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
This project focuses on integrating the frontend of the grades view page with the reimplemented '''grades_controller.rb (E2510)''' backend in Expertiza. This integration requires modifications to both the frontend and backend to establish a seamless connection, ensuring that grading data is dynamically retrieved and displayed accurately. By adhering to best design principles such as modularity, maintainability, and scalability, the implementation will enhance system efficiency and long-term usability. Key improvements include replacing dummy data with real database values, refining data flow between the UI and backend, and optimizing API interactions for better performance. These enhancements will create a more intuitive and reliable grading system, providing a seamless experience for instructors and students while maintaining a well-structured and adaptable codebase for future development.&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
# '''Establish a Robust Connection Between the Frontend and Backend''': Ensure smooth data retrieval and updates between the grades view page and the backend by integrating dynamic data through API calls, replacing the current hardcoded dummy data.&lt;br /&gt;
# '''Define and Implement Clear API Endpoints''': Create well-structured API endpoints in grades_controller.rb for retrieving and displaying grades, ensuring they return appropriate data based on user roles (students, instructors, TAs) and maintain role-based access controls.&lt;br /&gt;
# '''Dynamic Data Integration''': Modify the frontend to consume real-time data fetched from the backend, ensuring an intuitive and responsive UI that reflects the actual grading information. &lt;br /&gt;
# '''Refactor Frontend and Backend Components''': Refactor both the frontend and backend as necessary to align with SOLID and DRY principles, ensuring modularity, maintainability, and scalability. This includes eliminating redundant logic and optimizing code for better readability.&lt;br /&gt;
# '''Implement Proper Permission Checks''': Ensure that only authorized users can access grade information by implementing robust privilege checks and ensuring that the data is securely accessible to students, instructors, and TAs based on their roles.&lt;br /&gt;
# '''Optimize Database Queries and API Responses''': Enhance the efficiency of database queries and API responses to reduce unnecessary load and ensure that data is retrieved and displayed promptly.&lt;br /&gt;
# '''Testing and Validation''': Implement comprehensive unit and integration tests to verify the correctness of data flow, UI interactions, and role-based access controls, ensuring that the system functions correctly and securely.&lt;br /&gt;
&lt;br /&gt;
=Reimplementation Plan=&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populated data with the appropriate HTTP GET and HTTP POST calls. This shift is necessary to ensure that our application reflects real-time data from the backend rather than relying on static or hardcoded values, which can quickly become outdated or inconsistent. It also enables better scalability and maintainability, as changes to the data only need to be made in the backend, without requiring manual updates in the frontend code.&lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
'''Author Feedback''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
'''Heatmap Data''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
'''Team-mate Data''':&lt;br /&gt;
   {&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The current implementation caters to the backend for a Ruby-embedded front-end, where data is rendered server-side and passed directly into the view. We need to update the APIs to return data in a format that can be consumed by the React UI, typically JSON. This shift is essential to decouple the front-end from the server-side rendering logic, allowing for a more interactive and dynamic user experience. By transitioning to a React-based interface, we gain better control over UI state and responsiveness, while also aligning with modern web development practices. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and instead return plain JSON objects using render json: in the response. This change is necessary to align with a frontend architecture that uses React or another JavaScript framework, which expects structured data from the backend in JSON format rather than relying on server-rendered templates. By shifting to JSON responses, we enable cleaner API endpoints, facilitate easier testing and debugging, and support a more maintainable, decoupled frontend-backend integration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    # prepare feedback summaries&lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
  1.1. Students&lt;br /&gt;
  1.2. Teams&lt;br /&gt;
  1.3. TA&lt;br /&gt;
  1.4. Professor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
  2.1 assignments&lt;br /&gt;
  2.2 assignment_questionnaire&lt;br /&gt;
  2.3 questionnaires&lt;br /&gt;
  2.4 participant&lt;br /&gt;
  2.5 signed_up_teams&lt;br /&gt;
  2.6 teams_users&lt;br /&gt;
  2.7 due_dates&lt;br /&gt;
  2.8 late_policies&lt;br /&gt;
  2.9 questions&lt;br /&gt;
  2.10 review_scores&lt;br /&gt;
  2.11 review_grades&lt;br /&gt;
&lt;br /&gt;
== Data Flow Overview ==&lt;br /&gt;
The diagram below illustrates how data flows between the frontend React components and the grades_controller.rb backend during a typical grading data fetch operation.&lt;br /&gt;
&lt;br /&gt;
* The user (e.g., instructor or student) interacts with the React-based grades view (e.g., ReviewTable, RoundSelector, or Statistics).&lt;br /&gt;
* The component triggers an API request to a specific action in grades_controller.rb (e.g., GET /grades/:id/summary).&lt;br /&gt;
*The controller action queries the relevant models (e.g., Assignment, Team, ReviewResponseMap) and compiles a JSON response.&lt;br /&gt;
* The response is sent back to the frontend and parsed.&lt;br /&gt;
*The React components update the UI (tables, heatmaps, statistics) based on the received data.&lt;br /&gt;
&lt;br /&gt;
This architecture ensures a clean separation between frontend and backend logic, improving maintainability and testability.&lt;br /&gt;
[[File:Dataflow.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
The test plan for Phase 2 focuses on verifying the successful integration of the newly reimplemented &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the React-based UI components. We aim to ensure data is:&lt;br /&gt;
&lt;br /&gt;
* Correctly fetched from the backend  &lt;br /&gt;
* Appropriately displayed in the frontend  &lt;br /&gt;
* Functionally sound under both normal and edge-case scenarios&lt;br /&gt;
&lt;br /&gt;
== Tools and Frameworks ==&lt;br /&gt;
We plan to use the following tools and frameworks for testing:&lt;br /&gt;
&lt;br /&gt;
* '''Frontend''': Jest and React Testing Library for unit and integration tests&lt;br /&gt;
* '''Backend''': RSpec for controller and model tests&lt;br /&gt;
* '''Integration Testing''': Capybara and Selenium for simulating real user behavior&lt;br /&gt;
* '''Test Coverage''': SimpleCov&lt;br /&gt;
&lt;br /&gt;
== 1. UI Integration Tests ==&lt;br /&gt;
&lt;br /&gt;
These tests ensure the frontend correctly interacts with backend APIs and renders the data appropriately.&lt;br /&gt;
&lt;br /&gt;
=== ReviewTable Component ===&lt;br /&gt;
&lt;br /&gt;
* Validate that the component makes a successful API call to fetch author feedback  &lt;br /&gt;
* Ensure feedback is rendered in the correct table structure  &lt;br /&gt;
* Test loading state before data is fetched  &lt;br /&gt;
* Handle empty or malformed feedback responses gracefully  &lt;br /&gt;
&lt;br /&gt;
=== RoundSelector Component ===&lt;br /&gt;
&lt;br /&gt;
* Verify API call to fetch heatmap data is triggered on component load  &lt;br /&gt;
* Check that heatmap data is correctly visualized for different review rounds  &lt;br /&gt;
* Test behavior with no data, incomplete data, or delayed response  &lt;br /&gt;
&lt;br /&gt;
=== Statistics Component ===&lt;br /&gt;
&lt;br /&gt;
* Confirm it correctly fetches teammate evaluations and author feedback  &lt;br /&gt;
* Ensure charts or tables reflect the received backend data accurately  &lt;br /&gt;
* Test switching between different teams or assignments and verify correct display  &lt;br /&gt;
&lt;br /&gt;
=== General UI Considerations ===&lt;br /&gt;
&lt;br /&gt;
* Test frontend responsiveness to backend failures (500, 404, timeout)  &lt;br /&gt;
* Ensure authorization errors are handled and appropriate messages displayed  &lt;br /&gt;
&lt;br /&gt;
== 2. Backend API Tests ==&lt;br /&gt;
&lt;br /&gt;
While unit tests exist, integration-level tests will be added or updated to ensure UI compatibility.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
* Validate all &amp;lt;code&amp;gt;GET&amp;lt;/code&amp;gt; endpoints return properly structured JSON objects  &lt;br /&gt;
* Simulate various user roles (student, TA, instructor) and ensure access control  &lt;br /&gt;
* Include test cases for:&lt;br /&gt;
** No grades present  &lt;br /&gt;
** Partial data (e.g. missing feedback or evaluations)  &lt;br /&gt;
** Large number of records  &lt;br /&gt;
&lt;br /&gt;
=== Security &amp;amp; Permissions ===&lt;br /&gt;
&lt;br /&gt;
* Ensure students can only fetch their grades and feedback  &lt;br /&gt;
* Ensure TAs and instructors can access full assignment data  &lt;br /&gt;
* Test token/session-based access restrictions (if applicable)  &lt;br /&gt;
&lt;br /&gt;
== 3. Database Preparation ==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, seed data will simulate real-world usage and we will ensure that:&lt;br /&gt;
* Tests will use isolated fixtures or factories to ensure data consistency&lt;br /&gt;
* All database states will be reset before each test suite run&lt;br /&gt;
&lt;br /&gt;
=== Tables and Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;assignments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_participant&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;participants&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;questionnaires&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;questions&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_questionnaire&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;signed_up_teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;teams_users&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;late_policies&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
=== Scenarios ===&lt;br /&gt;
&lt;br /&gt;
* Single student assigned  &lt;br /&gt;
* Team assignments with/without feedback  &lt;br /&gt;
* Late submissions triggering late policies  &lt;br /&gt;
* Multiple review rounds per assignment&lt;br /&gt;
&lt;br /&gt;
== 4. Regression &amp;amp; CI Testing ==&lt;br /&gt;
&lt;br /&gt;
To ensure updates do not break existing functionality:&lt;br /&gt;
&lt;br /&gt;
* Re-run all existing unit tests  &lt;br /&gt;
* Include snapshot tests for frontend components  &lt;br /&gt;
* Use CI pipelines to automatically trigger tests on pull requests  &lt;br /&gt;
&lt;br /&gt;
== Test Plan Summary ==&lt;br /&gt;
&lt;br /&gt;
This test plan outlines the approach for integrating &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the frontend. By combining backend tests, UI integration checks, and realistic database scenarios, we aim to deliver a seamless user experience. The plan emphasizes early detection of issues and supports long-term maintainability through regression testing. As development progresses, the plan will be updated to cover new insights and edge cases.&lt;br /&gt;
&lt;br /&gt;
=Completed Reimplementation Details=&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The previous implementation was designed for a Ruby-embedded front-end, where data was rendered server-side and injected directly into the view. We have since updated the APIs to return data in a format suitable for consumption by the React UI, typically as JSON objects. This change successfully decouples the front-end from the server-side rendering logic, enabling a more interactive and responsive user experience. By transitioning to a React-based interface, we now have improved control over UI state and better alignment with modern web development practices.&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
In this controller, we have updated the GET functions to remove the use of instance variables and instead return plain JSON objects using render json: in the response. This update was essential to align with the frontend architecture, which now relies on a React-based interface that expects structured data from the backend in JSON format rather than server-rendered templates. By returning JSON responses, we’ve established cleaner and more consistent API endpoints, improved the testability and debuggability of our backend logic, and created a more maintainable and decoupled integration between the frontend and backend systems. The following functions were updated as part of this integration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  def view_grading_report&lt;br /&gt;
    assignment_id = params[:id].to_i&lt;br /&gt;
    data = get_data_for_heat_map(assignment_id)&lt;br /&gt;
    &lt;br /&gt;
    render json: data, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
    &lt;br /&gt;
  def view_my_scores&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team_id = TeamsUser.team_id(participant.assignment_id, participant.user_id)&lt;br /&gt;
    # return if redirect_when_disallowed(participant)&lt;br /&gt;
    questions = fetch_questionnaires_and_questions(assignment)&lt;br /&gt;
    pscore = fetch_participant_scores(participant, questions)&lt;br /&gt;
    topic_id = SignedUpTeam.find_topic_id_for_user(participant.assignment.id, participant.user_id)&lt;br /&gt;
    stage = participant.assignment.current_stage(topic_id)&lt;br /&gt;
    # all_penalties = update_penalties(assignment)&lt;br /&gt;
    # Feedback Summary needs to be checked once&lt;br /&gt;
    # summary_ws_url = WEBSERVICE_CONFIG['summary_webservice_url']&lt;br /&gt;
    sum = SummaryHelper::Summary.new.summarize_reviews_by_reviewee(questions, assignment, team_id, 'http://peerlogic.csc.ncsu.edu/sum/v1.0/summary/8/lsa', session)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      topic_id: topic_id,&lt;br /&gt;
      stage: stage,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      summary: sum.summary,&lt;br /&gt;
      avg_scores_by_round: sum.avg_scores_by_round,&lt;br /&gt;
      avg_scores_by_criterion: sum.avg_scores_by_criterion&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def view_team&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    team_id = team.id&lt;br /&gt;
  &lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: assignment.id).map(&amp;amp;:questionnaire)&lt;br /&gt;
    questions = retrieve_questions(questionnaires, assignment.id)&lt;br /&gt;
    pscore = Response.participant_scores(participant, questions)&lt;br /&gt;
    vmlist = process_questionare_for_team(assignment, team_id,questionnaires, team, participant)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team: team,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      vmlist: vmlist&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These updates were important for the backend and ensured seamless communication with the React frontend. By removing instance variables and returning structured JSON responses, we eliminated dependencies on server-side rendering and enabled the frontend to dynamically manage and render data. This not only enhances performance and flexibility but also improves maintainability and scalability as the application evolves. Moreover, it allows the backend and frontend to evolve independently, supporting better separation of concerns and aligning with current best practices in full-stack web development.&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
==Data Flow Overview==&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2.5	Test Plan&lt;br /&gt;
2.6	Tools and Frameworks&lt;br /&gt;
2.7	1. UI Integration Tests&lt;br /&gt;
2.7.1	ReviewTable Component&lt;br /&gt;
2.7.2	RoundSelector Component&lt;br /&gt;
2.7.3	Statistics Component&lt;br /&gt;
2.7.4	General UI Considerations&lt;br /&gt;
2.8	2. Backend API Tests&lt;br /&gt;
2.8.1	grades_controller.rb&lt;br /&gt;
2.8.2	Security &amp;amp; Permissions&lt;br /&gt;
2.9	3. Database Preparation&lt;br /&gt;
2.9.1	Tables and Test Coverage&lt;br /&gt;
2.9.2	Scenarios&lt;br /&gt;
2.10	4. Regression &amp;amp; CI Testing&lt;br /&gt;
2.11	Test Plan Summary&lt;br /&gt;
&lt;br /&gt;
==Adhering to Priciples==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164220</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164220"/>
		<updated>2025-04-20T18:02:20Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* API */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of this project is to integrate the frontend of the grades view page with the reimplemented '''''grades_controller.rb (E2510)''''' backend in Expertiza, ensuring a seamless connection between both layers. This integration involves refining the interaction between the UI and backend while adhering to best design principles such as modularity, maintainability, and scalability. The grades_controller.rb is responsible for managing grading functionality, allowing instructors to view and modify assignment grades while enabling students to access their evaluations. By following SOLID and DRY principles, this reimplementation enhances code clarity, reduces redundancy, and improves overall system efficiency.&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
The &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; is responsible for managing and delivering grading data to users in the Expertiza system. It enables instructors to view, calculate, and release grades to students, while also allowing students to view feedback and scores for assignments. The controller plays an important role in coordinating backend logic for reviews and grade visibility.&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
The previous implementation successfully created a functional frontend UI page in Expertiza, addressing design inconsistencies and improving usability. It introduced a visually cohesive interface with an intuitive layout, enhanced responsiveness, and improved information display, allowing users to navigate grading data more efficiently. However, the interface was populated using dummy data, limiting its practical use. This reimplemented UI will utilize real data from the database (that has been populated in this round), ensuring that grading information is dynamically retrieved and displayed accurately through JSON objects. Additionally, this phase will connect the redesigned frontend with some new components in the grades_controller.rb. Specifically, the GET functions in the grades_controller were reimplemented to return JSON objects (instead of instance variables) that could be accessed via an API call. Thus, this new implementation ensures seamless communication between the UI and backend while adhering to best design practices for maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
This project focuses on integrating the frontend of the grades view page with the reimplemented '''grades_controller.rb (E2510)''' backend in Expertiza. This integration requires modifications to both the frontend and backend to establish a seamless connection, ensuring that grading data is dynamically retrieved and displayed accurately. By adhering to best design principles such as modularity, maintainability, and scalability, the implementation will enhance system efficiency and long-term usability. Key improvements include replacing dummy data with real database values, refining data flow between the UI and backend, and optimizing API interactions for better performance. These enhancements will create a more intuitive and reliable grading system, providing a seamless experience for instructors and students while maintaining a well-structured and adaptable codebase for future development.&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
# '''Establish a Robust Connection Between the Frontend and Backend''': Ensure smooth data retrieval and updates between the grades view page and the backend by integrating dynamic data through API calls, replacing the current hardcoded dummy data.&lt;br /&gt;
# '''Define and Implement Clear API Endpoints''': Create well-structured API endpoints in grades_controller.rb for retrieving and displaying grades, ensuring they return appropriate data based on user roles (students, instructors, TAs) and maintain role-based access controls.&lt;br /&gt;
# '''Dynamic Data Integration''': Modify the frontend to consume real-time data fetched from the backend, ensuring an intuitive and responsive UI that reflects the actual grading information. &lt;br /&gt;
# '''Refactor Frontend and Backend Components''': Refactor both the frontend and backend as necessary to align with SOLID and DRY principles, ensuring modularity, maintainability, and scalability. This includes eliminating redundant logic and optimizing code for better readability.&lt;br /&gt;
# '''Implement Proper Permission Checks''': Ensure that only authorized users can access grade information by implementing robust privilege checks and ensuring that the data is securely accessible to students, instructors, and TAs based on their roles.&lt;br /&gt;
# '''Optimize Database Queries and API Responses''': Enhance the efficiency of database queries and API responses to reduce unnecessary load and ensure that data is retrieved and displayed promptly.&lt;br /&gt;
# '''Testing and Validation''': Implement comprehensive unit and integration tests to verify the correctness of data flow, UI interactions, and role-based access controls, ensuring that the system functions correctly and securely.&lt;br /&gt;
&lt;br /&gt;
=Reimplementation Plan=&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populated data with the appropriate HTTP GET and HTTP POST calls. This shift is necessary to ensure that our application reflects real-time data from the backend rather than relying on static or hardcoded values, which can quickly become outdated or inconsistent. It also enables better scalability and maintainability, as changes to the data only need to be made in the backend, without requiring manual updates in the frontend code.&lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
'''Author Feedback''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
'''Heatmap Data''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
'''Team-mate Data''':&lt;br /&gt;
   {&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The current implementation caters to the backend for a Ruby-embedded front-end, where data is rendered server-side and passed directly into the view. We need to update the APIs to return data in a format that can be consumed by the React UI, typically JSON. This shift is essential to decouple the front-end from the server-side rendering logic, allowing for a more interactive and dynamic user experience. By transitioning to a React-based interface, we gain better control over UI state and responsiveness, while also aligning with modern web development practices. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and instead return plain JSON objects using render json: in the response. This change is necessary to align with a frontend architecture that uses React or another JavaScript framework, which expects structured data from the backend in JSON format rather than relying on server-rendered templates. By shifting to JSON responses, we enable cleaner API endpoints, facilitate easier testing and debugging, and support a more maintainable, decoupled frontend-backend integration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    # prepare feedback summaries&lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
  1.1. Students&lt;br /&gt;
  1.2. Teams&lt;br /&gt;
  1.3. TA&lt;br /&gt;
  1.4. Professor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
  2.1 assignments&lt;br /&gt;
  2.2 assignment_questionnaire&lt;br /&gt;
  2.3 questionnaires&lt;br /&gt;
  2.4 participant&lt;br /&gt;
  2.5 signed_up_teams&lt;br /&gt;
  2.6 teams_users&lt;br /&gt;
  2.7 due_dates&lt;br /&gt;
  2.8 late_policies&lt;br /&gt;
  2.9 questions&lt;br /&gt;
  2.10 review_scores&lt;br /&gt;
  2.11 review_grades&lt;br /&gt;
&lt;br /&gt;
== Data Flow Overview ==&lt;br /&gt;
The diagram below illustrates how data flows between the frontend React components and the grades_controller.rb backend during a typical grading data fetch operation.&lt;br /&gt;
&lt;br /&gt;
* The user (e.g., instructor or student) interacts with the React-based grades view (e.g., ReviewTable, RoundSelector, or Statistics).&lt;br /&gt;
* The component triggers an API request to a specific action in grades_controller.rb (e.g., GET /grades/:id/summary).&lt;br /&gt;
*The controller action queries the relevant models (e.g., Assignment, Team, ReviewResponseMap) and compiles a JSON response.&lt;br /&gt;
* The response is sent back to the frontend and parsed.&lt;br /&gt;
*The React components update the UI (tables, heatmaps, statistics) based on the received data.&lt;br /&gt;
&lt;br /&gt;
This architecture ensures a clean separation between frontend and backend logic, improving maintainability and testability.&lt;br /&gt;
[[File:Dataflow.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
The test plan for Phase 2 focuses on verifying the successful integration of the newly reimplemented &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the React-based UI components. We aim to ensure data is:&lt;br /&gt;
&lt;br /&gt;
* Correctly fetched from the backend  &lt;br /&gt;
* Appropriately displayed in the frontend  &lt;br /&gt;
* Functionally sound under both normal and edge-case scenarios&lt;br /&gt;
&lt;br /&gt;
== Tools and Frameworks ==&lt;br /&gt;
We plan to use the following tools and frameworks for testing:&lt;br /&gt;
&lt;br /&gt;
* '''Frontend''': Jest and React Testing Library for unit and integration tests&lt;br /&gt;
* '''Backend''': RSpec for controller and model tests&lt;br /&gt;
* '''Integration Testing''': Capybara and Selenium for simulating real user behavior&lt;br /&gt;
* '''Test Coverage''': SimpleCov&lt;br /&gt;
&lt;br /&gt;
== 1. UI Integration Tests ==&lt;br /&gt;
&lt;br /&gt;
These tests ensure the frontend correctly interacts with backend APIs and renders the data appropriately.&lt;br /&gt;
&lt;br /&gt;
=== ReviewTable Component ===&lt;br /&gt;
&lt;br /&gt;
* Validate that the component makes a successful API call to fetch author feedback  &lt;br /&gt;
* Ensure feedback is rendered in the correct table structure  &lt;br /&gt;
* Test loading state before data is fetched  &lt;br /&gt;
* Handle empty or malformed feedback responses gracefully  &lt;br /&gt;
&lt;br /&gt;
=== RoundSelector Component ===&lt;br /&gt;
&lt;br /&gt;
* Verify API call to fetch heatmap data is triggered on component load  &lt;br /&gt;
* Check that heatmap data is correctly visualized for different review rounds  &lt;br /&gt;
* Test behavior with no data, incomplete data, or delayed response  &lt;br /&gt;
&lt;br /&gt;
=== Statistics Component ===&lt;br /&gt;
&lt;br /&gt;
* Confirm it correctly fetches teammate evaluations and author feedback  &lt;br /&gt;
* Ensure charts or tables reflect the received backend data accurately  &lt;br /&gt;
* Test switching between different teams or assignments and verify correct display  &lt;br /&gt;
&lt;br /&gt;
=== General UI Considerations ===&lt;br /&gt;
&lt;br /&gt;
* Test frontend responsiveness to backend failures (500, 404, timeout)  &lt;br /&gt;
* Ensure authorization errors are handled and appropriate messages displayed  &lt;br /&gt;
&lt;br /&gt;
== 2. Backend API Tests ==&lt;br /&gt;
&lt;br /&gt;
While unit tests exist, integration-level tests will be added or updated to ensure UI compatibility.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
* Validate all &amp;lt;code&amp;gt;GET&amp;lt;/code&amp;gt; endpoints return properly structured JSON objects  &lt;br /&gt;
* Simulate various user roles (student, TA, instructor) and ensure access control  &lt;br /&gt;
* Include test cases for:&lt;br /&gt;
** No grades present  &lt;br /&gt;
** Partial data (e.g. missing feedback or evaluations)  &lt;br /&gt;
** Large number of records  &lt;br /&gt;
&lt;br /&gt;
=== Security &amp;amp; Permissions ===&lt;br /&gt;
&lt;br /&gt;
* Ensure students can only fetch their grades and feedback  &lt;br /&gt;
* Ensure TAs and instructors can access full assignment data  &lt;br /&gt;
* Test token/session-based access restrictions (if applicable)  &lt;br /&gt;
&lt;br /&gt;
== 3. Database Preparation ==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, seed data will simulate real-world usage and we will ensure that:&lt;br /&gt;
* Tests will use isolated fixtures or factories to ensure data consistency&lt;br /&gt;
* All database states will be reset before each test suite run&lt;br /&gt;
&lt;br /&gt;
=== Tables and Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;assignments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_participant&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;participants&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;questionnaires&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;questions&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_questionnaire&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;signed_up_teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;teams_users&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;late_policies&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
=== Scenarios ===&lt;br /&gt;
&lt;br /&gt;
* Single student assigned  &lt;br /&gt;
* Team assignments with/without feedback  &lt;br /&gt;
* Late submissions triggering late policies  &lt;br /&gt;
* Multiple review rounds per assignment&lt;br /&gt;
&lt;br /&gt;
== 4. Regression &amp;amp; CI Testing ==&lt;br /&gt;
&lt;br /&gt;
To ensure updates do not break existing functionality:&lt;br /&gt;
&lt;br /&gt;
* Re-run all existing unit tests  &lt;br /&gt;
* Include snapshot tests for frontend components  &lt;br /&gt;
* Use CI pipelines to automatically trigger tests on pull requests  &lt;br /&gt;
&lt;br /&gt;
== Test Plan Summary ==&lt;br /&gt;
&lt;br /&gt;
This test plan outlines the approach for integrating &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the frontend. By combining backend tests, UI integration checks, and realistic database scenarios, we aim to deliver a seamless user experience. The plan emphasizes early detection of issues and supports long-term maintainability through regression testing. As development progresses, the plan will be updated to cover new insights and edge cases.&lt;br /&gt;
&lt;br /&gt;
=Completed Reimplementation Details=&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The previous implementation was designed for a Ruby-embedded front-end, where data was rendered server-side and injected directly into the view. We have since updated the APIs to return data in a format suitable for consumption by the React UI, typically as JSON objects. This change successfully decouples the front-end from the server-side rendering logic, enabling a more interactive and responsive user experience. By transitioning to a React-based interface, we now have improved control over UI state and better alignment with modern web development practices.&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
In this controller, we have updated the GET functions to remove the use of instance variables and instead return plain JSON objects using render json: in the response. This update was essential to align with the frontend architecture, which now relies on a React-based interface that expects structured data from the backend in JSON format rather than server-rendered templates. By returning JSON responses, we’ve established cleaner and more consistent API endpoints, improved the testability and debuggability of our backend logic, and created a more maintainable and decoupled integration between the frontend and backend systems. The following functions were updated as part of this integration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  def view_grading_report&lt;br /&gt;
    assignment_id = params[:id].to_i&lt;br /&gt;
    data = get_data_for_heat_map(assignment_id)&lt;br /&gt;
    &lt;br /&gt;
    render json: data, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
    &lt;br /&gt;
  def view_my_scores&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team_id = TeamsUser.team_id(participant.assignment_id, participant.user_id)&lt;br /&gt;
    # return if redirect_when_disallowed(participant)&lt;br /&gt;
    questions = fetch_questionnaires_and_questions(assignment)&lt;br /&gt;
    pscore = fetch_participant_scores(participant, questions)&lt;br /&gt;
    topic_id = SignedUpTeam.find_topic_id_for_user(participant.assignment.id, participant.user_id)&lt;br /&gt;
    stage = participant.assignment.current_stage(topic_id)&lt;br /&gt;
    # all_penalties = update_penalties(assignment)&lt;br /&gt;
    # Feedback Summary needs to be checked once&lt;br /&gt;
    # summary_ws_url = WEBSERVICE_CONFIG['summary_webservice_url']&lt;br /&gt;
    sum = SummaryHelper::Summary.new.summarize_reviews_by_reviewee(questions, assignment, team_id, 'http://peerlogic.csc.ncsu.edu/sum/v1.0/summary/8/lsa', session)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      topic_id: topic_id,&lt;br /&gt;
      stage: stage,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      summary: sum.summary,&lt;br /&gt;
      avg_scores_by_round: sum.avg_scores_by_round,&lt;br /&gt;
      avg_scores_by_criterion: sum.avg_scores_by_criterion&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def view_team&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    team_id = team.id&lt;br /&gt;
  &lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: assignment.id).map(&amp;amp;:questionnaire)&lt;br /&gt;
    questions = retrieve_questions(questionnaires, assignment.id)&lt;br /&gt;
    pscore = Response.participant_scores(participant, questions)&lt;br /&gt;
    vmlist = process_questionare_for_team(assignment, team_id,questionnaires, team, participant)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team: team,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      vmlist: vmlist&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These updates were important for the backend and ensured seamless communication with the React frontend. By removing instance variables and returning structured JSON responses, we eliminated dependencies on server-side rendering and enabled the frontend to dynamically manage and render data. This not only enhances performance and flexibility but also improves maintainability and scalability as the application evolves. Moreover, it allows the backend and frontend to evolve independently, supporting better separation of concerns and aligning with current best practices in full-stack web development.&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
==Data Flow Overview==&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
==Adhering to Priciples==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164219</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164219"/>
		<updated>2025-04-20T18:00:56Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* API */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of this project is to integrate the frontend of the grades view page with the reimplemented '''''grades_controller.rb (E2510)''''' backend in Expertiza, ensuring a seamless connection between both layers. This integration involves refining the interaction between the UI and backend while adhering to best design principles such as modularity, maintainability, and scalability. The grades_controller.rb is responsible for managing grading functionality, allowing instructors to view and modify assignment grades while enabling students to access their evaluations. By following SOLID and DRY principles, this reimplementation enhances code clarity, reduces redundancy, and improves overall system efficiency.&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
The &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; is responsible for managing and delivering grading data to users in the Expertiza system. It enables instructors to view, calculate, and release grades to students, while also allowing students to view feedback and scores for assignments. The controller plays an important role in coordinating backend logic for reviews and grade visibility.&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
The previous implementation successfully created a functional frontend UI page in Expertiza, addressing design inconsistencies and improving usability. It introduced a visually cohesive interface with an intuitive layout, enhanced responsiveness, and improved information display, allowing users to navigate grading data more efficiently. However, the interface was populated using dummy data, limiting its practical use. This reimplemented UI will utilize real data from the database (that has been populated in this round), ensuring that grading information is dynamically retrieved and displayed accurately through JSON objects. Additionally, this phase will connect the redesigned frontend with some new components in the grades_controller.rb. Specifically, the GET functions in the grades_controller were reimplemented to return JSON objects (instead of instance variables) that could be accessed via an API call. Thus, this new implementation ensures seamless communication between the UI and backend while adhering to best design practices for maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
This project focuses on integrating the frontend of the grades view page with the reimplemented '''grades_controller.rb (E2510)''' backend in Expertiza. This integration requires modifications to both the frontend and backend to establish a seamless connection, ensuring that grading data is dynamically retrieved and displayed accurately. By adhering to best design principles such as modularity, maintainability, and scalability, the implementation will enhance system efficiency and long-term usability. Key improvements include replacing dummy data with real database values, refining data flow between the UI and backend, and optimizing API interactions for better performance. These enhancements will create a more intuitive and reliable grading system, providing a seamless experience for instructors and students while maintaining a well-structured and adaptable codebase for future development.&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
# '''Establish a Robust Connection Between the Frontend and Backend''': Ensure smooth data retrieval and updates between the grades view page and the backend by integrating dynamic data through API calls, replacing the current hardcoded dummy data.&lt;br /&gt;
# '''Define and Implement Clear API Endpoints''': Create well-structured API endpoints in grades_controller.rb for retrieving and displaying grades, ensuring they return appropriate data based on user roles (students, instructors, TAs) and maintain role-based access controls.&lt;br /&gt;
# '''Dynamic Data Integration''': Modify the frontend to consume real-time data fetched from the backend, ensuring an intuitive and responsive UI that reflects the actual grading information. &lt;br /&gt;
# '''Refactor Frontend and Backend Components''': Refactor both the frontend and backend as necessary to align with SOLID and DRY principles, ensuring modularity, maintainability, and scalability. This includes eliminating redundant logic and optimizing code for better readability.&lt;br /&gt;
# '''Implement Proper Permission Checks''': Ensure that only authorized users can access grade information by implementing robust privilege checks and ensuring that the data is securely accessible to students, instructors, and TAs based on their roles.&lt;br /&gt;
# '''Optimize Database Queries and API Responses''': Enhance the efficiency of database queries and API responses to reduce unnecessary load and ensure that data is retrieved and displayed promptly.&lt;br /&gt;
# '''Testing and Validation''': Implement comprehensive unit and integration tests to verify the correctness of data flow, UI interactions, and role-based access controls, ensuring that the system functions correctly and securely.&lt;br /&gt;
&lt;br /&gt;
=Reimplementation Plan=&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populated data with the appropriate HTTP GET and HTTP POST calls. This shift is necessary to ensure that our application reflects real-time data from the backend rather than relying on static or hardcoded values, which can quickly become outdated or inconsistent. It also enables better scalability and maintainability, as changes to the data only need to be made in the backend, without requiring manual updates in the frontend code.&lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
'''Author Feedback''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
'''Heatmap Data''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
'''Team-mate Data''':&lt;br /&gt;
   {&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The current implementation caters to the backend for a Ruby-embedded front-end, where data is rendered server-side and passed directly into the view. We need to update the APIs to return data in a format that can be consumed by the React UI, typically JSON. This shift is essential to decouple the front-end from the server-side rendering logic, allowing for a more interactive and dynamic user experience. By transitioning to a React-based interface, we gain better control over UI state and responsiveness, while also aligning with modern web development practices. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and instead return plain JSON objects using render json: in the response. This change is necessary to align with a frontend architecture that uses React or another JavaScript framework, which expects structured data from the backend in JSON format rather than relying on server-rendered templates. By shifting to JSON responses, we enable cleaner API endpoints, facilitate easier testing and debugging, and support a more maintainable, decoupled frontend-backend integration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    # prepare feedback summaries&lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
  1.1. Students&lt;br /&gt;
  1.2. Teams&lt;br /&gt;
  1.3. TA&lt;br /&gt;
  1.4. Professor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
  2.1 assignments&lt;br /&gt;
  2.2 assignment_questionnaire&lt;br /&gt;
  2.3 questionnaires&lt;br /&gt;
  2.4 participant&lt;br /&gt;
  2.5 signed_up_teams&lt;br /&gt;
  2.6 teams_users&lt;br /&gt;
  2.7 due_dates&lt;br /&gt;
  2.8 late_policies&lt;br /&gt;
  2.9 questions&lt;br /&gt;
  2.10 review_scores&lt;br /&gt;
  2.11 review_grades&lt;br /&gt;
&lt;br /&gt;
== Data Flow Overview ==&lt;br /&gt;
The diagram below illustrates how data flows between the frontend React components and the grades_controller.rb backend during a typical grading data fetch operation.&lt;br /&gt;
&lt;br /&gt;
* The user (e.g., instructor or student) interacts with the React-based grades view (e.g., ReviewTable, RoundSelector, or Statistics).&lt;br /&gt;
* The component triggers an API request to a specific action in grades_controller.rb (e.g., GET /grades/:id/summary).&lt;br /&gt;
*The controller action queries the relevant models (e.g., Assignment, Team, ReviewResponseMap) and compiles a JSON response.&lt;br /&gt;
* The response is sent back to the frontend and parsed.&lt;br /&gt;
*The React components update the UI (tables, heatmaps, statistics) based on the received data.&lt;br /&gt;
&lt;br /&gt;
This architecture ensures a clean separation between frontend and backend logic, improving maintainability and testability.&lt;br /&gt;
[[File:Dataflow.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
The test plan for Phase 2 focuses on verifying the successful integration of the newly reimplemented &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the React-based UI components. We aim to ensure data is:&lt;br /&gt;
&lt;br /&gt;
* Correctly fetched from the backend  &lt;br /&gt;
* Appropriately displayed in the frontend  &lt;br /&gt;
* Functionally sound under both normal and edge-case scenarios&lt;br /&gt;
&lt;br /&gt;
== Tools and Frameworks ==&lt;br /&gt;
We plan to use the following tools and frameworks for testing:&lt;br /&gt;
&lt;br /&gt;
* '''Frontend''': Jest and React Testing Library for unit and integration tests&lt;br /&gt;
* '''Backend''': RSpec for controller and model tests&lt;br /&gt;
* '''Integration Testing''': Capybara and Selenium for simulating real user behavior&lt;br /&gt;
* '''Test Coverage''': SimpleCov&lt;br /&gt;
&lt;br /&gt;
== 1. UI Integration Tests ==&lt;br /&gt;
&lt;br /&gt;
These tests ensure the frontend correctly interacts with backend APIs and renders the data appropriately.&lt;br /&gt;
&lt;br /&gt;
=== ReviewTable Component ===&lt;br /&gt;
&lt;br /&gt;
* Validate that the component makes a successful API call to fetch author feedback  &lt;br /&gt;
* Ensure feedback is rendered in the correct table structure  &lt;br /&gt;
* Test loading state before data is fetched  &lt;br /&gt;
* Handle empty or malformed feedback responses gracefully  &lt;br /&gt;
&lt;br /&gt;
=== RoundSelector Component ===&lt;br /&gt;
&lt;br /&gt;
* Verify API call to fetch heatmap data is triggered on component load  &lt;br /&gt;
* Check that heatmap data is correctly visualized for different review rounds  &lt;br /&gt;
* Test behavior with no data, incomplete data, or delayed response  &lt;br /&gt;
&lt;br /&gt;
=== Statistics Component ===&lt;br /&gt;
&lt;br /&gt;
* Confirm it correctly fetches teammate evaluations and author feedback  &lt;br /&gt;
* Ensure charts or tables reflect the received backend data accurately  &lt;br /&gt;
* Test switching between different teams or assignments and verify correct display  &lt;br /&gt;
&lt;br /&gt;
=== General UI Considerations ===&lt;br /&gt;
&lt;br /&gt;
* Test frontend responsiveness to backend failures (500, 404, timeout)  &lt;br /&gt;
* Ensure authorization errors are handled and appropriate messages displayed  &lt;br /&gt;
&lt;br /&gt;
== 2. Backend API Tests ==&lt;br /&gt;
&lt;br /&gt;
While unit tests exist, integration-level tests will be added or updated to ensure UI compatibility.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
* Validate all &amp;lt;code&amp;gt;GET&amp;lt;/code&amp;gt; endpoints return properly structured JSON objects  &lt;br /&gt;
* Simulate various user roles (student, TA, instructor) and ensure access control  &lt;br /&gt;
* Include test cases for:&lt;br /&gt;
** No grades present  &lt;br /&gt;
** Partial data (e.g. missing feedback or evaluations)  &lt;br /&gt;
** Large number of records  &lt;br /&gt;
&lt;br /&gt;
=== Security &amp;amp; Permissions ===&lt;br /&gt;
&lt;br /&gt;
* Ensure students can only fetch their grades and feedback  &lt;br /&gt;
* Ensure TAs and instructors can access full assignment data  &lt;br /&gt;
* Test token/session-based access restrictions (if applicable)  &lt;br /&gt;
&lt;br /&gt;
== 3. Database Preparation ==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, seed data will simulate real-world usage and we will ensure that:&lt;br /&gt;
* Tests will use isolated fixtures or factories to ensure data consistency&lt;br /&gt;
* All database states will be reset before each test suite run&lt;br /&gt;
&lt;br /&gt;
=== Tables and Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;assignments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_participant&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;participants&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;questionnaires&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;questions&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_questionnaire&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;signed_up_teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;teams_users&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;late_policies&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
=== Scenarios ===&lt;br /&gt;
&lt;br /&gt;
* Single student assigned  &lt;br /&gt;
* Team assignments with/without feedback  &lt;br /&gt;
* Late submissions triggering late policies  &lt;br /&gt;
* Multiple review rounds per assignment&lt;br /&gt;
&lt;br /&gt;
== 4. Regression &amp;amp; CI Testing ==&lt;br /&gt;
&lt;br /&gt;
To ensure updates do not break existing functionality:&lt;br /&gt;
&lt;br /&gt;
* Re-run all existing unit tests  &lt;br /&gt;
* Include snapshot tests for frontend components  &lt;br /&gt;
* Use CI pipelines to automatically trigger tests on pull requests  &lt;br /&gt;
&lt;br /&gt;
== Test Plan Summary ==&lt;br /&gt;
&lt;br /&gt;
This test plan outlines the approach for integrating &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the frontend. By combining backend tests, UI integration checks, and realistic database scenarios, we aim to deliver a seamless user experience. The plan emphasizes early detection of issues and supports long-term maintainability through regression testing. As development progresses, the plan will be updated to cover new insights and edge cases.&lt;br /&gt;
&lt;br /&gt;
=Completed Reimplementation Details=&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The previous implementation was designed for a Ruby-embedded front-end, where data was rendered server-side and injected directly into the view. We have since updated the APIs to return data in a format suitable for consumption by the React UI, typically as JSON objects. This change successfully decouples the front-end from the server-side rendering logic, enabling a more interactive and responsive user experience. By transitioning to a React-based interface, we now have improved control over UI state and better alignment with modern web development practices.&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
In this controller, we have updated the GET functions to remove the use of instance variables and instead return plain JSON objects using render json: in the response. This update was essential to align with the frontend architecture, which now relies on a React-based interface that expects structured data from the backend in JSON format rather than server-rendered templates. By returning JSON responses, we’ve established cleaner and more consistent API endpoints, improved the testability and debuggability of our backend logic, and created a more maintainable and decoupled integration between the frontend and backend systems. The following functions were updated as part of this integration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  def view_grading_report&lt;br /&gt;
    assignment_id = params[:id].to_i&lt;br /&gt;
    data = get_data_for_heat_map(assignment_id)&lt;br /&gt;
    &lt;br /&gt;
    render json: data, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
    &lt;br /&gt;
  def view_my_scores&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team_id = TeamsUser.team_id(participant.assignment_id, participant.user_id)&lt;br /&gt;
    # return if redirect_when_disallowed(participant)&lt;br /&gt;
    questions = fetch_questionnaires_and_questions(assignment)&lt;br /&gt;
    pscore = fetch_participant_scores(participant, questions)&lt;br /&gt;
    topic_id = SignedUpTeam.find_topic_id_for_user(participant.assignment.id, participant.user_id)&lt;br /&gt;
    stage = participant.assignment.current_stage(topic_id)&lt;br /&gt;
    # all_penalties = update_penalties(assignment)&lt;br /&gt;
    # Feedback Summary needs to be checked once&lt;br /&gt;
    # summary_ws_url = WEBSERVICE_CONFIG['summary_webservice_url']&lt;br /&gt;
    sum = SummaryHelper::Summary.new.summarize_reviews_by_reviewee(questions, assignment, team_id, 'http://peerlogic.csc.ncsu.edu/sum/v1.0/summary/8/lsa', session)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      topic_id: topic_id,&lt;br /&gt;
      stage: stage,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      summary: sum.summary,&lt;br /&gt;
      avg_scores_by_round: sum.avg_scores_by_round,&lt;br /&gt;
      avg_scores_by_criterion: sum.avg_scores_by_criterion&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def view_team&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    team_id = team.id&lt;br /&gt;
  &lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: assignment.id).map(&amp;amp;:questionnaire)&lt;br /&gt;
    questions = retrieve_questions(questionnaires, assignment.id)&lt;br /&gt;
    pscore = Response.participant_scores(participant, questions)&lt;br /&gt;
    vmlist = process_questionare_for_team(assignment, team_id,questionnaires, team, participant)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team: team,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      vmlist: vmlist&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
==Data Flow Overview==&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
==Adhering to Priciples==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164218</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164218"/>
		<updated>2025-04-20T18:00:34Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* API */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of this project is to integrate the frontend of the grades view page with the reimplemented '''''grades_controller.rb (E2510)''''' backend in Expertiza, ensuring a seamless connection between both layers. This integration involves refining the interaction between the UI and backend while adhering to best design principles such as modularity, maintainability, and scalability. The grades_controller.rb is responsible for managing grading functionality, allowing instructors to view and modify assignment grades while enabling students to access their evaluations. By following SOLID and DRY principles, this reimplementation enhances code clarity, reduces redundancy, and improves overall system efficiency.&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
The &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; is responsible for managing and delivering grading data to users in the Expertiza system. It enables instructors to view, calculate, and release grades to students, while also allowing students to view feedback and scores for assignments. The controller plays an important role in coordinating backend logic for reviews and grade visibility.&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
The previous implementation successfully created a functional frontend UI page in Expertiza, addressing design inconsistencies and improving usability. It introduced a visually cohesive interface with an intuitive layout, enhanced responsiveness, and improved information display, allowing users to navigate grading data more efficiently. However, the interface was populated using dummy data, limiting its practical use. This reimplemented UI will utilize real data from the database (that has been populated in this round), ensuring that grading information is dynamically retrieved and displayed accurately through JSON objects. Additionally, this phase will connect the redesigned frontend with some new components in the grades_controller.rb. Specifically, the GET functions in the grades_controller were reimplemented to return JSON objects (instead of instance variables) that could be accessed via an API call. Thus, this new implementation ensures seamless communication between the UI and backend while adhering to best design practices for maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
This project focuses on integrating the frontend of the grades view page with the reimplemented '''grades_controller.rb (E2510)''' backend in Expertiza. This integration requires modifications to both the frontend and backend to establish a seamless connection, ensuring that grading data is dynamically retrieved and displayed accurately. By adhering to best design principles such as modularity, maintainability, and scalability, the implementation will enhance system efficiency and long-term usability. Key improvements include replacing dummy data with real database values, refining data flow between the UI and backend, and optimizing API interactions for better performance. These enhancements will create a more intuitive and reliable grading system, providing a seamless experience for instructors and students while maintaining a well-structured and adaptable codebase for future development.&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
# '''Establish a Robust Connection Between the Frontend and Backend''': Ensure smooth data retrieval and updates between the grades view page and the backend by integrating dynamic data through API calls, replacing the current hardcoded dummy data.&lt;br /&gt;
# '''Define and Implement Clear API Endpoints''': Create well-structured API endpoints in grades_controller.rb for retrieving and displaying grades, ensuring they return appropriate data based on user roles (students, instructors, TAs) and maintain role-based access controls.&lt;br /&gt;
# '''Dynamic Data Integration''': Modify the frontend to consume real-time data fetched from the backend, ensuring an intuitive and responsive UI that reflects the actual grading information. &lt;br /&gt;
# '''Refactor Frontend and Backend Components''': Refactor both the frontend and backend as necessary to align with SOLID and DRY principles, ensuring modularity, maintainability, and scalability. This includes eliminating redundant logic and optimizing code for better readability.&lt;br /&gt;
# '''Implement Proper Permission Checks''': Ensure that only authorized users can access grade information by implementing robust privilege checks and ensuring that the data is securely accessible to students, instructors, and TAs based on their roles.&lt;br /&gt;
# '''Optimize Database Queries and API Responses''': Enhance the efficiency of database queries and API responses to reduce unnecessary load and ensure that data is retrieved and displayed promptly.&lt;br /&gt;
# '''Testing and Validation''': Implement comprehensive unit and integration tests to verify the correctness of data flow, UI interactions, and role-based access controls, ensuring that the system functions correctly and securely.&lt;br /&gt;
&lt;br /&gt;
=Reimplementation Plan=&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populated data with the appropriate HTTP GET and HTTP POST calls. This shift is necessary to ensure that our application reflects real-time data from the backend rather than relying on static or hardcoded values, which can quickly become outdated or inconsistent. It also enables better scalability and maintainability, as changes to the data only need to be made in the backend, without requiring manual updates in the frontend code.&lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
'''Author Feedback''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
'''Heatmap Data''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
'''Team-mate Data''':&lt;br /&gt;
   {&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The current implementation caters to the backend for a Ruby-embedded front-end, where data is rendered server-side and passed directly into the view. We need to update the APIs to return data in a format that can be consumed by the React UI, typically JSON. This shift is essential to decouple the front-end from the server-side rendering logic, allowing for a more interactive and dynamic user experience. By transitioning to a React-based interface, we gain better control over UI state and responsiveness, while also aligning with modern web development practices. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and instead return plain JSON objects using render json: in the response. This change is necessary to align with a frontend architecture that uses React or another JavaScript framework, which expects structured data from the backend in JSON format rather than relying on server-rendered templates. By shifting to JSON responses, we enable cleaner API endpoints, facilitate easier testing and debugging, and support a more maintainable, decoupled frontend-backend integration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    # prepare feedback summaries&lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
  1.1. Students&lt;br /&gt;
  1.2. Teams&lt;br /&gt;
  1.3. TA&lt;br /&gt;
  1.4. Professor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
  2.1 assignments&lt;br /&gt;
  2.2 assignment_questionnaire&lt;br /&gt;
  2.3 questionnaires&lt;br /&gt;
  2.4 participant&lt;br /&gt;
  2.5 signed_up_teams&lt;br /&gt;
  2.6 teams_users&lt;br /&gt;
  2.7 due_dates&lt;br /&gt;
  2.8 late_policies&lt;br /&gt;
  2.9 questions&lt;br /&gt;
  2.10 review_scores&lt;br /&gt;
  2.11 review_grades&lt;br /&gt;
&lt;br /&gt;
== Data Flow Overview ==&lt;br /&gt;
The diagram below illustrates how data flows between the frontend React components and the grades_controller.rb backend during a typical grading data fetch operation.&lt;br /&gt;
&lt;br /&gt;
* The user (e.g., instructor or student) interacts with the React-based grades view (e.g., ReviewTable, RoundSelector, or Statistics).&lt;br /&gt;
* The component triggers an API request to a specific action in grades_controller.rb (e.g., GET /grades/:id/summary).&lt;br /&gt;
*The controller action queries the relevant models (e.g., Assignment, Team, ReviewResponseMap) and compiles a JSON response.&lt;br /&gt;
* The response is sent back to the frontend and parsed.&lt;br /&gt;
*The React components update the UI (tables, heatmaps, statistics) based on the received data.&lt;br /&gt;
&lt;br /&gt;
This architecture ensures a clean separation between frontend and backend logic, improving maintainability and testability.&lt;br /&gt;
[[File:Dataflow.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
The test plan for Phase 2 focuses on verifying the successful integration of the newly reimplemented &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the React-based UI components. We aim to ensure data is:&lt;br /&gt;
&lt;br /&gt;
* Correctly fetched from the backend  &lt;br /&gt;
* Appropriately displayed in the frontend  &lt;br /&gt;
* Functionally sound under both normal and edge-case scenarios&lt;br /&gt;
&lt;br /&gt;
== Tools and Frameworks ==&lt;br /&gt;
We plan to use the following tools and frameworks for testing:&lt;br /&gt;
&lt;br /&gt;
* '''Frontend''': Jest and React Testing Library for unit and integration tests&lt;br /&gt;
* '''Backend''': RSpec for controller and model tests&lt;br /&gt;
* '''Integration Testing''': Capybara and Selenium for simulating real user behavior&lt;br /&gt;
* '''Test Coverage''': SimpleCov&lt;br /&gt;
&lt;br /&gt;
== 1. UI Integration Tests ==&lt;br /&gt;
&lt;br /&gt;
These tests ensure the frontend correctly interacts with backend APIs and renders the data appropriately.&lt;br /&gt;
&lt;br /&gt;
=== ReviewTable Component ===&lt;br /&gt;
&lt;br /&gt;
* Validate that the component makes a successful API call to fetch author feedback  &lt;br /&gt;
* Ensure feedback is rendered in the correct table structure  &lt;br /&gt;
* Test loading state before data is fetched  &lt;br /&gt;
* Handle empty or malformed feedback responses gracefully  &lt;br /&gt;
&lt;br /&gt;
=== RoundSelector Component ===&lt;br /&gt;
&lt;br /&gt;
* Verify API call to fetch heatmap data is triggered on component load  &lt;br /&gt;
* Check that heatmap data is correctly visualized for different review rounds  &lt;br /&gt;
* Test behavior with no data, incomplete data, or delayed response  &lt;br /&gt;
&lt;br /&gt;
=== Statistics Component ===&lt;br /&gt;
&lt;br /&gt;
* Confirm it correctly fetches teammate evaluations and author feedback  &lt;br /&gt;
* Ensure charts or tables reflect the received backend data accurately  &lt;br /&gt;
* Test switching between different teams or assignments and verify correct display  &lt;br /&gt;
&lt;br /&gt;
=== General UI Considerations ===&lt;br /&gt;
&lt;br /&gt;
* Test frontend responsiveness to backend failures (500, 404, timeout)  &lt;br /&gt;
* Ensure authorization errors are handled and appropriate messages displayed  &lt;br /&gt;
&lt;br /&gt;
== 2. Backend API Tests ==&lt;br /&gt;
&lt;br /&gt;
While unit tests exist, integration-level tests will be added or updated to ensure UI compatibility.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
* Validate all &amp;lt;code&amp;gt;GET&amp;lt;/code&amp;gt; endpoints return properly structured JSON objects  &lt;br /&gt;
* Simulate various user roles (student, TA, instructor) and ensure access control  &lt;br /&gt;
* Include test cases for:&lt;br /&gt;
** No grades present  &lt;br /&gt;
** Partial data (e.g. missing feedback or evaluations)  &lt;br /&gt;
** Large number of records  &lt;br /&gt;
&lt;br /&gt;
=== Security &amp;amp; Permissions ===&lt;br /&gt;
&lt;br /&gt;
* Ensure students can only fetch their grades and feedback  &lt;br /&gt;
* Ensure TAs and instructors can access full assignment data  &lt;br /&gt;
* Test token/session-based access restrictions (if applicable)  &lt;br /&gt;
&lt;br /&gt;
== 3. Database Preparation ==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, seed data will simulate real-world usage and we will ensure that:&lt;br /&gt;
* Tests will use isolated fixtures or factories to ensure data consistency&lt;br /&gt;
* All database states will be reset before each test suite run&lt;br /&gt;
&lt;br /&gt;
=== Tables and Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;assignments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_participant&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;participants&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;questionnaires&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;questions&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_questionnaire&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;signed_up_teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;teams_users&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;late_policies&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
=== Scenarios ===&lt;br /&gt;
&lt;br /&gt;
* Single student assigned  &lt;br /&gt;
* Team assignments with/without feedback  &lt;br /&gt;
* Late submissions triggering late policies  &lt;br /&gt;
* Multiple review rounds per assignment&lt;br /&gt;
&lt;br /&gt;
== 4. Regression &amp;amp; CI Testing ==&lt;br /&gt;
&lt;br /&gt;
To ensure updates do not break existing functionality:&lt;br /&gt;
&lt;br /&gt;
* Re-run all existing unit tests  &lt;br /&gt;
* Include snapshot tests for frontend components  &lt;br /&gt;
* Use CI pipelines to automatically trigger tests on pull requests  &lt;br /&gt;
&lt;br /&gt;
== Test Plan Summary ==&lt;br /&gt;
&lt;br /&gt;
This test plan outlines the approach for integrating &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the frontend. By combining backend tests, UI integration checks, and realistic database scenarios, we aim to deliver a seamless user experience. The plan emphasizes early detection of issues and supports long-term maintainability through regression testing. As development progresses, the plan will be updated to cover new insights and edge cases.&lt;br /&gt;
&lt;br /&gt;
=Completed Reimplementation Details=&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The previous implementation was designed for a Ruby-embedded front-end, where data was rendered server-side and injected directly into the view. We have since updated the APIs to return data in a format suitable for consumption by the React UI, typically as JSON objects. This change successfully decouples the front-end from the server-side rendering logic, enabling a more interactive and responsive user experience. By transitioning to a React-based interface, we now have improved control over UI state and better alignment with modern web development practices.&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
In this controller, we have updated the GET functions to remove the use of instance variables and instead return plain JSON objects using render json: in the response. This update was essential to align with the frontend architecture, which now relies on a React-based interface that expects structured data from the backend in JSON format rather than server-rendered templates. By returning JSON responses, we’ve established cleaner and more consistent API endpoints, improved the testability and debuggability of our backend logic, and created a more maintainable and decoupled integration between the frontend and backend systems. The following functions were updated as part of this integration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  def view_grading_report&lt;br /&gt;
    assignment_id = params[:id].to_i&lt;br /&gt;
    data = get_data_for_heat_map(assignment_id)&lt;br /&gt;
    &lt;br /&gt;
    render json: data, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
  def view_my_scores&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team_id = TeamsUser.team_id(participant.assignment_id, participant.user_id)&lt;br /&gt;
    # return if redirect_when_disallowed(participant)&lt;br /&gt;
    questions = fetch_questionnaires_and_questions(assignment)&lt;br /&gt;
    pscore = fetch_participant_scores(participant, questions)&lt;br /&gt;
    topic_id = SignedUpTeam.find_topic_id_for_user(participant.assignment.id, participant.user_id)&lt;br /&gt;
    stage = participant.assignment.current_stage(topic_id)&lt;br /&gt;
    # all_penalties = update_penalties(assignment)&lt;br /&gt;
    # Feedback Summary needs to be checked once&lt;br /&gt;
    # summary_ws_url = WEBSERVICE_CONFIG['summary_webservice_url']&lt;br /&gt;
    sum = SummaryHelper::Summary.new.summarize_reviews_by_reviewee(questions, assignment, team_id, 'http://peerlogic.csc.ncsu.edu/sum/v1.0/summary/8/lsa', session)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      topic_id: topic_id,&lt;br /&gt;
      stage: stage,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      summary: sum.summary,&lt;br /&gt;
      avg_scores_by_round: sum.avg_scores_by_round,&lt;br /&gt;
      avg_scores_by_criterion: sum.avg_scores_by_criterion&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  def view_team&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    team_id = team.id&lt;br /&gt;
  &lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: assignment.id).map(&amp;amp;:questionnaire)&lt;br /&gt;
    questions = retrieve_questions(questionnaires, assignment.id)&lt;br /&gt;
    pscore = Response.participant_scores(participant, questions)&lt;br /&gt;
    vmlist = process_questionare_for_team(assignment, team_id,questionnaires, team, participant)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team: team,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      vmlist: vmlist&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
==Data Flow Overview==&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
==Adhering to Priciples==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164217</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164217"/>
		<updated>2025-04-20T17:59:57Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* API */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of this project is to integrate the frontend of the grades view page with the reimplemented '''''grades_controller.rb (E2510)''''' backend in Expertiza, ensuring a seamless connection between both layers. This integration involves refining the interaction between the UI and backend while adhering to best design principles such as modularity, maintainability, and scalability. The grades_controller.rb is responsible for managing grading functionality, allowing instructors to view and modify assignment grades while enabling students to access their evaluations. By following SOLID and DRY principles, this reimplementation enhances code clarity, reduces redundancy, and improves overall system efficiency.&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
The &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; is responsible for managing and delivering grading data to users in the Expertiza system. It enables instructors to view, calculate, and release grades to students, while also allowing students to view feedback and scores for assignments. The controller plays an important role in coordinating backend logic for reviews and grade visibility.&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
The previous implementation successfully created a functional frontend UI page in Expertiza, addressing design inconsistencies and improving usability. It introduced a visually cohesive interface with an intuitive layout, enhanced responsiveness, and improved information display, allowing users to navigate grading data more efficiently. However, the interface was populated using dummy data, limiting its practical use. This reimplemented UI will utilize real data from the database (that has been populated in this round), ensuring that grading information is dynamically retrieved and displayed accurately through JSON objects. Additionally, this phase will connect the redesigned frontend with some new components in the grades_controller.rb. Specifically, the GET functions in the grades_controller were reimplemented to return JSON objects (instead of instance variables) that could be accessed via an API call. Thus, this new implementation ensures seamless communication between the UI and backend while adhering to best design practices for maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
This project focuses on integrating the frontend of the grades view page with the reimplemented '''grades_controller.rb (E2510)''' backend in Expertiza. This integration requires modifications to both the frontend and backend to establish a seamless connection, ensuring that grading data is dynamically retrieved and displayed accurately. By adhering to best design principles such as modularity, maintainability, and scalability, the implementation will enhance system efficiency and long-term usability. Key improvements include replacing dummy data with real database values, refining data flow between the UI and backend, and optimizing API interactions for better performance. These enhancements will create a more intuitive and reliable grading system, providing a seamless experience for instructors and students while maintaining a well-structured and adaptable codebase for future development.&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
# '''Establish a Robust Connection Between the Frontend and Backend''': Ensure smooth data retrieval and updates between the grades view page and the backend by integrating dynamic data through API calls, replacing the current hardcoded dummy data.&lt;br /&gt;
# '''Define and Implement Clear API Endpoints''': Create well-structured API endpoints in grades_controller.rb for retrieving and displaying grades, ensuring they return appropriate data based on user roles (students, instructors, TAs) and maintain role-based access controls.&lt;br /&gt;
# '''Dynamic Data Integration''': Modify the frontend to consume real-time data fetched from the backend, ensuring an intuitive and responsive UI that reflects the actual grading information. &lt;br /&gt;
# '''Refactor Frontend and Backend Components''': Refactor both the frontend and backend as necessary to align with SOLID and DRY principles, ensuring modularity, maintainability, and scalability. This includes eliminating redundant logic and optimizing code for better readability.&lt;br /&gt;
# '''Implement Proper Permission Checks''': Ensure that only authorized users can access grade information by implementing robust privilege checks and ensuring that the data is securely accessible to students, instructors, and TAs based on their roles.&lt;br /&gt;
# '''Optimize Database Queries and API Responses''': Enhance the efficiency of database queries and API responses to reduce unnecessary load and ensure that data is retrieved and displayed promptly.&lt;br /&gt;
# '''Testing and Validation''': Implement comprehensive unit and integration tests to verify the correctness of data flow, UI interactions, and role-based access controls, ensuring that the system functions correctly and securely.&lt;br /&gt;
&lt;br /&gt;
=Reimplementation Plan=&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populated data with the appropriate HTTP GET and HTTP POST calls. This shift is necessary to ensure that our application reflects real-time data from the backend rather than relying on static or hardcoded values, which can quickly become outdated or inconsistent. It also enables better scalability and maintainability, as changes to the data only need to be made in the backend, without requiring manual updates in the frontend code.&lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
'''Author Feedback''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
'''Heatmap Data''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
'''Team-mate Data''':&lt;br /&gt;
   {&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The current implementation caters to the backend for a Ruby-embedded front-end, where data is rendered server-side and passed directly into the view. We need to update the APIs to return data in a format that can be consumed by the React UI, typically JSON. This shift is essential to decouple the front-end from the server-side rendering logic, allowing for a more interactive and dynamic user experience. By transitioning to a React-based interface, we gain better control over UI state and responsiveness, while also aligning with modern web development practices. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and instead return plain JSON objects using render json: in the response. This change is necessary to align with a frontend architecture that uses React or another JavaScript framework, which expects structured data from the backend in JSON format rather than relying on server-rendered templates. By shifting to JSON responses, we enable cleaner API endpoints, facilitate easier testing and debugging, and support a more maintainable, decoupled frontend-backend integration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    # prepare feedback summaries&lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
  1.1. Students&lt;br /&gt;
  1.2. Teams&lt;br /&gt;
  1.3. TA&lt;br /&gt;
  1.4. Professor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
  2.1 assignments&lt;br /&gt;
  2.2 assignment_questionnaire&lt;br /&gt;
  2.3 questionnaires&lt;br /&gt;
  2.4 participant&lt;br /&gt;
  2.5 signed_up_teams&lt;br /&gt;
  2.6 teams_users&lt;br /&gt;
  2.7 due_dates&lt;br /&gt;
  2.8 late_policies&lt;br /&gt;
  2.9 questions&lt;br /&gt;
  2.10 review_scores&lt;br /&gt;
  2.11 review_grades&lt;br /&gt;
&lt;br /&gt;
== Data Flow Overview ==&lt;br /&gt;
The diagram below illustrates how data flows between the frontend React components and the grades_controller.rb backend during a typical grading data fetch operation.&lt;br /&gt;
&lt;br /&gt;
* The user (e.g., instructor or student) interacts with the React-based grades view (e.g., ReviewTable, RoundSelector, or Statistics).&lt;br /&gt;
* The component triggers an API request to a specific action in grades_controller.rb (e.g., GET /grades/:id/summary).&lt;br /&gt;
*The controller action queries the relevant models (e.g., Assignment, Team, ReviewResponseMap) and compiles a JSON response.&lt;br /&gt;
* The response is sent back to the frontend and parsed.&lt;br /&gt;
*The React components update the UI (tables, heatmaps, statistics) based on the received data.&lt;br /&gt;
&lt;br /&gt;
This architecture ensures a clean separation between frontend and backend logic, improving maintainability and testability.&lt;br /&gt;
[[File:Dataflow.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
The test plan for Phase 2 focuses on verifying the successful integration of the newly reimplemented &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the React-based UI components. We aim to ensure data is:&lt;br /&gt;
&lt;br /&gt;
* Correctly fetched from the backend  &lt;br /&gt;
* Appropriately displayed in the frontend  &lt;br /&gt;
* Functionally sound under both normal and edge-case scenarios&lt;br /&gt;
&lt;br /&gt;
== Tools and Frameworks ==&lt;br /&gt;
We plan to use the following tools and frameworks for testing:&lt;br /&gt;
&lt;br /&gt;
* '''Frontend''': Jest and React Testing Library for unit and integration tests&lt;br /&gt;
* '''Backend''': RSpec for controller and model tests&lt;br /&gt;
* '''Integration Testing''': Capybara and Selenium for simulating real user behavior&lt;br /&gt;
* '''Test Coverage''': SimpleCov&lt;br /&gt;
&lt;br /&gt;
== 1. UI Integration Tests ==&lt;br /&gt;
&lt;br /&gt;
These tests ensure the frontend correctly interacts with backend APIs and renders the data appropriately.&lt;br /&gt;
&lt;br /&gt;
=== ReviewTable Component ===&lt;br /&gt;
&lt;br /&gt;
* Validate that the component makes a successful API call to fetch author feedback  &lt;br /&gt;
* Ensure feedback is rendered in the correct table structure  &lt;br /&gt;
* Test loading state before data is fetched  &lt;br /&gt;
* Handle empty or malformed feedback responses gracefully  &lt;br /&gt;
&lt;br /&gt;
=== RoundSelector Component ===&lt;br /&gt;
&lt;br /&gt;
* Verify API call to fetch heatmap data is triggered on component load  &lt;br /&gt;
* Check that heatmap data is correctly visualized for different review rounds  &lt;br /&gt;
* Test behavior with no data, incomplete data, or delayed response  &lt;br /&gt;
&lt;br /&gt;
=== Statistics Component ===&lt;br /&gt;
&lt;br /&gt;
* Confirm it correctly fetches teammate evaluations and author feedback  &lt;br /&gt;
* Ensure charts or tables reflect the received backend data accurately  &lt;br /&gt;
* Test switching between different teams or assignments and verify correct display  &lt;br /&gt;
&lt;br /&gt;
=== General UI Considerations ===&lt;br /&gt;
&lt;br /&gt;
* Test frontend responsiveness to backend failures (500, 404, timeout)  &lt;br /&gt;
* Ensure authorization errors are handled and appropriate messages displayed  &lt;br /&gt;
&lt;br /&gt;
== 2. Backend API Tests ==&lt;br /&gt;
&lt;br /&gt;
While unit tests exist, integration-level tests will be added or updated to ensure UI compatibility.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
* Validate all &amp;lt;code&amp;gt;GET&amp;lt;/code&amp;gt; endpoints return properly structured JSON objects  &lt;br /&gt;
* Simulate various user roles (student, TA, instructor) and ensure access control  &lt;br /&gt;
* Include test cases for:&lt;br /&gt;
** No grades present  &lt;br /&gt;
** Partial data (e.g. missing feedback or evaluations)  &lt;br /&gt;
** Large number of records  &lt;br /&gt;
&lt;br /&gt;
=== Security &amp;amp; Permissions ===&lt;br /&gt;
&lt;br /&gt;
* Ensure students can only fetch their grades and feedback  &lt;br /&gt;
* Ensure TAs and instructors can access full assignment data  &lt;br /&gt;
* Test token/session-based access restrictions (if applicable)  &lt;br /&gt;
&lt;br /&gt;
== 3. Database Preparation ==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, seed data will simulate real-world usage and we will ensure that:&lt;br /&gt;
* Tests will use isolated fixtures or factories to ensure data consistency&lt;br /&gt;
* All database states will be reset before each test suite run&lt;br /&gt;
&lt;br /&gt;
=== Tables and Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;assignments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_participant&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;participants&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;questionnaires&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;questions&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_questionnaire&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;signed_up_teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;teams_users&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;late_policies&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
=== Scenarios ===&lt;br /&gt;
&lt;br /&gt;
* Single student assigned  &lt;br /&gt;
* Team assignments with/without feedback  &lt;br /&gt;
* Late submissions triggering late policies  &lt;br /&gt;
* Multiple review rounds per assignment&lt;br /&gt;
&lt;br /&gt;
== 4. Regression &amp;amp; CI Testing ==&lt;br /&gt;
&lt;br /&gt;
To ensure updates do not break existing functionality:&lt;br /&gt;
&lt;br /&gt;
* Re-run all existing unit tests  &lt;br /&gt;
* Include snapshot tests for frontend components  &lt;br /&gt;
* Use CI pipelines to automatically trigger tests on pull requests  &lt;br /&gt;
&lt;br /&gt;
== Test Plan Summary ==&lt;br /&gt;
&lt;br /&gt;
This test plan outlines the approach for integrating &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the frontend. By combining backend tests, UI integration checks, and realistic database scenarios, we aim to deliver a seamless user experience. The plan emphasizes early detection of issues and supports long-term maintainability through regression testing. As development progresses, the plan will be updated to cover new insights and edge cases.&lt;br /&gt;
&lt;br /&gt;
=Completed Reimplementation Details=&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The previous implementation was designed for a Ruby-embedded front-end, where data was rendered server-side and injected directly into the view. We have since updated the APIs to return data in a format suitable for consumption by the React UI, typically as JSON objects. This change successfully decouples the front-end from the server-side rendering logic, enabling a more interactive and responsive user experience. By transitioning to a React-based interface, we now have improved control over UI state and better alignment with modern web development practices.&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
In this controller, we have updated the GET functions to remove the use of instance variables and instead return plain JSON objects using render json: in the response. This update was essential to align with the frontend architecture, which now relies on a React-based interface that expects structured data from the backend in JSON format rather than server-rendered templates. By returning JSON responses, we’ve established cleaner and more consistent API endpoints, improved the testability and debuggability of our backend logic, and created a more maintainable and decoupled integration between the frontend and backend systems. The following functions were updated as part of this integration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  def view_grading_report&lt;br /&gt;
    assignment_id = params[:id].to_i&lt;br /&gt;
    data = get_data_for_heat_map(assignment_id)&lt;br /&gt;
    &lt;br /&gt;
    render json: data, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
  def view_my_scores&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team_id = TeamsUser.team_id(participant.assignment_id, participant.user_id)&lt;br /&gt;
&lt;br /&gt;
    # return if redirect_when_disallowed(participant)&lt;br /&gt;
  &lt;br /&gt;
    questions = fetch_questionnaires_and_questions(assignment)&lt;br /&gt;
  &lt;br /&gt;
    pscore = fetch_participant_scores(participant, questions)&lt;br /&gt;
  &lt;br /&gt;
    topic_id = SignedUpTeam.find_topic_id_for_user(participant.assignment.id, participant.user_id)&lt;br /&gt;
    stage = participant.assignment.current_stage(topic_id)&lt;br /&gt;
  &lt;br /&gt;
    # all_penalties = update_penalties(assignment)&lt;br /&gt;
  &lt;br /&gt;
    # Feedback Summary needs to be checked once&lt;br /&gt;
    # summary_ws_url = WEBSERVICE_CONFIG['summary_webservice_url']&lt;br /&gt;
    sum = SummaryHelper::Summary.new.summarize_reviews_by_reviewee(questions, assignment, team_id, 'http://peerlogic.csc.ncsu.edu/sum/v1.0/summary/8/lsa', session)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      topic_id: topic_id,&lt;br /&gt;
      stage: stage,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      summary: sum.summary,&lt;br /&gt;
      avg_scores_by_round: sum.avg_scores_by_round,&lt;br /&gt;
      avg_scores_by_criterion: sum.avg_scores_by_criterion&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  def view_team&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    team = participant.team&lt;br /&gt;
    team_id = team.id&lt;br /&gt;
  &lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: assignment.id).map(&amp;amp;:questionnaire)&lt;br /&gt;
    questions = retrieve_questions(questionnaires, assignment.id)&lt;br /&gt;
    pscore = Response.participant_scores(participant, questions)&lt;br /&gt;
    vmlist = process_questionare_for_team(assignment, team_id,questionnaires, team, participant)&lt;br /&gt;
  &lt;br /&gt;
    render json: {&lt;br /&gt;
      participant: participant,&lt;br /&gt;
      assignment: assignment,&lt;br /&gt;
      team: team,&lt;br /&gt;
      team_id: team_id,&lt;br /&gt;
      questions: questions,&lt;br /&gt;
      pscore: pscore,&lt;br /&gt;
      vmlist: vmlist&lt;br /&gt;
    }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
==Data Flow Overview==&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
==Adhering to Priciples==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164216</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164216"/>
		<updated>2025-04-20T17:52:34Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* Completed Reimplementation Details */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of this project is to integrate the frontend of the grades view page with the reimplemented '''''grades_controller.rb (E2510)''''' backend in Expertiza, ensuring a seamless connection between both layers. This integration involves refining the interaction between the UI and backend while adhering to best design principles such as modularity, maintainability, and scalability. The grades_controller.rb is responsible for managing grading functionality, allowing instructors to view and modify assignment grades while enabling students to access their evaluations. By following SOLID and DRY principles, this reimplementation enhances code clarity, reduces redundancy, and improves overall system efficiency.&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
The &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; is responsible for managing and delivering grading data to users in the Expertiza system. It enables instructors to view, calculate, and release grades to students, while also allowing students to view feedback and scores for assignments. The controller plays an important role in coordinating backend logic for reviews and grade visibility.&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
The previous implementation successfully created a functional frontend UI page in Expertiza, addressing design inconsistencies and improving usability. It introduced a visually cohesive interface with an intuitive layout, enhanced responsiveness, and improved information display, allowing users to navigate grading data more efficiently. However, the interface was populated using dummy data, limiting its practical use. This reimplemented UI will utilize real data from the database (that has been populated in this round), ensuring that grading information is dynamically retrieved and displayed accurately through JSON objects. Additionally, this phase will connect the redesigned frontend with some new components in the grades_controller.rb. Specifically, the GET functions in the grades_controller were reimplemented to return JSON objects (instead of instance variables) that could be accessed via an API call. Thus, this new implementation ensures seamless communication between the UI and backend while adhering to best design practices for maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
This project focuses on integrating the frontend of the grades view page with the reimplemented '''grades_controller.rb (E2510)''' backend in Expertiza. This integration requires modifications to both the frontend and backend to establish a seamless connection, ensuring that grading data is dynamically retrieved and displayed accurately. By adhering to best design principles such as modularity, maintainability, and scalability, the implementation will enhance system efficiency and long-term usability. Key improvements include replacing dummy data with real database values, refining data flow between the UI and backend, and optimizing API interactions for better performance. These enhancements will create a more intuitive and reliable grading system, providing a seamless experience for instructors and students while maintaining a well-structured and adaptable codebase for future development.&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
# '''Establish a Robust Connection Between the Frontend and Backend''': Ensure smooth data retrieval and updates between the grades view page and the backend by integrating dynamic data through API calls, replacing the current hardcoded dummy data.&lt;br /&gt;
# '''Define and Implement Clear API Endpoints''': Create well-structured API endpoints in grades_controller.rb for retrieving and displaying grades, ensuring they return appropriate data based on user roles (students, instructors, TAs) and maintain role-based access controls.&lt;br /&gt;
# '''Dynamic Data Integration''': Modify the frontend to consume real-time data fetched from the backend, ensuring an intuitive and responsive UI that reflects the actual grading information. &lt;br /&gt;
# '''Refactor Frontend and Backend Components''': Refactor both the frontend and backend as necessary to align with SOLID and DRY principles, ensuring modularity, maintainability, and scalability. This includes eliminating redundant logic and optimizing code for better readability.&lt;br /&gt;
# '''Implement Proper Permission Checks''': Ensure that only authorized users can access grade information by implementing robust privilege checks and ensuring that the data is securely accessible to students, instructors, and TAs based on their roles.&lt;br /&gt;
# '''Optimize Database Queries and API Responses''': Enhance the efficiency of database queries and API responses to reduce unnecessary load and ensure that data is retrieved and displayed promptly.&lt;br /&gt;
# '''Testing and Validation''': Implement comprehensive unit and integration tests to verify the correctness of data flow, UI interactions, and role-based access controls, ensuring that the system functions correctly and securely.&lt;br /&gt;
&lt;br /&gt;
=Reimplementation Plan=&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populated data with the appropriate HTTP GET and HTTP POST calls. This shift is necessary to ensure that our application reflects real-time data from the backend rather than relying on static or hardcoded values, which can quickly become outdated or inconsistent. It also enables better scalability and maintainability, as changes to the data only need to be made in the backend, without requiring manual updates in the frontend code.&lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
'''Author Feedback''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
'''Heatmap Data''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
'''Team-mate Data''':&lt;br /&gt;
   {&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The current implementation caters to the backend for a Ruby-embedded front-end, where data is rendered server-side and passed directly into the view. We need to update the APIs to return data in a format that can be consumed by the React UI, typically JSON. This shift is essential to decouple the front-end from the server-side rendering logic, allowing for a more interactive and dynamic user experience. By transitioning to a React-based interface, we gain better control over UI state and responsiveness, while also aligning with modern web development practices. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and instead return plain JSON objects using render json: in the response. This change is necessary to align with a frontend architecture that uses React or another JavaScript framework, which expects structured data from the backend in JSON format rather than relying on server-rendered templates. By shifting to JSON responses, we enable cleaner API endpoints, facilitate easier testing and debugging, and support a more maintainable, decoupled frontend-backend integration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    # prepare feedback summaries&lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
  1.1. Students&lt;br /&gt;
  1.2. Teams&lt;br /&gt;
  1.3. TA&lt;br /&gt;
  1.4. Professor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
  2.1 assignments&lt;br /&gt;
  2.2 assignment_questionnaire&lt;br /&gt;
  2.3 questionnaires&lt;br /&gt;
  2.4 participant&lt;br /&gt;
  2.5 signed_up_teams&lt;br /&gt;
  2.6 teams_users&lt;br /&gt;
  2.7 due_dates&lt;br /&gt;
  2.8 late_policies&lt;br /&gt;
  2.9 questions&lt;br /&gt;
  2.10 review_scores&lt;br /&gt;
  2.11 review_grades&lt;br /&gt;
&lt;br /&gt;
== Data Flow Overview ==&lt;br /&gt;
The diagram below illustrates how data flows between the frontend React components and the grades_controller.rb backend during a typical grading data fetch operation.&lt;br /&gt;
&lt;br /&gt;
* The user (e.g., instructor or student) interacts with the React-based grades view (e.g., ReviewTable, RoundSelector, or Statistics).&lt;br /&gt;
* The component triggers an API request to a specific action in grades_controller.rb (e.g., GET /grades/:id/summary).&lt;br /&gt;
*The controller action queries the relevant models (e.g., Assignment, Team, ReviewResponseMap) and compiles a JSON response.&lt;br /&gt;
* The response is sent back to the frontend and parsed.&lt;br /&gt;
*The React components update the UI (tables, heatmaps, statistics) based on the received data.&lt;br /&gt;
&lt;br /&gt;
This architecture ensures a clean separation between frontend and backend logic, improving maintainability and testability.&lt;br /&gt;
[[File:Dataflow.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
The test plan for Phase 2 focuses on verifying the successful integration of the newly reimplemented &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the React-based UI components. We aim to ensure data is:&lt;br /&gt;
&lt;br /&gt;
* Correctly fetched from the backend  &lt;br /&gt;
* Appropriately displayed in the frontend  &lt;br /&gt;
* Functionally sound under both normal and edge-case scenarios&lt;br /&gt;
&lt;br /&gt;
== Tools and Frameworks ==&lt;br /&gt;
We plan to use the following tools and frameworks for testing:&lt;br /&gt;
&lt;br /&gt;
* '''Frontend''': Jest and React Testing Library for unit and integration tests&lt;br /&gt;
* '''Backend''': RSpec for controller and model tests&lt;br /&gt;
* '''Integration Testing''': Capybara and Selenium for simulating real user behavior&lt;br /&gt;
* '''Test Coverage''': SimpleCov&lt;br /&gt;
&lt;br /&gt;
== 1. UI Integration Tests ==&lt;br /&gt;
&lt;br /&gt;
These tests ensure the frontend correctly interacts with backend APIs and renders the data appropriately.&lt;br /&gt;
&lt;br /&gt;
=== ReviewTable Component ===&lt;br /&gt;
&lt;br /&gt;
* Validate that the component makes a successful API call to fetch author feedback  &lt;br /&gt;
* Ensure feedback is rendered in the correct table structure  &lt;br /&gt;
* Test loading state before data is fetched  &lt;br /&gt;
* Handle empty or malformed feedback responses gracefully  &lt;br /&gt;
&lt;br /&gt;
=== RoundSelector Component ===&lt;br /&gt;
&lt;br /&gt;
* Verify API call to fetch heatmap data is triggered on component load  &lt;br /&gt;
* Check that heatmap data is correctly visualized for different review rounds  &lt;br /&gt;
* Test behavior with no data, incomplete data, or delayed response  &lt;br /&gt;
&lt;br /&gt;
=== Statistics Component ===&lt;br /&gt;
&lt;br /&gt;
* Confirm it correctly fetches teammate evaluations and author feedback  &lt;br /&gt;
* Ensure charts or tables reflect the received backend data accurately  &lt;br /&gt;
* Test switching between different teams or assignments and verify correct display  &lt;br /&gt;
&lt;br /&gt;
=== General UI Considerations ===&lt;br /&gt;
&lt;br /&gt;
* Test frontend responsiveness to backend failures (500, 404, timeout)  &lt;br /&gt;
* Ensure authorization errors are handled and appropriate messages displayed  &lt;br /&gt;
&lt;br /&gt;
== 2. Backend API Tests ==&lt;br /&gt;
&lt;br /&gt;
While unit tests exist, integration-level tests will be added or updated to ensure UI compatibility.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
* Validate all &amp;lt;code&amp;gt;GET&amp;lt;/code&amp;gt; endpoints return properly structured JSON objects  &lt;br /&gt;
* Simulate various user roles (student, TA, instructor) and ensure access control  &lt;br /&gt;
* Include test cases for:&lt;br /&gt;
** No grades present  &lt;br /&gt;
** Partial data (e.g. missing feedback or evaluations)  &lt;br /&gt;
** Large number of records  &lt;br /&gt;
&lt;br /&gt;
=== Security &amp;amp; Permissions ===&lt;br /&gt;
&lt;br /&gt;
* Ensure students can only fetch their grades and feedback  &lt;br /&gt;
* Ensure TAs and instructors can access full assignment data  &lt;br /&gt;
* Test token/session-based access restrictions (if applicable)  &lt;br /&gt;
&lt;br /&gt;
== 3. Database Preparation ==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, seed data will simulate real-world usage and we will ensure that:&lt;br /&gt;
* Tests will use isolated fixtures or factories to ensure data consistency&lt;br /&gt;
* All database states will be reset before each test suite run&lt;br /&gt;
&lt;br /&gt;
=== Tables and Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;assignments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_participant&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;participants&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;questionnaires&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;questions&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_questionnaire&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;signed_up_teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;teams_users&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;late_policies&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
=== Scenarios ===&lt;br /&gt;
&lt;br /&gt;
* Single student assigned  &lt;br /&gt;
* Team assignments with/without feedback  &lt;br /&gt;
* Late submissions triggering late policies  &lt;br /&gt;
* Multiple review rounds per assignment&lt;br /&gt;
&lt;br /&gt;
== 4. Regression &amp;amp; CI Testing ==&lt;br /&gt;
&lt;br /&gt;
To ensure updates do not break existing functionality:&lt;br /&gt;
&lt;br /&gt;
* Re-run all existing unit tests  &lt;br /&gt;
* Include snapshot tests for frontend components  &lt;br /&gt;
* Use CI pipelines to automatically trigger tests on pull requests  &lt;br /&gt;
&lt;br /&gt;
== Test Plan Summary ==&lt;br /&gt;
&lt;br /&gt;
This test plan outlines the approach for integrating &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the frontend. By combining backend tests, UI integration checks, and realistic database scenarios, we aim to deliver a seamless user experience. The plan emphasizes early detection of issues and supports long-term maintainability through regression testing. As development progresses, the plan will be updated to cover new insights and edge cases.&lt;br /&gt;
&lt;br /&gt;
=Completed Reimplementation Details=&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The previous implementation was designed for a Ruby-embedded front-end, where data was rendered server-side and injected directly into the view. We have since updated the APIs to return data in a format suitable for consumption by the React UI, typically as JSON objects. This change successfully decouples the front-end from the server-side rendering logic, enabling a more interactive and responsive user experience. By transitioning to a React-based interface, we now have improved control over UI state and better alignment with modern web development practices.&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
In this controller, we have updated the GET functions to remove the use of instance variables and instead return plain JSON objects using render json: in the response. This update was essential to align with the frontend architecture, which now relies on a React-based interface that expects structured data from the backend in JSON format rather than server-rendered templates. By returning JSON responses, we’ve established cleaner and more consistent API endpoints, improved the testability and debuggability of our backend logic, and created a more maintainable and decoupled integration between the frontend and backend systems. The following functions were updated as part of this integration:&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
==Data Flow Overview==&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
==Adhering to Priciples==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164215</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164215"/>
		<updated>2025-04-20T17:51:41Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* API */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of this project is to integrate the frontend of the grades view page with the reimplemented '''''grades_controller.rb (E2510)''''' backend in Expertiza, ensuring a seamless connection between both layers. This integration involves refining the interaction between the UI and backend while adhering to best design principles such as modularity, maintainability, and scalability. The grades_controller.rb is responsible for managing grading functionality, allowing instructors to view and modify assignment grades while enabling students to access their evaluations. By following SOLID and DRY principles, this reimplementation enhances code clarity, reduces redundancy, and improves overall system efficiency.&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
The &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; is responsible for managing and delivering grading data to users in the Expertiza system. It enables instructors to view, calculate, and release grades to students, while also allowing students to view feedback and scores for assignments. The controller plays an important role in coordinating backend logic for reviews and grade visibility.&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
The previous implementation successfully created a functional frontend UI page in Expertiza, addressing design inconsistencies and improving usability. It introduced a visually cohesive interface with an intuitive layout, enhanced responsiveness, and improved information display, allowing users to navigate grading data more efficiently. However, the interface was populated using dummy data, limiting its practical use. This reimplemented UI will utilize real data from the database (that has been populated in this round), ensuring that grading information is dynamically retrieved and displayed accurately through JSON objects. Additionally, this phase will connect the redesigned frontend with some new components in the grades_controller.rb. Specifically, the GET functions in the grades_controller were reimplemented to return JSON objects (instead of instance variables) that could be accessed via an API call. Thus, this new implementation ensures seamless communication between the UI and backend while adhering to best design practices for maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
This project focuses on integrating the frontend of the grades view page with the reimplemented '''grades_controller.rb (E2510)''' backend in Expertiza. This integration requires modifications to both the frontend and backend to establish a seamless connection, ensuring that grading data is dynamically retrieved and displayed accurately. By adhering to best design principles such as modularity, maintainability, and scalability, the implementation will enhance system efficiency and long-term usability. Key improvements include replacing dummy data with real database values, refining data flow between the UI and backend, and optimizing API interactions for better performance. These enhancements will create a more intuitive and reliable grading system, providing a seamless experience for instructors and students while maintaining a well-structured and adaptable codebase for future development.&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
# '''Establish a Robust Connection Between the Frontend and Backend''': Ensure smooth data retrieval and updates between the grades view page and the backend by integrating dynamic data through API calls, replacing the current hardcoded dummy data.&lt;br /&gt;
# '''Define and Implement Clear API Endpoints''': Create well-structured API endpoints in grades_controller.rb for retrieving and displaying grades, ensuring they return appropriate data based on user roles (students, instructors, TAs) and maintain role-based access controls.&lt;br /&gt;
# '''Dynamic Data Integration''': Modify the frontend to consume real-time data fetched from the backend, ensuring an intuitive and responsive UI that reflects the actual grading information. &lt;br /&gt;
# '''Refactor Frontend and Backend Components''': Refactor both the frontend and backend as necessary to align with SOLID and DRY principles, ensuring modularity, maintainability, and scalability. This includes eliminating redundant logic and optimizing code for better readability.&lt;br /&gt;
# '''Implement Proper Permission Checks''': Ensure that only authorized users can access grade information by implementing robust privilege checks and ensuring that the data is securely accessible to students, instructors, and TAs based on their roles.&lt;br /&gt;
# '''Optimize Database Queries and API Responses''': Enhance the efficiency of database queries and API responses to reduce unnecessary load and ensure that data is retrieved and displayed promptly.&lt;br /&gt;
# '''Testing and Validation''': Implement comprehensive unit and integration tests to verify the correctness of data flow, UI interactions, and role-based access controls, ensuring that the system functions correctly and securely.&lt;br /&gt;
&lt;br /&gt;
=Reimplementation Plan=&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populated data with the appropriate HTTP GET and HTTP POST calls. This shift is necessary to ensure that our application reflects real-time data from the backend rather than relying on static or hardcoded values, which can quickly become outdated or inconsistent. It also enables better scalability and maintainability, as changes to the data only need to be made in the backend, without requiring manual updates in the frontend code.&lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
'''Author Feedback''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
'''Heatmap Data''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
'''Team-mate Data''':&lt;br /&gt;
   {&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The current implementation caters to the backend for a Ruby-embedded front-end, where data is rendered server-side and passed directly into the view. We need to update the APIs to return data in a format that can be consumed by the React UI, typically JSON. This shift is essential to decouple the front-end from the server-side rendering logic, allowing for a more interactive and dynamic user experience. By transitioning to a React-based interface, we gain better control over UI state and responsiveness, while also aligning with modern web development practices. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and instead return plain JSON objects using render json: in the response. This change is necessary to align with a frontend architecture that uses React or another JavaScript framework, which expects structured data from the backend in JSON format rather than relying on server-rendered templates. By shifting to JSON responses, we enable cleaner API endpoints, facilitate easier testing and debugging, and support a more maintainable, decoupled frontend-backend integration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    # prepare feedback summaries&lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
  1.1. Students&lt;br /&gt;
  1.2. Teams&lt;br /&gt;
  1.3. TA&lt;br /&gt;
  1.4. Professor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
  2.1 assignments&lt;br /&gt;
  2.2 assignment_questionnaire&lt;br /&gt;
  2.3 questionnaires&lt;br /&gt;
  2.4 participant&lt;br /&gt;
  2.5 signed_up_teams&lt;br /&gt;
  2.6 teams_users&lt;br /&gt;
  2.7 due_dates&lt;br /&gt;
  2.8 late_policies&lt;br /&gt;
  2.9 questions&lt;br /&gt;
  2.10 review_scores&lt;br /&gt;
  2.11 review_grades&lt;br /&gt;
&lt;br /&gt;
== Data Flow Overview ==&lt;br /&gt;
The diagram below illustrates how data flows between the frontend React components and the grades_controller.rb backend during a typical grading data fetch operation.&lt;br /&gt;
&lt;br /&gt;
* The user (e.g., instructor or student) interacts with the React-based grades view (e.g., ReviewTable, RoundSelector, or Statistics).&lt;br /&gt;
* The component triggers an API request to a specific action in grades_controller.rb (e.g., GET /grades/:id/summary).&lt;br /&gt;
*The controller action queries the relevant models (e.g., Assignment, Team, ReviewResponseMap) and compiles a JSON response.&lt;br /&gt;
* The response is sent back to the frontend and parsed.&lt;br /&gt;
*The React components update the UI (tables, heatmaps, statistics) based on the received data.&lt;br /&gt;
&lt;br /&gt;
This architecture ensures a clean separation between frontend and backend logic, improving maintainability and testability.&lt;br /&gt;
[[File:Dataflow.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
The test plan for Phase 2 focuses on verifying the successful integration of the newly reimplemented &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the React-based UI components. We aim to ensure data is:&lt;br /&gt;
&lt;br /&gt;
* Correctly fetched from the backend  &lt;br /&gt;
* Appropriately displayed in the frontend  &lt;br /&gt;
* Functionally sound under both normal and edge-case scenarios&lt;br /&gt;
&lt;br /&gt;
== Tools and Frameworks ==&lt;br /&gt;
We plan to use the following tools and frameworks for testing:&lt;br /&gt;
&lt;br /&gt;
* '''Frontend''': Jest and React Testing Library for unit and integration tests&lt;br /&gt;
* '''Backend''': RSpec for controller and model tests&lt;br /&gt;
* '''Integration Testing''': Capybara and Selenium for simulating real user behavior&lt;br /&gt;
* '''Test Coverage''': SimpleCov&lt;br /&gt;
&lt;br /&gt;
== 1. UI Integration Tests ==&lt;br /&gt;
&lt;br /&gt;
These tests ensure the frontend correctly interacts with backend APIs and renders the data appropriately.&lt;br /&gt;
&lt;br /&gt;
=== ReviewTable Component ===&lt;br /&gt;
&lt;br /&gt;
* Validate that the component makes a successful API call to fetch author feedback  &lt;br /&gt;
* Ensure feedback is rendered in the correct table structure  &lt;br /&gt;
* Test loading state before data is fetched  &lt;br /&gt;
* Handle empty or malformed feedback responses gracefully  &lt;br /&gt;
&lt;br /&gt;
=== RoundSelector Component ===&lt;br /&gt;
&lt;br /&gt;
* Verify API call to fetch heatmap data is triggered on component load  &lt;br /&gt;
* Check that heatmap data is correctly visualized for different review rounds  &lt;br /&gt;
* Test behavior with no data, incomplete data, or delayed response  &lt;br /&gt;
&lt;br /&gt;
=== Statistics Component ===&lt;br /&gt;
&lt;br /&gt;
* Confirm it correctly fetches teammate evaluations and author feedback  &lt;br /&gt;
* Ensure charts or tables reflect the received backend data accurately  &lt;br /&gt;
* Test switching between different teams or assignments and verify correct display  &lt;br /&gt;
&lt;br /&gt;
=== General UI Considerations ===&lt;br /&gt;
&lt;br /&gt;
* Test frontend responsiveness to backend failures (500, 404, timeout)  &lt;br /&gt;
* Ensure authorization errors are handled and appropriate messages displayed  &lt;br /&gt;
&lt;br /&gt;
== 2. Backend API Tests ==&lt;br /&gt;
&lt;br /&gt;
While unit tests exist, integration-level tests will be added or updated to ensure UI compatibility.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
* Validate all &amp;lt;code&amp;gt;GET&amp;lt;/code&amp;gt; endpoints return properly structured JSON objects  &lt;br /&gt;
* Simulate various user roles (student, TA, instructor) and ensure access control  &lt;br /&gt;
* Include test cases for:&lt;br /&gt;
** No grades present  &lt;br /&gt;
** Partial data (e.g. missing feedback or evaluations)  &lt;br /&gt;
** Large number of records  &lt;br /&gt;
&lt;br /&gt;
=== Security &amp;amp; Permissions ===&lt;br /&gt;
&lt;br /&gt;
* Ensure students can only fetch their grades and feedback  &lt;br /&gt;
* Ensure TAs and instructors can access full assignment data  &lt;br /&gt;
* Test token/session-based access restrictions (if applicable)  &lt;br /&gt;
&lt;br /&gt;
== 3. Database Preparation ==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, seed data will simulate real-world usage and we will ensure that:&lt;br /&gt;
* Tests will use isolated fixtures or factories to ensure data consistency&lt;br /&gt;
* All database states will be reset before each test suite run&lt;br /&gt;
&lt;br /&gt;
=== Tables and Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;assignments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_participant&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;participants&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;questionnaires&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;questions&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_questionnaire&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;signed_up_teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;teams_users&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;late_policies&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
=== Scenarios ===&lt;br /&gt;
&lt;br /&gt;
* Single student assigned  &lt;br /&gt;
* Team assignments with/without feedback  &lt;br /&gt;
* Late submissions triggering late policies  &lt;br /&gt;
* Multiple review rounds per assignment&lt;br /&gt;
&lt;br /&gt;
== 4. Regression &amp;amp; CI Testing ==&lt;br /&gt;
&lt;br /&gt;
To ensure updates do not break existing functionality:&lt;br /&gt;
&lt;br /&gt;
* Re-run all existing unit tests  &lt;br /&gt;
* Include snapshot tests for frontend components  &lt;br /&gt;
* Use CI pipelines to automatically trigger tests on pull requests  &lt;br /&gt;
&lt;br /&gt;
== Test Plan Summary ==&lt;br /&gt;
&lt;br /&gt;
This test plan outlines the approach for integrating &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the frontend. By combining backend tests, UI integration checks, and realistic database scenarios, we aim to deliver a seamless user experience. The plan emphasizes early detection of issues and supports long-term maintainability through regression testing. As development progresses, the plan will be updated to cover new insights and edge cases.&lt;br /&gt;
&lt;br /&gt;
=Completed Reimplementation Details=&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The previous implementation was designed for a Ruby-embedded front-end, where data was rendered server-side and injected directly into the view. We have since updated the APIs to return data in a format suitable for consumption by the React UI, typically as JSON objects. This change successfully decouples the front-end from the server-side rendering logic, enabling a more interactive and responsive user experience. By transitioning to a React-based interface, we now have improved control over UI state and better alignment with modern web development practices.&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
In this controller, we have updated the GET functions to remove the use of instance variables and instead return plain JSON objects using render json: in the response. This update was essential to align with the frontend architecture, which now relies on a React-based interface that expects structured data from the backend in JSON format rather than server-rendered templates. By returning JSON responses, we’ve established cleaner and more consistent API endpoints, improved the testability and debuggability of our backend logic, and created a more maintainable and decoupled integration between the frontend and backend systems. The following functions were updated as part of this integration:&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
==Data Flow Overview==&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
==Adhering to Priciples==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164214</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164214"/>
		<updated>2025-04-20T17:50:20Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* API */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of this project is to integrate the frontend of the grades view page with the reimplemented '''''grades_controller.rb (E2510)''''' backend in Expertiza, ensuring a seamless connection between both layers. This integration involves refining the interaction between the UI and backend while adhering to best design principles such as modularity, maintainability, and scalability. The grades_controller.rb is responsible for managing grading functionality, allowing instructors to view and modify assignment grades while enabling students to access their evaluations. By following SOLID and DRY principles, this reimplementation enhances code clarity, reduces redundancy, and improves overall system efficiency.&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
The &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; is responsible for managing and delivering grading data to users in the Expertiza system. It enables instructors to view, calculate, and release grades to students, while also allowing students to view feedback and scores for assignments. The controller plays an important role in coordinating backend logic for reviews and grade visibility.&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
The previous implementation successfully created a functional frontend UI page in Expertiza, addressing design inconsistencies and improving usability. It introduced a visually cohesive interface with an intuitive layout, enhanced responsiveness, and improved information display, allowing users to navigate grading data more efficiently. However, the interface was populated using dummy data, limiting its practical use. This reimplemented UI will utilize real data from the database (that has been populated in this round), ensuring that grading information is dynamically retrieved and displayed accurately through JSON objects. Additionally, this phase will connect the redesigned frontend with some new components in the grades_controller.rb. Specifically, the GET functions in the grades_controller were reimplemented to return JSON objects (instead of instance variables) that could be accessed via an API call. Thus, this new implementation ensures seamless communication between the UI and backend while adhering to best design practices for maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
This project focuses on integrating the frontend of the grades view page with the reimplemented '''grades_controller.rb (E2510)''' backend in Expertiza. This integration requires modifications to both the frontend and backend to establish a seamless connection, ensuring that grading data is dynamically retrieved and displayed accurately. By adhering to best design principles such as modularity, maintainability, and scalability, the implementation will enhance system efficiency and long-term usability. Key improvements include replacing dummy data with real database values, refining data flow between the UI and backend, and optimizing API interactions for better performance. These enhancements will create a more intuitive and reliable grading system, providing a seamless experience for instructors and students while maintaining a well-structured and adaptable codebase for future development.&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
# '''Establish a Robust Connection Between the Frontend and Backend''': Ensure smooth data retrieval and updates between the grades view page and the backend by integrating dynamic data through API calls, replacing the current hardcoded dummy data.&lt;br /&gt;
# '''Define and Implement Clear API Endpoints''': Create well-structured API endpoints in grades_controller.rb for retrieving and displaying grades, ensuring they return appropriate data based on user roles (students, instructors, TAs) and maintain role-based access controls.&lt;br /&gt;
# '''Dynamic Data Integration''': Modify the frontend to consume real-time data fetched from the backend, ensuring an intuitive and responsive UI that reflects the actual grading information. &lt;br /&gt;
# '''Refactor Frontend and Backend Components''': Refactor both the frontend and backend as necessary to align with SOLID and DRY principles, ensuring modularity, maintainability, and scalability. This includes eliminating redundant logic and optimizing code for better readability.&lt;br /&gt;
# '''Implement Proper Permission Checks''': Ensure that only authorized users can access grade information by implementing robust privilege checks and ensuring that the data is securely accessible to students, instructors, and TAs based on their roles.&lt;br /&gt;
# '''Optimize Database Queries and API Responses''': Enhance the efficiency of database queries and API responses to reduce unnecessary load and ensure that data is retrieved and displayed promptly.&lt;br /&gt;
# '''Testing and Validation''': Implement comprehensive unit and integration tests to verify the correctness of data flow, UI interactions, and role-based access controls, ensuring that the system functions correctly and securely.&lt;br /&gt;
&lt;br /&gt;
=Reimplementation Plan=&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populated data with the appropriate HTTP GET and HTTP POST calls. This shift is necessary to ensure that our application reflects real-time data from the backend rather than relying on static or hardcoded values, which can quickly become outdated or inconsistent. It also enables better scalability and maintainability, as changes to the data only need to be made in the backend, without requiring manual updates in the frontend code.&lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
'''Author Feedback''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
'''Heatmap Data''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
'''Team-mate Data''':&lt;br /&gt;
   {&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The current implementation caters to the backend for a Ruby-embedded front-end, where data is rendered server-side and passed directly into the view. We need to update the APIs to return data in a format that can be consumed by the React UI, typically JSON. This shift is essential to decouple the front-end from the server-side rendering logic, allowing for a more interactive and dynamic user experience. By transitioning to a React-based interface, we gain better control over UI state and responsiveness, while also aligning with modern web development practices. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and instead return plain JSON objects using render json: in the response. This change is necessary to align with a frontend architecture that uses React or another JavaScript framework, which expects structured data from the backend in JSON format rather than relying on server-rendered templates. By shifting to JSON responses, we enable cleaner API endpoints, facilitate easier testing and debugging, and support a more maintainable, decoupled frontend-backend integration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    # prepare feedback summaries&lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
  1.1. Students&lt;br /&gt;
  1.2. Teams&lt;br /&gt;
  1.3. TA&lt;br /&gt;
  1.4. Professor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
  2.1 assignments&lt;br /&gt;
  2.2 assignment_questionnaire&lt;br /&gt;
  2.3 questionnaires&lt;br /&gt;
  2.4 participant&lt;br /&gt;
  2.5 signed_up_teams&lt;br /&gt;
  2.6 teams_users&lt;br /&gt;
  2.7 due_dates&lt;br /&gt;
  2.8 late_policies&lt;br /&gt;
  2.9 questions&lt;br /&gt;
  2.10 review_scores&lt;br /&gt;
  2.11 review_grades&lt;br /&gt;
&lt;br /&gt;
== Data Flow Overview ==&lt;br /&gt;
The diagram below illustrates how data flows between the frontend React components and the grades_controller.rb backend during a typical grading data fetch operation.&lt;br /&gt;
&lt;br /&gt;
* The user (e.g., instructor or student) interacts with the React-based grades view (e.g., ReviewTable, RoundSelector, or Statistics).&lt;br /&gt;
* The component triggers an API request to a specific action in grades_controller.rb (e.g., GET /grades/:id/summary).&lt;br /&gt;
*The controller action queries the relevant models (e.g., Assignment, Team, ReviewResponseMap) and compiles a JSON response.&lt;br /&gt;
* The response is sent back to the frontend and parsed.&lt;br /&gt;
*The React components update the UI (tables, heatmaps, statistics) based on the received data.&lt;br /&gt;
&lt;br /&gt;
This architecture ensures a clean separation between frontend and backend logic, improving maintainability and testability.&lt;br /&gt;
[[File:Dataflow.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
The test plan for Phase 2 focuses on verifying the successful integration of the newly reimplemented &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the React-based UI components. We aim to ensure data is:&lt;br /&gt;
&lt;br /&gt;
* Correctly fetched from the backend  &lt;br /&gt;
* Appropriately displayed in the frontend  &lt;br /&gt;
* Functionally sound under both normal and edge-case scenarios&lt;br /&gt;
&lt;br /&gt;
== Tools and Frameworks ==&lt;br /&gt;
We plan to use the following tools and frameworks for testing:&lt;br /&gt;
&lt;br /&gt;
* '''Frontend''': Jest and React Testing Library for unit and integration tests&lt;br /&gt;
* '''Backend''': RSpec for controller and model tests&lt;br /&gt;
* '''Integration Testing''': Capybara and Selenium for simulating real user behavior&lt;br /&gt;
* '''Test Coverage''': SimpleCov&lt;br /&gt;
&lt;br /&gt;
== 1. UI Integration Tests ==&lt;br /&gt;
&lt;br /&gt;
These tests ensure the frontend correctly interacts with backend APIs and renders the data appropriately.&lt;br /&gt;
&lt;br /&gt;
=== ReviewTable Component ===&lt;br /&gt;
&lt;br /&gt;
* Validate that the component makes a successful API call to fetch author feedback  &lt;br /&gt;
* Ensure feedback is rendered in the correct table structure  &lt;br /&gt;
* Test loading state before data is fetched  &lt;br /&gt;
* Handle empty or malformed feedback responses gracefully  &lt;br /&gt;
&lt;br /&gt;
=== RoundSelector Component ===&lt;br /&gt;
&lt;br /&gt;
* Verify API call to fetch heatmap data is triggered on component load  &lt;br /&gt;
* Check that heatmap data is correctly visualized for different review rounds  &lt;br /&gt;
* Test behavior with no data, incomplete data, or delayed response  &lt;br /&gt;
&lt;br /&gt;
=== Statistics Component ===&lt;br /&gt;
&lt;br /&gt;
* Confirm it correctly fetches teammate evaluations and author feedback  &lt;br /&gt;
* Ensure charts or tables reflect the received backend data accurately  &lt;br /&gt;
* Test switching between different teams or assignments and verify correct display  &lt;br /&gt;
&lt;br /&gt;
=== General UI Considerations ===&lt;br /&gt;
&lt;br /&gt;
* Test frontend responsiveness to backend failures (500, 404, timeout)  &lt;br /&gt;
* Ensure authorization errors are handled and appropriate messages displayed  &lt;br /&gt;
&lt;br /&gt;
== 2. Backend API Tests ==&lt;br /&gt;
&lt;br /&gt;
While unit tests exist, integration-level tests will be added or updated to ensure UI compatibility.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
* Validate all &amp;lt;code&amp;gt;GET&amp;lt;/code&amp;gt; endpoints return properly structured JSON objects  &lt;br /&gt;
* Simulate various user roles (student, TA, instructor) and ensure access control  &lt;br /&gt;
* Include test cases for:&lt;br /&gt;
** No grades present  &lt;br /&gt;
** Partial data (e.g. missing feedback or evaluations)  &lt;br /&gt;
** Large number of records  &lt;br /&gt;
&lt;br /&gt;
=== Security &amp;amp; Permissions ===&lt;br /&gt;
&lt;br /&gt;
* Ensure students can only fetch their grades and feedback  &lt;br /&gt;
* Ensure TAs and instructors can access full assignment data  &lt;br /&gt;
* Test token/session-based access restrictions (if applicable)  &lt;br /&gt;
&lt;br /&gt;
== 3. Database Preparation ==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, seed data will simulate real-world usage and we will ensure that:&lt;br /&gt;
* Tests will use isolated fixtures or factories to ensure data consistency&lt;br /&gt;
* All database states will be reset before each test suite run&lt;br /&gt;
&lt;br /&gt;
=== Tables and Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;assignments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_participant&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;participants&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;questionnaires&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;questions&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_questionnaire&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;signed_up_teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;teams_users&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;late_policies&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
=== Scenarios ===&lt;br /&gt;
&lt;br /&gt;
* Single student assigned  &lt;br /&gt;
* Team assignments with/without feedback  &lt;br /&gt;
* Late submissions triggering late policies  &lt;br /&gt;
* Multiple review rounds per assignment&lt;br /&gt;
&lt;br /&gt;
== 4. Regression &amp;amp; CI Testing ==&lt;br /&gt;
&lt;br /&gt;
To ensure updates do not break existing functionality:&lt;br /&gt;
&lt;br /&gt;
* Re-run all existing unit tests  &lt;br /&gt;
* Include snapshot tests for frontend components  &lt;br /&gt;
* Use CI pipelines to automatically trigger tests on pull requests  &lt;br /&gt;
&lt;br /&gt;
== Test Plan Summary ==&lt;br /&gt;
&lt;br /&gt;
This test plan outlines the approach for integrating &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the frontend. By combining backend tests, UI integration checks, and realistic database scenarios, we aim to deliver a seamless user experience. The plan emphasizes early detection of issues and supports long-term maintainability through regression testing. As development progresses, the plan will be updated to cover new insights and edge cases.&lt;br /&gt;
&lt;br /&gt;
=Completed Reimplementation Details=&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The previous implementation was designed for a Ruby-embedded front-end, where data was rendered server-side and injected directly into the view. We have since updated the APIs to return data in a format suitable for consumption by the React UI, typically as JSON objects. This change successfully decouples the front-end from the server-side rendering logic, enabling a more interactive and responsive user experience. By transitioning to a React-based interface, we now have improved control over UI state and better alignment with modern web development practices.&lt;br /&gt;
&lt;br /&gt;
grades_controller.rb&lt;br /&gt;
&lt;br /&gt;
In this controller, we have updated the following functions to remove the use of instance variables and instead return plain JSON objects using render json: in the response. This update was essential to align with the frontend architecture, which now relies on a React-based interface that expects structured data from the backend in JSON format rather than server-rendered templates. By returning JSON responses, we’ve established cleaner and more consistent API endpoints, improved the testability and debuggability of our backend logic, and created a more maintainable and decoupled integration between the frontend and backend systems. The following files were updated as part of this integration:&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
==Data Flow Overview==&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
==Adhering to Priciples==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164213</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164213"/>
		<updated>2025-04-20T17:48:41Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* API */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of this project is to integrate the frontend of the grades view page with the reimplemented '''''grades_controller.rb (E2510)''''' backend in Expertiza, ensuring a seamless connection between both layers. This integration involves refining the interaction between the UI and backend while adhering to best design principles such as modularity, maintainability, and scalability. The grades_controller.rb is responsible for managing grading functionality, allowing instructors to view and modify assignment grades while enabling students to access their evaluations. By following SOLID and DRY principles, this reimplementation enhances code clarity, reduces redundancy, and improves overall system efficiency.&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
The &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; is responsible for managing and delivering grading data to users in the Expertiza system. It enables instructors to view, calculate, and release grades to students, while also allowing students to view feedback and scores for assignments. The controller plays an important role in coordinating backend logic for reviews and grade visibility.&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
The previous implementation successfully created a functional frontend UI page in Expertiza, addressing design inconsistencies and improving usability. It introduced a visually cohesive interface with an intuitive layout, enhanced responsiveness, and improved information display, allowing users to navigate grading data more efficiently. However, the interface was populated using dummy data, limiting its practical use. This reimplemented UI will utilize real data from the database (that has been populated in this round), ensuring that grading information is dynamically retrieved and displayed accurately through JSON objects. Additionally, this phase will connect the redesigned frontend with some new components in the grades_controller.rb. Specifically, the GET functions in the grades_controller were reimplemented to return JSON objects (instead of instance variables) that could be accessed via an API call. Thus, this new implementation ensures seamless communication between the UI and backend while adhering to best design practices for maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
This project focuses on integrating the frontend of the grades view page with the reimplemented '''grades_controller.rb (E2510)''' backend in Expertiza. This integration requires modifications to both the frontend and backend to establish a seamless connection, ensuring that grading data is dynamically retrieved and displayed accurately. By adhering to best design principles such as modularity, maintainability, and scalability, the implementation will enhance system efficiency and long-term usability. Key improvements include replacing dummy data with real database values, refining data flow between the UI and backend, and optimizing API interactions for better performance. These enhancements will create a more intuitive and reliable grading system, providing a seamless experience for instructors and students while maintaining a well-structured and adaptable codebase for future development.&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
# '''Establish a Robust Connection Between the Frontend and Backend''': Ensure smooth data retrieval and updates between the grades view page and the backend by integrating dynamic data through API calls, replacing the current hardcoded dummy data.&lt;br /&gt;
# '''Define and Implement Clear API Endpoints''': Create well-structured API endpoints in grades_controller.rb for retrieving and displaying grades, ensuring they return appropriate data based on user roles (students, instructors, TAs) and maintain role-based access controls.&lt;br /&gt;
# '''Dynamic Data Integration''': Modify the frontend to consume real-time data fetched from the backend, ensuring an intuitive and responsive UI that reflects the actual grading information. &lt;br /&gt;
# '''Refactor Frontend and Backend Components''': Refactor both the frontend and backend as necessary to align with SOLID and DRY principles, ensuring modularity, maintainability, and scalability. This includes eliminating redundant logic and optimizing code for better readability.&lt;br /&gt;
# '''Implement Proper Permission Checks''': Ensure that only authorized users can access grade information by implementing robust privilege checks and ensuring that the data is securely accessible to students, instructors, and TAs based on their roles.&lt;br /&gt;
# '''Optimize Database Queries and API Responses''': Enhance the efficiency of database queries and API responses to reduce unnecessary load and ensure that data is retrieved and displayed promptly.&lt;br /&gt;
# '''Testing and Validation''': Implement comprehensive unit and integration tests to verify the correctness of data flow, UI interactions, and role-based access controls, ensuring that the system functions correctly and securely.&lt;br /&gt;
&lt;br /&gt;
=Reimplementation Plan=&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populated data with the appropriate HTTP GET and HTTP POST calls. This shift is necessary to ensure that our application reflects real-time data from the backend rather than relying on static or hardcoded values, which can quickly become outdated or inconsistent. It also enables better scalability and maintainability, as changes to the data only need to be made in the backend, without requiring manual updates in the frontend code.&lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
'''Author Feedback''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
'''Heatmap Data''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
'''Team-mate Data''':&lt;br /&gt;
   {&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The current implementation caters to the backend for a Ruby-embedded front-end, where data is rendered server-side and passed directly into the view. We need to update the APIs to return data in a format that can be consumed by the React UI, typically JSON. This shift is essential to decouple the front-end from the server-side rendering logic, allowing for a more interactive and dynamic user experience. By transitioning to a React-based interface, we gain better control over UI state and responsiveness, while also aligning with modern web development practices. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and instead return plain JSON objects using render json: in the response. This change is necessary to align with a frontend architecture that uses React or another JavaScript framework, which expects structured data from the backend in JSON format rather than relying on server-rendered templates. By shifting to JSON responses, we enable cleaner API endpoints, facilitate easier testing and debugging, and support a more maintainable, decoupled frontend-backend integration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    # prepare feedback summaries&lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
  1.1. Students&lt;br /&gt;
  1.2. Teams&lt;br /&gt;
  1.3. TA&lt;br /&gt;
  1.4. Professor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
  2.1 assignments&lt;br /&gt;
  2.2 assignment_questionnaire&lt;br /&gt;
  2.3 questionnaires&lt;br /&gt;
  2.4 participant&lt;br /&gt;
  2.5 signed_up_teams&lt;br /&gt;
  2.6 teams_users&lt;br /&gt;
  2.7 due_dates&lt;br /&gt;
  2.8 late_policies&lt;br /&gt;
  2.9 questions&lt;br /&gt;
  2.10 review_scores&lt;br /&gt;
  2.11 review_grades&lt;br /&gt;
&lt;br /&gt;
== Data Flow Overview ==&lt;br /&gt;
The diagram below illustrates how data flows between the frontend React components and the grades_controller.rb backend during a typical grading data fetch operation.&lt;br /&gt;
&lt;br /&gt;
* The user (e.g., instructor or student) interacts with the React-based grades view (e.g., ReviewTable, RoundSelector, or Statistics).&lt;br /&gt;
* The component triggers an API request to a specific action in grades_controller.rb (e.g., GET /grades/:id/summary).&lt;br /&gt;
*The controller action queries the relevant models (e.g., Assignment, Team, ReviewResponseMap) and compiles a JSON response.&lt;br /&gt;
* The response is sent back to the frontend and parsed.&lt;br /&gt;
*The React components update the UI (tables, heatmaps, statistics) based on the received data.&lt;br /&gt;
&lt;br /&gt;
This architecture ensures a clean separation between frontend and backend logic, improving maintainability and testability.&lt;br /&gt;
[[File:Dataflow.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
The test plan for Phase 2 focuses on verifying the successful integration of the newly reimplemented &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the React-based UI components. We aim to ensure data is:&lt;br /&gt;
&lt;br /&gt;
* Correctly fetched from the backend  &lt;br /&gt;
* Appropriately displayed in the frontend  &lt;br /&gt;
* Functionally sound under both normal and edge-case scenarios&lt;br /&gt;
&lt;br /&gt;
== Tools and Frameworks ==&lt;br /&gt;
We plan to use the following tools and frameworks for testing:&lt;br /&gt;
&lt;br /&gt;
* '''Frontend''': Jest and React Testing Library for unit and integration tests&lt;br /&gt;
* '''Backend''': RSpec for controller and model tests&lt;br /&gt;
* '''Integration Testing''': Capybara and Selenium for simulating real user behavior&lt;br /&gt;
* '''Test Coverage''': SimpleCov&lt;br /&gt;
&lt;br /&gt;
== 1. UI Integration Tests ==&lt;br /&gt;
&lt;br /&gt;
These tests ensure the frontend correctly interacts with backend APIs and renders the data appropriately.&lt;br /&gt;
&lt;br /&gt;
=== ReviewTable Component ===&lt;br /&gt;
&lt;br /&gt;
* Validate that the component makes a successful API call to fetch author feedback  &lt;br /&gt;
* Ensure feedback is rendered in the correct table structure  &lt;br /&gt;
* Test loading state before data is fetched  &lt;br /&gt;
* Handle empty or malformed feedback responses gracefully  &lt;br /&gt;
&lt;br /&gt;
=== RoundSelector Component ===&lt;br /&gt;
&lt;br /&gt;
* Verify API call to fetch heatmap data is triggered on component load  &lt;br /&gt;
* Check that heatmap data is correctly visualized for different review rounds  &lt;br /&gt;
* Test behavior with no data, incomplete data, or delayed response  &lt;br /&gt;
&lt;br /&gt;
=== Statistics Component ===&lt;br /&gt;
&lt;br /&gt;
* Confirm it correctly fetches teammate evaluations and author feedback  &lt;br /&gt;
* Ensure charts or tables reflect the received backend data accurately  &lt;br /&gt;
* Test switching between different teams or assignments and verify correct display  &lt;br /&gt;
&lt;br /&gt;
=== General UI Considerations ===&lt;br /&gt;
&lt;br /&gt;
* Test frontend responsiveness to backend failures (500, 404, timeout)  &lt;br /&gt;
* Ensure authorization errors are handled and appropriate messages displayed  &lt;br /&gt;
&lt;br /&gt;
== 2. Backend API Tests ==&lt;br /&gt;
&lt;br /&gt;
While unit tests exist, integration-level tests will be added or updated to ensure UI compatibility.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
* Validate all &amp;lt;code&amp;gt;GET&amp;lt;/code&amp;gt; endpoints return properly structured JSON objects  &lt;br /&gt;
* Simulate various user roles (student, TA, instructor) and ensure access control  &lt;br /&gt;
* Include test cases for:&lt;br /&gt;
** No grades present  &lt;br /&gt;
** Partial data (e.g. missing feedback or evaluations)  &lt;br /&gt;
** Large number of records  &lt;br /&gt;
&lt;br /&gt;
=== Security &amp;amp; Permissions ===&lt;br /&gt;
&lt;br /&gt;
* Ensure students can only fetch their grades and feedback  &lt;br /&gt;
* Ensure TAs and instructors can access full assignment data  &lt;br /&gt;
* Test token/session-based access restrictions (if applicable)  &lt;br /&gt;
&lt;br /&gt;
== 3. Database Preparation ==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, seed data will simulate real-world usage and we will ensure that:&lt;br /&gt;
* Tests will use isolated fixtures or factories to ensure data consistency&lt;br /&gt;
* All database states will be reset before each test suite run&lt;br /&gt;
&lt;br /&gt;
=== Tables and Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;assignments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_participant&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;participants&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;questionnaires&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;questions&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_questionnaire&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;signed_up_teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;teams_users&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;late_policies&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
=== Scenarios ===&lt;br /&gt;
&lt;br /&gt;
* Single student assigned  &lt;br /&gt;
* Team assignments with/without feedback  &lt;br /&gt;
* Late submissions triggering late policies  &lt;br /&gt;
* Multiple review rounds per assignment&lt;br /&gt;
&lt;br /&gt;
== 4. Regression &amp;amp; CI Testing ==&lt;br /&gt;
&lt;br /&gt;
To ensure updates do not break existing functionality:&lt;br /&gt;
&lt;br /&gt;
* Re-run all existing unit tests  &lt;br /&gt;
* Include snapshot tests for frontend components  &lt;br /&gt;
* Use CI pipelines to automatically trigger tests on pull requests  &lt;br /&gt;
&lt;br /&gt;
== Test Plan Summary ==&lt;br /&gt;
&lt;br /&gt;
This test plan outlines the approach for integrating &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the frontend. By combining backend tests, UI integration checks, and realistic database scenarios, we aim to deliver a seamless user experience. The plan emphasizes early detection of issues and supports long-term maintainability through regression testing. As development progresses, the plan will be updated to cover new insights and edge cases.&lt;br /&gt;
&lt;br /&gt;
=Completed Reimplementation Details=&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The previous implementation was designed for a Ruby-embedded front-end, where data was rendered server-side and injected directly into the view. We have since updated the APIs to return data in a format suitable for consumption by the React UI, typically as JSON objects. This change successfully decouples the front-end from the server-side rendering logic, enabling a more interactive and responsive user experience. By transitioning to a React-based interface, we now have improved control over UI state and better alignment with modern web development practices. The following files were updated as part of this integration:&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
==Data Flow Overview==&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
==Adhering to Priciples==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164212</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164212"/>
		<updated>2025-04-20T17:46:46Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* Completed Reimplementation Details */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of this project is to integrate the frontend of the grades view page with the reimplemented '''''grades_controller.rb (E2510)''''' backend in Expertiza, ensuring a seamless connection between both layers. This integration involves refining the interaction between the UI and backend while adhering to best design principles such as modularity, maintainability, and scalability. The grades_controller.rb is responsible for managing grading functionality, allowing instructors to view and modify assignment grades while enabling students to access their evaluations. By following SOLID and DRY principles, this reimplementation enhances code clarity, reduces redundancy, and improves overall system efficiency.&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
The &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; is responsible for managing and delivering grading data to users in the Expertiza system. It enables instructors to view, calculate, and release grades to students, while also allowing students to view feedback and scores for assignments. The controller plays an important role in coordinating backend logic for reviews and grade visibility.&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
The previous implementation successfully created a functional frontend UI page in Expertiza, addressing design inconsistencies and improving usability. It introduced a visually cohesive interface with an intuitive layout, enhanced responsiveness, and improved information display, allowing users to navigate grading data more efficiently. However, the interface was populated using dummy data, limiting its practical use. This reimplemented UI will utilize real data from the database (that has been populated in this round), ensuring that grading information is dynamically retrieved and displayed accurately through JSON objects. Additionally, this phase will connect the redesigned frontend with some new components in the grades_controller.rb. Specifically, the GET functions in the grades_controller were reimplemented to return JSON objects (instead of instance variables) that could be accessed via an API call. Thus, this new implementation ensures seamless communication between the UI and backend while adhering to best design practices for maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
This project focuses on integrating the frontend of the grades view page with the reimplemented '''grades_controller.rb (E2510)''' backend in Expertiza. This integration requires modifications to both the frontend and backend to establish a seamless connection, ensuring that grading data is dynamically retrieved and displayed accurately. By adhering to best design principles such as modularity, maintainability, and scalability, the implementation will enhance system efficiency and long-term usability. Key improvements include replacing dummy data with real database values, refining data flow between the UI and backend, and optimizing API interactions for better performance. These enhancements will create a more intuitive and reliable grading system, providing a seamless experience for instructors and students while maintaining a well-structured and adaptable codebase for future development.&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
# '''Establish a Robust Connection Between the Frontend and Backend''': Ensure smooth data retrieval and updates between the grades view page and the backend by integrating dynamic data through API calls, replacing the current hardcoded dummy data.&lt;br /&gt;
# '''Define and Implement Clear API Endpoints''': Create well-structured API endpoints in grades_controller.rb for retrieving and displaying grades, ensuring they return appropriate data based on user roles (students, instructors, TAs) and maintain role-based access controls.&lt;br /&gt;
# '''Dynamic Data Integration''': Modify the frontend to consume real-time data fetched from the backend, ensuring an intuitive and responsive UI that reflects the actual grading information. &lt;br /&gt;
# '''Refactor Frontend and Backend Components''': Refactor both the frontend and backend as necessary to align with SOLID and DRY principles, ensuring modularity, maintainability, and scalability. This includes eliminating redundant logic and optimizing code for better readability.&lt;br /&gt;
# '''Implement Proper Permission Checks''': Ensure that only authorized users can access grade information by implementing robust privilege checks and ensuring that the data is securely accessible to students, instructors, and TAs based on their roles.&lt;br /&gt;
# '''Optimize Database Queries and API Responses''': Enhance the efficiency of database queries and API responses to reduce unnecessary load and ensure that data is retrieved and displayed promptly.&lt;br /&gt;
# '''Testing and Validation''': Implement comprehensive unit and integration tests to verify the correctness of data flow, UI interactions, and role-based access controls, ensuring that the system functions correctly and securely.&lt;br /&gt;
&lt;br /&gt;
=Reimplementation Plan=&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populated data with the appropriate HTTP GET and HTTP POST calls. This shift is necessary to ensure that our application reflects real-time data from the backend rather than relying on static or hardcoded values, which can quickly become outdated or inconsistent. It also enables better scalability and maintainability, as changes to the data only need to be made in the backend, without requiring manual updates in the frontend code.&lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
'''Author Feedback''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
'''Heatmap Data''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
'''Team-mate Data''':&lt;br /&gt;
   {&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The current implementation caters to the backend for a Ruby-embedded front-end, where data is rendered server-side and passed directly into the view. We need to update the APIs to return data in a format that can be consumed by the React UI, typically JSON. This shift is essential to decouple the front-end from the server-side rendering logic, allowing for a more interactive and dynamic user experience. By transitioning to a React-based interface, we gain better control over UI state and responsiveness, while also aligning with modern web development practices. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and instead return plain JSON objects using render json: in the response. This change is necessary to align with a frontend architecture that uses React or another JavaScript framework, which expects structured data from the backend in JSON format rather than relying on server-rendered templates. By shifting to JSON responses, we enable cleaner API endpoints, facilitate easier testing and debugging, and support a more maintainable, decoupled frontend-backend integration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    # prepare feedback summaries&lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
  1.1. Students&lt;br /&gt;
  1.2. Teams&lt;br /&gt;
  1.3. TA&lt;br /&gt;
  1.4. Professor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
  2.1 assignments&lt;br /&gt;
  2.2 assignment_questionnaire&lt;br /&gt;
  2.3 questionnaires&lt;br /&gt;
  2.4 participant&lt;br /&gt;
  2.5 signed_up_teams&lt;br /&gt;
  2.6 teams_users&lt;br /&gt;
  2.7 due_dates&lt;br /&gt;
  2.8 late_policies&lt;br /&gt;
  2.9 questions&lt;br /&gt;
  2.10 review_scores&lt;br /&gt;
  2.11 review_grades&lt;br /&gt;
&lt;br /&gt;
== Data Flow Overview ==&lt;br /&gt;
The diagram below illustrates how data flows between the frontend React components and the grades_controller.rb backend during a typical grading data fetch operation.&lt;br /&gt;
&lt;br /&gt;
* The user (e.g., instructor or student) interacts with the React-based grades view (e.g., ReviewTable, RoundSelector, or Statistics).&lt;br /&gt;
* The component triggers an API request to a specific action in grades_controller.rb (e.g., GET /grades/:id/summary).&lt;br /&gt;
*The controller action queries the relevant models (e.g., Assignment, Team, ReviewResponseMap) and compiles a JSON response.&lt;br /&gt;
* The response is sent back to the frontend and parsed.&lt;br /&gt;
*The React components update the UI (tables, heatmaps, statistics) based on the received data.&lt;br /&gt;
&lt;br /&gt;
This architecture ensures a clean separation between frontend and backend logic, improving maintainability and testability.&lt;br /&gt;
[[File:Dataflow.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
The test plan for Phase 2 focuses on verifying the successful integration of the newly reimplemented &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the React-based UI components. We aim to ensure data is:&lt;br /&gt;
&lt;br /&gt;
* Correctly fetched from the backend  &lt;br /&gt;
* Appropriately displayed in the frontend  &lt;br /&gt;
* Functionally sound under both normal and edge-case scenarios&lt;br /&gt;
&lt;br /&gt;
== Tools and Frameworks ==&lt;br /&gt;
We plan to use the following tools and frameworks for testing:&lt;br /&gt;
&lt;br /&gt;
* '''Frontend''': Jest and React Testing Library for unit and integration tests&lt;br /&gt;
* '''Backend''': RSpec for controller and model tests&lt;br /&gt;
* '''Integration Testing''': Capybara and Selenium for simulating real user behavior&lt;br /&gt;
* '''Test Coverage''': SimpleCov&lt;br /&gt;
&lt;br /&gt;
== 1. UI Integration Tests ==&lt;br /&gt;
&lt;br /&gt;
These tests ensure the frontend correctly interacts with backend APIs and renders the data appropriately.&lt;br /&gt;
&lt;br /&gt;
=== ReviewTable Component ===&lt;br /&gt;
&lt;br /&gt;
* Validate that the component makes a successful API call to fetch author feedback  &lt;br /&gt;
* Ensure feedback is rendered in the correct table structure  &lt;br /&gt;
* Test loading state before data is fetched  &lt;br /&gt;
* Handle empty or malformed feedback responses gracefully  &lt;br /&gt;
&lt;br /&gt;
=== RoundSelector Component ===&lt;br /&gt;
&lt;br /&gt;
* Verify API call to fetch heatmap data is triggered on component load  &lt;br /&gt;
* Check that heatmap data is correctly visualized for different review rounds  &lt;br /&gt;
* Test behavior with no data, incomplete data, or delayed response  &lt;br /&gt;
&lt;br /&gt;
=== Statistics Component ===&lt;br /&gt;
&lt;br /&gt;
* Confirm it correctly fetches teammate evaluations and author feedback  &lt;br /&gt;
* Ensure charts or tables reflect the received backend data accurately  &lt;br /&gt;
* Test switching between different teams or assignments and verify correct display  &lt;br /&gt;
&lt;br /&gt;
=== General UI Considerations ===&lt;br /&gt;
&lt;br /&gt;
* Test frontend responsiveness to backend failures (500, 404, timeout)  &lt;br /&gt;
* Ensure authorization errors are handled and appropriate messages displayed  &lt;br /&gt;
&lt;br /&gt;
== 2. Backend API Tests ==&lt;br /&gt;
&lt;br /&gt;
While unit tests exist, integration-level tests will be added or updated to ensure UI compatibility.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
* Validate all &amp;lt;code&amp;gt;GET&amp;lt;/code&amp;gt; endpoints return properly structured JSON objects  &lt;br /&gt;
* Simulate various user roles (student, TA, instructor) and ensure access control  &lt;br /&gt;
* Include test cases for:&lt;br /&gt;
** No grades present  &lt;br /&gt;
** Partial data (e.g. missing feedback or evaluations)  &lt;br /&gt;
** Large number of records  &lt;br /&gt;
&lt;br /&gt;
=== Security &amp;amp; Permissions ===&lt;br /&gt;
&lt;br /&gt;
* Ensure students can only fetch their grades and feedback  &lt;br /&gt;
* Ensure TAs and instructors can access full assignment data  &lt;br /&gt;
* Test token/session-based access restrictions (if applicable)  &lt;br /&gt;
&lt;br /&gt;
== 3. Database Preparation ==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, seed data will simulate real-world usage and we will ensure that:&lt;br /&gt;
* Tests will use isolated fixtures or factories to ensure data consistency&lt;br /&gt;
* All database states will be reset before each test suite run&lt;br /&gt;
&lt;br /&gt;
=== Tables and Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;assignments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_participant&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;participants&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;questionnaires&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;questions&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_questionnaire&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;signed_up_teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;teams_users&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;late_policies&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
=== Scenarios ===&lt;br /&gt;
&lt;br /&gt;
* Single student assigned  &lt;br /&gt;
* Team assignments with/without feedback  &lt;br /&gt;
* Late submissions triggering late policies  &lt;br /&gt;
* Multiple review rounds per assignment&lt;br /&gt;
&lt;br /&gt;
== 4. Regression &amp;amp; CI Testing ==&lt;br /&gt;
&lt;br /&gt;
To ensure updates do not break existing functionality:&lt;br /&gt;
&lt;br /&gt;
* Re-run all existing unit tests  &lt;br /&gt;
* Include snapshot tests for frontend components  &lt;br /&gt;
* Use CI pipelines to automatically trigger tests on pull requests  &lt;br /&gt;
&lt;br /&gt;
== Test Plan Summary ==&lt;br /&gt;
&lt;br /&gt;
This test plan outlines the approach for integrating &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the frontend. By combining backend tests, UI integration checks, and realistic database scenarios, we aim to deliver a seamless user experience. The plan emphasizes early detection of issues and supports long-term maintainability through regression testing. As development progresses, the plan will be updated to cover new insights and edge cases.&lt;br /&gt;
&lt;br /&gt;
=Completed Reimplementation Details=&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
==Data Flow Overview==&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
==Adhering to Priciples==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164211</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164211"/>
		<updated>2025-04-20T17:44:39Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* Completed Reimplementation Details */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of this project is to integrate the frontend of the grades view page with the reimplemented '''''grades_controller.rb (E2510)''''' backend in Expertiza, ensuring a seamless connection between both layers. This integration involves refining the interaction between the UI and backend while adhering to best design principles such as modularity, maintainability, and scalability. The grades_controller.rb is responsible for managing grading functionality, allowing instructors to view and modify assignment grades while enabling students to access their evaluations. By following SOLID and DRY principles, this reimplementation enhances code clarity, reduces redundancy, and improves overall system efficiency.&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
The &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; is responsible for managing and delivering grading data to users in the Expertiza system. It enables instructors to view, calculate, and release grades to students, while also allowing students to view feedback and scores for assignments. The controller plays an important role in coordinating backend logic for reviews and grade visibility.&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
The previous implementation successfully created a functional frontend UI page in Expertiza, addressing design inconsistencies and improving usability. It introduced a visually cohesive interface with an intuitive layout, enhanced responsiveness, and improved information display, allowing users to navigate grading data more efficiently. However, the interface was populated using dummy data, limiting its practical use. This reimplemented UI will utilize real data from the database (that has been populated in this round), ensuring that grading information is dynamically retrieved and displayed accurately through JSON objects. Additionally, this phase will connect the redesigned frontend with some new components in the grades_controller.rb. Specifically, the GET functions in the grades_controller were reimplemented to return JSON objects (instead of instance variables) that could be accessed via an API call. Thus, this new implementation ensures seamless communication between the UI and backend while adhering to best design practices for maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
This project focuses on integrating the frontend of the grades view page with the reimplemented '''grades_controller.rb (E2510)''' backend in Expertiza. This integration requires modifications to both the frontend and backend to establish a seamless connection, ensuring that grading data is dynamically retrieved and displayed accurately. By adhering to best design principles such as modularity, maintainability, and scalability, the implementation will enhance system efficiency and long-term usability. Key improvements include replacing dummy data with real database values, refining data flow between the UI and backend, and optimizing API interactions for better performance. These enhancements will create a more intuitive and reliable grading system, providing a seamless experience for instructors and students while maintaining a well-structured and adaptable codebase for future development.&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
# '''Establish a Robust Connection Between the Frontend and Backend''': Ensure smooth data retrieval and updates between the grades view page and the backend by integrating dynamic data through API calls, replacing the current hardcoded dummy data.&lt;br /&gt;
# '''Define and Implement Clear API Endpoints''': Create well-structured API endpoints in grades_controller.rb for retrieving and displaying grades, ensuring they return appropriate data based on user roles (students, instructors, TAs) and maintain role-based access controls.&lt;br /&gt;
# '''Dynamic Data Integration''': Modify the frontend to consume real-time data fetched from the backend, ensuring an intuitive and responsive UI that reflects the actual grading information. &lt;br /&gt;
# '''Refactor Frontend and Backend Components''': Refactor both the frontend and backend as necessary to align with SOLID and DRY principles, ensuring modularity, maintainability, and scalability. This includes eliminating redundant logic and optimizing code for better readability.&lt;br /&gt;
# '''Implement Proper Permission Checks''': Ensure that only authorized users can access grade information by implementing robust privilege checks and ensuring that the data is securely accessible to students, instructors, and TAs based on their roles.&lt;br /&gt;
# '''Optimize Database Queries and API Responses''': Enhance the efficiency of database queries and API responses to reduce unnecessary load and ensure that data is retrieved and displayed promptly.&lt;br /&gt;
# '''Testing and Validation''': Implement comprehensive unit and integration tests to verify the correctness of data flow, UI interactions, and role-based access controls, ensuring that the system functions correctly and securely.&lt;br /&gt;
&lt;br /&gt;
=Reimplementation Plan=&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populated data with the appropriate HTTP GET and HTTP POST calls. This shift is necessary to ensure that our application reflects real-time data from the backend rather than relying on static or hardcoded values, which can quickly become outdated or inconsistent. It also enables better scalability and maintainability, as changes to the data only need to be made in the backend, without requiring manual updates in the frontend code.&lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
'''Author Feedback''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
'''Heatmap Data''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
'''Team-mate Data''':&lt;br /&gt;
   {&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The current implementation caters to the backend for a Ruby-embedded front-end, where data is rendered server-side and passed directly into the view. We need to update the APIs to return data in a format that can be consumed by the React UI, typically JSON. This shift is essential to decouple the front-end from the server-side rendering logic, allowing for a more interactive and dynamic user experience. By transitioning to a React-based interface, we gain better control over UI state and responsiveness, while also aligning with modern web development practices. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and instead return plain JSON objects using render json: in the response. This change is necessary to align with a frontend architecture that uses React or another JavaScript framework, which expects structured data from the backend in JSON format rather than relying on server-rendered templates. By shifting to JSON responses, we enable cleaner API endpoints, facilitate easier testing and debugging, and support a more maintainable, decoupled frontend-backend integration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    # prepare feedback summaries&lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
  1.1. Students&lt;br /&gt;
  1.2. Teams&lt;br /&gt;
  1.3. TA&lt;br /&gt;
  1.4. Professor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
  2.1 assignments&lt;br /&gt;
  2.2 assignment_questionnaire&lt;br /&gt;
  2.3 questionnaires&lt;br /&gt;
  2.4 participant&lt;br /&gt;
  2.5 signed_up_teams&lt;br /&gt;
  2.6 teams_users&lt;br /&gt;
  2.7 due_dates&lt;br /&gt;
  2.8 late_policies&lt;br /&gt;
  2.9 questions&lt;br /&gt;
  2.10 review_scores&lt;br /&gt;
  2.11 review_grades&lt;br /&gt;
&lt;br /&gt;
== Data Flow Overview ==&lt;br /&gt;
The diagram below illustrates how data flows between the frontend React components and the grades_controller.rb backend during a typical grading data fetch operation.&lt;br /&gt;
&lt;br /&gt;
* The user (e.g., instructor or student) interacts with the React-based grades view (e.g., ReviewTable, RoundSelector, or Statistics).&lt;br /&gt;
* The component triggers an API request to a specific action in grades_controller.rb (e.g., GET /grades/:id/summary).&lt;br /&gt;
*The controller action queries the relevant models (e.g., Assignment, Team, ReviewResponseMap) and compiles a JSON response.&lt;br /&gt;
* The response is sent back to the frontend and parsed.&lt;br /&gt;
*The React components update the UI (tables, heatmaps, statistics) based on the received data.&lt;br /&gt;
&lt;br /&gt;
This architecture ensures a clean separation between frontend and backend logic, improving maintainability and testability.&lt;br /&gt;
[[File:Dataflow.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
The test plan for Phase 2 focuses on verifying the successful integration of the newly reimplemented &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the React-based UI components. We aim to ensure data is:&lt;br /&gt;
&lt;br /&gt;
* Correctly fetched from the backend  &lt;br /&gt;
* Appropriately displayed in the frontend  &lt;br /&gt;
* Functionally sound under both normal and edge-case scenarios&lt;br /&gt;
&lt;br /&gt;
== Tools and Frameworks ==&lt;br /&gt;
We plan to use the following tools and frameworks for testing:&lt;br /&gt;
&lt;br /&gt;
* '''Frontend''': Jest and React Testing Library for unit and integration tests&lt;br /&gt;
* '''Backend''': RSpec for controller and model tests&lt;br /&gt;
* '''Integration Testing''': Capybara and Selenium for simulating real user behavior&lt;br /&gt;
* '''Test Coverage''': SimpleCov&lt;br /&gt;
&lt;br /&gt;
== 1. UI Integration Tests ==&lt;br /&gt;
&lt;br /&gt;
These tests ensure the frontend correctly interacts with backend APIs and renders the data appropriately.&lt;br /&gt;
&lt;br /&gt;
=== ReviewTable Component ===&lt;br /&gt;
&lt;br /&gt;
* Validate that the component makes a successful API call to fetch author feedback  &lt;br /&gt;
* Ensure feedback is rendered in the correct table structure  &lt;br /&gt;
* Test loading state before data is fetched  &lt;br /&gt;
* Handle empty or malformed feedback responses gracefully  &lt;br /&gt;
&lt;br /&gt;
=== RoundSelector Component ===&lt;br /&gt;
&lt;br /&gt;
* Verify API call to fetch heatmap data is triggered on component load  &lt;br /&gt;
* Check that heatmap data is correctly visualized for different review rounds  &lt;br /&gt;
* Test behavior with no data, incomplete data, or delayed response  &lt;br /&gt;
&lt;br /&gt;
=== Statistics Component ===&lt;br /&gt;
&lt;br /&gt;
* Confirm it correctly fetches teammate evaluations and author feedback  &lt;br /&gt;
* Ensure charts or tables reflect the received backend data accurately  &lt;br /&gt;
* Test switching between different teams or assignments and verify correct display  &lt;br /&gt;
&lt;br /&gt;
=== General UI Considerations ===&lt;br /&gt;
&lt;br /&gt;
* Test frontend responsiveness to backend failures (500, 404, timeout)  &lt;br /&gt;
* Ensure authorization errors are handled and appropriate messages displayed  &lt;br /&gt;
&lt;br /&gt;
== 2. Backend API Tests ==&lt;br /&gt;
&lt;br /&gt;
While unit tests exist, integration-level tests will be added or updated to ensure UI compatibility.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
* Validate all &amp;lt;code&amp;gt;GET&amp;lt;/code&amp;gt; endpoints return properly structured JSON objects  &lt;br /&gt;
* Simulate various user roles (student, TA, instructor) and ensure access control  &lt;br /&gt;
* Include test cases for:&lt;br /&gt;
** No grades present  &lt;br /&gt;
** Partial data (e.g. missing feedback or evaluations)  &lt;br /&gt;
** Large number of records  &lt;br /&gt;
&lt;br /&gt;
=== Security &amp;amp; Permissions ===&lt;br /&gt;
&lt;br /&gt;
* Ensure students can only fetch their grades and feedback  &lt;br /&gt;
* Ensure TAs and instructors can access full assignment data  &lt;br /&gt;
* Test token/session-based access restrictions (if applicable)  &lt;br /&gt;
&lt;br /&gt;
== 3. Database Preparation ==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, seed data will simulate real-world usage and we will ensure that:&lt;br /&gt;
* Tests will use isolated fixtures or factories to ensure data consistency&lt;br /&gt;
* All database states will be reset before each test suite run&lt;br /&gt;
&lt;br /&gt;
=== Tables and Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;assignments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_participant&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;participants&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;questionnaires&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;questions&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_questionnaire&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;signed_up_teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;teams_users&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;late_policies&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
=== Scenarios ===&lt;br /&gt;
&lt;br /&gt;
* Single student assigned  &lt;br /&gt;
* Team assignments with/without feedback  &lt;br /&gt;
* Late submissions triggering late policies  &lt;br /&gt;
* Multiple review rounds per assignment&lt;br /&gt;
&lt;br /&gt;
== 4. Regression &amp;amp; CI Testing ==&lt;br /&gt;
&lt;br /&gt;
To ensure updates do not break existing functionality:&lt;br /&gt;
&lt;br /&gt;
* Re-run all existing unit tests  &lt;br /&gt;
* Include snapshot tests for frontend components  &lt;br /&gt;
* Use CI pipelines to automatically trigger tests on pull requests  &lt;br /&gt;
&lt;br /&gt;
== Test Plan Summary ==&lt;br /&gt;
&lt;br /&gt;
This test plan outlines the approach for integrating &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the frontend. By combining backend tests, UI integration checks, and realistic database scenarios, we aim to deliver a seamless user experience. The plan emphasizes early detection of issues and supports long-term maintainability through regression testing. As development progresses, the plan will be updated to cover new insights and edge cases.&lt;br /&gt;
&lt;br /&gt;
=Completed Reimplementation Details=&lt;br /&gt;
&lt;br /&gt;
2.1	UI&lt;br /&gt;
2.2	API&lt;br /&gt;
2.3	Database&lt;br /&gt;
2.4	Data Flow Overview&lt;br /&gt;
2.5	Test Plan&lt;br /&gt;
2.6	Tools and Frameworks&lt;br /&gt;
2.7	1. UI Integration Tests&lt;br /&gt;
2.7.1	ReviewTable Component&lt;br /&gt;
2.7.2	RoundSelector Component&lt;br /&gt;
2.7.3	Statistics Component&lt;br /&gt;
2.7.4	General UI Considerations&lt;br /&gt;
2.8	2. Backend API Tests&lt;br /&gt;
2.8.1	grades_controller.rb&lt;br /&gt;
2.8.2	Security &amp;amp; Permissions&lt;br /&gt;
2.9	3. Database Preparation&lt;br /&gt;
2.9.1	Tables and Test Coverage&lt;br /&gt;
2.9.2	Scenarios&lt;br /&gt;
2.10	4. Regression &amp;amp; CI Testing&lt;br /&gt;
2.11	Test Plan Summary&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164210</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164210"/>
		<updated>2025-04-20T17:43:43Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* Implementation Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of this project is to integrate the frontend of the grades view page with the reimplemented '''''grades_controller.rb (E2510)''''' backend in Expertiza, ensuring a seamless connection between both layers. This integration involves refining the interaction between the UI and backend while adhering to best design principles such as modularity, maintainability, and scalability. The grades_controller.rb is responsible for managing grading functionality, allowing instructors to view and modify assignment grades while enabling students to access their evaluations. By following SOLID and DRY principles, this reimplementation enhances code clarity, reduces redundancy, and improves overall system efficiency.&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
The &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; is responsible for managing and delivering grading data to users in the Expertiza system. It enables instructors to view, calculate, and release grades to students, while also allowing students to view feedback and scores for assignments. The controller plays an important role in coordinating backend logic for reviews and grade visibility.&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
The previous implementation successfully created a functional frontend UI page in Expertiza, addressing design inconsistencies and improving usability. It introduced a visually cohesive interface with an intuitive layout, enhanced responsiveness, and improved information display, allowing users to navigate grading data more efficiently. However, the interface was populated using dummy data, limiting its practical use. This reimplemented UI will utilize real data from the database (that has been populated in this round), ensuring that grading information is dynamically retrieved and displayed accurately through JSON objects. Additionally, this phase will connect the redesigned frontend with some new components in the grades_controller.rb. Specifically, the GET functions in the grades_controller were reimplemented to return JSON objects (instead of instance variables) that could be accessed via an API call. Thus, this new implementation ensures seamless communication between the UI and backend while adhering to best design practices for maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
This project focuses on integrating the frontend of the grades view page with the reimplemented '''grades_controller.rb (E2510)''' backend in Expertiza. This integration requires modifications to both the frontend and backend to establish a seamless connection, ensuring that grading data is dynamically retrieved and displayed accurately. By adhering to best design principles such as modularity, maintainability, and scalability, the implementation will enhance system efficiency and long-term usability. Key improvements include replacing dummy data with real database values, refining data flow between the UI and backend, and optimizing API interactions for better performance. These enhancements will create a more intuitive and reliable grading system, providing a seamless experience for instructors and students while maintaining a well-structured and adaptable codebase for future development.&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
# '''Establish a Robust Connection Between the Frontend and Backend''': Ensure smooth data retrieval and updates between the grades view page and the backend by integrating dynamic data through API calls, replacing the current hardcoded dummy data.&lt;br /&gt;
# '''Define and Implement Clear API Endpoints''': Create well-structured API endpoints in grades_controller.rb for retrieving and displaying grades, ensuring they return appropriate data based on user roles (students, instructors, TAs) and maintain role-based access controls.&lt;br /&gt;
# '''Dynamic Data Integration''': Modify the frontend to consume real-time data fetched from the backend, ensuring an intuitive and responsive UI that reflects the actual grading information. &lt;br /&gt;
# '''Refactor Frontend and Backend Components''': Refactor both the frontend and backend as necessary to align with SOLID and DRY principles, ensuring modularity, maintainability, and scalability. This includes eliminating redundant logic and optimizing code for better readability.&lt;br /&gt;
# '''Implement Proper Permission Checks''': Ensure that only authorized users can access grade information by implementing robust privilege checks and ensuring that the data is securely accessible to students, instructors, and TAs based on their roles.&lt;br /&gt;
# '''Optimize Database Queries and API Responses''': Enhance the efficiency of database queries and API responses to reduce unnecessary load and ensure that data is retrieved and displayed promptly.&lt;br /&gt;
# '''Testing and Validation''': Implement comprehensive unit and integration tests to verify the correctness of data flow, UI interactions, and role-based access controls, ensuring that the system functions correctly and securely.&lt;br /&gt;
&lt;br /&gt;
=Reimplementation Plan=&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populated data with the appropriate HTTP GET and HTTP POST calls. This shift is necessary to ensure that our application reflects real-time data from the backend rather than relying on static or hardcoded values, which can quickly become outdated or inconsistent. It also enables better scalability and maintainability, as changes to the data only need to be made in the backend, without requiring manual updates in the frontend code.&lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
'''Author Feedback''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
'''Heatmap Data''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
'''Team-mate Data''':&lt;br /&gt;
   {&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The current implementation caters to the backend for a Ruby-embedded front-end, where data is rendered server-side and passed directly into the view. We need to update the APIs to return data in a format that can be consumed by the React UI, typically JSON. This shift is essential to decouple the front-end from the server-side rendering logic, allowing for a more interactive and dynamic user experience. By transitioning to a React-based interface, we gain better control over UI state and responsiveness, while also aligning with modern web development practices. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and instead return plain JSON objects using render json: in the response. This change is necessary to align with a frontend architecture that uses React or another JavaScript framework, which expects structured data from the backend in JSON format rather than relying on server-rendered templates. By shifting to JSON responses, we enable cleaner API endpoints, facilitate easier testing and debugging, and support a more maintainable, decoupled frontend-backend integration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    # prepare feedback summaries&lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
  1.1. Students&lt;br /&gt;
  1.2. Teams&lt;br /&gt;
  1.3. TA&lt;br /&gt;
  1.4. Professor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
  2.1 assignments&lt;br /&gt;
  2.2 assignment_questionnaire&lt;br /&gt;
  2.3 questionnaires&lt;br /&gt;
  2.4 participant&lt;br /&gt;
  2.5 signed_up_teams&lt;br /&gt;
  2.6 teams_users&lt;br /&gt;
  2.7 due_dates&lt;br /&gt;
  2.8 late_policies&lt;br /&gt;
  2.9 questions&lt;br /&gt;
  2.10 review_scores&lt;br /&gt;
  2.11 review_grades&lt;br /&gt;
&lt;br /&gt;
== Data Flow Overview ==&lt;br /&gt;
The diagram below illustrates how data flows between the frontend React components and the grades_controller.rb backend during a typical grading data fetch operation.&lt;br /&gt;
&lt;br /&gt;
* The user (e.g., instructor or student) interacts with the React-based grades view (e.g., ReviewTable, RoundSelector, or Statistics).&lt;br /&gt;
* The component triggers an API request to a specific action in grades_controller.rb (e.g., GET /grades/:id/summary).&lt;br /&gt;
*The controller action queries the relevant models (e.g., Assignment, Team, ReviewResponseMap) and compiles a JSON response.&lt;br /&gt;
* The response is sent back to the frontend and parsed.&lt;br /&gt;
*The React components update the UI (tables, heatmaps, statistics) based on the received data.&lt;br /&gt;
&lt;br /&gt;
This architecture ensures a clean separation between frontend and backend logic, improving maintainability and testability.&lt;br /&gt;
[[File:Dataflow.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
The test plan for Phase 2 focuses on verifying the successful integration of the newly reimplemented &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the React-based UI components. We aim to ensure data is:&lt;br /&gt;
&lt;br /&gt;
* Correctly fetched from the backend  &lt;br /&gt;
* Appropriately displayed in the frontend  &lt;br /&gt;
* Functionally sound under both normal and edge-case scenarios&lt;br /&gt;
&lt;br /&gt;
== Tools and Frameworks ==&lt;br /&gt;
We plan to use the following tools and frameworks for testing:&lt;br /&gt;
&lt;br /&gt;
* '''Frontend''': Jest and React Testing Library for unit and integration tests&lt;br /&gt;
* '''Backend''': RSpec for controller and model tests&lt;br /&gt;
* '''Integration Testing''': Capybara and Selenium for simulating real user behavior&lt;br /&gt;
* '''Test Coverage''': SimpleCov&lt;br /&gt;
&lt;br /&gt;
== 1. UI Integration Tests ==&lt;br /&gt;
&lt;br /&gt;
These tests ensure the frontend correctly interacts with backend APIs and renders the data appropriately.&lt;br /&gt;
&lt;br /&gt;
=== ReviewTable Component ===&lt;br /&gt;
&lt;br /&gt;
* Validate that the component makes a successful API call to fetch author feedback  &lt;br /&gt;
* Ensure feedback is rendered in the correct table structure  &lt;br /&gt;
* Test loading state before data is fetched  &lt;br /&gt;
* Handle empty or malformed feedback responses gracefully  &lt;br /&gt;
&lt;br /&gt;
=== RoundSelector Component ===&lt;br /&gt;
&lt;br /&gt;
* Verify API call to fetch heatmap data is triggered on component load  &lt;br /&gt;
* Check that heatmap data is correctly visualized for different review rounds  &lt;br /&gt;
* Test behavior with no data, incomplete data, or delayed response  &lt;br /&gt;
&lt;br /&gt;
=== Statistics Component ===&lt;br /&gt;
&lt;br /&gt;
* Confirm it correctly fetches teammate evaluations and author feedback  &lt;br /&gt;
* Ensure charts or tables reflect the received backend data accurately  &lt;br /&gt;
* Test switching between different teams or assignments and verify correct display  &lt;br /&gt;
&lt;br /&gt;
=== General UI Considerations ===&lt;br /&gt;
&lt;br /&gt;
* Test frontend responsiveness to backend failures (500, 404, timeout)  &lt;br /&gt;
* Ensure authorization errors are handled and appropriate messages displayed  &lt;br /&gt;
&lt;br /&gt;
== 2. Backend API Tests ==&lt;br /&gt;
&lt;br /&gt;
While unit tests exist, integration-level tests will be added or updated to ensure UI compatibility.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
* Validate all &amp;lt;code&amp;gt;GET&amp;lt;/code&amp;gt; endpoints return properly structured JSON objects  &lt;br /&gt;
* Simulate various user roles (student, TA, instructor) and ensure access control  &lt;br /&gt;
* Include test cases for:&lt;br /&gt;
** No grades present  &lt;br /&gt;
** Partial data (e.g. missing feedback or evaluations)  &lt;br /&gt;
** Large number of records  &lt;br /&gt;
&lt;br /&gt;
=== Security &amp;amp; Permissions ===&lt;br /&gt;
&lt;br /&gt;
* Ensure students can only fetch their grades and feedback  &lt;br /&gt;
* Ensure TAs and instructors can access full assignment data  &lt;br /&gt;
* Test token/session-based access restrictions (if applicable)  &lt;br /&gt;
&lt;br /&gt;
== 3. Database Preparation ==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, seed data will simulate real-world usage and we will ensure that:&lt;br /&gt;
* Tests will use isolated fixtures or factories to ensure data consistency&lt;br /&gt;
* All database states will be reset before each test suite run&lt;br /&gt;
&lt;br /&gt;
=== Tables and Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;assignments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_participant&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;participants&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;questionnaires&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;questions&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_questionnaire&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;signed_up_teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;teams_users&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;late_policies&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
=== Scenarios ===&lt;br /&gt;
&lt;br /&gt;
* Single student assigned  &lt;br /&gt;
* Team assignments with/without feedback  &lt;br /&gt;
* Late submissions triggering late policies  &lt;br /&gt;
* Multiple review rounds per assignment&lt;br /&gt;
&lt;br /&gt;
== 4. Regression &amp;amp; CI Testing ==&lt;br /&gt;
&lt;br /&gt;
To ensure updates do not break existing functionality:&lt;br /&gt;
&lt;br /&gt;
* Re-run all existing unit tests  &lt;br /&gt;
* Include snapshot tests for frontend components  &lt;br /&gt;
* Use CI pipelines to automatically trigger tests on pull requests  &lt;br /&gt;
&lt;br /&gt;
== Test Plan Summary ==&lt;br /&gt;
&lt;br /&gt;
This test plan outlines the approach for integrating &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the frontend. By combining backend tests, UI integration checks, and realistic database scenarios, we aim to deliver a seamless user experience. The plan emphasizes early detection of issues and supports long-term maintainability through regression testing. As development progresses, the plan will be updated to cover new insights and edge cases.&lt;br /&gt;
&lt;br /&gt;
=Completed Reimplementation Details=&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164209</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164209"/>
		<updated>2025-04-20T17:43:22Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of this project is to integrate the frontend of the grades view page with the reimplemented '''''grades_controller.rb (E2510)''''' backend in Expertiza, ensuring a seamless connection between both layers. This integration involves refining the interaction between the UI and backend while adhering to best design principles such as modularity, maintainability, and scalability. The grades_controller.rb is responsible for managing grading functionality, allowing instructors to view and modify assignment grades while enabling students to access their evaluations. By following SOLID and DRY principles, this reimplementation enhances code clarity, reduces redundancy, and improves overall system efficiency.&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
The &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; is responsible for managing and delivering grading data to users in the Expertiza system. It enables instructors to view, calculate, and release grades to students, while also allowing students to view feedback and scores for assignments. The controller plays an important role in coordinating backend logic for reviews and grade visibility.&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
The previous implementation successfully created a functional frontend UI page in Expertiza, addressing design inconsistencies and improving usability. It introduced a visually cohesive interface with an intuitive layout, enhanced responsiveness, and improved information display, allowing users to navigate grading data more efficiently. However, the interface was populated using dummy data, limiting its practical use. This reimplemented UI will utilize real data from the database (that has been populated in this round), ensuring that grading information is dynamically retrieved and displayed accurately through JSON objects. Additionally, this phase will connect the redesigned frontend with some new components in the grades_controller.rb. Specifically, the GET functions in the grades_controller were reimplemented to return JSON objects (instead of instance variables) that could be accessed via an API call. Thus, this new implementation ensures seamless communication between the UI and backend while adhering to best design practices for maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
This project focuses on integrating the frontend of the grades view page with the reimplemented '''grades_controller.rb (E2510)''' backend in Expertiza. This integration requires modifications to both the frontend and backend to establish a seamless connection, ensuring that grading data is dynamically retrieved and displayed accurately. By adhering to best design principles such as modularity, maintainability, and scalability, the implementation will enhance system efficiency and long-term usability. Key improvements include replacing dummy data with real database values, refining data flow between the UI and backend, and optimizing API interactions for better performance. These enhancements will create a more intuitive and reliable grading system, providing a seamless experience for instructors and students while maintaining a well-structured and adaptable codebase for future development.&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
# '''Establish a Robust Connection Between the Frontend and Backend''': Ensure smooth data retrieval and updates between the grades view page and the backend by integrating dynamic data through API calls, replacing the current hardcoded dummy data.&lt;br /&gt;
# '''Define and Implement Clear API Endpoints''': Create well-structured API endpoints in grades_controller.rb for retrieving and displaying grades, ensuring they return appropriate data based on user roles (students, instructors, TAs) and maintain role-based access controls.&lt;br /&gt;
# '''Dynamic Data Integration''': Modify the frontend to consume real-time data fetched from the backend, ensuring an intuitive and responsive UI that reflects the actual grading information. &lt;br /&gt;
# '''Refactor Frontend and Backend Components''': Refactor both the frontend and backend as necessary to align with SOLID and DRY principles, ensuring modularity, maintainability, and scalability. This includes eliminating redundant logic and optimizing code for better readability.&lt;br /&gt;
# '''Implement Proper Permission Checks''': Ensure that only authorized users can access grade information by implementing robust privilege checks and ensuring that the data is securely accessible to students, instructors, and TAs based on their roles.&lt;br /&gt;
# '''Optimize Database Queries and API Responses''': Enhance the efficiency of database queries and API responses to reduce unnecessary load and ensure that data is retrieved and displayed promptly.&lt;br /&gt;
# '''Testing and Validation''': Implement comprehensive unit and integration tests to verify the correctness of data flow, UI interactions, and role-based access controls, ensuring that the system functions correctly and securely.&lt;br /&gt;
&lt;br /&gt;
=Implementation Plan=&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populated data with the appropriate HTTP GET and HTTP POST calls. This shift is necessary to ensure that our application reflects real-time data from the backend rather than relying on static or hardcoded values, which can quickly become outdated or inconsistent. It also enables better scalability and maintainability, as changes to the data only need to be made in the backend, without requiring manual updates in the frontend code.&lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
'''Author Feedback''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
'''Heatmap Data''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
'''Team-mate Data''':&lt;br /&gt;
   {&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The current implementation caters to the backend for a Ruby-embedded front-end, where data is rendered server-side and passed directly into the view. We need to update the APIs to return data in a format that can be consumed by the React UI, typically JSON. This shift is essential to decouple the front-end from the server-side rendering logic, allowing for a more interactive and dynamic user experience. By transitioning to a React-based interface, we gain better control over UI state and responsiveness, while also aligning with modern web development practices. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and instead return plain JSON objects using render json: in the response. This change is necessary to align with a frontend architecture that uses React or another JavaScript framework, which expects structured data from the backend in JSON format rather than relying on server-rendered templates. By shifting to JSON responses, we enable cleaner API endpoints, facilitate easier testing and debugging, and support a more maintainable, decoupled frontend-backend integration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    # prepare feedback summaries&lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
  1.1. Students&lt;br /&gt;
  1.2. Teams&lt;br /&gt;
  1.3. TA&lt;br /&gt;
  1.4. Professor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
  2.1 assignments&lt;br /&gt;
  2.2 assignment_questionnaire&lt;br /&gt;
  2.3 questionnaires&lt;br /&gt;
  2.4 participant&lt;br /&gt;
  2.5 signed_up_teams&lt;br /&gt;
  2.6 teams_users&lt;br /&gt;
  2.7 due_dates&lt;br /&gt;
  2.8 late_policies&lt;br /&gt;
  2.9 questions&lt;br /&gt;
  2.10 review_scores&lt;br /&gt;
  2.11 review_grades&lt;br /&gt;
&lt;br /&gt;
== Data Flow Overview ==&lt;br /&gt;
The diagram below illustrates how data flows between the frontend React components and the grades_controller.rb backend during a typical grading data fetch operation.&lt;br /&gt;
&lt;br /&gt;
* The user (e.g., instructor or student) interacts with the React-based grades view (e.g., ReviewTable, RoundSelector, or Statistics).&lt;br /&gt;
* The component triggers an API request to a specific action in grades_controller.rb (e.g., GET /grades/:id/summary).&lt;br /&gt;
*The controller action queries the relevant models (e.g., Assignment, Team, ReviewResponseMap) and compiles a JSON response.&lt;br /&gt;
* The response is sent back to the frontend and parsed.&lt;br /&gt;
*The React components update the UI (tables, heatmaps, statistics) based on the received data.&lt;br /&gt;
&lt;br /&gt;
This architecture ensures a clean separation between frontend and backend logic, improving maintainability and testability.&lt;br /&gt;
[[File:Dataflow.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
The test plan for Phase 2 focuses on verifying the successful integration of the newly reimplemented &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the React-based UI components. We aim to ensure data is:&lt;br /&gt;
&lt;br /&gt;
* Correctly fetched from the backend  &lt;br /&gt;
* Appropriately displayed in the frontend  &lt;br /&gt;
* Functionally sound under both normal and edge-case scenarios&lt;br /&gt;
&lt;br /&gt;
== Tools and Frameworks ==&lt;br /&gt;
We plan to use the following tools and frameworks for testing:&lt;br /&gt;
&lt;br /&gt;
* '''Frontend''': Jest and React Testing Library for unit and integration tests&lt;br /&gt;
* '''Backend''': RSpec for controller and model tests&lt;br /&gt;
* '''Integration Testing''': Capybara and Selenium for simulating real user behavior&lt;br /&gt;
* '''Test Coverage''': SimpleCov&lt;br /&gt;
&lt;br /&gt;
== 1. UI Integration Tests ==&lt;br /&gt;
&lt;br /&gt;
These tests ensure the frontend correctly interacts with backend APIs and renders the data appropriately.&lt;br /&gt;
&lt;br /&gt;
=== ReviewTable Component ===&lt;br /&gt;
&lt;br /&gt;
* Validate that the component makes a successful API call to fetch author feedback  &lt;br /&gt;
* Ensure feedback is rendered in the correct table structure  &lt;br /&gt;
* Test loading state before data is fetched  &lt;br /&gt;
* Handle empty or malformed feedback responses gracefully  &lt;br /&gt;
&lt;br /&gt;
=== RoundSelector Component ===&lt;br /&gt;
&lt;br /&gt;
* Verify API call to fetch heatmap data is triggered on component load  &lt;br /&gt;
* Check that heatmap data is correctly visualized for different review rounds  &lt;br /&gt;
* Test behavior with no data, incomplete data, or delayed response  &lt;br /&gt;
&lt;br /&gt;
=== Statistics Component ===&lt;br /&gt;
&lt;br /&gt;
* Confirm it correctly fetches teammate evaluations and author feedback  &lt;br /&gt;
* Ensure charts or tables reflect the received backend data accurately  &lt;br /&gt;
* Test switching between different teams or assignments and verify correct display  &lt;br /&gt;
&lt;br /&gt;
=== General UI Considerations ===&lt;br /&gt;
&lt;br /&gt;
* Test frontend responsiveness to backend failures (500, 404, timeout)  &lt;br /&gt;
* Ensure authorization errors are handled and appropriate messages displayed  &lt;br /&gt;
&lt;br /&gt;
== 2. Backend API Tests ==&lt;br /&gt;
&lt;br /&gt;
While unit tests exist, integration-level tests will be added or updated to ensure UI compatibility.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
* Validate all &amp;lt;code&amp;gt;GET&amp;lt;/code&amp;gt; endpoints return properly structured JSON objects  &lt;br /&gt;
* Simulate various user roles (student, TA, instructor) and ensure access control  &lt;br /&gt;
* Include test cases for:&lt;br /&gt;
** No grades present  &lt;br /&gt;
** Partial data (e.g. missing feedback or evaluations)  &lt;br /&gt;
** Large number of records  &lt;br /&gt;
&lt;br /&gt;
=== Security &amp;amp; Permissions ===&lt;br /&gt;
&lt;br /&gt;
* Ensure students can only fetch their grades and feedback  &lt;br /&gt;
* Ensure TAs and instructors can access full assignment data  &lt;br /&gt;
* Test token/session-based access restrictions (if applicable)  &lt;br /&gt;
&lt;br /&gt;
== 3. Database Preparation ==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, seed data will simulate real-world usage and we will ensure that:&lt;br /&gt;
* Tests will use isolated fixtures or factories to ensure data consistency&lt;br /&gt;
* All database states will be reset before each test suite run&lt;br /&gt;
&lt;br /&gt;
=== Tables and Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;assignments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_participant&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;participants&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;questionnaires&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;questions&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_questionnaire&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;signed_up_teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;teams_users&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;late_policies&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
=== Scenarios ===&lt;br /&gt;
&lt;br /&gt;
* Single student assigned  &lt;br /&gt;
* Team assignments with/without feedback  &lt;br /&gt;
* Late submissions triggering late policies  &lt;br /&gt;
* Multiple review rounds per assignment&lt;br /&gt;
&lt;br /&gt;
== 4. Regression &amp;amp; CI Testing ==&lt;br /&gt;
&lt;br /&gt;
To ensure updates do not break existing functionality:&lt;br /&gt;
&lt;br /&gt;
* Re-run all existing unit tests  &lt;br /&gt;
* Include snapshot tests for frontend components  &lt;br /&gt;
* Use CI pipelines to automatically trigger tests on pull requests  &lt;br /&gt;
&lt;br /&gt;
== Test Plan Summary ==&lt;br /&gt;
&lt;br /&gt;
This test plan outlines the approach for integrating &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the frontend. By combining backend tests, UI integration checks, and realistic database scenarios, we aim to deliver a seamless user experience. The plan emphasizes early detection of issues and supports long-term maintainability through regression testing. As development progresses, the plan will be updated to cover new insights and edge cases.&lt;br /&gt;
&lt;br /&gt;
=Completed Reimplementation Details=&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164208</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164208"/>
		<updated>2025-04-20T17:36:20Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* Implementation Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of this project is to integrate the frontend of the grades view page with the reimplemented '''''grades_controller.rb (E2510)''''' backend in Expertiza, ensuring a seamless connection between both layers. This integration involves refining the interaction between the UI and backend while adhering to best design principles such as modularity, maintainability, and scalability. The grades_controller.rb is responsible for managing grading functionality, allowing instructors to view and modify assignment grades while enabling students to access their evaluations. By following SOLID and DRY principles, this reimplementation enhances code clarity, reduces redundancy, and improves overall system efficiency.&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
The &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; is responsible for managing and delivering grading data to users in the Expertiza system. It enables instructors to view, calculate, and release grades to students, while also allowing students to view feedback and scores for assignments. The controller plays an important role in coordinating backend logic for reviews and grade visibility.&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
The previous implementation successfully created a functional frontend UI page in Expertiza, addressing design inconsistencies and improving usability. It introduced a visually cohesive interface with an intuitive layout, enhanced responsiveness, and improved information display, allowing users to navigate grading data more efficiently. However, the interface was populated using dummy data, limiting its practical use. This reimplemented UI will utilize real data from the database (that has been populated in this round), ensuring that grading information is dynamically retrieved and displayed accurately through JSON objects. Additionally, this phase will connect the redesigned frontend with some new components in the grades_controller.rb. Specifically, the GET functions in the grades_controller were reimplemented to return JSON objects (instead of instance variables) that could be accessed via an API call. Thus, this new implementation ensures seamless communication between the UI and backend while adhering to best design practices for maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
This project focuses on integrating the frontend of the grades view page with the reimplemented '''grades_controller.rb (E2510)''' backend in Expertiza. This integration requires modifications to both the frontend and backend to establish a seamless connection, ensuring that grading data is dynamically retrieved and displayed accurately. By adhering to best design principles such as modularity, maintainability, and scalability, the implementation will enhance system efficiency and long-term usability. Key improvements include replacing dummy data with real database values, refining data flow between the UI and backend, and optimizing API interactions for better performance. These enhancements will create a more intuitive and reliable grading system, providing a seamless experience for instructors and students while maintaining a well-structured and adaptable codebase for future development.&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
# '''Establish a Robust Connection Between the Frontend and Backend''': Ensure smooth data retrieval and updates between the grades view page and the backend by integrating dynamic data through API calls, replacing the current hardcoded dummy data.&lt;br /&gt;
# '''Define and Implement Clear API Endpoints''': Create well-structured API endpoints in grades_controller.rb for retrieving and displaying grades, ensuring they return appropriate data based on user roles (students, instructors, TAs) and maintain role-based access controls.&lt;br /&gt;
# '''Dynamic Data Integration''': Modify the frontend to consume real-time data fetched from the backend, ensuring an intuitive and responsive UI that reflects the actual grading information. &lt;br /&gt;
# '''Refactor Frontend and Backend Components''': Refactor both the frontend and backend as necessary to align with SOLID and DRY principles, ensuring modularity, maintainability, and scalability. This includes eliminating redundant logic and optimizing code for better readability.&lt;br /&gt;
# '''Implement Proper Permission Checks''': Ensure that only authorized users can access grade information by implementing robust privilege checks and ensuring that the data is securely accessible to students, instructors, and TAs based on their roles.&lt;br /&gt;
# '''Optimize Database Queries and API Responses''': Enhance the efficiency of database queries and API responses to reduce unnecessary load and ensure that data is retrieved and displayed promptly.&lt;br /&gt;
# '''Testing and Validation''': Implement comprehensive unit and integration tests to verify the correctness of data flow, UI interactions, and role-based access controls, ensuring that the system functions correctly and securely.&lt;br /&gt;
&lt;br /&gt;
=Implementation Plan=&lt;br /&gt;
&lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populated data with the appropriate HTTP GET and HTTP POST calls. This shift is necessary to ensure that our application reflects real-time data from the backend rather than relying on static or hardcoded values, which can quickly become outdated or inconsistent. It also enables better scalability and maintainability, as changes to the data only need to be made in the backend, without requiring manual updates in the frontend code.&lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
'''Author Feedback''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
'''Heatmap Data''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
'''Team-mate Data''':&lt;br /&gt;
   {&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The current implementation caters to the backend for a Ruby-embedded front-end, where data is rendered server-side and passed directly into the view. We need to update the APIs to return data in a format that can be consumed by the React UI, typically JSON. This shift is essential to decouple the front-end from the server-side rendering logic, allowing for a more interactive and dynamic user experience. By transitioning to a React-based interface, we gain better control over UI state and responsiveness, while also aligning with modern web development practices. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and instead return plain JSON objects using render json: in the response. This change is necessary to align with a frontend architecture that uses React or another JavaScript framework, which expects structured data from the backend in JSON format rather than relying on server-rendered templates. By shifting to JSON responses, we enable cleaner API endpoints, facilitate easier testing and debugging, and support a more maintainable, decoupled frontend-backend integration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    # prepare feedback summaries&lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
  1.1. Students&lt;br /&gt;
  1.2. Teams&lt;br /&gt;
  1.3. TA&lt;br /&gt;
  1.4. Professor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
  2.1 assignments&lt;br /&gt;
  2.2 assignment_questionnaire&lt;br /&gt;
  2.3 questionnaires&lt;br /&gt;
  2.4 participant&lt;br /&gt;
  2.5 signed_up_teams&lt;br /&gt;
  2.6 teams_users&lt;br /&gt;
  2.7 due_dates&lt;br /&gt;
  2.8 late_policies&lt;br /&gt;
  2.9 questions&lt;br /&gt;
  2.10 review_scores&lt;br /&gt;
  2.11 review_grades&lt;br /&gt;
&lt;br /&gt;
== Data Flow Overview ==&lt;br /&gt;
The diagram below illustrates how data flows between the frontend React components and the grades_controller.rb backend during a typical grading data fetch operation.&lt;br /&gt;
&lt;br /&gt;
* The user (e.g., instructor or student) interacts with the React-based grades view (e.g., ReviewTable, RoundSelector, or Statistics).&lt;br /&gt;
* The component triggers an API request to a specific action in grades_controller.rb (e.g., GET /grades/:id/summary).&lt;br /&gt;
*The controller action queries the relevant models (e.g., Assignment, Team, ReviewResponseMap) and compiles a JSON response.&lt;br /&gt;
* The response is sent back to the frontend and parsed.&lt;br /&gt;
*The React components update the UI (tables, heatmaps, statistics) based on the received data.&lt;br /&gt;
&lt;br /&gt;
This architecture ensures a clean separation between frontend and backend logic, improving maintainability and testability.&lt;br /&gt;
[[File:Dataflow.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
The test plan for Phase 2 focuses on verifying the successful integration of the newly reimplemented &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the React-based UI components. We aim to ensure data is:&lt;br /&gt;
&lt;br /&gt;
* Correctly fetched from the backend  &lt;br /&gt;
* Appropriately displayed in the frontend  &lt;br /&gt;
* Functionally sound under both normal and edge-case scenarios&lt;br /&gt;
&lt;br /&gt;
== Tools and Frameworks ==&lt;br /&gt;
We plan to use the following tools and frameworks for testing:&lt;br /&gt;
&lt;br /&gt;
* '''Frontend''': Jest and React Testing Library for unit and integration tests&lt;br /&gt;
* '''Backend''': RSpec for controller and model tests&lt;br /&gt;
* '''Integration Testing''': Capybara and Selenium for simulating real user behavior&lt;br /&gt;
* '''Test Coverage''': SimpleCov&lt;br /&gt;
&lt;br /&gt;
== 1. UI Integration Tests ==&lt;br /&gt;
&lt;br /&gt;
These tests ensure the frontend correctly interacts with backend APIs and renders the data appropriately.&lt;br /&gt;
&lt;br /&gt;
=== ReviewTable Component ===&lt;br /&gt;
&lt;br /&gt;
* Validate that the component makes a successful API call to fetch author feedback  &lt;br /&gt;
* Ensure feedback is rendered in the correct table structure  &lt;br /&gt;
* Test loading state before data is fetched  &lt;br /&gt;
* Handle empty or malformed feedback responses gracefully  &lt;br /&gt;
&lt;br /&gt;
=== RoundSelector Component ===&lt;br /&gt;
&lt;br /&gt;
* Verify API call to fetch heatmap data is triggered on component load  &lt;br /&gt;
* Check that heatmap data is correctly visualized for different review rounds  &lt;br /&gt;
* Test behavior with no data, incomplete data, or delayed response  &lt;br /&gt;
&lt;br /&gt;
=== Statistics Component ===&lt;br /&gt;
&lt;br /&gt;
* Confirm it correctly fetches teammate evaluations and author feedback  &lt;br /&gt;
* Ensure charts or tables reflect the received backend data accurately  &lt;br /&gt;
* Test switching between different teams or assignments and verify correct display  &lt;br /&gt;
&lt;br /&gt;
=== General UI Considerations ===&lt;br /&gt;
&lt;br /&gt;
* Test frontend responsiveness to backend failures (500, 404, timeout)  &lt;br /&gt;
* Ensure authorization errors are handled and appropriate messages displayed  &lt;br /&gt;
&lt;br /&gt;
== 2. Backend API Tests ==&lt;br /&gt;
&lt;br /&gt;
While unit tests exist, integration-level tests will be added or updated to ensure UI compatibility.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
* Validate all &amp;lt;code&amp;gt;GET&amp;lt;/code&amp;gt; endpoints return properly structured JSON objects  &lt;br /&gt;
* Simulate various user roles (student, TA, instructor) and ensure access control  &lt;br /&gt;
* Include test cases for:&lt;br /&gt;
** No grades present  &lt;br /&gt;
** Partial data (e.g. missing feedback or evaluations)  &lt;br /&gt;
** Large number of records  &lt;br /&gt;
&lt;br /&gt;
=== Security &amp;amp; Permissions ===&lt;br /&gt;
&lt;br /&gt;
* Ensure students can only fetch their grades and feedback  &lt;br /&gt;
* Ensure TAs and instructors can access full assignment data  &lt;br /&gt;
* Test token/session-based access restrictions (if applicable)  &lt;br /&gt;
&lt;br /&gt;
== 3. Database Preparation ==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, seed data will simulate real-world usage and we will ensure that:&lt;br /&gt;
* Tests will use isolated fixtures or factories to ensure data consistency&lt;br /&gt;
* All database states will be reset before each test suite run&lt;br /&gt;
&lt;br /&gt;
=== Tables and Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;assignments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_participant&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;participants&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;questionnaires&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;questions&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_questionnaire&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;signed_up_teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;teams_users&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;late_policies&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
=== Scenarios ===&lt;br /&gt;
&lt;br /&gt;
* Single student assigned  &lt;br /&gt;
* Team assignments with/without feedback  &lt;br /&gt;
* Late submissions triggering late policies  &lt;br /&gt;
* Multiple review rounds per assignment&lt;br /&gt;
&lt;br /&gt;
== 4. Regression &amp;amp; CI Testing ==&lt;br /&gt;
&lt;br /&gt;
To ensure updates do not break existing functionality:&lt;br /&gt;
&lt;br /&gt;
* Re-run all existing unit tests  &lt;br /&gt;
* Include snapshot tests for frontend components  &lt;br /&gt;
* Use CI pipelines to automatically trigger tests on pull requests  &lt;br /&gt;
&lt;br /&gt;
== Test Plan Summary ==&lt;br /&gt;
&lt;br /&gt;
This test plan outlines the approach for integrating &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the frontend. By combining backend tests, UI integration checks, and realistic database scenarios, we aim to deliver a seamless user experience. The plan emphasizes early detection of issues and supports long-term maintainability through regression testing. As development progresses, the plan will be updated to cover new insights and edge cases.&lt;br /&gt;
&lt;br /&gt;
==Implementation Details==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164207</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164207"/>
		<updated>2025-04-20T17:35:44Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* API */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of this project is to integrate the frontend of the grades view page with the reimplemented '''''grades_controller.rb (E2510)''''' backend in Expertiza, ensuring a seamless connection between both layers. This integration involves refining the interaction between the UI and backend while adhering to best design principles such as modularity, maintainability, and scalability. The grades_controller.rb is responsible for managing grading functionality, allowing instructors to view and modify assignment grades while enabling students to access their evaluations. By following SOLID and DRY principles, this reimplementation enhances code clarity, reduces redundancy, and improves overall system efficiency.&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
The &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; is responsible for managing and delivering grading data to users in the Expertiza system. It enables instructors to view, calculate, and release grades to students, while also allowing students to view feedback and scores for assignments. The controller plays an important role in coordinating backend logic for reviews and grade visibility.&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
The previous implementation successfully created a functional frontend UI page in Expertiza, addressing design inconsistencies and improving usability. It introduced a visually cohesive interface with an intuitive layout, enhanced responsiveness, and improved information display, allowing users to navigate grading data more efficiently. However, the interface was populated using dummy data, limiting its practical use. This reimplemented UI will utilize real data from the database (that has been populated in this round), ensuring that grading information is dynamically retrieved and displayed accurately through JSON objects. Additionally, this phase will connect the redesigned frontend with some new components in the grades_controller.rb. Specifically, the GET functions in the grades_controller were reimplemented to return JSON objects (instead of instance variables) that could be accessed via an API call. Thus, this new implementation ensures seamless communication between the UI and backend while adhering to best design practices for maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
This project focuses on integrating the frontend of the grades view page with the reimplemented '''grades_controller.rb (E2510)''' backend in Expertiza. This integration requires modifications to both the frontend and backend to establish a seamless connection, ensuring that grading data is dynamically retrieved and displayed accurately. By adhering to best design principles such as modularity, maintainability, and scalability, the implementation will enhance system efficiency and long-term usability. Key improvements include replacing dummy data with real database values, refining data flow between the UI and backend, and optimizing API interactions for better performance. These enhancements will create a more intuitive and reliable grading system, providing a seamless experience for instructors and students while maintaining a well-structured and adaptable codebase for future development.&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
# '''Establish a Robust Connection Between the Frontend and Backend''': Ensure smooth data retrieval and updates between the grades view page and the backend by integrating dynamic data through API calls, replacing the current hardcoded dummy data.&lt;br /&gt;
# '''Define and Implement Clear API Endpoints''': Create well-structured API endpoints in grades_controller.rb for retrieving and displaying grades, ensuring they return appropriate data based on user roles (students, instructors, TAs) and maintain role-based access controls.&lt;br /&gt;
# '''Dynamic Data Integration''': Modify the frontend to consume real-time data fetched from the backend, ensuring an intuitive and responsive UI that reflects the actual grading information. &lt;br /&gt;
# '''Refactor Frontend and Backend Components''': Refactor both the frontend and backend as necessary to align with SOLID and DRY principles, ensuring modularity, maintainability, and scalability. This includes eliminating redundant logic and optimizing code for better readability.&lt;br /&gt;
# '''Implement Proper Permission Checks''': Ensure that only authorized users can access grade information by implementing robust privilege checks and ensuring that the data is securely accessible to students, instructors, and TAs based on their roles.&lt;br /&gt;
# '''Optimize Database Queries and API Responses''': Enhance the efficiency of database queries and API responses to reduce unnecessary load and ensure that data is retrieved and displayed promptly.&lt;br /&gt;
# '''Testing and Validation''': Implement comprehensive unit and integration tests to verify the correctness of data flow, UI interactions, and role-based access controls, ensuring that the system functions correctly and securely.&lt;br /&gt;
&lt;br /&gt;
==Implementation Plan==&lt;br /&gt;
 &lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populated data with the appropriate HTTP GET and HTTP POST calls. This shift is necessary to ensure that our application reflects real-time data from the backend rather than relying on static or hardcoded values, which can quickly become outdated or inconsistent. It also enables better scalability and maintainability, as changes to the data only need to be made in the backend, without requiring manual updates in the frontend code.&lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
'''Author Feedback''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
'''Heatmap Data''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
'''Team-mate Data''':&lt;br /&gt;
   {&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The current implementation caters to the backend for a Ruby-embedded front-end, where data is rendered server-side and passed directly into the view. We need to update the APIs to return data in a format that can be consumed by the React UI, typically JSON. This shift is essential to decouple the front-end from the server-side rendering logic, allowing for a more interactive and dynamic user experience. By transitioning to a React-based interface, we gain better control over UI state and responsiveness, while also aligning with modern web development practices. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and instead return plain JSON objects using render json: in the response. This change is necessary to align with a frontend architecture that uses React or another JavaScript framework, which expects structured data from the backend in JSON format rather than relying on server-rendered templates. By shifting to JSON responses, we enable cleaner API endpoints, facilitate easier testing and debugging, and support a more maintainable, decoupled frontend-backend integration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    # prepare feedback summaries&lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
  1.1. Students&lt;br /&gt;
  1.2. Teams&lt;br /&gt;
  1.3. TA&lt;br /&gt;
  1.4. Professor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
  2.1 assignments&lt;br /&gt;
  2.2 assignment_questionnaire&lt;br /&gt;
  2.3 questionnaires&lt;br /&gt;
  2.4 participant&lt;br /&gt;
  2.5 signed_up_teams&lt;br /&gt;
  2.6 teams_users&lt;br /&gt;
  2.7 due_dates&lt;br /&gt;
  2.8 late_policies&lt;br /&gt;
  2.9 questions&lt;br /&gt;
  2.10 review_scores&lt;br /&gt;
  2.11 review_grades&lt;br /&gt;
&lt;br /&gt;
== Data Flow Overview ==&lt;br /&gt;
The diagram below illustrates how data flows between the frontend React components and the grades_controller.rb backend during a typical grading data fetch operation.&lt;br /&gt;
&lt;br /&gt;
* The user (e.g., instructor or student) interacts with the React-based grades view (e.g., ReviewTable, RoundSelector, or Statistics).&lt;br /&gt;
* The component triggers an API request to a specific action in grades_controller.rb (e.g., GET /grades/:id/summary).&lt;br /&gt;
*The controller action queries the relevant models (e.g., Assignment, Team, ReviewResponseMap) and compiles a JSON response.&lt;br /&gt;
* The response is sent back to the frontend and parsed.&lt;br /&gt;
*The React components update the UI (tables, heatmaps, statistics) based on the received data.&lt;br /&gt;
&lt;br /&gt;
This architecture ensures a clean separation between frontend and backend logic, improving maintainability and testability.&lt;br /&gt;
[[File:Dataflow.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
The test plan for Phase 2 focuses on verifying the successful integration of the newly reimplemented &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the React-based UI components. We aim to ensure data is:&lt;br /&gt;
&lt;br /&gt;
* Correctly fetched from the backend  &lt;br /&gt;
* Appropriately displayed in the frontend  &lt;br /&gt;
* Functionally sound under both normal and edge-case scenarios&lt;br /&gt;
&lt;br /&gt;
== Tools and Frameworks ==&lt;br /&gt;
We plan to use the following tools and frameworks for testing:&lt;br /&gt;
&lt;br /&gt;
* '''Frontend''': Jest and React Testing Library for unit and integration tests&lt;br /&gt;
* '''Backend''': RSpec for controller and model tests&lt;br /&gt;
* '''Integration Testing''': Capybara and Selenium for simulating real user behavior&lt;br /&gt;
* '''Test Coverage''': SimpleCov&lt;br /&gt;
&lt;br /&gt;
== 1. UI Integration Tests ==&lt;br /&gt;
&lt;br /&gt;
These tests ensure the frontend correctly interacts with backend APIs and renders the data appropriately.&lt;br /&gt;
&lt;br /&gt;
=== ReviewTable Component ===&lt;br /&gt;
&lt;br /&gt;
* Validate that the component makes a successful API call to fetch author feedback  &lt;br /&gt;
* Ensure feedback is rendered in the correct table structure  &lt;br /&gt;
* Test loading state before data is fetched  &lt;br /&gt;
* Handle empty or malformed feedback responses gracefully  &lt;br /&gt;
&lt;br /&gt;
=== RoundSelector Component ===&lt;br /&gt;
&lt;br /&gt;
* Verify API call to fetch heatmap data is triggered on component load  &lt;br /&gt;
* Check that heatmap data is correctly visualized for different review rounds  &lt;br /&gt;
* Test behavior with no data, incomplete data, or delayed response  &lt;br /&gt;
&lt;br /&gt;
=== Statistics Component ===&lt;br /&gt;
&lt;br /&gt;
* Confirm it correctly fetches teammate evaluations and author feedback  &lt;br /&gt;
* Ensure charts or tables reflect the received backend data accurately  &lt;br /&gt;
* Test switching between different teams or assignments and verify correct display  &lt;br /&gt;
&lt;br /&gt;
=== General UI Considerations ===&lt;br /&gt;
&lt;br /&gt;
* Test frontend responsiveness to backend failures (500, 404, timeout)  &lt;br /&gt;
* Ensure authorization errors are handled and appropriate messages displayed  &lt;br /&gt;
&lt;br /&gt;
== 2. Backend API Tests ==&lt;br /&gt;
&lt;br /&gt;
While unit tests exist, integration-level tests will be added or updated to ensure UI compatibility.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
* Validate all &amp;lt;code&amp;gt;GET&amp;lt;/code&amp;gt; endpoints return properly structured JSON objects  &lt;br /&gt;
* Simulate various user roles (student, TA, instructor) and ensure access control  &lt;br /&gt;
* Include test cases for:&lt;br /&gt;
** No grades present  &lt;br /&gt;
** Partial data (e.g. missing feedback or evaluations)  &lt;br /&gt;
** Large number of records  &lt;br /&gt;
&lt;br /&gt;
=== Security &amp;amp; Permissions ===&lt;br /&gt;
&lt;br /&gt;
* Ensure students can only fetch their grades and feedback  &lt;br /&gt;
* Ensure TAs and instructors can access full assignment data  &lt;br /&gt;
* Test token/session-based access restrictions (if applicable)  &lt;br /&gt;
&lt;br /&gt;
== 3. Database Preparation ==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, seed data will simulate real-world usage and we will ensure that:&lt;br /&gt;
* Tests will use isolated fixtures or factories to ensure data consistency&lt;br /&gt;
* All database states will be reset before each test suite run&lt;br /&gt;
&lt;br /&gt;
=== Tables and Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;assignments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_participant&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;participants&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;questionnaires&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;questions&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_questionnaire&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;signed_up_teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;teams_users&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;late_policies&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
=== Scenarios ===&lt;br /&gt;
&lt;br /&gt;
* Single student assigned  &lt;br /&gt;
* Team assignments with/without feedback  &lt;br /&gt;
* Late submissions triggering late policies  &lt;br /&gt;
* Multiple review rounds per assignment&lt;br /&gt;
&lt;br /&gt;
== 4. Regression &amp;amp; CI Testing ==&lt;br /&gt;
&lt;br /&gt;
To ensure updates do not break existing functionality:&lt;br /&gt;
&lt;br /&gt;
* Re-run all existing unit tests  &lt;br /&gt;
* Include snapshot tests for frontend components  &lt;br /&gt;
* Use CI pipelines to automatically trigger tests on pull requests  &lt;br /&gt;
&lt;br /&gt;
== Test Plan Summary ==&lt;br /&gt;
&lt;br /&gt;
This test plan outlines the approach for integrating &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the frontend. By combining backend tests, UI integration checks, and realistic database scenarios, we aim to deliver a seamless user experience. The plan emphasizes early detection of issues and supports long-term maintainability through regression testing. As development progresses, the plan will be updated to cover new insights and edge cases.&lt;br /&gt;
&lt;br /&gt;
==Implementation Details==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164206</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164206"/>
		<updated>2025-04-20T17:35:28Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* API */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of this project is to integrate the frontend of the grades view page with the reimplemented '''''grades_controller.rb (E2510)''''' backend in Expertiza, ensuring a seamless connection between both layers. This integration involves refining the interaction between the UI and backend while adhering to best design principles such as modularity, maintainability, and scalability. The grades_controller.rb is responsible for managing grading functionality, allowing instructors to view and modify assignment grades while enabling students to access their evaluations. By following SOLID and DRY principles, this reimplementation enhances code clarity, reduces redundancy, and improves overall system efficiency.&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
The &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; is responsible for managing and delivering grading data to users in the Expertiza system. It enables instructors to view, calculate, and release grades to students, while also allowing students to view feedback and scores for assignments. The controller plays an important role in coordinating backend logic for reviews and grade visibility.&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
The previous implementation successfully created a functional frontend UI page in Expertiza, addressing design inconsistencies and improving usability. It introduced a visually cohesive interface with an intuitive layout, enhanced responsiveness, and improved information display, allowing users to navigate grading data more efficiently. However, the interface was populated using dummy data, limiting its practical use. This reimplemented UI will utilize real data from the database (that has been populated in this round), ensuring that grading information is dynamically retrieved and displayed accurately through JSON objects. Additionally, this phase will connect the redesigned frontend with some new components in the grades_controller.rb. Specifically, the GET functions in the grades_controller were reimplemented to return JSON objects (instead of instance variables) that could be accessed via an API call. Thus, this new implementation ensures seamless communication between the UI and backend while adhering to best design practices for maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
This project focuses on integrating the frontend of the grades view page with the reimplemented '''grades_controller.rb (E2510)''' backend in Expertiza. This integration requires modifications to both the frontend and backend to establish a seamless connection, ensuring that grading data is dynamically retrieved and displayed accurately. By adhering to best design principles such as modularity, maintainability, and scalability, the implementation will enhance system efficiency and long-term usability. Key improvements include replacing dummy data with real database values, refining data flow between the UI and backend, and optimizing API interactions for better performance. These enhancements will create a more intuitive and reliable grading system, providing a seamless experience for instructors and students while maintaining a well-structured and adaptable codebase for future development.&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
# '''Establish a Robust Connection Between the Frontend and Backend''': Ensure smooth data retrieval and updates between the grades view page and the backend by integrating dynamic data through API calls, replacing the current hardcoded dummy data.&lt;br /&gt;
# '''Define and Implement Clear API Endpoints''': Create well-structured API endpoints in grades_controller.rb for retrieving and displaying grades, ensuring they return appropriate data based on user roles (students, instructors, TAs) and maintain role-based access controls.&lt;br /&gt;
# '''Dynamic Data Integration''': Modify the frontend to consume real-time data fetched from the backend, ensuring an intuitive and responsive UI that reflects the actual grading information. &lt;br /&gt;
# '''Refactor Frontend and Backend Components''': Refactor both the frontend and backend as necessary to align with SOLID and DRY principles, ensuring modularity, maintainability, and scalability. This includes eliminating redundant logic and optimizing code for better readability.&lt;br /&gt;
# '''Implement Proper Permission Checks''': Ensure that only authorized users can access grade information by implementing robust privilege checks and ensuring that the data is securely accessible to students, instructors, and TAs based on their roles.&lt;br /&gt;
# '''Optimize Database Queries and API Responses''': Enhance the efficiency of database queries and API responses to reduce unnecessary load and ensure that data is retrieved and displayed promptly.&lt;br /&gt;
# '''Testing and Validation''': Implement comprehensive unit and integration tests to verify the correctness of data flow, UI interactions, and role-based access controls, ensuring that the system functions correctly and securely.&lt;br /&gt;
&lt;br /&gt;
==Implementation Plan==&lt;br /&gt;
 &lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populated data with the appropriate HTTP GET and HTTP POST calls. This shift is necessary to ensure that our application reflects real-time data from the backend rather than relying on static or hardcoded values, which can quickly become outdated or inconsistent. It also enables better scalability and maintainability, as changes to the data only need to be made in the backend, without requiring manual updates in the frontend code.&lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
'''Author Feedback''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
'''Heatmap Data''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
'''Team-mate Data''':&lt;br /&gt;
   {&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The current implementation caters to the backend for a Ruby-embedded front-end, where data is rendered server-side and passed directly into the view. We need to update the APIs to return data in a format that can be consumed by the React UI, typically JSON. This shift is essential to decouple the front-end from the server-side rendering logic, allowing for a more interactive and dynamic user experience. By transitioning to a React-based interface, we gain better control over UI state and responsiveness, while also aligning with modern web development practices. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and instead return plain JSON objects using render json: in the response. This change is necessary to align with a frontend architecture that uses React or another JavaScript framework, which expects structured data from the backend in JSON format rather than relying on server-rendered templates. By shifting to JSON responses, we enable cleaner API endpoints, facilitate easier testing and debugging, and support a more maintainable, decoupled frontend-backend integration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    # prepare feedback summaries&lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def edit_participant_scores &lt;br /&gt;
    @participant = find_participant(params[:id])&lt;br /&gt;
    return unless @participant # Exit early if participant not found&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @questions = list_questions(@assignment)&lt;br /&gt;
    @scores = Response.review_grades(@participant, @questions)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
  1.1. Students&lt;br /&gt;
  1.2. Teams&lt;br /&gt;
  1.3. TA&lt;br /&gt;
  1.4. Professor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
  2.1 assignments&lt;br /&gt;
  2.2 assignment_questionnaire&lt;br /&gt;
  2.3 questionnaires&lt;br /&gt;
  2.4 participant&lt;br /&gt;
  2.5 signed_up_teams&lt;br /&gt;
  2.6 teams_users&lt;br /&gt;
  2.7 due_dates&lt;br /&gt;
  2.8 late_policies&lt;br /&gt;
  2.9 questions&lt;br /&gt;
  2.10 review_scores&lt;br /&gt;
  2.11 review_grades&lt;br /&gt;
&lt;br /&gt;
== Data Flow Overview ==&lt;br /&gt;
The diagram below illustrates how data flows between the frontend React components and the grades_controller.rb backend during a typical grading data fetch operation.&lt;br /&gt;
&lt;br /&gt;
* The user (e.g., instructor or student) interacts with the React-based grades view (e.g., ReviewTable, RoundSelector, or Statistics).&lt;br /&gt;
* The component triggers an API request to a specific action in grades_controller.rb (e.g., GET /grades/:id/summary).&lt;br /&gt;
*The controller action queries the relevant models (e.g., Assignment, Team, ReviewResponseMap) and compiles a JSON response.&lt;br /&gt;
* The response is sent back to the frontend and parsed.&lt;br /&gt;
*The React components update the UI (tables, heatmaps, statistics) based on the received data.&lt;br /&gt;
&lt;br /&gt;
This architecture ensures a clean separation between frontend and backend logic, improving maintainability and testability.&lt;br /&gt;
[[File:Dataflow.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
The test plan for Phase 2 focuses on verifying the successful integration of the newly reimplemented &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the React-based UI components. We aim to ensure data is:&lt;br /&gt;
&lt;br /&gt;
* Correctly fetched from the backend  &lt;br /&gt;
* Appropriately displayed in the frontend  &lt;br /&gt;
* Functionally sound under both normal and edge-case scenarios&lt;br /&gt;
&lt;br /&gt;
== Tools and Frameworks ==&lt;br /&gt;
We plan to use the following tools and frameworks for testing:&lt;br /&gt;
&lt;br /&gt;
* '''Frontend''': Jest and React Testing Library for unit and integration tests&lt;br /&gt;
* '''Backend''': RSpec for controller and model tests&lt;br /&gt;
* '''Integration Testing''': Capybara and Selenium for simulating real user behavior&lt;br /&gt;
* '''Test Coverage''': SimpleCov&lt;br /&gt;
&lt;br /&gt;
== 1. UI Integration Tests ==&lt;br /&gt;
&lt;br /&gt;
These tests ensure the frontend correctly interacts with backend APIs and renders the data appropriately.&lt;br /&gt;
&lt;br /&gt;
=== ReviewTable Component ===&lt;br /&gt;
&lt;br /&gt;
* Validate that the component makes a successful API call to fetch author feedback  &lt;br /&gt;
* Ensure feedback is rendered in the correct table structure  &lt;br /&gt;
* Test loading state before data is fetched  &lt;br /&gt;
* Handle empty or malformed feedback responses gracefully  &lt;br /&gt;
&lt;br /&gt;
=== RoundSelector Component ===&lt;br /&gt;
&lt;br /&gt;
* Verify API call to fetch heatmap data is triggered on component load  &lt;br /&gt;
* Check that heatmap data is correctly visualized for different review rounds  &lt;br /&gt;
* Test behavior with no data, incomplete data, or delayed response  &lt;br /&gt;
&lt;br /&gt;
=== Statistics Component ===&lt;br /&gt;
&lt;br /&gt;
* Confirm it correctly fetches teammate evaluations and author feedback  &lt;br /&gt;
* Ensure charts or tables reflect the received backend data accurately  &lt;br /&gt;
* Test switching between different teams or assignments and verify correct display  &lt;br /&gt;
&lt;br /&gt;
=== General UI Considerations ===&lt;br /&gt;
&lt;br /&gt;
* Test frontend responsiveness to backend failures (500, 404, timeout)  &lt;br /&gt;
* Ensure authorization errors are handled and appropriate messages displayed  &lt;br /&gt;
&lt;br /&gt;
== 2. Backend API Tests ==&lt;br /&gt;
&lt;br /&gt;
While unit tests exist, integration-level tests will be added or updated to ensure UI compatibility.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
* Validate all &amp;lt;code&amp;gt;GET&amp;lt;/code&amp;gt; endpoints return properly structured JSON objects  &lt;br /&gt;
* Simulate various user roles (student, TA, instructor) and ensure access control  &lt;br /&gt;
* Include test cases for:&lt;br /&gt;
** No grades present  &lt;br /&gt;
** Partial data (e.g. missing feedback or evaluations)  &lt;br /&gt;
** Large number of records  &lt;br /&gt;
&lt;br /&gt;
=== Security &amp;amp; Permissions ===&lt;br /&gt;
&lt;br /&gt;
* Ensure students can only fetch their grades and feedback  &lt;br /&gt;
* Ensure TAs and instructors can access full assignment data  &lt;br /&gt;
* Test token/session-based access restrictions (if applicable)  &lt;br /&gt;
&lt;br /&gt;
== 3. Database Preparation ==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, seed data will simulate real-world usage and we will ensure that:&lt;br /&gt;
* Tests will use isolated fixtures or factories to ensure data consistency&lt;br /&gt;
* All database states will be reset before each test suite run&lt;br /&gt;
&lt;br /&gt;
=== Tables and Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;assignments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_participant&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;participants&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;questionnaires&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;questions&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_questionnaire&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;signed_up_teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;teams_users&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;late_policies&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
=== Scenarios ===&lt;br /&gt;
&lt;br /&gt;
* Single student assigned  &lt;br /&gt;
* Team assignments with/without feedback  &lt;br /&gt;
* Late submissions triggering late policies  &lt;br /&gt;
* Multiple review rounds per assignment&lt;br /&gt;
&lt;br /&gt;
== 4. Regression &amp;amp; CI Testing ==&lt;br /&gt;
&lt;br /&gt;
To ensure updates do not break existing functionality:&lt;br /&gt;
&lt;br /&gt;
* Re-run all existing unit tests  &lt;br /&gt;
* Include snapshot tests for frontend components  &lt;br /&gt;
* Use CI pipelines to automatically trigger tests on pull requests  &lt;br /&gt;
&lt;br /&gt;
== Test Plan Summary ==&lt;br /&gt;
&lt;br /&gt;
This test plan outlines the approach for integrating &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the frontend. By combining backend tests, UI integration checks, and realistic database scenarios, we aim to deliver a seamless user experience. The plan emphasizes early detection of issues and supports long-term maintainability through regression testing. As development progresses, the plan will be updated to cover new insights and edge cases.&lt;br /&gt;
&lt;br /&gt;
==Implementation Details==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164205</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164205"/>
		<updated>2025-04-20T17:35:20Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* API */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of this project is to integrate the frontend of the grades view page with the reimplemented '''''grades_controller.rb (E2510)''''' backend in Expertiza, ensuring a seamless connection between both layers. This integration involves refining the interaction between the UI and backend while adhering to best design principles such as modularity, maintainability, and scalability. The grades_controller.rb is responsible for managing grading functionality, allowing instructors to view and modify assignment grades while enabling students to access their evaluations. By following SOLID and DRY principles, this reimplementation enhances code clarity, reduces redundancy, and improves overall system efficiency.&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
The &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; is responsible for managing and delivering grading data to users in the Expertiza system. It enables instructors to view, calculate, and release grades to students, while also allowing students to view feedback and scores for assignments. The controller plays an important role in coordinating backend logic for reviews and grade visibility.&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
The previous implementation successfully created a functional frontend UI page in Expertiza, addressing design inconsistencies and improving usability. It introduced a visually cohesive interface with an intuitive layout, enhanced responsiveness, and improved information display, allowing users to navigate grading data more efficiently. However, the interface was populated using dummy data, limiting its practical use. This reimplemented UI will utilize real data from the database (that has been populated in this round), ensuring that grading information is dynamically retrieved and displayed accurately through JSON objects. Additionally, this phase will connect the redesigned frontend with some new components in the grades_controller.rb. Specifically, the GET functions in the grades_controller were reimplemented to return JSON objects (instead of instance variables) that could be accessed via an API call. Thus, this new implementation ensures seamless communication between the UI and backend while adhering to best design practices for maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
This project focuses on integrating the frontend of the grades view page with the reimplemented '''grades_controller.rb (E2510)''' backend in Expertiza. This integration requires modifications to both the frontend and backend to establish a seamless connection, ensuring that grading data is dynamically retrieved and displayed accurately. By adhering to best design principles such as modularity, maintainability, and scalability, the implementation will enhance system efficiency and long-term usability. Key improvements include replacing dummy data with real database values, refining data flow between the UI and backend, and optimizing API interactions for better performance. These enhancements will create a more intuitive and reliable grading system, providing a seamless experience for instructors and students while maintaining a well-structured and adaptable codebase for future development.&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
# '''Establish a Robust Connection Between the Frontend and Backend''': Ensure smooth data retrieval and updates between the grades view page and the backend by integrating dynamic data through API calls, replacing the current hardcoded dummy data.&lt;br /&gt;
# '''Define and Implement Clear API Endpoints''': Create well-structured API endpoints in grades_controller.rb for retrieving and displaying grades, ensuring they return appropriate data based on user roles (students, instructors, TAs) and maintain role-based access controls.&lt;br /&gt;
# '''Dynamic Data Integration''': Modify the frontend to consume real-time data fetched from the backend, ensuring an intuitive and responsive UI that reflects the actual grading information. &lt;br /&gt;
# '''Refactor Frontend and Backend Components''': Refactor both the frontend and backend as necessary to align with SOLID and DRY principles, ensuring modularity, maintainability, and scalability. This includes eliminating redundant logic and optimizing code for better readability.&lt;br /&gt;
# '''Implement Proper Permission Checks''': Ensure that only authorized users can access grade information by implementing robust privilege checks and ensuring that the data is securely accessible to students, instructors, and TAs based on their roles.&lt;br /&gt;
# '''Optimize Database Queries and API Responses''': Enhance the efficiency of database queries and API responses to reduce unnecessary load and ensure that data is retrieved and displayed promptly.&lt;br /&gt;
# '''Testing and Validation''': Implement comprehensive unit and integration tests to verify the correctness of data flow, UI interactions, and role-based access controls, ensuring that the system functions correctly and securely.&lt;br /&gt;
&lt;br /&gt;
==Implementation Plan==&lt;br /&gt;
 &lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populated data with the appropriate HTTP GET and HTTP POST calls. This shift is necessary to ensure that our application reflects real-time data from the backend rather than relying on static or hardcoded values, which can quickly become outdated or inconsistent. It also enables better scalability and maintainability, as changes to the data only need to be made in the backend, without requiring manual updates in the frontend code.&lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
'''Author Feedback''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
'''Heatmap Data''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
'''Team-mate Data''':&lt;br /&gt;
   {&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The current implementation caters to the backend for a Ruby-embedded front-end, where data is rendered server-side and passed directly into the view. We need to update the APIs to return data in a format that can be consumed by the React UI, typically JSON. This shift is essential to decouple the front-end from the server-side rendering logic, allowing for a more interactive and dynamic user experience. By transitioning to a React-based interface, we gain better control over UI state and responsiveness, while also aligning with modern web development practices. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and instead return plain JSON objects using render json: in the response. This change is necessary to align with a frontend architecture that uses React or another JavaScript framework, which expects structured data from the backend in JSON format rather than relying on server-rendered templates. By shifting to JSON responses, we enable cleaner API endpoints, facilitate easier testing and debugging, and support a more maintainable, decoupled frontend-backend integration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    # prepare feedback summaries&lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def edit_participant_scores &lt;br /&gt;
    @participant = find_participant(params[:id])&lt;br /&gt;
    return unless @participant # Exit early if participant not found&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @questions = list_questions(@assignment)&lt;br /&gt;
    @scores = Response.review_grades(@participant, @questions)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
  1.1. Students&lt;br /&gt;
  1.2. Teams&lt;br /&gt;
  1.3. TA&lt;br /&gt;
  1.4. Professor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
  2.1 assignments&lt;br /&gt;
  2.2 assignment_questionnaire&lt;br /&gt;
  2.3 questionnaires&lt;br /&gt;
  2.4 participant&lt;br /&gt;
  2.5 signed_up_teams&lt;br /&gt;
  2.6 teams_users&lt;br /&gt;
  2.7 due_dates&lt;br /&gt;
  2.8 late_policies&lt;br /&gt;
  2.9 questions&lt;br /&gt;
  2.10 review_scores&lt;br /&gt;
  2.11 review_grades&lt;br /&gt;
&lt;br /&gt;
== Data Flow Overview ==&lt;br /&gt;
The diagram below illustrates how data flows between the frontend React components and the grades_controller.rb backend during a typical grading data fetch operation.&lt;br /&gt;
&lt;br /&gt;
* The user (e.g., instructor or student) interacts with the React-based grades view (e.g., ReviewTable, RoundSelector, or Statistics).&lt;br /&gt;
* The component triggers an API request to a specific action in grades_controller.rb (e.g., GET /grades/:id/summary).&lt;br /&gt;
*The controller action queries the relevant models (e.g., Assignment, Team, ReviewResponseMap) and compiles a JSON response.&lt;br /&gt;
* The response is sent back to the frontend and parsed.&lt;br /&gt;
*The React components update the UI (tables, heatmaps, statistics) based on the received data.&lt;br /&gt;
&lt;br /&gt;
This architecture ensures a clean separation between frontend and backend logic, improving maintainability and testability.&lt;br /&gt;
[[File:Dataflow.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
The test plan for Phase 2 focuses on verifying the successful integration of the newly reimplemented &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the React-based UI components. We aim to ensure data is:&lt;br /&gt;
&lt;br /&gt;
* Correctly fetched from the backend  &lt;br /&gt;
* Appropriately displayed in the frontend  &lt;br /&gt;
* Functionally sound under both normal and edge-case scenarios&lt;br /&gt;
&lt;br /&gt;
== Tools and Frameworks ==&lt;br /&gt;
We plan to use the following tools and frameworks for testing:&lt;br /&gt;
&lt;br /&gt;
* '''Frontend''': Jest and React Testing Library for unit and integration tests&lt;br /&gt;
* '''Backend''': RSpec for controller and model tests&lt;br /&gt;
* '''Integration Testing''': Capybara and Selenium for simulating real user behavior&lt;br /&gt;
* '''Test Coverage''': SimpleCov&lt;br /&gt;
&lt;br /&gt;
== 1. UI Integration Tests ==&lt;br /&gt;
&lt;br /&gt;
These tests ensure the frontend correctly interacts with backend APIs and renders the data appropriately.&lt;br /&gt;
&lt;br /&gt;
=== ReviewTable Component ===&lt;br /&gt;
&lt;br /&gt;
* Validate that the component makes a successful API call to fetch author feedback  &lt;br /&gt;
* Ensure feedback is rendered in the correct table structure  &lt;br /&gt;
* Test loading state before data is fetched  &lt;br /&gt;
* Handle empty or malformed feedback responses gracefully  &lt;br /&gt;
&lt;br /&gt;
=== RoundSelector Component ===&lt;br /&gt;
&lt;br /&gt;
* Verify API call to fetch heatmap data is triggered on component load  &lt;br /&gt;
* Check that heatmap data is correctly visualized for different review rounds  &lt;br /&gt;
* Test behavior with no data, incomplete data, or delayed response  &lt;br /&gt;
&lt;br /&gt;
=== Statistics Component ===&lt;br /&gt;
&lt;br /&gt;
* Confirm it correctly fetches teammate evaluations and author feedback  &lt;br /&gt;
* Ensure charts or tables reflect the received backend data accurately  &lt;br /&gt;
* Test switching between different teams or assignments and verify correct display  &lt;br /&gt;
&lt;br /&gt;
=== General UI Considerations ===&lt;br /&gt;
&lt;br /&gt;
* Test frontend responsiveness to backend failures (500, 404, timeout)  &lt;br /&gt;
* Ensure authorization errors are handled and appropriate messages displayed  &lt;br /&gt;
&lt;br /&gt;
== 2. Backend API Tests ==&lt;br /&gt;
&lt;br /&gt;
While unit tests exist, integration-level tests will be added or updated to ensure UI compatibility.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
* Validate all &amp;lt;code&amp;gt;GET&amp;lt;/code&amp;gt; endpoints return properly structured JSON objects  &lt;br /&gt;
* Simulate various user roles (student, TA, instructor) and ensure access control  &lt;br /&gt;
* Include test cases for:&lt;br /&gt;
** No grades present  &lt;br /&gt;
** Partial data (e.g. missing feedback or evaluations)  &lt;br /&gt;
** Large number of records  &lt;br /&gt;
&lt;br /&gt;
=== Security &amp;amp; Permissions ===&lt;br /&gt;
&lt;br /&gt;
* Ensure students can only fetch their grades and feedback  &lt;br /&gt;
* Ensure TAs and instructors can access full assignment data  &lt;br /&gt;
* Test token/session-based access restrictions (if applicable)  &lt;br /&gt;
&lt;br /&gt;
== 3. Database Preparation ==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, seed data will simulate real-world usage and we will ensure that:&lt;br /&gt;
* Tests will use isolated fixtures or factories to ensure data consistency&lt;br /&gt;
* All database states will be reset before each test suite run&lt;br /&gt;
&lt;br /&gt;
=== Tables and Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;assignments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_participant&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;participants&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;questionnaires&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;questions&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_questionnaire&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;signed_up_teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;teams_users&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;late_policies&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
=== Scenarios ===&lt;br /&gt;
&lt;br /&gt;
* Single student assigned  &lt;br /&gt;
* Team assignments with/without feedback  &lt;br /&gt;
* Late submissions triggering late policies  &lt;br /&gt;
* Multiple review rounds per assignment&lt;br /&gt;
&lt;br /&gt;
== 4. Regression &amp;amp; CI Testing ==&lt;br /&gt;
&lt;br /&gt;
To ensure updates do not break existing functionality:&lt;br /&gt;
&lt;br /&gt;
* Re-run all existing unit tests  &lt;br /&gt;
* Include snapshot tests for frontend components  &lt;br /&gt;
* Use CI pipelines to automatically trigger tests on pull requests  &lt;br /&gt;
&lt;br /&gt;
== Test Plan Summary ==&lt;br /&gt;
&lt;br /&gt;
This test plan outlines the approach for integrating &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the frontend. By combining backend tests, UI integration checks, and realistic database scenarios, we aim to deliver a seamless user experience. The plan emphasizes early detection of issues and supports long-term maintainability through regression testing. As development progresses, the plan will be updated to cover new insights and edge cases.&lt;br /&gt;
&lt;br /&gt;
==Implementation Details==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164204</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164204"/>
		<updated>2025-04-20T17:33:37Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* UI */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of this project is to integrate the frontend of the grades view page with the reimplemented '''''grades_controller.rb (E2510)''''' backend in Expertiza, ensuring a seamless connection between both layers. This integration involves refining the interaction between the UI and backend while adhering to best design principles such as modularity, maintainability, and scalability. The grades_controller.rb is responsible for managing grading functionality, allowing instructors to view and modify assignment grades while enabling students to access their evaluations. By following SOLID and DRY principles, this reimplementation enhances code clarity, reduces redundancy, and improves overall system efficiency.&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
The &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; is responsible for managing and delivering grading data to users in the Expertiza system. It enables instructors to view, calculate, and release grades to students, while also allowing students to view feedback and scores for assignments. The controller plays an important role in coordinating backend logic for reviews and grade visibility.&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
The previous implementation successfully created a functional frontend UI page in Expertiza, addressing design inconsistencies and improving usability. It introduced a visually cohesive interface with an intuitive layout, enhanced responsiveness, and improved information display, allowing users to navigate grading data more efficiently. However, the interface was populated using dummy data, limiting its practical use. This reimplemented UI will utilize real data from the database (that has been populated in this round), ensuring that grading information is dynamically retrieved and displayed accurately through JSON objects. Additionally, this phase will connect the redesigned frontend with some new components in the grades_controller.rb. Specifically, the GET functions in the grades_controller were reimplemented to return JSON objects (instead of instance variables) that could be accessed via an API call. Thus, this new implementation ensures seamless communication between the UI and backend while adhering to best design practices for maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
This project focuses on integrating the frontend of the grades view page with the reimplemented '''grades_controller.rb (E2510)''' backend in Expertiza. This integration requires modifications to both the frontend and backend to establish a seamless connection, ensuring that grading data is dynamically retrieved and displayed accurately. By adhering to best design principles such as modularity, maintainability, and scalability, the implementation will enhance system efficiency and long-term usability. Key improvements include replacing dummy data with real database values, refining data flow between the UI and backend, and optimizing API interactions for better performance. These enhancements will create a more intuitive and reliable grading system, providing a seamless experience for instructors and students while maintaining a well-structured and adaptable codebase for future development.&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
# '''Establish a Robust Connection Between the Frontend and Backend''': Ensure smooth data retrieval and updates between the grades view page and the backend by integrating dynamic data through API calls, replacing the current hardcoded dummy data.&lt;br /&gt;
# '''Define and Implement Clear API Endpoints''': Create well-structured API endpoints in grades_controller.rb for retrieving and displaying grades, ensuring they return appropriate data based on user roles (students, instructors, TAs) and maintain role-based access controls.&lt;br /&gt;
# '''Dynamic Data Integration''': Modify the frontend to consume real-time data fetched from the backend, ensuring an intuitive and responsive UI that reflects the actual grading information. &lt;br /&gt;
# '''Refactor Frontend and Backend Components''': Refactor both the frontend and backend as necessary to align with SOLID and DRY principles, ensuring modularity, maintainability, and scalability. This includes eliminating redundant logic and optimizing code for better readability.&lt;br /&gt;
# '''Implement Proper Permission Checks''': Ensure that only authorized users can access grade information by implementing robust privilege checks and ensuring that the data is securely accessible to students, instructors, and TAs based on their roles.&lt;br /&gt;
# '''Optimize Database Queries and API Responses''': Enhance the efficiency of database queries and API responses to reduce unnecessary load and ensure that data is retrieved and displayed promptly.&lt;br /&gt;
# '''Testing and Validation''': Implement comprehensive unit and integration tests to verify the correctness of data flow, UI interactions, and role-based access controls, ensuring that the system functions correctly and securely.&lt;br /&gt;
&lt;br /&gt;
==Implementation Plan==&lt;br /&gt;
 &lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populated data with the appropriate HTTP GET and HTTP POST calls. This shift is necessary to ensure that our application reflects real-time data from the backend rather than relying on static or hardcoded values, which can quickly become outdated or inconsistent. It also enables better scalability and maintainability, as changes to the data only need to be made in the backend, without requiring manual updates in the frontend code.&lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
'''Author Feedback''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
'''Heatmap Data''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
'''Team-mate Data''':&lt;br /&gt;
   {&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
Current implementation caters to the backend for a ruby embedded front-end. We need to update the APIs to return data that can be consumed by the React UI. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and make it a json object for response from the API so the UI can consume it. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    # prepare feedback summaries&lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def edit_participant_scores &lt;br /&gt;
    @participant = find_participant(params[:id])&lt;br /&gt;
    return unless @participant # Exit early if participant not found&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @questions = list_questions(@assignment)&lt;br /&gt;
    @scores = Response.review_grades(@participant, @questions)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
  1.1. Students&lt;br /&gt;
  1.2. Teams&lt;br /&gt;
  1.3. TA&lt;br /&gt;
  1.4. Professor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
  2.1 assignments&lt;br /&gt;
  2.2 assignment_questionnaire&lt;br /&gt;
  2.3 questionnaires&lt;br /&gt;
  2.4 participant&lt;br /&gt;
  2.5 signed_up_teams&lt;br /&gt;
  2.6 teams_users&lt;br /&gt;
  2.7 due_dates&lt;br /&gt;
  2.8 late_policies&lt;br /&gt;
  2.9 questions&lt;br /&gt;
  2.10 review_scores&lt;br /&gt;
  2.11 review_grades&lt;br /&gt;
&lt;br /&gt;
== Data Flow Overview ==&lt;br /&gt;
The diagram below illustrates how data flows between the frontend React components and the grades_controller.rb backend during a typical grading data fetch operation.&lt;br /&gt;
&lt;br /&gt;
* The user (e.g., instructor or student) interacts with the React-based grades view (e.g., ReviewTable, RoundSelector, or Statistics).&lt;br /&gt;
* The component triggers an API request to a specific action in grades_controller.rb (e.g., GET /grades/:id/summary).&lt;br /&gt;
*The controller action queries the relevant models (e.g., Assignment, Team, ReviewResponseMap) and compiles a JSON response.&lt;br /&gt;
* The response is sent back to the frontend and parsed.&lt;br /&gt;
*The React components update the UI (tables, heatmaps, statistics) based on the received data.&lt;br /&gt;
&lt;br /&gt;
This architecture ensures a clean separation between frontend and backend logic, improving maintainability and testability.&lt;br /&gt;
[[File:Dataflow.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
The test plan for Phase 2 focuses on verifying the successful integration of the newly reimplemented &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the React-based UI components. We aim to ensure data is:&lt;br /&gt;
&lt;br /&gt;
* Correctly fetched from the backend  &lt;br /&gt;
* Appropriately displayed in the frontend  &lt;br /&gt;
* Functionally sound under both normal and edge-case scenarios&lt;br /&gt;
&lt;br /&gt;
== Tools and Frameworks ==&lt;br /&gt;
We plan to use the following tools and frameworks for testing:&lt;br /&gt;
&lt;br /&gt;
* '''Frontend''': Jest and React Testing Library for unit and integration tests&lt;br /&gt;
* '''Backend''': RSpec for controller and model tests&lt;br /&gt;
* '''Integration Testing''': Capybara and Selenium for simulating real user behavior&lt;br /&gt;
* '''Test Coverage''': SimpleCov&lt;br /&gt;
&lt;br /&gt;
== 1. UI Integration Tests ==&lt;br /&gt;
&lt;br /&gt;
These tests ensure the frontend correctly interacts with backend APIs and renders the data appropriately.&lt;br /&gt;
&lt;br /&gt;
=== ReviewTable Component ===&lt;br /&gt;
&lt;br /&gt;
* Validate that the component makes a successful API call to fetch author feedback  &lt;br /&gt;
* Ensure feedback is rendered in the correct table structure  &lt;br /&gt;
* Test loading state before data is fetched  &lt;br /&gt;
* Handle empty or malformed feedback responses gracefully  &lt;br /&gt;
&lt;br /&gt;
=== RoundSelector Component ===&lt;br /&gt;
&lt;br /&gt;
* Verify API call to fetch heatmap data is triggered on component load  &lt;br /&gt;
* Check that heatmap data is correctly visualized for different review rounds  &lt;br /&gt;
* Test behavior with no data, incomplete data, or delayed response  &lt;br /&gt;
&lt;br /&gt;
=== Statistics Component ===&lt;br /&gt;
&lt;br /&gt;
* Confirm it correctly fetches teammate evaluations and author feedback  &lt;br /&gt;
* Ensure charts or tables reflect the received backend data accurately  &lt;br /&gt;
* Test switching between different teams or assignments and verify correct display  &lt;br /&gt;
&lt;br /&gt;
=== General UI Considerations ===&lt;br /&gt;
&lt;br /&gt;
* Test frontend responsiveness to backend failures (500, 404, timeout)  &lt;br /&gt;
* Ensure authorization errors are handled and appropriate messages displayed  &lt;br /&gt;
&lt;br /&gt;
== 2. Backend API Tests ==&lt;br /&gt;
&lt;br /&gt;
While unit tests exist, integration-level tests will be added or updated to ensure UI compatibility.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
* Validate all &amp;lt;code&amp;gt;GET&amp;lt;/code&amp;gt; endpoints return properly structured JSON objects  &lt;br /&gt;
* Simulate various user roles (student, TA, instructor) and ensure access control  &lt;br /&gt;
* Include test cases for:&lt;br /&gt;
** No grades present  &lt;br /&gt;
** Partial data (e.g. missing feedback or evaluations)  &lt;br /&gt;
** Large number of records  &lt;br /&gt;
&lt;br /&gt;
=== Security &amp;amp; Permissions ===&lt;br /&gt;
&lt;br /&gt;
* Ensure students can only fetch their grades and feedback  &lt;br /&gt;
* Ensure TAs and instructors can access full assignment data  &lt;br /&gt;
* Test token/session-based access restrictions (if applicable)  &lt;br /&gt;
&lt;br /&gt;
== 3. Database Preparation ==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, seed data will simulate real-world usage and we will ensure that:&lt;br /&gt;
* Tests will use isolated fixtures or factories to ensure data consistency&lt;br /&gt;
* All database states will be reset before each test suite run&lt;br /&gt;
&lt;br /&gt;
=== Tables and Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;assignments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_participant&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;participants&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;questionnaires&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;questions&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_questionnaire&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;signed_up_teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;teams_users&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;late_policies&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
=== Scenarios ===&lt;br /&gt;
&lt;br /&gt;
* Single student assigned  &lt;br /&gt;
* Team assignments with/without feedback  &lt;br /&gt;
* Late submissions triggering late policies  &lt;br /&gt;
* Multiple review rounds per assignment&lt;br /&gt;
&lt;br /&gt;
== 4. Regression &amp;amp; CI Testing ==&lt;br /&gt;
&lt;br /&gt;
To ensure updates do not break existing functionality:&lt;br /&gt;
&lt;br /&gt;
* Re-run all existing unit tests  &lt;br /&gt;
* Include snapshot tests for frontend components  &lt;br /&gt;
* Use CI pipelines to automatically trigger tests on pull requests  &lt;br /&gt;
&lt;br /&gt;
== Test Plan Summary ==&lt;br /&gt;
&lt;br /&gt;
This test plan outlines the approach for integrating &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the frontend. By combining backend tests, UI integration checks, and realistic database scenarios, we aim to deliver a seamless user experience. The plan emphasizes early detection of issues and supports long-term maintainability through regression testing. As development progresses, the plan will be updated to cover new insights and edge cases.&lt;br /&gt;
&lt;br /&gt;
==Implementation Details==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164203</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=164203"/>
		<updated>2025-04-20T17:26:34Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* Previous Implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of this project is to integrate the frontend of the grades view page with the reimplemented '''''grades_controller.rb (E2510)''''' backend in Expertiza, ensuring a seamless connection between both layers. This integration involves refining the interaction between the UI and backend while adhering to best design principles such as modularity, maintainability, and scalability. The grades_controller.rb is responsible for managing grading functionality, allowing instructors to view and modify assignment grades while enabling students to access their evaluations. By following SOLID and DRY principles, this reimplementation enhances code clarity, reduces redundancy, and improves overall system efficiency.&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
The &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; is responsible for managing and delivering grading data to users in the Expertiza system. It enables instructors to view, calculate, and release grades to students, while also allowing students to view feedback and scores for assignments. The controller plays an important role in coordinating backend logic for reviews and grade visibility.&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
The previous implementation successfully created a functional frontend UI page in Expertiza, addressing design inconsistencies and improving usability. It introduced a visually cohesive interface with an intuitive layout, enhanced responsiveness, and improved information display, allowing users to navigate grading data more efficiently. However, the interface was populated using dummy data, limiting its practical use. This reimplemented UI will utilize real data from the database (that has been populated in this round), ensuring that grading information is dynamically retrieved and displayed accurately through JSON objects. Additionally, this phase will connect the redesigned frontend with some new components in the grades_controller.rb. Specifically, the GET functions in the grades_controller were reimplemented to return JSON objects (instead of instance variables) that could be accessed via an API call. Thus, this new implementation ensures seamless communication between the UI and backend while adhering to best design practices for maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
This project focuses on integrating the frontend of the grades view page with the reimplemented '''grades_controller.rb (E2510)''' backend in Expertiza. This integration requires modifications to both the frontend and backend to establish a seamless connection, ensuring that grading data is dynamically retrieved and displayed accurately. By adhering to best design principles such as modularity, maintainability, and scalability, the implementation will enhance system efficiency and long-term usability. Key improvements include replacing dummy data with real database values, refining data flow between the UI and backend, and optimizing API interactions for better performance. These enhancements will create a more intuitive and reliable grading system, providing a seamless experience for instructors and students while maintaining a well-structured and adaptable codebase for future development.&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
# '''Establish a Robust Connection Between the Frontend and Backend''': Ensure smooth data retrieval and updates between the grades view page and the backend by integrating dynamic data through API calls, replacing the current hardcoded dummy data.&lt;br /&gt;
# '''Define and Implement Clear API Endpoints''': Create well-structured API endpoints in grades_controller.rb for retrieving and displaying grades, ensuring they return appropriate data based on user roles (students, instructors, TAs) and maintain role-based access controls.&lt;br /&gt;
# '''Dynamic Data Integration''': Modify the frontend to consume real-time data fetched from the backend, ensuring an intuitive and responsive UI that reflects the actual grading information. &lt;br /&gt;
# '''Refactor Frontend and Backend Components''': Refactor both the frontend and backend as necessary to align with SOLID and DRY principles, ensuring modularity, maintainability, and scalability. This includes eliminating redundant logic and optimizing code for better readability.&lt;br /&gt;
# '''Implement Proper Permission Checks''': Ensure that only authorized users can access grade information by implementing robust privilege checks and ensuring that the data is securely accessible to students, instructors, and TAs based on their roles.&lt;br /&gt;
# '''Optimize Database Queries and API Responses''': Enhance the efficiency of database queries and API responses to reduce unnecessary load and ensure that data is retrieved and displayed promptly.&lt;br /&gt;
# '''Testing and Validation''': Implement comprehensive unit and integration tests to verify the correctness of data flow, UI interactions, and role-based access controls, ensuring that the system functions correctly and securely.&lt;br /&gt;
&lt;br /&gt;
==Implementation Plan==&lt;br /&gt;
 &lt;br /&gt;
==UI==&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populate data with the appropriate HTTP GET and HTTP POST calls. &lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
   '''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
   '''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
   '''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
'''Author Feedback''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
    }&lt;br /&gt;
'''Heatmap Data''':&lt;br /&gt;
   {&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
'''Team-mate Data''':&lt;br /&gt;
   {&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
Current implementation caters to the backend for a ruby embedded front-end. We need to update the APIs to return data that can be consumed by the React UI. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and make it a json object for response from the API so the UI can consume it. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    # prepare feedback summaries&lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def edit_participant_scores &lt;br /&gt;
    @participant = find_participant(params[:id])&lt;br /&gt;
    return unless @participant # Exit early if participant not found&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @questions = list_questions(@assignment)&lt;br /&gt;
    @scores = Response.review_grades(@participant, @questions)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
  1.1. Students&lt;br /&gt;
  1.2. Teams&lt;br /&gt;
  1.3. TA&lt;br /&gt;
  1.4. Professor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
  2.1 assignments&lt;br /&gt;
  2.2 assignment_questionnaire&lt;br /&gt;
  2.3 questionnaires&lt;br /&gt;
  2.4 participant&lt;br /&gt;
  2.5 signed_up_teams&lt;br /&gt;
  2.6 teams_users&lt;br /&gt;
  2.7 due_dates&lt;br /&gt;
  2.8 late_policies&lt;br /&gt;
  2.9 questions&lt;br /&gt;
  2.10 review_scores&lt;br /&gt;
  2.11 review_grades&lt;br /&gt;
&lt;br /&gt;
== Data Flow Overview ==&lt;br /&gt;
The diagram below illustrates how data flows between the frontend React components and the grades_controller.rb backend during a typical grading data fetch operation.&lt;br /&gt;
&lt;br /&gt;
* The user (e.g., instructor or student) interacts with the React-based grades view (e.g., ReviewTable, RoundSelector, or Statistics).&lt;br /&gt;
* The component triggers an API request to a specific action in grades_controller.rb (e.g., GET /grades/:id/summary).&lt;br /&gt;
*The controller action queries the relevant models (e.g., Assignment, Team, ReviewResponseMap) and compiles a JSON response.&lt;br /&gt;
* The response is sent back to the frontend and parsed.&lt;br /&gt;
*The React components update the UI (tables, heatmaps, statistics) based on the received data.&lt;br /&gt;
&lt;br /&gt;
This architecture ensures a clean separation between frontend and backend logic, improving maintainability and testability.&lt;br /&gt;
[[File:Dataflow.png|center|600px]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
The test plan for Phase 2 focuses on verifying the successful integration of the newly reimplemented &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the React-based UI components. We aim to ensure data is:&lt;br /&gt;
&lt;br /&gt;
* Correctly fetched from the backend  &lt;br /&gt;
* Appropriately displayed in the frontend  &lt;br /&gt;
* Functionally sound under both normal and edge-case scenarios&lt;br /&gt;
&lt;br /&gt;
== Tools and Frameworks ==&lt;br /&gt;
We plan to use the following tools and frameworks for testing:&lt;br /&gt;
&lt;br /&gt;
* '''Frontend''': Jest and React Testing Library for unit and integration tests&lt;br /&gt;
* '''Backend''': RSpec for controller and model tests&lt;br /&gt;
* '''Integration Testing''': Capybara and Selenium for simulating real user behavior&lt;br /&gt;
* '''Test Coverage''': SimpleCov&lt;br /&gt;
&lt;br /&gt;
== 1. UI Integration Tests ==&lt;br /&gt;
&lt;br /&gt;
These tests ensure the frontend correctly interacts with backend APIs and renders the data appropriately.&lt;br /&gt;
&lt;br /&gt;
=== ReviewTable Component ===&lt;br /&gt;
&lt;br /&gt;
* Validate that the component makes a successful API call to fetch author feedback  &lt;br /&gt;
* Ensure feedback is rendered in the correct table structure  &lt;br /&gt;
* Test loading state before data is fetched  &lt;br /&gt;
* Handle empty or malformed feedback responses gracefully  &lt;br /&gt;
&lt;br /&gt;
=== RoundSelector Component ===&lt;br /&gt;
&lt;br /&gt;
* Verify API call to fetch heatmap data is triggered on component load  &lt;br /&gt;
* Check that heatmap data is correctly visualized for different review rounds  &lt;br /&gt;
* Test behavior with no data, incomplete data, or delayed response  &lt;br /&gt;
&lt;br /&gt;
=== Statistics Component ===&lt;br /&gt;
&lt;br /&gt;
* Confirm it correctly fetches teammate evaluations and author feedback  &lt;br /&gt;
* Ensure charts or tables reflect the received backend data accurately  &lt;br /&gt;
* Test switching between different teams or assignments and verify correct display  &lt;br /&gt;
&lt;br /&gt;
=== General UI Considerations ===&lt;br /&gt;
&lt;br /&gt;
* Test frontend responsiveness to backend failures (500, 404, timeout)  &lt;br /&gt;
* Ensure authorization errors are handled and appropriate messages displayed  &lt;br /&gt;
&lt;br /&gt;
== 2. Backend API Tests ==&lt;br /&gt;
&lt;br /&gt;
While unit tests exist, integration-level tests will be added or updated to ensure UI compatibility.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
* Validate all &amp;lt;code&amp;gt;GET&amp;lt;/code&amp;gt; endpoints return properly structured JSON objects  &lt;br /&gt;
* Simulate various user roles (student, TA, instructor) and ensure access control  &lt;br /&gt;
* Include test cases for:&lt;br /&gt;
** No grades present  &lt;br /&gt;
** Partial data (e.g. missing feedback or evaluations)  &lt;br /&gt;
** Large number of records  &lt;br /&gt;
&lt;br /&gt;
=== Security &amp;amp; Permissions ===&lt;br /&gt;
&lt;br /&gt;
* Ensure students can only fetch their grades and feedback  &lt;br /&gt;
* Ensure TAs and instructors can access full assignment data  &lt;br /&gt;
* Test token/session-based access restrictions (if applicable)  &lt;br /&gt;
&lt;br /&gt;
== 3. Database Preparation ==&lt;br /&gt;
&lt;br /&gt;
To enable consistent and repeatable testing, seed data will simulate real-world usage and we will ensure that:&lt;br /&gt;
* Tests will use isolated fixtures or factories to ensure data consistency&lt;br /&gt;
* All database states will be reset before each test suite run&lt;br /&gt;
&lt;br /&gt;
=== Tables and Test Coverage ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;assignments&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_participant&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;participants&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;questionnaires&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;questions&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_questionnaire&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;signed_up_teams&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;teams_users&amp;lt;/code&amp;gt;  &lt;br /&gt;
* &amp;lt;code&amp;gt;due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;assignment_due_dates&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;late_policies&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
=== Scenarios ===&lt;br /&gt;
&lt;br /&gt;
* Single student assigned  &lt;br /&gt;
* Team assignments with/without feedback  &lt;br /&gt;
* Late submissions triggering late policies  &lt;br /&gt;
* Multiple review rounds per assignment&lt;br /&gt;
&lt;br /&gt;
== 4. Regression &amp;amp; CI Testing ==&lt;br /&gt;
&lt;br /&gt;
To ensure updates do not break existing functionality:&lt;br /&gt;
&lt;br /&gt;
* Re-run all existing unit tests  &lt;br /&gt;
* Include snapshot tests for frontend components  &lt;br /&gt;
* Use CI pipelines to automatically trigger tests on pull requests  &lt;br /&gt;
&lt;br /&gt;
== Test Plan Summary ==&lt;br /&gt;
&lt;br /&gt;
This test plan outlines the approach for integrating &amp;lt;code&amp;gt;grades_controller.rb&amp;lt;/code&amp;gt; with the frontend. By combining backend tests, UI integration checks, and realistic database scenarios, we aim to deliver a seamless user experience. The plan emphasizes early detection of issues and supports long-term maintainability through regression testing. As development progresses, the plan will be updated to cover new insights and edge cases.&lt;br /&gt;
&lt;br /&gt;
==Implementation Details==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=163047</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=163047"/>
		<updated>2025-04-03T13:09:28Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* Specific Objectives */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of this project is to integrate the frontend of the grades view page with the reimplemented '''''grades_controller.rb (E2510)''''' backend in Expertiza, ensuring a seamless connection between both layers. This integration involves refining the interaction between the UI and backend while adhering to best design principles such as modularity, maintainability, and scalability. The grades_controller.rb is responsible for managing grading functionality, allowing instructors to view and modify assignment grades while enabling students to access their evaluations. By following SOLID and DRY principles, this reimplementation enhances code clarity, reduces redundancy, and improves overall system efficiency.&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
The previous implementation successfully created a functional frontend UI page in Expertiza, addressing design inconsistencies and improving usability. It introduced a visually cohesive interface with an intuitive layout, enhanced responsiveness, and improved information display, allowing users to navigate grading data more efficiently. However, the interface was populated using dummy data, limiting its practical use. The new implementation will focus on integrating real data from the database, ensuring that grading information is dynamically retrieved and displayed accurately. Additionally, this phase will connect the redesigned frontend with the newly reimplemented grades_controller.rb, enabling seamless communication between the UI and backend while adhering to best design practices for maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
This project focuses on integrating the frontend of the grades view page with the reimplemented '''grades_controller.rb (E2510)''' backend in Expertiza. This integration requires modifications to both the frontend and backend to establish a seamless connection, ensuring that grading data is dynamically retrieved and displayed accurately. By adhering to best design principles such as modularity, maintainability, and scalability, the implementation will enhance system efficiency and long-term usability. Key improvements include replacing dummy data with real database values, refining data flow between the UI and backend, and optimizing API interactions for better performance. These enhancements will create a more intuitive and reliable grading system, providing a seamless experience for instructors and students while maintaining a well-structured and adaptable codebase for future development.&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
# Establish a Robust Connection Between the Frontend and Backend: Ensure smooth data retrieval and updates between the grades view page and the backend by integrating dynamic data through API calls, replacing the current hardcoded dummy data.&lt;br /&gt;
# Define and Implement Clear API Endpoints: Create well-structured API endpoints in grades_controller.rb for retrieving and displaying grades, ensuring they return appropriate data based on user roles (students, instructors, TAs) and maintain role-based access controls.&lt;br /&gt;
# Dynamic Data Integration: Modify the frontend to consume real-time data fetched from the backend, ensuring an intuitive and responsive UI that reflects the actual grading information. &lt;br /&gt;
# Refactor Frontend and Backend Components: Refactor both the frontend and backend as necessary to align with SOLID and DRY principles, ensuring modularity, maintainability, and scalability. This includes eliminating redundant logic and optimizing code for better readability.&lt;br /&gt;
# Implement Proper Permission Checks: Ensure that only authorized users can access grade information by implementing robust privilege checks and ensuring that the data is securely accessible to students, instructors, and TAs based on their roles.&lt;br /&gt;
# Optimize Database Queries and API Responses: Enhance the efficiency of database queries and API responses to reduce unnecessary load and ensure that data is retrieved and displayed promptly.&lt;br /&gt;
# Testing and Validation: Implement comprehensive unit and integration tests to verify the correctness of data flow, UI interactions, and role-based access controls, ensuring that the system functions correctly and securely.&lt;br /&gt;
&lt;br /&gt;
==Implementation Plan==&lt;br /&gt;
 &lt;br /&gt;
===UI===&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populate data with the appropriate HTTP GET and HTTP POST calls. &lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
'''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
'''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
'''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
Author Feedback:&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Heatmap Data:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Team-mate Data:&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
===API===&lt;br /&gt;
&lt;br /&gt;
Current implementation caters to the backend for a ruby embedded front-end. We need to update the APIs to return data that can be consumed by the React UI. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''Grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and make it a json object for response from the API so the UI can consume it. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    # prepare feedback summaries&lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def edit_participant_scores &lt;br /&gt;
    @participant = find_participant(params[:id])&lt;br /&gt;
    return unless @participant # Exit early if participant not found&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @questions = list_questions(@assignment)&lt;br /&gt;
    @scores = Response.review_grades(@participant, @questions)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Database===&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
1.1. Students&lt;br /&gt;
&lt;br /&gt;
1.2. Teams&lt;br /&gt;
&lt;br /&gt;
1.3. TA&lt;br /&gt;
&lt;br /&gt;
1.4. Professor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
2.1 assignments&lt;br /&gt;
&lt;br /&gt;
2.2 assignment_questionnaire&lt;br /&gt;
&lt;br /&gt;
2.3 questionnaires&lt;br /&gt;
&lt;br /&gt;
2.4 questions&lt;br /&gt;
&lt;br /&gt;
2.5 assignment_participant&lt;br /&gt;
&lt;br /&gt;
2.6 participant&lt;br /&gt;
&lt;br /&gt;
2.7 signed_up_teams&lt;br /&gt;
&lt;br /&gt;
2.8 teams_users&lt;br /&gt;
&lt;br /&gt;
2.9 questions&lt;br /&gt;
&lt;br /&gt;
2.10 due_dates&lt;br /&gt;
&lt;br /&gt;
2.11 assignment_due_dates&lt;br /&gt;
&lt;br /&gt;
2.12 late_policies&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Implementation Details==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
=Team=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=163046</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=163046"/>
		<updated>2025-04-03T13:07:47Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* Specific Objectives */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of this project is to integrate the frontend of the grades view page with the reimplemented '''''grades_controller.rb (E2510)''''' backend in Expertiza, ensuring a seamless connection between both layers. This integration involves refining the interaction between the UI and backend while adhering to best design principles such as modularity, maintainability, and scalability. The grades_controller.rb is responsible for managing grading functionality, allowing instructors to view and modify assignment grades while enabling students to access their evaluations. By following SOLID and DRY principles, this reimplementation enhances code clarity, reduces redundancy, and improves overall system efficiency.&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
The previous implementation successfully created a functional frontend UI page in Expertiza, addressing design inconsistencies and improving usability. It introduced a visually cohesive interface with an intuitive layout, enhanced responsiveness, and improved information display, allowing users to navigate grading data more efficiently. However, the interface was populated using dummy data, limiting its practical use. The new implementation will focus on integrating real data from the database, ensuring that grading information is dynamically retrieved and displayed accurately. Additionally, this phase will connect the redesigned frontend with the newly reimplemented grades_controller.rb, enabling seamless communication between the UI and backend while adhering to best design practices for maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
This project focuses on integrating the frontend of the grades view page with the reimplemented '''grades_controller.rb (E2510)''' backend in Expertiza. This integration requires modifications to both the frontend and backend to establish a seamless connection, ensuring that grading data is dynamically retrieved and displayed accurately. By adhering to best design principles such as modularity, maintainability, and scalability, the implementation will enhance system efficiency and long-term usability. Key improvements include replacing dummy data with real database values, refining data flow between the UI and backend, and optimizing API interactions for better performance. These enhancements will create a more intuitive and reliable grading system, providing a seamless experience for instructors and students while maintaining a well-structured and adaptable codebase for future development.&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
# Establish a Robust Connection Between the Frontend and Backend: Ensure smooth data retrieval and updates between the grades view page and the backend by integrating dynamic data through API calls, replacing the current hardcoded dummy data.&lt;br /&gt;
# Define and Implement Clear API Endpoints: Create well-structured API endpoints in grades_controller.rb for retrieving and displaying grades, ensuring they return appropriate data based on user roles (students, instructors, TAs) and maintain role-based access controls.&lt;br /&gt;
# Dynamic Data Integration: Modify the frontend to consume real-time data fetched from the backend, ensuring an intuitive and responsive UI that reflects the actual grading information.# &lt;br /&gt;
# Refactor Frontend and Backend Components: Refactor both the frontend and backend as necessary to align with SOLID and DRY principles, ensuring modularity, maintainability, and scalability. This includes eliminating redundant logic and optimizing code for better readability.&lt;br /&gt;
# Implement Proper Permission Checks: Ensure that only authorized users can access grade information by implementing robust privilege checks and ensuring that the data is securely accessible to students, instructors, and TAs based on their roles.&lt;br /&gt;
# Optimize Database Queries and API Responses: Enhance the efficiency of database queries and API responses to reduce unnecessary load and ensure that data is retrieved and displayed promptly.&lt;br /&gt;
# Testing and Validation: Implement comprehensive unit and integration tests to verify the correctness of data flow, UI interactions, and role-based access controls, ensuring that the system functions correctly and securely.&lt;br /&gt;
&lt;br /&gt;
==Implementation Plan==&lt;br /&gt;
 &lt;br /&gt;
===UI===&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populate data with the appropriate HTTP GET and HTTP POST calls. &lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
'''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
'''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
'''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
Author Feedback:&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Heatmap Data:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Team-mate Data:&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
===API===&lt;br /&gt;
&lt;br /&gt;
Current implementation caters to the backend for a ruby embedded front-end. We need to update the APIs to return data that can be consumed by the React UI. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''Grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and make it a json object for response from the API so the UI can consume it. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    # prepare feedback summaries&lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def edit_participant_scores &lt;br /&gt;
    @participant = find_participant(params[:id])&lt;br /&gt;
    return unless @participant # Exit early if participant not found&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @questions = list_questions(@assignment)&lt;br /&gt;
    @scores = Response.review_grades(@participant, @questions)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Database===&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
1.1. Students&lt;br /&gt;
&lt;br /&gt;
1.2. Teams&lt;br /&gt;
&lt;br /&gt;
1.3. TA&lt;br /&gt;
&lt;br /&gt;
1.4. Professor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
2.1 assignments&lt;br /&gt;
&lt;br /&gt;
2.2 assignment_questionnaire&lt;br /&gt;
&lt;br /&gt;
2.3 questionnaires&lt;br /&gt;
&lt;br /&gt;
2.4 questions&lt;br /&gt;
&lt;br /&gt;
2.5 assignment_participant&lt;br /&gt;
&lt;br /&gt;
2.6 participant&lt;br /&gt;
&lt;br /&gt;
2.7 signed_up_teams&lt;br /&gt;
&lt;br /&gt;
2.8 teams_users&lt;br /&gt;
&lt;br /&gt;
2.9 questions&lt;br /&gt;
&lt;br /&gt;
2.10 due_dates&lt;br /&gt;
&lt;br /&gt;
2.11 assignment_due_dates&lt;br /&gt;
&lt;br /&gt;
2.12 late_policies&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Implementation Details==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
=Team=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=163045</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=163045"/>
		<updated>2025-04-03T13:05:06Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* Project Statement */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of this project is to integrate the frontend of the grades view page with the reimplemented '''''grades_controller.rb (E2510)''''' backend in Expertiza, ensuring a seamless connection between both layers. This integration involves refining the interaction between the UI and backend while adhering to best design principles such as modularity, maintainability, and scalability. The grades_controller.rb is responsible for managing grading functionality, allowing instructors to view and modify assignment grades while enabling students to access their evaluations. By following SOLID and DRY principles, this reimplementation enhances code clarity, reduces redundancy, and improves overall system efficiency.&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
The previous implementation successfully created a functional frontend UI page in Expertiza, addressing design inconsistencies and improving usability. It introduced a visually cohesive interface with an intuitive layout, enhanced responsiveness, and improved information display, allowing users to navigate grading data more efficiently. However, the interface was populated using dummy data, limiting its practical use. The new implementation will focus on integrating real data from the database, ensuring that grading information is dynamically retrieved and displayed accurately. Additionally, this phase will connect the redesigned frontend with the newly reimplemented grades_controller.rb, enabling seamless communication between the UI and backend while adhering to best design practices for maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
This project focuses on integrating the frontend of the grades view page with the reimplemented '''grades_controller.rb (E2510)''' backend in Expertiza. This integration requires modifications to both the frontend and backend to establish a seamless connection, ensuring that grading data is dynamically retrieved and displayed accurately. By adhering to best design principles such as modularity, maintainability, and scalability, the implementation will enhance system efficiency and long-term usability. Key improvements include replacing dummy data with real database values, refining data flow between the UI and backend, and optimizing API interactions for better performance. These enhancements will create a more intuitive and reliable grading system, providing a seamless experience for instructors and students while maintaining a well-structured and adaptable codebase for future development.&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Implementation Plan==&lt;br /&gt;
 &lt;br /&gt;
===UI===&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populate data with the appropriate HTTP GET and HTTP POST calls. &lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
'''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
'''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
'''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
Author Feedback:&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Heatmap Data:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Team-mate Data:&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
===API===&lt;br /&gt;
&lt;br /&gt;
Current implementation caters to the backend for a ruby embedded front-end. We need to update the APIs to return data that can be consumed by the React UI. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''Grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and make it a json object for response from the API so the UI can consume it. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    # prepare feedback summaries&lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def edit_participant_scores &lt;br /&gt;
    @participant = find_participant(params[:id])&lt;br /&gt;
    return unless @participant # Exit early if participant not found&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @questions = list_questions(@assignment)&lt;br /&gt;
    @scores = Response.review_grades(@participant, @questions)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Database===&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
1.1. Students&lt;br /&gt;
&lt;br /&gt;
1.2. Teams&lt;br /&gt;
&lt;br /&gt;
1.3. TA&lt;br /&gt;
&lt;br /&gt;
1.4. Professor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
2.1 assignments&lt;br /&gt;
&lt;br /&gt;
2.2 assignment_questionnaire&lt;br /&gt;
&lt;br /&gt;
2.3 questionnaires&lt;br /&gt;
&lt;br /&gt;
2.4 questions&lt;br /&gt;
&lt;br /&gt;
2.5 assignment_participant&lt;br /&gt;
&lt;br /&gt;
2.6 participant&lt;br /&gt;
&lt;br /&gt;
2.7 signed_up_teams&lt;br /&gt;
&lt;br /&gt;
2.8 teams_users&lt;br /&gt;
&lt;br /&gt;
2.9 questions&lt;br /&gt;
&lt;br /&gt;
2.10 due_dates&lt;br /&gt;
&lt;br /&gt;
2.11 assignment_due_dates&lt;br /&gt;
&lt;br /&gt;
2.12 late_policies&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Implementation Details==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
=Team=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=163044</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=163044"/>
		<updated>2025-04-03T13:03:01Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* Previous Implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of this project is to integrate the frontend of the grades view page with the reimplemented '''''grades_controller.rb (E2510)''''' backend in Expertiza, ensuring a seamless connection between both layers. This integration involves refining the interaction between the UI and backend while adhering to best design principles such as modularity, maintainability, and scalability. The grades_controller.rb is responsible for managing grading functionality, allowing instructors to view and modify assignment grades while enabling students to access their evaluations. By following SOLID and DRY principles, this reimplementation enhances code clarity, reduces redundancy, and improves overall system efficiency.&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
The previous implementation successfully created a functional frontend UI page in Expertiza, addressing design inconsistencies and improving usability. It introduced a visually cohesive interface with an intuitive layout, enhanced responsiveness, and improved information display, allowing users to navigate grading data more efficiently. However, the interface was populated using dummy data, limiting its practical use. The new implementation will focus on integrating real data from the database, ensuring that grading information is dynamically retrieved and displayed accurately. Additionally, this phase will connect the redesigned frontend with the newly reimplemented grades_controller.rb, enabling seamless communication between the UI and backend while adhering to best design practices for maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Implementation Plan==&lt;br /&gt;
 &lt;br /&gt;
===UI===&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populate data with the appropriate HTTP GET and HTTP POST calls. &lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
'''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
'''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
'''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
Author Feedback:&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Heatmap Data:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Team-mate Data:&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
===API===&lt;br /&gt;
&lt;br /&gt;
Current implementation caters to the backend for a ruby embedded front-end. We need to update the APIs to return data that can be consumed by the React UI. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''Grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and make it a json object for response from the API so the UI can consume it. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    # prepare feedback summaries&lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def edit_participant_scores &lt;br /&gt;
    @participant = find_participant(params[:id])&lt;br /&gt;
    return unless @participant # Exit early if participant not found&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @questions = list_questions(@assignment)&lt;br /&gt;
    @scores = Response.review_grades(@participant, @questions)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Database===&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
1.1. Students&lt;br /&gt;
&lt;br /&gt;
1.2. Teams&lt;br /&gt;
&lt;br /&gt;
1.3. TA&lt;br /&gt;
&lt;br /&gt;
1.4. Professor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
2.1 assignments&lt;br /&gt;
&lt;br /&gt;
2.2 assignment_questionnaire&lt;br /&gt;
&lt;br /&gt;
2.3 questionnaires&lt;br /&gt;
&lt;br /&gt;
2.4 questions&lt;br /&gt;
&lt;br /&gt;
2.5 assignment_participant&lt;br /&gt;
&lt;br /&gt;
2.6 participant&lt;br /&gt;
&lt;br /&gt;
2.7 signed_up_teams&lt;br /&gt;
&lt;br /&gt;
2.8 teams_users&lt;br /&gt;
&lt;br /&gt;
2.9 questions&lt;br /&gt;
&lt;br /&gt;
2.10 due_dates&lt;br /&gt;
&lt;br /&gt;
2.11 assignment_due_dates&lt;br /&gt;
&lt;br /&gt;
2.12 late_policies&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Implementation Details==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
=Team=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=163043</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=163043"/>
		<updated>2025-04-03T12:57:51Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of this project is to integrate the frontend of the grades view page with the reimplemented '''''grades_controller.rb (E2510)''''' backend in Expertiza, ensuring a seamless connection between both layers. This integration involves refining the interaction between the UI and backend while adhering to best design principles such as modularity, maintainability, and scalability. The grades_controller.rb is responsible for managing grading functionality, allowing instructors to view and modify assignment grades while enabling students to access their evaluations. By following SOLID and DRY principles, this reimplementation enhances code clarity, reduces redundancy, and improves overall system efficiency.&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Implementation Plan==&lt;br /&gt;
 &lt;br /&gt;
===UI===&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populate data with the appropriate HTTP GET and HTTP POST calls. &lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
'''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
'''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
'''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
Author Feedback:&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Heatmap Data:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Team-mate Data:&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
===API===&lt;br /&gt;
&lt;br /&gt;
Current implementation caters to the backend for a ruby embedded front-end. We need to update the APIs to return data that can be consumed by the React UI. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''Grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and make it a json object for response from the API so the UI can consume it. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    # prepare feedback summaries&lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def edit_participant_scores &lt;br /&gt;
    @participant = find_participant(params[:id])&lt;br /&gt;
    return unless @participant # Exit early if participant not found&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @questions = list_questions(@assignment)&lt;br /&gt;
    @scores = Response.review_grades(@participant, @questions)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Database===&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
1.1. Students&lt;br /&gt;
&lt;br /&gt;
1.2. Teams&lt;br /&gt;
&lt;br /&gt;
1.3. TA&lt;br /&gt;
&lt;br /&gt;
1.4. Professor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
2.1 assignments&lt;br /&gt;
&lt;br /&gt;
2.2 assignment_questionnaire&lt;br /&gt;
&lt;br /&gt;
2.3 questionnaires&lt;br /&gt;
&lt;br /&gt;
2.4 questions&lt;br /&gt;
&lt;br /&gt;
2.5 assignment_participant&lt;br /&gt;
&lt;br /&gt;
2.6 participant&lt;br /&gt;
&lt;br /&gt;
2.7 signed_up_teams&lt;br /&gt;
&lt;br /&gt;
2.8 teams_users&lt;br /&gt;
&lt;br /&gt;
2.9 questions&lt;br /&gt;
&lt;br /&gt;
2.10 due_dates&lt;br /&gt;
&lt;br /&gt;
2.11 assignment_due_dates&lt;br /&gt;
&lt;br /&gt;
2.12 late_policies&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Implementation Details==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
=Team=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=163042</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=163042"/>
		<updated>2025-04-03T12:57:33Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of this project is to integrate the frontend of the grades view page with the reimplemented ('''''grades_controller.rb (E2510)''''') backend in Expertiza, ensuring a seamless connection between both layers. This integration involves refining the interaction between the UI and backend while adhering to best design principles such as modularity, maintainability, and scalability. The grades_controller.rb is responsible for managing grading functionality, allowing instructors to view and modify assignment grades while enabling students to access their evaluations. By following SOLID and DRY principles, this reimplementation enhances code clarity, reduces redundancy, and improves overall system efficiency.&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Implementation Plan==&lt;br /&gt;
 &lt;br /&gt;
===UI===&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populate data with the appropriate HTTP GET and HTTP POST calls. &lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
'''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
'''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
'''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
Author Feedback:&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Heatmap Data:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Team-mate Data:&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
===API===&lt;br /&gt;
&lt;br /&gt;
Current implementation caters to the backend for a ruby embedded front-end. We need to update the APIs to return data that can be consumed by the React UI. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''Grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and make it a json object for response from the API so the UI can consume it. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    # prepare feedback summaries&lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def edit_participant_scores &lt;br /&gt;
    @participant = find_participant(params[:id])&lt;br /&gt;
    return unless @participant # Exit early if participant not found&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @questions = list_questions(@assignment)&lt;br /&gt;
    @scores = Response.review_grades(@participant, @questions)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Database===&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
1.1. Students&lt;br /&gt;
&lt;br /&gt;
1.2. Teams&lt;br /&gt;
&lt;br /&gt;
1.3. TA&lt;br /&gt;
&lt;br /&gt;
1.4. Professor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
2.1 assignments&lt;br /&gt;
&lt;br /&gt;
2.2 assignment_questionnaire&lt;br /&gt;
&lt;br /&gt;
2.3 questionnaires&lt;br /&gt;
&lt;br /&gt;
2.4 questions&lt;br /&gt;
&lt;br /&gt;
2.5 assignment_participant&lt;br /&gt;
&lt;br /&gt;
2.6 participant&lt;br /&gt;
&lt;br /&gt;
2.7 signed_up_teams&lt;br /&gt;
&lt;br /&gt;
2.8 teams_users&lt;br /&gt;
&lt;br /&gt;
2.9 questions&lt;br /&gt;
&lt;br /&gt;
2.10 due_dates&lt;br /&gt;
&lt;br /&gt;
2.11 assignment_due_dates&lt;br /&gt;
&lt;br /&gt;
2.12 late_policies&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Implementation Details==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
=Team=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=163041</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=163041"/>
		<updated>2025-04-03T12:55:45Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Integration of Grades View Frontend with Grades Controller Backend=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Implementation Plan==&lt;br /&gt;
 &lt;br /&gt;
===UI===&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populate data with the appropriate HTTP GET and HTTP POST calls. &lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
'''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
'''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
'''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
Author Feedback:&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Heatmap Data:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Team-mate Data:&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
===API===&lt;br /&gt;
&lt;br /&gt;
Current implementation caters to the backend for a ruby embedded front-end. We need to update the APIs to return data that can be consumed by the React UI. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''Grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and make it a json object for response from the API so the UI can consume it. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    # prepare feedback summaries&lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def edit_participant_scores &lt;br /&gt;
    @participant = find_participant(params[:id])&lt;br /&gt;
    return unless @participant # Exit early if participant not found&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @questions = list_questions(@assignment)&lt;br /&gt;
    @scores = Response.review_grades(@participant, @questions)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Database===&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
1.1. Students&lt;br /&gt;
&lt;br /&gt;
1.2. Teams&lt;br /&gt;
&lt;br /&gt;
1.3. TA&lt;br /&gt;
&lt;br /&gt;
1.4. Professor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
2.1 assignments&lt;br /&gt;
&lt;br /&gt;
2.2 assignment_questionnaire&lt;br /&gt;
&lt;br /&gt;
2.3 questionnaires&lt;br /&gt;
&lt;br /&gt;
2.4 questions&lt;br /&gt;
&lt;br /&gt;
2.5 assignment_participant&lt;br /&gt;
&lt;br /&gt;
2.6 participant&lt;br /&gt;
&lt;br /&gt;
2.7 signed_up_teams&lt;br /&gt;
&lt;br /&gt;
2.8 teams_users&lt;br /&gt;
&lt;br /&gt;
2.9 questions&lt;br /&gt;
&lt;br /&gt;
2.10 due_dates&lt;br /&gt;
&lt;br /&gt;
2.11 assignment_due_dates&lt;br /&gt;
&lt;br /&gt;
2.12 late_policies&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Implementation Details==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
=Team=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=163040</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=163040"/>
		<updated>2025-04-03T12:44:11Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* Implementation Details */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Reimplement Grades Controller (Frontend + Backend)=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Implementation Plan==&lt;br /&gt;
 &lt;br /&gt;
===UI===&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populate data with the appropriate HTTP GET and HTTP POST calls. &lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
'''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
'''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
'''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
Author Feedback:&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Heatmap Data:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Team-mate Data:&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
===API===&lt;br /&gt;
&lt;br /&gt;
Current implementation caters to the backend for a ruby embedded front-end. We need to update the APIs to return data that can be consumed by the React UI. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''Grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and make it a json object for response from the API so the UI can consume it. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    # prepare feedback summaries&lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def edit_participant_scores &lt;br /&gt;
    @participant = find_participant(params[:id])&lt;br /&gt;
    return unless @participant # Exit early if participant not found&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @questions = list_questions(@assignment)&lt;br /&gt;
    @scores = Response.review_grades(@participant, @questions)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Database===&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
1.1. Students&lt;br /&gt;
&lt;br /&gt;
1.2. Teams&lt;br /&gt;
&lt;br /&gt;
1.3. TA&lt;br /&gt;
&lt;br /&gt;
1.4. Professor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
2.1 assignments&lt;br /&gt;
&lt;br /&gt;
2.2 assignment_questionnaire&lt;br /&gt;
&lt;br /&gt;
2.3 questionnaires&lt;br /&gt;
&lt;br /&gt;
2.4 questions&lt;br /&gt;
&lt;br /&gt;
2.5 assignment_participant&lt;br /&gt;
&lt;br /&gt;
2.6 participant&lt;br /&gt;
&lt;br /&gt;
2.7 signed_up_teams&lt;br /&gt;
&lt;br /&gt;
2.8 teams_users&lt;br /&gt;
&lt;br /&gt;
2.9 questions&lt;br /&gt;
&lt;br /&gt;
2.10 due_dates&lt;br /&gt;
&lt;br /&gt;
2.11 assignment_due_dates&lt;br /&gt;
&lt;br /&gt;
2.12 late_policies&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Implementation Details==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Implementation Details===&lt;br /&gt;
&lt;br /&gt;
By adhering to SOLID and DRY principles, we can reimplement the grades controller in a way that ensures seamless compatibility with the UI while maintaining a clean, efficient, and scalable architecture. By keeping the controller focused solely on handling HTTP requests and delegating grading logic to dedicated service objects, we enhance separation of concerns and reduce redundancy. Implementing well-structured API endpoints that follow RESTful principles will ensure that the frontend can easily retrieve and update grading data without unnecessary complexity. Additionally, by designing the system to be extensible through abstraction and modular components, we allow future enhancements—such as new grading policies or UI updates—without modifying existing core logic. Standardizing validation and error-handling mechanisms across both layers will improve data consistency and provide a smoother user experience. This structured approach not only ensures compatibility with the UI but also creates a robust foundation for long-term maintainability and scalability.&lt;br /&gt;
&lt;br /&gt;
=Team=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=163039</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=163039"/>
		<updated>2025-04-03T12:41:24Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* Implementation Details */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Reimplement Grades Controller (Frontend + Backend)=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Implementation Plan==&lt;br /&gt;
 &lt;br /&gt;
===UI===&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populate data with the appropriate HTTP GET and HTTP POST calls. &lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
'''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
'''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
'''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
Author Feedback:&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Heatmap Data:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Team-mate Data:&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
===API===&lt;br /&gt;
&lt;br /&gt;
Current implementation caters to the backend for a ruby embedded front-end. We need to update the APIs to return data that can be consumed by the React UI. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''Grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and make it a json object for response from the API so the UI can consume it. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    # prepare feedback summaries&lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def edit_participant_scores &lt;br /&gt;
    @participant = find_participant(params[:id])&lt;br /&gt;
    return unless @participant # Exit early if participant not found&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @questions = list_questions(@assignment)&lt;br /&gt;
    @scores = Response.review_grades(@participant, @questions)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Database===&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
1.1. Students&lt;br /&gt;
&lt;br /&gt;
1.2. Teams&lt;br /&gt;
&lt;br /&gt;
1.3. TA&lt;br /&gt;
&lt;br /&gt;
1.4. Professor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
2.1 assignments&lt;br /&gt;
&lt;br /&gt;
2.2 assignment_questionnaire&lt;br /&gt;
&lt;br /&gt;
2.3 questionnaires&lt;br /&gt;
&lt;br /&gt;
2.4 questions&lt;br /&gt;
&lt;br /&gt;
2.5 assignment_participant&lt;br /&gt;
&lt;br /&gt;
2.6 participant&lt;br /&gt;
&lt;br /&gt;
2.7 signed_up_teams&lt;br /&gt;
&lt;br /&gt;
2.8 teams_users&lt;br /&gt;
&lt;br /&gt;
2.9 questions&lt;br /&gt;
&lt;br /&gt;
2.10 due_dates&lt;br /&gt;
&lt;br /&gt;
2.11 assignment_due_dates&lt;br /&gt;
&lt;br /&gt;
2.12 late_policies&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Implementation Details==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend, ensuring a more maintainable, scalable, and efficient design. By refining the controller’s scope to its intended core functionality, we will enhance separation of concerns, making the system easier to extend and modify without introducing unnecessary complexity. As we rebuild the connection between the frontend UI and the backend, we will ensure that each component has a clearly defined responsibility, reducing dependencies and promoting modularity. This approach will allow for greater flexibility in future updates, improve overall code clarity, and align with best practices in software architecture. By structuring the system around these principles, we will create a robust foundation that supports long-term maintainability and adaptability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===DRY Principle===&lt;br /&gt;
&lt;br /&gt;
We aim to adhere to the DRY principle by eliminating redundancy and centralizing logic, ensuring a more modular and maintainable system. As we reimplement the connection between the frontend UI and the backend grades controller, we will focus on streamlining data flow and avoiding duplication in both layers. By structuring the system to rely on reusable components and well-defined method calls, we will improve consistency and reduce the risk of discrepancies across the application. This approach will enhance code clarity, simplify future modifications, and create a more efficient and scalable implementation.&lt;br /&gt;
&lt;br /&gt;
=Team=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=163038</id>
		<title>CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2530_Reimplement_Grades_Controller_(Frontend_%2B_Backend)&amp;diff=163038"/>
		<updated>2025-04-03T12:37:58Z</updated>

		<summary type="html">&lt;p&gt;Cdandre5: /* Implementation Details */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=E2530: Reimplement Grades Controller (Frontend + Backend)=&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Previous Implementation==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Project Statement==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Specific Objectives==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Implementation Plan==&lt;br /&gt;
 &lt;br /&gt;
===UI===&lt;br /&gt;
&lt;br /&gt;
1. The Fetch API is a built-in JavaScript interface for making HTTP requests to backend APIs, providing a modern and flexible way to handle network operations. We would replace the currently pre-populate data with the appropriate HTTP GET and HTTP POST calls. &lt;br /&gt;
&lt;br /&gt;
2. Files and components that need to updated:&lt;br /&gt;
&lt;br /&gt;
'''ReviewTable.tsx:''' This component is loaded from the App.tsx. It makes use of the dummyAuthorFeedback data. We would need to replace this json with the appropriate API call from the backend. &lt;br /&gt;
&lt;br /&gt;
'''RoundSelector.tsx:''' This component makes use of the dummy data for a heat map. So we would need to replace it with the API call to get the heat map data from the APIs.&lt;br /&gt;
&lt;br /&gt;
'''Statistics.tsx:''' This component uses the team-mates data and author feedback data which would need to be mapped to APIs from the backend. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Replace dummy data and substitute with actual API calls. Following are the samples of some the dummy data being used which would need to be translated to the API responses:&lt;br /&gt;
&lt;br /&gt;
Author Feedback:&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;This reviewer appeared to understand my work.&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer demonstrated a deep understanding of the work, providing insightful feedback.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;While the reviewer grasped the main points, some aspects could have been clarified further.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's understanding was evident, although certain nuances could have been explored more.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer showcased a comprehensive understanding of the work, offering valuable insights.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The reviewer's comprehension was evident, but a few minor details could have been addressed.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Heatmap Data:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
      &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
      &amp;quot;questionText&amp;quot;: &amp;quot;What is the main purpose of this feature?&amp;quot;,&lt;br /&gt;
      &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;Great work on this aspect!&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 3, &amp;quot;comment&amp;quot;: &amp;quot;Could use some improvement here.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The presentation was well-organized and clear. However, some points could have been elaborated further to provide a deeper understanding of the topic.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Emma&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The speaker demonstrated a profound understanding of the subject matter, making the session engaging and informative.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Mike&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The visuals were compelling and helped in understanding complex concepts easily. However, there were a few slides with too much text, which made it hard to follow at times.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The use of real-world examples made the concepts more relatable and easier to grasp. Additionally, the speaker was engaging and kept the audience hooked throughout.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;David&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The interactive exercises were beneficial in reinforcing the learning. However, there were a few technical glitches that disrupted the flow.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Olivia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The hands-on activities were the highlight of the session, providing practical experience that complemented the theoretical learning.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;William&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;The guest speaker brought a fresh perspective to the topic, offering valuable insights that sparked further discussions among the participants.&amp;quot; },&lt;br /&gt;
        { &amp;quot;name&amp;quot;: &amp;quot;Sophia&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;The case studies presented were enlightening, providing practical examples that showcased the application of theoretical concepts.&amp;quot; }&lt;br /&gt;
      ],&lt;br /&gt;
      &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
      &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Team-mate Data:&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
          &amp;quot;questionNumber&amp;quot;: &amp;quot;1&amp;quot;,&lt;br /&gt;
          &amp;quot;questionText&amp;quot;: &amp;quot;How many times was this person late to meetings?&amp;quot;,&lt;br /&gt;
          &amp;quot;reviews&amp;quot;: [&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was never late for any meeting.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Alice&amp;quot;, &amp;quot;score&amp;quot;: 4, &amp;quot;comment&amp;quot;: &amp;quot;She was late once due to traffic.&amp;quot; },&lt;br /&gt;
            { &amp;quot;name&amp;quot;: &amp;quot;Bob&amp;quot;, &amp;quot;score&amp;quot;: 5, &amp;quot;comment&amp;quot;: &amp;quot;He was punctual for all meetings.&amp;quot; }&lt;br /&gt;
          ],&lt;br /&gt;
          &amp;quot;RowAvg&amp;quot;: 0,&lt;br /&gt;
          &amp;quot;maxScore&amp;quot;: 5&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
===API===&lt;br /&gt;
&lt;br /&gt;
Current implementation caters to the backend for a ruby embedded front-end. We need to update the APIs to return data that can be consumed by the React UI. The files that need to be updated for the integration would be as follows:&lt;br /&gt;
&lt;br /&gt;
'''Grades_controller.rb:'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Update the following functions to remove instance variables and make it a json object for response from the API so the UI can consume it. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   def view_grading_report&lt;br /&gt;
    get_data_for_heat_map(params[:id].to_i)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    @show_reputation = false&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   def view_my_scores&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id].to_i)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team_id = TeamsUser.team_id(@participant.assignment_id, @participant.user_id)&lt;br /&gt;
    return if redirect_when_disallowed&lt;br /&gt;
&lt;br /&gt;
    fetch_questionnaires_and_questions&lt;br /&gt;
    fetch_participant_scores&lt;br /&gt;
  &lt;br /&gt;
    @topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)&lt;br /&gt;
    @stage = @participant.assignment.current_stage(@topic_id)&lt;br /&gt;
    update_penalties&lt;br /&gt;
    &lt;br /&gt;
    # prepare feedback summaries&lt;br /&gt;
    fetch_feedback_summary&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
   def view_team&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @team = @participant.team&lt;br /&gt;
    @team_id = @team.id&lt;br /&gt;
&lt;br /&gt;
    questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: nil).map(&amp;amp;:questionnaire)&lt;br /&gt;
    @questions = retrieve_questions(questionnaires, @assignment.id)&lt;br /&gt;
    @pscore = Response.participant_scores(@participant, @questions)&lt;br /&gt;
    @penalties = get_penalty(@participant.id)&lt;br /&gt;
    @vmlist = process_questionare_for_team(@assignment, @team_id)&lt;br /&gt;
&lt;br /&gt;
    @current_role_name = current_role_name&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def edit_participant_scores &lt;br /&gt;
    @participant = find_participant(params[:id])&lt;br /&gt;
    return unless @participant # Exit early if participant not found&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    @questions = list_questions(@assignment)&lt;br /&gt;
    @scores = Response.review_grades(@participant, @questions)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Database===&lt;br /&gt;
&lt;br /&gt;
1. Populate the database with appropriate dummy data to cover all possible scenarios when visiting the &lt;br /&gt;
&lt;br /&gt;
1.1. Students&lt;br /&gt;
&lt;br /&gt;
1.2. Teams&lt;br /&gt;
&lt;br /&gt;
1.3. TA&lt;br /&gt;
&lt;br /&gt;
1.4. Professor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The following database tables would be populated with the data which can be accessed via the API layer and then displayed on the UI&lt;br /&gt;
&lt;br /&gt;
2.1 assignments&lt;br /&gt;
&lt;br /&gt;
2.2 assignment_questionnaire&lt;br /&gt;
&lt;br /&gt;
2.3 questionnaires&lt;br /&gt;
&lt;br /&gt;
2.4 questions&lt;br /&gt;
&lt;br /&gt;
2.5 assignment_participant&lt;br /&gt;
&lt;br /&gt;
2.6 participant&lt;br /&gt;
&lt;br /&gt;
2.7 signed_up_teams&lt;br /&gt;
&lt;br /&gt;
2.8 teams_users&lt;br /&gt;
&lt;br /&gt;
2.9 questions&lt;br /&gt;
&lt;br /&gt;
2.10 due_dates&lt;br /&gt;
&lt;br /&gt;
2.11 assignment_due_dates&lt;br /&gt;
&lt;br /&gt;
2.12 late_policies&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Implementation Details==&lt;br /&gt;
&lt;br /&gt;
===SOLID Principles===&lt;br /&gt;
&lt;br /&gt;
We will focus on adhering to SOLID design principles as we reimplement the grades controller on both the frontend and backend. By refining the controller’s scope to its intended core functionality, we aim to create a more maintainable and efficient design. This approach ensures better separation of concerns, improved extensibility, and overall code clarity while aligning with best practices in software architecture.&lt;br /&gt;
&lt;br /&gt;
=Team=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Mentor==&lt;br /&gt;
&lt;br /&gt;
* Singh Shaktawat, Aniket &amp;lt;[mailto:ashakta@ncsu.edu ashakta@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
&lt;br /&gt;
* Andrews, Christopher                    &amp;lt;[mailto:cdandre5@ncsu.edu cdandre5@ncsu.edu]&amp;gt;&lt;br /&gt;
* Andurkar, Priya                  &amp;lt;[mailto:pandurk@ncsu.edu pandurk@ncsu.edu]&amp;gt;&lt;br /&gt;
* Shah, Jayneel            &amp;lt;[mailto:jshah26@ncsu.edu jshah26@ncsu.edu]&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
==Link to Pull Request==&lt;br /&gt;
&lt;br /&gt;
==Link to Tests==&lt;/div&gt;</summary>
		<author><name>Cdandre5</name></author>
	</entry>
</feed>