Skip to content

feat: add student achievement PDF portfolio export#285

Closed
Swara888 wants to merge 2 commits intoEswaramuthu:mainfrom
Swara888:feature/pdf-portfolio-export
Closed

feat: add student achievement PDF portfolio export#285
Swara888 wants to merge 2 commits intoEswaramuthu:mainfrom
Swara888:feature/pdf-portfolio-export

Conversation

@Swara888
Copy link
Copy Markdown

@Swara888 Swara888 commented Mar 3, 2026

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?

  • Added a new /export-portfolio route in app.py.
  • Implemented dynamic PDF generation for student achievements.
  • Integrated student session validation for secure access.
  • Added "Download Portfolio PDF" button to student dashboard.
  • Ensured PDF includes student details and achievement records.

Are these changes tested?

Yes. The feature was manually tested by:

  • Logging in as a student.
  • Clicking the "Download Portfolio PDF" button.
  • Verifying that the generated PDF contains correct student details and achievements.

Are there any user-facing changes?

Yes. A new "Download Portfolio PDF" button has been added to the student dashboard.

@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 3, 2026

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

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 3, 2026

Thanks for creating a PR for your Issue! ☺️

We'll review it as soon as possible.
In the meantime, please double-check the file changes and ensure that all commits are accurate.

If there are any unresolved review comments, feel free to resolve them. 🙌🏼

Comment thread app.py
Comment on lines +557 to +560
student_id = session.get("student_id")
file_path = generate_student_pdf(student_id)

return redirect("/" + file_path)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Correctness: ⚠️ This route only checks 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]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread app.py

student_id = session.get("student_id")
file_path = generate_student_pdf(student_id)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment on lines +22 to +23
cursor.execute("SELECT student_name FROM student WHERE student_id=?", (student_id,))
student_name = cursor.fetchone()[0]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

@Swara888 Swara888 closed this by deleting the head repository Mar 26, 2026
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.

1 participant