feat: add student achievement PDF portfolio export#285
feat: add student achievement PDF portfolio export#285Swara888 wants to merge 2 commits intoEswaramuthu:mainfrom
Conversation
|
@Swara888 is attempting to deploy a commit to the 007's projects Team on Vercel. A member of the Team first needs to authorize it. |
Thanks for creating a PR for your Issue!
|
| student_id = session.get("student_id") | ||
| file_path = generate_student_pdf(student_id) | ||
|
|
||
| return redirect("/" + file_path) |
There was a problem hiding this comment.
Correctness: logged_in, so a teacher session (or any logged-in user without student_id) can reach generate_student_pdf(None), which will crash when fetchone()[0] runs. Add a guard for student_id (or require student role) and redirect if it’s missing.
🤖 AI Agent Prompt for Cursor/Windsurf
📋 Copy this prompt to your AI coding assistant (Cursor, Windsurf, etc.) to get help fixing this issue
In app.py around the export_portfolio route (lines ~557-560), add a guard that ensures a student_id exists in session before calling generate_student_pdf. Redirect to the student login if missing; do not allow teacher-only sessions to reach this path.
|
|
||
| cursor.execute("SELECT student_name FROM student WHERE student_id=?", (student_id,)) | ||
| student_name = cursor.fetchone()[0] | ||
|
|
There was a problem hiding this comment.
Correctness: If the student record doesn’t exist, cursor.fetchone() returns None and indexing [0] raises TypeError. Add a guard to fail clearly (or return) before using the result to avoid a 500.
🤖 AI Agent Prompt for Cursor/Windsurf
📋 Copy this prompt to your AI coding assistant (Cursor, Windsurf, etc.) to get help fixing this issue
In `services/pdf_export_service.py` around line 24, guard against `cursor.fetchone()` returning `None` when the student ID is missing. Add a check, close the connection, and raise a clear error (or return) before indexing the result.
|
|
||
| student_id = session.get("student_id") | ||
| file_path = generate_student_pdf(student_id) | ||
|
|
There was a problem hiding this comment.
Correctness: 🚨 The literal ======= line is a leftover merge-conflict marker, which makes the file invalid Python and will crash on import. Remove this marker so the module can load.
🤖 AI Agent Prompt for Cursor/Windsurf
📋 Copy this prompt to your AI coding assistant (Cursor, Windsurf, etc.) to get help fixing this issue
In `app.py` around line 861, remove the stray merge-conflict marker line `=======` so the file parses correctly. Only delete that line; no other changes needed.
| cursor.execute("SELECT student_name FROM student WHERE student_id=?", (student_id,)) | ||
| student_name = cursor.fetchone()[0] |
There was a problem hiding this comment.
Correctness: If the student_id doesn’t exist, fetchone() returns None and indexing [0] raises a TypeError, causing a 500. Handle the None case before accessing the row to avoid runtime crashes and to return a clearer error.
🤖 AI Agent Prompt for Cursor/Windsurf
📋 Copy this prompt to your AI coding assistant (Cursor, Windsurf, etc.) to get help fixing this issue
In `services/pdf_export_service.py` around lines 22-23, `cursor.fetchone()[0]` can crash when the student doesn’t exist. Update the code to check for `None` before indexing, close the DB connection, and raise a clear error (or otherwise handle the missing student case).
Which issue does this PR close?
Closes #.
Rationale for this change
Students currently can view their achievements on the dashboard, but there is no way to export them for academic, professional, or verification purposes. This PR introduces a PDF portfolio export feature to allow students to download a structured summary of their achievements.
What changes are included in this PR?
/export-portfolioroute in app.py.Are these changes tested?
Yes. The feature was manually tested by:
Are there any user-facing changes?
Yes. A new "Download Portfolio PDF" button has been added to the student dashboard.