Skip to content

Add CSV download for courses and registrations#66

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

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

Conversation

Copy link
Contributor

Copilot AI commented Mar 19, 2026

Adds the ability to download course and registration data as CSV files, triggered directly from the relevant UI sections.

Backend

  • DownloadsController (new) — two endpoints:
    • GET /api/downloads/courses — all courses via ICourseService.SearchCoursesAsync(null, null)
    • GET /api/downloads/registrations — all registrations via new GetAllRegistrationsAsync()
  • IRegistrationService / RegistrationService — added GetAllRegistrationsAsync() backed by the existing GetRegistrationsWithFiltersAsync(null, null, null) to bypass the 100-row pagination cap
  • CSV escaping covers: commas, double-quotes, newlines, and formula injection (leading =, +, -, @ tab-prefixed)

Frontend

  • Download CSV buttons added to the Courses and Registrations section action bars
  • downloadCoursesCsv() / downloadRegistrationsCsv() — fetch blob, invoke browser download via a temporary anchor; errors surface through the existing showErrorModal
  • Fallback filename uses Date.getUTC*() to match backend's DateTime.UtcNow convention

Tests

Nine unit tests added for DownloadsController using hand-written fakes (consistent with existing test style), covering: empty result sets, data rows, correct content type, comma quoting, double-quote escaping, and formula injection neutralisation.

Original prompt

This section details on the original issue you should resolve

<issue_title>Add download feature</issue_title>
<issue_description>Implement a download feature that allows users to download resources or data as needed within the CourseApplication platform. This could include course materials, generated reports, or any files relevant to user activity. The new feature should integrate seamlessly with the current application structure and UI.

Acceptance Criteria:

  • Users can trigger downloads from relevant sections.
  • The implementation supports common file types (e.g., PDF, DOCX, CSV).
  • Proper error handling is in place for failed downloads.
  • Access permissions for downloads are respected based on user role.

Potential Enhancements:

  • Download progress indicators for large files.
  • Bulk/multi-file download capability.

Implementation notes and code pointers:

  • The main front-end logic is located in frontend/script.js. This file handles navigation, UI updates, and contains candidate spots for adding UI controls and logic for download actions. For example, you can define new functions similar to refreshCourses, showCourseDetails, or utilize event handlers for modals to integrate download triggers (see script.js).
  • For managing download UI (modals/buttons), also reference the modal-related styles in frontend/styles.css for consistent UI updates (see styles.css).
  • To support backend file retrieval, consider creating an appropriate API endpoint in the .NET backend (possibly in Controllers/HomeController.cs) to serve downloadable files with access control (see HomeController.cs).
  • Ensure error handling in downloads leverages the front-end's error modal functionality (see showErrorModal in script.js) and server-side HTTP error responses.

Please consider best practices for file security during the download process.</issue_description>

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


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copy link

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.

Copilot wasn't able to review any files in this pull request.


You can also share your feedback on Copilot code review. Take the survey.

Co-authored-by: Hemavathi15sg <224925058+Hemavathi15sg@users.noreply.github.com>
Copilot AI changed the title [WIP] Add download feature for CourseApplication Add CSV download for courses and registrations Mar 19, 2026
Copilot AI requested a review from Hemavathi15sg March 19, 2026 07:21
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

3 participants