Skip to content

Add CSV download feature for courses, students, and registrations#68

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/add-download-feature-again
Draft

Add CSV download feature for courses, students, and registrations#68
Copilot wants to merge 2 commits intomainfrom
copilot/add-download-feature-again

Conversation

Copy link
Contributor

Copilot AI commented Mar 20, 2026

Users have no way to export application data for offline use or reporting. This adds CSV download endpoints and corresponding UI buttons for courses, students, and registrations.

Backend

  • New DownloadController with three endpoints:
    • GET /api/download/courses
    • GET /api/download/students
    • GET /api/download/registrations
  • RFC-compliant CSV escaping handles commas, quotes, newlines, and carriage returns
  • Filenames include datestamp (e.g. courses_20260320.csv)

Frontend

  • Download CSV button added alongside Refresh in both the View Courses and Registrations sections
  • downloadCsv(type) fetches the endpoint, resolves the filename from content-disposition, and triggers a browser file save with a safe setTimeout before revoking the object URL
async function downloadCsv(type) {
    const response = await fetch(`${API_BASE_URL}/download/${type}`);
    const blob = await response.blob();
    // filename extracted from content-disposition header
    const a = document.createElement('a');
    a.href = URL.createObjectURL(blob);
    a.download = filename;
    a.click();
    setTimeout(() => URL.revokeObjectURL(url), 100);
}

Tests

  • 13 unit tests in DownloadControllerTests covering content-type, header rows, data values, CSV field escaping, and null-guard constructors (Moq added to test project)
Original prompt

This section details on the original issue you should resolve

<issue_title>Add download feature to support file access</issue_title>
<issue_description>## Summary
Implement a download feature in the CourseApplication repository to allow users to download necessary files or data conveniently from the application.

Details

  • Enable users to download course materials or reports directly from the application interface.
  • Consider options to download different file formats (e.g., PDF, DOCX, CSV) if applicable.
  • Ensure proper user permissions and security checks for downloads.
  • Present a clear UI/UX for locating and initiating downloads.

Acceptance Criteria

  • A "Download" button is available where appropriate.
  • Files are downloaded reliably and securely.
  • The feature is tested and documented.

Please provide feedback if there are particular file types or download locations that should be prioritized.</issue_description>

Comments on the Issue (you are @copilot in this section)


📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

…ests

Co-authored-by: Hemavathi15sg <224925058+Hemavathi15sg@users.noreply.github.com>
Copilot AI changed the title [WIP] Add download feature to support file access Add CSV download feature for courses, students, and registrations Mar 20, 2026
Copilot AI requested a review from Hemavathi15sg March 20, 2026 10:12
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.

Add download feature to support file access

2 participants