Skip to content

Created a dashboard on the admin side to see contents of each course. - #175

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

Created a dashboard on the admin side to see contents of each course.#175
Deadman1225 wants to merge 8 commits into
Coding-Club-IITG:devfrom
Deadman1225:dev

Conversation

@Deadman1225

Copy link
Copy Markdown

The admin can see each folders and file for specific course number of students registered and contributions.
The admin can approve each contributions or reject it.
The admin can also delete any folder or file as well.

@RsbhThakur RsbhThakur linked an issue Jul 3, 2026 that may be closed by this pull request
@RsbhThakur
RsbhThakur self-requested a review July 3, 2026 06:39

@RsbhThakur RsbhThakur 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.

Note on Client Cache Desync:
Currently, when an admin deletes a file or folder using this new dashboard, it correctly deletes it from MongoDB, but the student client still shows the stale deleted file. This is because the student portal aggressively caches the course tree in sessionStorage (under the AllCourses key).

Since we want admin updates to reflect in the client, we need to invalidate this cache. As a simple fix, when navigating a folder on the client (handleFolderClick in BrowseFolder), we should fire an asynchronous background refresh API request to the backend and dispatch the fresh data to Redux. That way, any deleted items disappear dynamically for the student!

Comment thread admin/src/App.jsx Outdated
Comment thread admin/src/pages/Courses.jsx Outdated
Comment thread server/modules/admin/adminDashboard.controller.js Outdated
Comment thread server/modules/admin/adminDashboard.controller.js
Comment thread server/modules/admin/adminDashboard.controller.js Outdated

@RsbhThakur RsbhThakur 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.

Note on Client Cache Desync:
Currently, when an admin deletes a file or folder using this new dashboard, it correctly deletes it from MongoDB, but the student client still shows the stale deleted file. This is because the student portal aggressively caches the course tree in sessionStorage (under the AllCourses key).

Since we want admin updates to reflect in the client, we need to invalidate this cache. As a simple fix, when navigating a folder on the client (handleFolderClick in BrowseFolder), we should fire an asynchronous background refresh API request to the backend and dispatch the fresh data to Redux. That way, any deleted items disappear dynamically for the student!

Almost all issues are fixed! But this issue is still unresolved, @Deadman1225 think something for this.

@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.

Review Summary:
The file tree and pending contributions UI are functioning, but there are critical backend bugs and security oversights in this implementation that need to be resolved. Review the client cache invalidation issue raised by @RsbhThakur, the previous feedback on using react-toastify, and fix the routing and validation issues listed below.

File Comments:

  • File: admin/src/App.jsx

    • Comment: Security: The new <Route path="/admin/courses/:code" ... /> route is missing the <PrivateRoute> wrapper. This leaves the admin course dashboard accessible without authentication. Wrap it properly.
  • File: server/modules/admin/adminDashboard.controller.js (Function: handleContribution)

    • Comment: Bug: If the action parameter is neither "approve" nor "reject", the function reaches the end and returns undefined without sending any HTTP response. This hangs the client's request. Add a fallback to return a 400 Bad Request response for invalid actions.
    • Comment: Convention: Use strict equality (===) instead of loose equality (==) when checking the action parameter.
  • File: server/modules/admin/adminDashboard.controller.js (Function: deleteNode)

    • Comment: Security/Validation: The type parameter from req.params is used directly in the deletion logic, but there is no validation to ensure it is exactly "file" or "folder". Validate the type to prevent malformed requests from silently skipping the deletion logic and returning success.
  • File: server/modules/admin/adminDashboard.controller.js (Function: deleteFolderTree)

    • Comment: Performance: The recursive deletion logic triggers individual database calls in a loop. For deep folder structures, this will bottleneck the server. Batch the deletions or use a single bulk write operation.
  • File: admin/src/apis/courses.js

    • Comment: Cleanup: You imported Delete from lucide-react at the top of the file but never used it. Remove unused imports.

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.

Course View (2)

3 participants