Skip to content

Created an option to view and download file for admins when approving a file. - #200

Open
Deadman1225 wants to merge 6 commits into
Coding-Club-IITG:devfrom
Deadman1225:dev
Open

Deadman1225 wants to merge 6 commits into
Coding-Club-IITG:devfrom
Deadman1225:dev

Conversation

@Deadman1225

Copy link
Copy Markdown
Contributor
  • admin/src/pages/CourseDashboard.jsx -> pending contributions now render each file as its own row with a View link (opens the SharePoint preview via webUrl) and a Download button. Added a handleDownload handler.
  • admin/src/apis/courses.js -> added getFileDownloadUrl(fileId), which calls the existing GET /api/file/download/:fileID
    endpoint.

The Download button sends the file's OneDrive fileId to the existing /api/file/download/:fileID endpoint, which asks Microsoft Graph for a fresh @microsoft.graph.downloadUrl (a direct-to-bytes link) and returns it. The browser is then navigated to that URL to trigger the download.

@Deadman1225

Copy link
Copy Markdown
Contributor Author
Screenshot (191) Screenshot (192) Screenshot (193)

The View option opens the sharepoint link and the download button downloads the file directly.

@DreamBot706

Copy link
Copy Markdown
Contributor

is there a way to see all the unverified files of any course together? can you add this so that admins can approve files in courses without br

@Deadman1225

Copy link
Copy Markdown
Contributor Author
image Does this work? I made the BRless course form csv import so it has no folder structure, how do we fix that? For BRless course the contributions does show up, when i manually make them from compass, is there any easier way?

@DreamBot706

Copy link
Copy Markdown
Contributor

yup this looks good but push your commit to this branch so that I can see how you have fetched the unverified contributions, and what do you mean by "manually make them from compass", do you mean you iterate through all the contributions or something like that?

@Deadman1225

Copy link
Copy Markdown
Contributor Author

It was just part of me testing the feature out, i had to copy the contributions of other courses on compass and manually make them related to the BRless course, since I was not able to figure out any other way to test it.

@DreamBot706 DreamBot706 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Two issues found, the first one breaks the course dashboard. Details inline.

<button
onClick={() => handleContributionAction(contribution.contributionId, 'approve')}
className="inline-flex items-center gap-1.5 rounded-lg bg-green-600 px-3.5 py-2 text-sm font-semibold text-white hover:bg-green-700"
onClick={() => onAction(contribution.contributionId, "approve")}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Crash when a course has pending contributions. onAction and processingId aren't defined in CourseDashboard (they look copied from PendingContributions.jsx). As soon as an unapproved contribution renders, this throws ReferenceError: processingId is not defined and the dashboard can't be used to approve/reject. The existing handleContributionAction is still here but no longer called. Suggest wiring these buttons back to handleContributionAction and adding a local processing-id state (same for the Reject button below).

<FiCheck /> Approve
</button>
<button
onClick={() => onAction(contribution.contributionId, "reject")}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reject deletes files without confirmation. On the server, rejecting permanently deletes every file in the contribution from storage, removes them from the parent folder and deletes the contribution record. One misclick here loses a student's upload for good. The course dashboard confirms before rejecting; this page should too.

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