From 608854ebb02b1f9150fcfd1b2f13142a5a10d86c Mon Sep 17 00:00:00 2001 From: Jagraj Aulakh Date: Fri, 14 Apr 2023 16:56:25 -0400 Subject: [PATCH] #70 Add endpoint to get all content in a specific course --- backend/app/routes.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/backend/app/routes.py b/backend/app/routes.py index 0fb8692..df606d3 100644 --- a/backend/app/routes.py +++ b/backend/app/routes.py @@ -149,6 +149,18 @@ def get_students_in_course(id): resp["students"].append(s.to_dict()) return jsonify(resp) +@bp.route("/course//content", methods=["GET"]) +@login_required +def get_content_in_course(id): + c = Course.query.get(id) + if not c: + return error_response(400, f"course with id {id} not found") + + content = c.content.all() + resp = {"content": []} + for c in content: + resp["content"].append(c.to_dict()) + return jsonify(resp) @bp.route("/course//assignments", methods=["GET"]) @login_required