CSC/ECE 517 Spring 2024 - E2446 Implement Front End for Student Task List: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
 
(72 intermediate revisions by the same user not shown)
Line 4: Line 4:
== Introduction ==
== Introduction ==
The main objective of this project is to implement the front end for the Student Task list page within Expertiza.
The main objective of this project is to implement the front end for the Student Task list page within Expertiza.
== Problem Statement ==
This project aims to create a Student Task List page that displays all the assignments the current user is participating in. This involves fetching data from the backend API to retrieve the list of assignments, filtering them based on the current user's participation, and rendering the results in a visually appealing and intuitive manner using React components.


== Project Description ==
===Objective===
This project aims to implement the front-end of existing non-Typescript Student Task List page on Expertiza, by creating a new User Interface with React.js and Typescript for an enhanced, type-safe development experience. This page displays all the assignments the current user is participating in. It involves fetching data to retrieve the list of assignments, filtering them based on the current user's participation, and rendering the results in a visually appealing and intuitive manner using React components.
This is the visual blueprint for implementing the user interface:
This is the visual blueprint for implementing the user interface:


[[File:Student tasks blueprint.jpeg | 1000px]]<br>
[[File:Student tasks blueprint.jpeg | 1000px]]<br>


==Design==
===Development Steps===
Our aim is to replicate the design elements of the existing Student Tasks View Page using React, which is currently implemented using Ruby on Rails. We will be implementing the same in React with a few significant improvements, such as adhering to design principles and ensuring that we have a responsive UI.
*<u>Evaluate Current Interface</u>: Carefully review the existing Ruby on Rails UI to understand its structure and functionalities.
===Present Implementation in Expertiza===
*<u>Environment Setup</u>: Prepare your development environment with React, and TypeScript.
[[File:Student tasks present implementation.jpeg | 1000px]]<br>
*<u>Component Design</u>: Break down the UI into individual React components, defining their props and states.
*<u>TypeScript Implementation</u>: Write the logic for these components in TypeScript, focusing on type safety.
*<u>Functionality Replication</u>: Implement the same logic and features of the Rails application in our React components, ensuring feature parity.
*<u>Styling and Interactivity</u>: Apply styles and interactive elements to the components, which can be handled via CSS.
*<u>Testing</u>: Test the components individually and the application as a whole.
 
== Design ==
===Current Implementation in Expertiza (Ruby on Rails)===
 
The existing interface on Expertiza, developed with Ruby on Rails, displays a student's task list with assignments, due dates, and progress indicators.
 
===New Implementation (React JS & TypeScript)===
 
Our redesigned UI mirrors the functionality of the original page, now utilizing the robustness of TypeScript with React's dynamic rendering capabilities. We focused on creating a responsive and accessible interface, following contemporary design standards.
 
<b> Implementation Overview </b>
 
1. <b>Data Fetching:</b> We've constructed the UI with a focus on future integration with live data. Presently, we are leveraging structured dummy data to simulate the interaction with the backend.
 
<i>Implementation Steps</i>
*Setup of TypeScript interfaces to model the data structure for assignments.
*Mock data creation to simulate API responses for development purposes.
 
2. <b>React Component Design:</b> We constructed modular React components such as Header, TaskList, and TaskItem, enhancing code reusability and readability.
 
<i>Implementation Steps</i>
==== StudentTasksBox component ====
*Definition of StudentTasksBox component with TypeScript props for type checking. - [https://github.com/prathyu99/reimplementation-front-end/commit/15c58c643f474dabab0d336c16b5ca50464f9b4c Commit]<br>
 
<syntaxhighlight>
const StudentTasksBox: React.FC<StudentTasksBoxProps> = ({ dueTasks, revisions, studentsTeamedWith }) => {
 
    let totalStudents = 0;
    for (const semester in studentsTeamedWith) {
        totalStudents += studentsTeamedWith[semester].length;
    }
 
  // Function to calculate the number of days left until the due date
  const calculateDaysLeft = (dueDate: string) => {
    const today = new Date();
    const due = new Date(dueDate);
    const timeDiff = due.getTime() - today.getTime();
    const daysDiff = Math.ceil(timeDiff / (1000 * 3600 * 24));
    return daysDiff > 0 ? daysDiff : 0;
  };
 
  // Find the revisions that have not done yet based on the due date
  const revisedTasks = revisions.filter(revisions => calculateDaysLeft(revisions.dueDate) > 0);
 
// HTML for student task box
  return (
    <div className={styles.taskbox}>
        <div className={styles.section}>
          <span className={styles.badge}>0</span>
        <strong>Tasks not yet started</strong>
        </div>


===Reimplementation that needs to be done===
    {/* Revisions section (remains empty since revisions array is empty) */}
*<b>Page Replication Using React:</b> Duplicate the existing page layout and visual elements using React.
      <div className={styles.section}>
 
      <span className={styles.greyBadge}>{revisedTasks.length}</span>
*<b>Responsive Design Implementation:</b> Ensure the components adapt seamlessly to different screen sizes and devices.
        <strong>Revisions</strong>
 
        {revisedTasks.map((task, index) => {
*<b>Data Fetching Optimization:</b> Connect React components to backend API endpoints for retrieving accurate data.
                const daysLeft = calculateDaysLeft(task.dueDate);
 
                return (
*<b>Data Filtering based on Student Participation:</b> Implement filtering mechanisms to display data pertinent to each student's involvement.
                  <div key={index}>
    
                    &raquo; {task.name} ({daysLeft} day{daysLeft !== 1 ? 's' : ''} left)
*<b>Adherence to Modern Design Principles:</b> Incorporate contemporary design elements to enhance user experience and visual appeal.
                  </div>
                );
              })}
      </div>
 
 
      {/* Students who have teamed with you section */}
      <div className={styles.section}>
        <span className={styles.badge}>{totalStudents}</span>
        <strong>Students who have teamed with you</strong>
      </div>
      {Object.entries(studentsTeamedWith).map(([semester, students], index) => (
        <div key={index}>
          <strong>{semester}</strong>
          <span className="badge">{students.length}</span>
          {students.map((student, studentIndex) => (
            <div key={studentIndex}>
              &raquo; {student}
            </div>
          ))}
        </div>
      ))}
    </div>
   );
};
</syntaxhighlight><br>


==Database==
<b><i>New UI for StudentTasksBox Component</b></i> <br>
We prepared the database by cloning and configuring the reimplementation backend, adhering to the guidelines provided in the Backend Setup Instructions. We will be creating dummy assignment data for testing purposes.


==Components==
[[File:NewStudentTasksBox.jpeg | 500px]]<br><br>
*<b>App.tsx :</b> The App.tsx file serves as the main entry point for a React application, orchestrating the routing setup, integrating various pages and components, and managing global application states or contexts to ensure cohesive navigation and functionality throughout the app. We will be adding a protected route for "student_tasks" that directs to the StudentTasks component, accessible to users with the STUDENT role.


*<b>StudentTaskBox.tsx :</b> The StudentTaskbox.tsx file will render a sidebar component highlighting upcoming tasks, revisions and team collaborations.
==== StudentTasks component ====
*Creation of stateful StudentTasks component that handles list of assignments. [https://github.com/prathyu99/reimplementation-front-end/commit/5a07b9f78bf5f25b2f78c686ca2818fc545e5abd Commit]<br>
<syntaxhighlight>
const StudentTasks: React.FC = () => {
  // State and hooks initialization
  const participantTasks = testData.participantTasks;
  const currentUserId = testData.current_user_id;
  const auth = useSelector((state: RootState) => state.authentication);
  const dispatch = useDispatch();
  const navigate = useNavigate();


*<b>StudentTasksList.tsx :</b> The StudentTasksList.tsx file implements the main panel that displays a detailed list of assignments along with course information, topic, current stage, and other pertinent details.
  // State to hold tasks
  const [tasks, setTasks] = useState<Task[]>([]);
  const exampleDuties = testData.dueTasks;
  const taskRevisions = testData.revisions;
  const studentsTeamedWith = testData.studentsTeamedWith;


*<b>Checkbox.tsx :</b> Checkbox.tsx is a reusable React component for checkbox inputs; in our context, it's utilized to allow users to select their "Publishing Rights" preferences.
  // Effect to process tasks on component mount or update
  useEffect(() => {
    if (participantTasks) {
      const filteredParticipantTasks = participantTasks.filter(task => task.participant_id === currentUserId);


*<b>interfaces.ts :</b> This interface is used to ensure the studentTasks page receives and displays a consistent and specific subset of data regarding student assignments and related information.
      const mergedTasks = filteredParticipantTasks.map(task => {
        return {
          id: task.id,
          assignment: task.assignment,
          course: task.course,
          topic: task.topic || '-',
          currentStage: task.current_stage || 'Pending',
          reviewGrade: task.review_grade || 'N/A',
          badges: task.badges || '',
          stageDeadline: task.stage_deadline || 'No deadline',
          publishingRights: task.publishing_rights || false
        };
      });
      setTasks(mergedTasks);
    }
  }, [participantTasks]);
</syntaxhighlight>


==Files to be created/modified==
<b><i>New UI for StudentTasks Component</b></i> <br>
src/App.tsx
[[File:StudentTasks.jpeg | 1000px]]<br>


src/pages/StudentTasks/StudentTasksList.tsx (new File)
3. <b>Responsive Task Display:</b> Assignments are displayed within a TaskList component. We introduced pagination and asynchronous data loading indicators for a seamless user experience.
 
src/pages/StudentTasks/StudentTaskBox.tsx (new File)


src/pages/StudentTasks/interfaces.ts (new File)
<i>Implementation Steps</i>
*Integration of a pagination component to navigate through a long list of tasks.
src/components/Checkbox.tsx
*Implementation of loading indicators while data is being fetched or simulated.


==Changes required==
4. <b>Assignment Filtering:</b> Tasks are filtered based on the user's participation using tailored React hooks, providing a personalized view.
<b>Fetch Assignment Data:</b>
* Retrieve the list of assignments for the current user from the backend API.


<b>Component Design:</b>
<i>Implementation Steps</i>
* Design React components to represent various sections of the Student Task List page, including the header, task list, task item, etc.
*Usage of React hooks for filtering assignments based on user ID.
* Ensure modularity and reusability in component structure.


<b>Render Task List:</b>
5. <b>Error Handling:</b> Comprehensive error handling strategies were implemented to provide informative feedback for failed requests or empty datasets.
* Display fetched assignments in the task list component.
* Consider implementing pagination or infinite scrolling for large assignment lists.
* Provide loading indicators or skeletons to indicate data fetching progress.


<b>Filter Assignments:</b>
* Implement filtering based on the current user's participation.
* Pass user information (e.g., user ID or role) with API requests for backend data filtering.


<b>Error Handling:</b>
6. <b>Testing and Validation:</b> The project's testing phase ensures that the student task view list operates reliably through a manual testing process.
* Implement error handling for failed API requests or unexpected responses.
* Gracefully handle edge cases such as empty task lists or invalid data, displaying appropriate messages or fallback content.


==Design Patterns and Principles==
<i>Implementation Steps</i>
*Performing a thorough manual inspection of individual task items to ensure that they display the correct information and visual indicators align with the intended design specifications.
*Conducting manual user interaction simulations to verify the functionality of component links and buttons, checking that all elements respond appropriately to user actions.
*Assessing the visual feedback provided by the UI, such as hover states and active states, to confirm that they meet the usability standards set for the project.


Through these steps, we aim to validate the cohesive function and reliability of the interface by directly engaging with the system as end-users. This approach allows for immediate correction of any discrepancies and the enhancement of the user experience.<br><br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[[File:NewStudentTasks.jpeg | 1000px]]<br>


===Module Design Pattern:===
==Database==
We use the Module Design Pattern extensively, structuring our application into cohesive, interchangeable components like Table and StudentTasksBox. This pattern allows for a clean separation of concerns and enhances code readability and maintenance.
We prepared the database by cloning and configuring the reimplementation backend, adhering to the guidelines provided in the Backend Setup Instructions. We will be creating dummy assignment data for testing purposes.


===Lazy Loading & Suspense Pattern:===
==Components==
To improve our application’s performance and user experience, we employ Lazy Loading coupled with the Suspense Pattern. By deferring the loading of components until they are required, we minimize the initial load time and provide a placeholder loading state, ensuring a smooth and responsive interaction for the users.
*<b>App.tsx :</b> The App.tsx file serves as the main entry point for a React application, orchestrating the routing setup, integrating various pages and components, and managing global application states or contexts to ensure cohesive navigation and functionality throughout the app. We will be adding a protected route for "student_tasks" that directs to the StudentTasks component, accessible to users with the STUDENT role.


===Memoization Pattern:===
*<b>StudentTasksBox.tsx :</b> The StudentTaskbox.tsx file will render a sidebar component highlighting upcoming tasks, revisions and team collaborations.
Through useMemo, we embrace the Memoization Pattern to cache expensive function calls, avoiding unnecessary recalculations. This is especially beneficial for our dropdown options and table data which depend on the dataset fetched, ensuring that we optimize rendering performance.


===Singleton Hook Pattern:===
*<b>StudentTasks.tsx :</b> The StudentTasksList.tsx file implements the main panel that displays a detailed list of assignments along with course information, topic, current stage, and other pertinent details.
While implicit, our use of React's useState follows the Singleton Hook Pattern. It manages the state within a single instance of a component, preventing the duplication of state logic and preserving the component’s state across re-renders.


===Facade Pattern:===
==Files created/modified==
The commented useAPI hook represents the Facade Pattern, providing a simplified interface to the more complex logic of API calls. It abstracts the complexities of HTTP requests and state management related to fetching data, making the API interactions more straightforward for the rest of the application.
* src/App.tsx


===Observer Pattern with Hooks:===
* src/pages/StudentTasks/StudentTasksList.tsx (New File)
By leveraging useState and useEffect, we implement an Observer Pattern variant that allows our components to efficiently manage and respond to state changes. This hooks-based pattern provides a declarative way to synchronize the component with data and lifecycle events.
 
* src/pages/StudentTasks/StudentTaskBox.tsx (New File)


===Container-Presenter Pattern:===
* src/pages/StudentTasks/StudentTasks.module.css (New File)
While not explicitly stated, our component structure hints at a Container-Presenter Pattern, with the possibility of segregating logic-heavy containers from UI-focused presentational components. This further aligns with the React best practice of separation of concerns.
* src/pages/StudentTasks/StudentTasksBox.module.css (New File)


===Functional Programming Principles:===
* src/pages/StudentTasks/testData.json (New File)
We adhere to the principles of functional programming by avoiding class-based components and side-effects where possible. Our use of pure functions, hooks, and immutable state within functional components promotes a more predictable and easier-to-test codebase.


===DRY Principle:===
==Design Patterns and Principles==
Consistent with the DRY (Don't Repeat Yourself) Principle, we aim to minimize repetition by reusing components and logic through hooks and utility functions. This not only reduces code bloat but also simplifies updates and maintenance.


===Provider Pattern (Potential):===
Design patterns that help in achieving goals such as modularity, reusability, maintainability, and efficiency in developing the React application are:
Looking ahead, the implementation may benefit from the Provider Pattern by using React's Context API. This would allow us to pass down the application state and helper functions through the component tree without prop drilling, streamlining the process of sharing stateful logic across components.


===Future Considerations===
<b>1. Component-Based Architecture:</b> This pattern supports the breakdown of UI into smaller, reusable components as outlined in the plan. It ensures modularity and reusability, which aligns with the goal of designing React components for different sections of the Student Task List page. Related to "Component Design" in the implementation plan.
====HOC Pattern (Potential):====
In future developments, the Higher-Order Component (HOC) Pattern could be leveraged to enhance components with additional capabilities, such as routing or data fetching, without altering their inherent functionality.


====Mediator Pattern (Potential):====
<b>2. Container-Component Pattern:</b>This pattern separates concerns between presentation and logic, allowing container components to manage data fetching and ensures that the rendering of task list components is decoupled from data fetching and state management.
As the application scales and the complexity of interactions between components increases, the Mediator Pattern could serve as a centralized controller to manage the workflow and logic, facilitating communication between components in a decoupled manner.


<b>3. Higher-Order Components (HOCs):</b> This pattern could be used for "Component Design" and "Error Handling" in the changes plan to encapsulate common functionalities such as error handling, which aligns with the need to implement error handling for failed requests or unexpected responses.


== Test Plan ==
== Test Plan ==
1. Fetching Assignments from Backend API: Ensure that the frontend can successfully retrieve a list of assignments from the backend API.
Test Cases:
* Verify that the frontend sends a request to the backend API to fetch assignments for the current user.
Ensure that the correct user information (such as user ID or role) is included in the API request.
* Validate that the response from the backend contains the expected assignment data.
Check for error handling in case of failed API requests or unexpected responses.


2. Design and Structure React Components: Ensure that the React components for different parts of the Student Task List page are designed, structured, and implemented correctly.
<b>1. Design and Structure React Components:</b> Ensure that the React components for different parts of the Student Task List page are designed, structured, and implemented correctly.
Test Cases:
 
<i>Test Cases:</i>
* Review the design and modularity of React components for header, task list, task item, etc.
* Review the design and modularity of React components for header, task list, task item, etc.
* Confirm that components are structured in a reusable manner to facilitate maintenance and scalability.
* Confirm that components are structured in a reusable manner to facilitate maintenance and scalability.
* Verify that each component renders as expected and displays the necessary information.
* Verify that each component renders as expected and displays the necessary information.


3. Display Task List: Ensure that the fetched assignments are correctly displayed in the task list component.
<b>2. Display Task List:</b> Ensure that the fetched assignments are correctly displayed in the task list component.
Test Cases:
 
<i>Test Cases:</i>
* Verify that the task list component renders the fetched assignments.
* Verify that the task list component renders the fetched assignments.
* Check for pagination or infinite scrolling implementation if there are a large number of assignments.
* Check for pagination or infinite scrolling implementation if there are a large number of assignments.
* Validate the presence of loading indicators or skeletons to provide feedback while data is being fetched.
* Validate the presence of loading indicators or skeletons to provide feedback while data is being fetched.


4. Filter Assignments: Ensure that assignments are filtered based on the current user's participation.
<b>3. Filter Assignments:</b> Ensure that assignments are filtered based on the current user's participation.
Test Cases:
* Verify that the frontend correctly filters assignments based on user information sent with API requests.
* Ensure that filtered assignments match the user's participation as expected.
 
5. Error Handling and Edge Cases: Ensure that error handling and edge cases are properly addressed to enhance user experience.
Test Cases:
* Verify that appropriate error messages are displayed for failed API requests or unexpected responses.
* Test for graceful handling of edge cases such as empty task lists or invalid data.


6. Integration Testing: Ensure that different parts of the Student Task List page work together correctly.
<i>Test Cases:</i>
Test Cases:
* Verify that the frontend correctly filters assignments based on User ID.
* Verify that components integrate seamlessly to display assignments accurately.
* Test interactions between components to ensure smooth functionality.


== Important Links ==
== Important Links ==
* GitHub repo [https://github.com/expertiza/reimplementation-front-end]
* GitHub repo [https://github.com/prathyu99/reimplementation-front-end]
* Pull Request: To be added
* Pull Request: [https://github.com/expertiza/reimplementation-front-end/pull/52]
* Demo video: [https://www.youtube.com/watch?v=Y8mU2fRIbaY]


== Team ==
== Team ==
=====Mentor=====  
=====Mentor=====  


* Chetana Chunduru
* Chetana Chunduru <cchetan2@ncsu.edu>


=====Members=====  
=====Members=====  

Latest revision as of 16:01, 29 April 2024

Expertiza

Expertiza is an open-source learning management system built with Ruby on Rails as its core. Its features include creating tests and assignments, managing assignment teams and courses, and above all having a solid framework in place to facilitate peer reviews and group comments. The main objective of this project is to develop frontend React Components, with a particular focus on the Student Task list page. The goal is to create a fully functional user interface for these components using React.js and TypeScript.

Introduction

The main objective of this project is to implement the front end for the Student Task list page within Expertiza.

Project Description

Objective

This project aims to implement the front-end of existing non-Typescript Student Task List page on Expertiza, by creating a new User Interface with React.js and Typescript for an enhanced, type-safe development experience. This page displays all the assignments the current user is participating in. It involves fetching data to retrieve the list of assignments, filtering them based on the current user's participation, and rendering the results in a visually appealing and intuitive manner using React components. This is the visual blueprint for implementing the user interface:


Development Steps

  • Evaluate Current Interface: Carefully review the existing Ruby on Rails UI to understand its structure and functionalities.
  • Environment Setup: Prepare your development environment with React, and TypeScript.
  • Component Design: Break down the UI into individual React components, defining their props and states.
  • TypeScript Implementation: Write the logic for these components in TypeScript, focusing on type safety.
  • Functionality Replication: Implement the same logic and features of the Rails application in our React components, ensuring feature parity.
  • Styling and Interactivity: Apply styles and interactive elements to the components, which can be handled via CSS.
  • Testing: Test the components individually and the application as a whole.

Design

Current Implementation in Expertiza (Ruby on Rails)

The existing interface on Expertiza, developed with Ruby on Rails, displays a student's task list with assignments, due dates, and progress indicators.

New Implementation (React JS & TypeScript)

Our redesigned UI mirrors the functionality of the original page, now utilizing the robustness of TypeScript with React's dynamic rendering capabilities. We focused on creating a responsive and accessible interface, following contemporary design standards.

Implementation Overview

1. Data Fetching: We've constructed the UI with a focus on future integration with live data. Presently, we are leveraging structured dummy data to simulate the interaction with the backend.

Implementation Steps

  • Setup of TypeScript interfaces to model the data structure for assignments.
  • Mock data creation to simulate API responses for development purposes.

2. React Component Design: We constructed modular React components such as Header, TaskList, and TaskItem, enhancing code reusability and readability.

Implementation Steps

StudentTasksBox component

  • Definition of StudentTasksBox component with TypeScript props for type checking. - Commit
const StudentTasksBox: React.FC<StudentTasksBoxProps> = ({ dueTasks, revisions, studentsTeamedWith }) => {

    let totalStudents = 0;
    for (const semester in studentsTeamedWith) {
        totalStudents += studentsTeamedWith[semester].length;
    }

  // Function to calculate the number of days left until the due date
  const calculateDaysLeft = (dueDate: string) => {
    const today = new Date();
    const due = new Date(dueDate);
    const timeDiff = due.getTime() - today.getTime();
    const daysDiff = Math.ceil(timeDiff / (1000 * 3600 * 24));
    return daysDiff > 0 ? daysDiff : 0;
  };

  // Find the revisions that have not done yet based on the due date
  const revisedTasks = revisions.filter(revisions => calculateDaysLeft(revisions.dueDate) > 0);

// HTML for student task box
  return (
    <div className={styles.taskbox}>
        <div className={styles.section}>
          <span className={styles.badge}>0</span>
        <strong>Tasks not yet started</strong>
        </div>

    {/* Revisions section (remains empty since revisions array is empty) */}
      <div className={styles.section}>
      <span className={styles.greyBadge}>{revisedTasks.length}</span>
        <strong>Revisions</strong>
        {revisedTasks.map((task, index) => {
                const daysLeft = calculateDaysLeft(task.dueDate);
                return (
                  <div key={index}>
                    &raquo; {task.name} ({daysLeft} day{daysLeft !== 1 ? 's' : ''} left)
                  </div>
                );
              })}
      </div>


      {/* Students who have teamed with you section */}
      <div className={styles.section}>
        <span className={styles.badge}>{totalStudents}</span>
        <strong>Students who have teamed with you</strong>
      </div>
      {Object.entries(studentsTeamedWith).map(([semester, students], index) => (
        <div key={index}>
          <strong>{semester}</strong>
          <span className="badge">{students.length}</span>
          {students.map((student, studentIndex) => (
            <div key={studentIndex}>
              &raquo; {student}
            </div>
          ))}
        </div>
      ))}
    </div>
  );
};


New UI for StudentTasksBox Component



StudentTasks component

  • Creation of stateful StudentTasks component that handles list of assignments. Commit
const StudentTasks: React.FC = () => {
  // State and hooks initialization
  const participantTasks = testData.participantTasks;
  const currentUserId = testData.current_user_id;
  const auth = useSelector((state: RootState) => state.authentication);
  const dispatch = useDispatch();
  const navigate = useNavigate();

  // State to hold tasks
  const [tasks, setTasks] = useState<Task[]>([]);
  const exampleDuties = testData.dueTasks;
  const taskRevisions = testData.revisions;
  const studentsTeamedWith = testData.studentsTeamedWith;

  // Effect to process tasks on component mount or update
  useEffect(() => {
    if (participantTasks) {
      const filteredParticipantTasks = participantTasks.filter(task => task.participant_id === currentUserId);

      const mergedTasks = filteredParticipantTasks.map(task => {
        return {
          id: task.id,
          assignment: task.assignment,
          course: task.course,
          topic: task.topic || '-',
          currentStage: task.current_stage || 'Pending',
          reviewGrade: task.review_grade || 'N/A',
          badges: task.badges || '',
          stageDeadline: task.stage_deadline || 'No deadline',
          publishingRights: task.publishing_rights || false
        };
      });
      setTasks(mergedTasks);
    }
  }, [participantTasks]);

New UI for StudentTasks Component

3. Responsive Task Display: Assignments are displayed within a TaskList component. We introduced pagination and asynchronous data loading indicators for a seamless user experience.

Implementation Steps

  • Integration of a pagination component to navigate through a long list of tasks.
  • Implementation of loading indicators while data is being fetched or simulated.

4. Assignment Filtering: Tasks are filtered based on the user's participation using tailored React hooks, providing a personalized view.

Implementation Steps

  • Usage of React hooks for filtering assignments based on user ID.

5. Error Handling: Comprehensive error handling strategies were implemented to provide informative feedback for failed requests or empty datasets.


6. Testing and Validation: The project's testing phase ensures that the student task view list operates reliably through a manual testing process.

Implementation Steps

  • Performing a thorough manual inspection of individual task items to ensure that they display the correct information and visual indicators align with the intended design specifications.
  • Conducting manual user interaction simulations to verify the functionality of component links and buttons, checking that all elements respond appropriately to user actions.
  • Assessing the visual feedback provided by the UI, such as hover states and active states, to confirm that they meet the usability standards set for the project.

Through these steps, we aim to validate the cohesive function and reliability of the interface by directly engaging with the system as end-users. This approach allows for immediate correction of any discrepancies and the enhancement of the user experience.


                                                                                                                                                        Login page for accessing the system                                                        
                                                                                                                                                                                  Navigate to the "Assignments" tab to view list of assignments                                                        
                                             

Database

We prepared the database by cloning and configuring the reimplementation backend, adhering to the guidelines provided in the Backend Setup Instructions. We will be creating dummy assignment data for testing purposes.

Components

  • App.tsx : The App.tsx file serves as the main entry point for a React application, orchestrating the routing setup, integrating various pages and components, and managing global application states or contexts to ensure cohesive navigation and functionality throughout the app. We will be adding a protected route for "student_tasks" that directs to the StudentTasks component, accessible to users with the STUDENT role.
  • StudentTasksBox.tsx : The StudentTaskbox.tsx file will render a sidebar component highlighting upcoming tasks, revisions and team collaborations.
  • StudentTasks.tsx : The StudentTasksList.tsx file implements the main panel that displays a detailed list of assignments along with course information, topic, current stage, and other pertinent details.

Files created/modified

  • src/App.tsx
  • src/pages/StudentTasks/StudentTasksList.tsx (New File)
  • src/pages/StudentTasks/StudentTaskBox.tsx (New File)
  • src/pages/StudentTasks/StudentTasks.module.css (New File)
  • src/pages/StudentTasks/StudentTasksBox.module.css (New File)
  • src/pages/StudentTasks/testData.json (New File)

Design Patterns and Principles

Design patterns that help in achieving goals such as modularity, reusability, maintainability, and efficiency in developing the React application are:

1. Component-Based Architecture: This pattern supports the breakdown of UI into smaller, reusable components as outlined in the plan. It ensures modularity and reusability, which aligns with the goal of designing React components for different sections of the Student Task List page. Related to "Component Design" in the implementation plan.

2. Container-Component Pattern:This pattern separates concerns between presentation and logic, allowing container components to manage data fetching and ensures that the rendering of task list components is decoupled from data fetching and state management.

3. Higher-Order Components (HOCs): This pattern could be used for "Component Design" and "Error Handling" in the changes plan to encapsulate common functionalities such as error handling, which aligns with the need to implement error handling for failed requests or unexpected responses.

Test Plan

1. Design and Structure React Components: Ensure that the React components for different parts of the Student Task List page are designed, structured, and implemented correctly.

Test Cases:

  • Review the design and modularity of React components for header, task list, task item, etc.
  • Confirm that components are structured in a reusable manner to facilitate maintenance and scalability.
  • Verify that each component renders as expected and displays the necessary information.

2. Display Task List: Ensure that the fetched assignments are correctly displayed in the task list component.

Test Cases:

  • Verify that the task list component renders the fetched assignments.
  • Check for pagination or infinite scrolling implementation if there are a large number of assignments.
  • Validate the presence of loading indicators or skeletons to provide feedback while data is being fetched.

3. Filter Assignments: Ensure that assignments are filtered based on the current user's participation.

Test Cases:

  • Verify that the frontend correctly filters assignments based on User ID.

Important Links

  • GitHub repo [1]
  • Pull Request: [2]
  • Demo video: [3]

Team

Mentor
  • Chetana Chunduru <cchetan2@ncsu.edu>
Members
  • Prathyusha Kodali <pkodali@ncsu.edu>
  • Soubhagya Akkena <sakkena@ncsu.edu>
  • Sri Lakshmi Kotha <skotha2@ncsu.edu>