Skip to content

Comments

UI updates - graphs added in results#47

Closed
GowthamDhanaraju wants to merge 18 commits intoevalify:developmentfrom
GowthamDhanaraju:development
Closed

UI updates - graphs added in results#47
GowthamDhanaraju wants to merge 18 commits intoevalify:developmentfrom
GowthamDhanaraju:development

Conversation

@GowthamDhanaraju
Copy link
Contributor

@GowthamDhanaraju GowthamDhanaraju commented Jun 21, 2025

Summary by CodeRabbit

  • New Features

    • Introduced multiple new chart components for enhanced test result visualization, including performance trends, marks distribution, question-wise statistics, and student performance breakdowns.
    • Added interactive options to toggle chart layouts and filter visible data in performance charts.
    • Expanded student results pages with visual trends across courses and detailed performance breakdowns.
  • Enhancements

    • Improved teacher results page with reorganized and more comprehensive performance graphs and detailed score displays.
    • Updated test overview statistics to show both absolute marks and percentages.
    • Enriched mock data with additional courses, more detailed test entries, and expanded statistics for realistic testing.
  • Bug Fixes

    • Minor improvements to the rendering of multiple-choice options for clarity and maintainability.
  • Chores

    • Removed unused components and exports to streamline the codebase.

GowthamDhanaraju and others added 16 commits June 12, 2025 19:48
- Added icons to question and explanation titles in Match Following, MCQ, and True/False question components for better visual representation.
- Updated the MCQ question component to allow clickable options for selecting correct answers, enhancing user experience.
- Improved the Tiptap editor to accept a height prop for better customization.
- Refactored select components for cleaner code and improved styling.
- Created a new test page for editing questions with sample data to facilitate testing.
…anagement

- Created types for student overall results, recent test results, course results, test summaries, detailed test results, question results, and results filters.
- Implemented ResultsAPI class with methods to fetch student overview, course results, test summaries, detailed test results, and recent results.
- Added mock data for development and testing purposes for both student and teacher results.
feat: implement StudentResultsTable component for detailed student results

feat: define types for teacher-specific results in types.ts

refactor: remove deprecated TestSummaries component and related types

refactor: delete unused types from results/types.ts

fix: update results-api to use new types and mock data structure

feat: create utility functions for consistent score color display

chore: add stub for useRecentTestResults to resolve import errors
- Removed `question-stats-table` component and its export from `index.ts`.
- Added `marks-frequency-bar-chart`, `question-wise-bar-chart`, and `student-performance-pie-chart` components for improved data visualization.
- Updated mock data in `results-api.ts` to reflect more realistic test results and added new courses and tests.
- Increased the number of mock students and questions for better testing scenarios.
Copilot AI review requested due to automatic review settings June 21, 2025 10:10
@coderabbitai
Copy link

coderabbitai bot commented Jun 21, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This update introduces several new chart components for visualizing student and teacher test results, including performance trends, distributions, and question-wise analysis. It reorganizes the teacher and student results pages to incorporate these charts, enhances mock data with more detailed course and test entries, and removes obsolete components and exports.

Changes

File(s) Change Summary
src/app/(test)/student-results/page.tsx Added StudentPerformanceTrendsChart to the overview, passing courseResults as prop.
src/app/(test)/teacher-results/page.tsx Replaced old charts with new "Performance Graphs" section; added multiple new chart components and layout toggle.
src/components/results/common/detailed-test-result.tsx Refactored MCQ option rendering for clarity; added comment about chart removal; minor formatting changes.
src/components/results/common/marks-pie-chart.tsx Introduced new MarksPieChart component for marks distribution visualization.
src/components/results/common/question-bar-chart.tsx Introduced new QuestionBarChart component for stacked bar question results.
src/components/results/student/performance-distribution-chart.tsx Added StudentPerformanceDistributionChart for score distribution with grouping options.
src/components/results/student/performance-trends-chart.tsx Added StudentPerformanceTrendsChart for multi-course performance trends.
src/components/results/teacher/index.ts Removed export for obsolete question-stats-table.
src/components/results/teacher/marks-frequency-bar-chart.tsx Added MarksFrequencyBarChart for marks frequency visualization.
src/components/results/teacher/question-wise-bar-chart.tsx Added QuestionWiseBarChart for question-wise correct/wrong answer stats.
src/components/results/teacher/student-performance-pie-chart.tsx Added StudentPerformancePieChart for performance category distribution.
src/lib/results-api.ts Expanded mock data: added new courses, more detailed test results, and new fields for teacher stats.

Sequence Diagram(s)

sequenceDiagram
    participant Student as StudentResultsPage
    participant Trends as StudentPerformanceTrendsChart
    participant API as ResultsAPI

    Student->>API: Fetch courseResults
    Student->>Trends: Pass courseResults as prop
    Trends->>Student: Render performance trends chart
Loading
sequenceDiagram
    participant Teacher as TeacherResultsPage
    participant API as ResultsAPI
    participant Pie as StudentPerformancePieChart
    participant Bar as MarksFrequencyBarChart
    participant QBar as QuestionWiseBarChart

    Teacher->>API: Fetch test statistics
    Teacher->>Pie: Pass scores
    Teacher->>Bar: Pass scores
    Teacher->>QBar: Pass questionStats
    Pie->>Teacher: Render pie chart
    Bar->>Teacher: Render bar chart
    QBar->>Teacher: Render question-wise bar chart
Loading

Possibly related PRs

Suggested reviewers

  • Aksaykanthan

Poem

In the garden of tests, new charts bloom bright,
With pies and bars that dance in the light.
Trends and frequencies, colors anew,
Rabbits chart progress, for teachers and you!
Data hops lively, results on display—
Carrots for coders, hip-hip-hooray!
🥕📊

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /.npm/_logs/2025-06-21T11_09_57_455Z-debug-0.log


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3f10e10 and 1aa2c0e.

📒 Files selected for processing (5)
  • src/app/(test)/teacher-results/page.tsx (7 hunks)
  • src/components/results/student/performance-trends-chart.tsx (1 hunks)
  • src/components/results/teacher/marks-frequency-bar-chart.tsx (1 hunks)
  • src/components/results/teacher/question-wise-bar-chart.tsx (1 hunks)
  • src/components/results/teacher/student-performance-pie-chart.tsx (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces several new chart components and integrates them into both the teacher and student results pages to visualize performance data.

  • Added new reusable chart components (pie, bar, and line) under components/results
  • Integrated graphs into the teacher results page with toggleable layouts
  • Integrated performance trends chart into the student results page and cleaned up unused exports

Reviewed Changes

Copilot reviewed 11 out of 14 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/components/results/teacher/student-performance-pie-chart.tsx New pie chart for overall student performance
src/components/results/teacher/question-wise-bar-chart.tsx New bar chart for question-wise correct/wrong stats
src/components/results/teacher/marks-frequency-bar-chart.tsx New line chart for marks frequency distribution
src/components/results/teacher/index.ts Removed unused export
src/app/(test)/teacher-results/page.tsx Integrated teacher graphs section with layout toggle
src/components/results/student/performance-trends-chart.tsx New line chart for student performance trends
src/app/(test)/student-results/page.tsx Added performance trends chart to student view
Comments suppressed due to low confidence (1)

src/components/results/teacher/student-performance-pie-chart.tsx:1

  • This new chart component doesn’t have accompanying unit or integration tests. Consider adding tests to verify that getPerformanceDistribution correctly bins various score sets.
import React from "react";

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

🧹 Nitpick comments (9)
src/components/results/teacher/marks-frequency-bar-chart.tsx (1)

23-26: Consider renaming component to reflect actual chart type.

The component name MarksFrequencyBarChart suggests it renders a bar chart, but it actually renders a line chart. Consider renaming to MarksFrequencyLineChart for clarity.

src/components/results/student/performance-trends-chart.tsx (1)

32-89: Consider extracting chart dataset logic for better maintainability.

The dataset creation logic is quite complex and could benefit from extraction into a separate function to improve readability and testability.

Consider extracting:

const createCourseDatasets = (
  filteredCourses: CourseResult[], 
  labels: string[], 
  palette: string[]
) => {
  return filteredCourses.map((course, idx) => {
    // existing dataset logic here
  });
};

This would make the main component more focused and the dataset logic more testable.

src/components/results/teacher/question-wise-bar-chart.tsx (2)

30-34: Incomplete scroll logic implementation.

The scroll threshold logic sets up conditions but doesn't actually implement scrolling. The component slices data in horizontal mode but doesn't provide UI feedback about truncated data or scrolling controls.

Consider either:

  1. Implementing actual scroll behavior with UI indicators
  2. Removing the incomplete logic and handling scrolling at the parent level
  3. Adding a note in props documentation about external scroll handling

43-43: Hard-coded colors should use design system.

The green and red colors should be consistent with the application's design system rather than hard-coded hex values.

Consider using CSS custom properties or design system tokens:

-backgroundColor: "#22c55e",
+backgroundColor: "hsl(var(--success))",
-backgroundColor: "#ef4444",
+backgroundColor: "hsl(var(--destructive))",

Also applies to: 49-49

src/components/results/student/performance-distribution-chart.tsx (2)

56-60: Add explicit empty state handling.

While the function returns an empty array for no results, consider adding a user-facing empty state message in the component.

+if (tests.length === 0) {
+  return (
+    <Card className="border border-border shadow-sm">
+      <CardContent className="pt-6">
+        <div className="h-80 w-full flex items-center justify-center">
+          <p className="text-muted-foreground">No test data available</p>
+        </div>
+      </CardContent>
+    </Card>
+  );
+}

108-117: Consider adding accessibility labels to the select.

The select component could benefit from proper ARIA labels for better accessibility.

<Select value={grouping} onValueChange={handleGroupingChange}>
-  <SelectTrigger className="w-[100px] h-8">
+  <SelectTrigger className="w-[100px] h-8" aria-label="Score range grouping">
    <SelectValue placeholder="Group by" />
  </SelectTrigger>
src/app/(test)/teacher-results/page.tsx (3)

500-506: Extract repeated calculation into a helper function.

The calculation pattern (score/100) * totalMarks is repeated multiple times. Consider extracting it into a helper function for better maintainability.

Add a helper function at the component level:

+const calculateAbsoluteMarks = (percentage: number, totalMarks: number): string => {
+  return ((percentage / 100) * totalMarks).toFixed(1);
+};

Then simplify the repeated calculations:

-{testStatistics.averageScore.toFixed(1)}% (
-{(
-  (testStatistics.averageScore / 100) *
-  testStatistics.totalMarks
-).toFixed(1)}
-/{testStatistics.totalMarks})
+{testStatistics.averageScore.toFixed(1)}% (
+{calculateAbsoluteMarks(testStatistics.averageScore, testStatistics.totalMarks)}
+/{testStatistics.totalMarks})

Also applies to: 530-541, 551-557


574-591: Consider using a proper toggle component for better accessibility.

The current implementation works but could benefit from using a proper toggle/segmented control component that provides better keyboard navigation and ARIA attributes.

Consider using a ToggleGroup component from your UI library or implementing proper ARIA attributes:

-<div className="inline-flex rounded-md shadow-sm bg-muted border border-border">
+<div className="inline-flex rounded-md shadow-sm bg-muted border border-border" role="group" aria-label="Chart layout toggle">
  <button
    type="button"
-   aria-label="Vertical layout"
+   aria-label="Vertical layout"
+   aria-pressed={chartsStacked}
    className={...}
    onClick={() => setChartsStacked(true)}
  >

658-669: Remove commented out code.

This commented section should be removed since it has been replaced by the new Performance Graphs section. Keeping dead code creates confusion and maintenance overhead.

-{/* <div className="mb-2">
-  <h2 className="text-xl font-semibold">Question Analysis</h2>
-  <p className="text-sm text-muted-foreground mt-1">
-    Performance metrics for each question on the test
-  </p>
-</div>
-<div className="mb-8">
-  <QuestionBarChart questions={testStatistics?.questionStats || []} />
-</div>
-<div className="mb-8">
-  <MarksPieChart questions={testStatistics?.questionStats || []} />
-</div> */}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 24c1382 and 3f10e10.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (12)
  • src/app/(test)/student-results/page.tsx (2 hunks)
  • src/app/(test)/teacher-results/page.tsx (7 hunks)
  • src/components/results/common/detailed-test-result.tsx (3 hunks)
  • src/components/results/common/marks-pie-chart.tsx (1 hunks)
  • src/components/results/common/question-bar-chart.tsx (1 hunks)
  • src/components/results/student/performance-distribution-chart.tsx (1 hunks)
  • src/components/results/student/performance-trends-chart.tsx (1 hunks)
  • src/components/results/teacher/index.ts (0 hunks)
  • src/components/results/teacher/marks-frequency-bar-chart.tsx (1 hunks)
  • src/components/results/teacher/question-wise-bar-chart.tsx (1 hunks)
  • src/components/results/teacher/student-performance-pie-chart.tsx (1 hunks)
  • src/lib/results-api.ts (16 hunks)
💤 Files with no reviewable changes (1)
  • src/components/results/teacher/index.ts
🧰 Additional context used
🧬 Code Graph Analysis (6)
src/components/results/teacher/student-performance-pie-chart.tsx (2)
src/components/ui/tooltip.tsx (1)
  • Tooltip (61-61)
src/components/ui/card.tsx (4)
  • Card (85-85)
  • CardHeader (86-86)
  • CardTitle (88-88)
  • CardContent (91-91)
src/app/(test)/student-results/page.tsx (1)
src/components/results/student/performance-trends-chart.tsx (1)
  • StudentPerformanceTrendsChart (32-222)
src/components/results/student/performance-distribution-chart.tsx (3)
src/components/ui/tooltip.tsx (1)
  • Tooltip (61-61)
src/components/ui/card.tsx (4)
  • Card (85-85)
  • CardHeader (86-86)
  • CardTitle (88-88)
  • CardContent (91-91)
src/components/ui/select.tsx (5)
  • Select (175-175)
  • SelectTrigger (183-183)
  • SelectValue (184-184)
  • SelectContent (176-176)
  • SelectItem (178-178)
src/components/results/teacher/marks-frequency-bar-chart.tsx (2)
src/components/ui/tooltip.tsx (1)
  • Tooltip (61-61)
src/components/ui/card.tsx (4)
  • Card (85-85)
  • CardHeader (86-86)
  • CardTitle (88-88)
  • CardContent (91-91)
src/components/results/teacher/question-wise-bar-chart.tsx (2)
src/components/ui/tooltip.tsx (1)
  • Tooltip (61-61)
src/components/ui/card.tsx (4)
  • Card (85-85)
  • CardHeader (86-86)
  • CardTitle (88-88)
  • CardContent (91-91)
src/lib/results-api.ts (3)
src/components/results/index.ts (2)
  • StudentTestResult (17-17)
  • QuestionStat (18-18)
src/components/results/teacher/types.ts (2)
  • StudentTestResult (39-54)
  • QuestionStat (76-86)
src/components/results/teacher/question-wise-bar-chart.tsx (1)
  • QuestionStat (15-19)
🔇 Additional comments (15)
src/components/results/common/marks-pie-chart.tsx (1)

1-47: LGTM! Clean and well-structured pie chart component.

The implementation correctly handles the three answer states (correct, wrong, unanswered) with proper mark aggregation and fallback handling. The Chart.js configuration is appropriate with good color choices and responsive design.

src/components/results/common/question-bar-chart.tsx (1)

1-66: LGTM! Well-implemented stacked bar chart for question analysis.

The component correctly transforms question results into binary datasets for visualization, with proper Chart.js configuration including stacked axes, integer precision, and responsive design.

src/lib/results-api.ts (2)

169-296: LGTM! Enhanced mock data supports new visualization components.

The expanded test data across courses provides richer datasets for the new chart components, enabling more realistic performance trend visualization.

Also applies to: 303-401, 407-505, 699-891


1441-1443: Good enhancement to support detailed analytics.

Increasing the sample sizes (30 students, 20 questions) and adding totalStudents field provides more comprehensive data for the teacher analytics charts.

Also applies to: 1462-1463, 1504-1504

src/app/(test)/student-results/page.tsx (2)

15-15: LGTM! Clean import addition.

The import follows the established pattern for component imports.


174-178: Well-positioned chart integration.

The performance trends chart is logically placed in the overview section and correctly uses the courseResults state as its data source.

src/components/results/common/detailed-test-result.tsx (2)

139-177: Good refactoring for improved readability.

Introducing isCorrect and isSelected constants eliminates repeated expressions and makes the conditional logic clearer.


313-315: Improved formatting for better readability.

Breaking the function call across multiple lines improves code readability.

src/components/results/student/performance-distribution-chart.tsx (2)

33-39: Well-designed color mapping function.

The color progression from red (low scores) to green (high scores) provides intuitive visual feedback aligned with common score interpretations.


60-91: Solid distribution calculation logic.

The bin generation and score assignment logic handles edge cases well, particularly the special handling for perfect scores (100%) to ensure they fall into the last bin.

src/app/(test)/teacher-results/page.tsx (5)

30-31: LGTM!

The new icon imports for layout toggle functionality are appropriate.


35-39: LGTM!

The chart component imports align with the new visualization features mentioned in the PR objectives.


63-63: LGTM!

The state variable for managing chart layout is well-named and properly initialized.


516-520: Good defensive programming with nullish coalescing.

The handling of potentially null totalStudents with the ?? operator is appropriate.


682-683: ```shell
#!/bin/bash
set -e

Locate occurrences of testStatistics and surrounding context in page.tsx

rg -n 'testStatistics' -C5 src/app/(test)/teacher-results/page.tsx

Show the top of the file to inspect data fetching / props resolution

sed -n '1,200p' src/app/(test)/teacher-results/page.tsx


</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

…e colors; update performance distribution comments
- Fix SSR compatibility in student-performance-pie-chart by adding window check for getComputedStyle
- Fix rounding error in QuestionWiseBarChart calculation to ensure correct + wrong = attemptedCount
- Rename QuestionStat to QuestionStatChart in question-wise-bar-chart to avoid type conflicts
- Add useThemeColors hook for SSR-safe theme detection in chart components
- Switch from sonner to useToast hook for toast messages (partial implementation)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants