Skip to content

Commit

Permalink
fixed constraint issue for updating a completed assessment.
Browse files Browse the repository at this point in the history
  • Loading branch information
sah0017 committed Dec 23, 2024
1 parent dfd5ae1 commit 9af597a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions BackEndFlask/controller/Routes/Completed_assessment_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,23 @@ def add_completed_assessment():
@admin_check()
def update_completed_assessment():
try:
assessment_data = request.json
team_id = int(assessment_data["team_id"])
if (team_id == -1):
assessment_data["team_id"] = None
user_id = int(assessment_data["user_id"])
if (user_id == -1):
assessment_data["user_id"] = None

completed_assessment_id = request.args.get("completed_assessment_id")

updated_completed_assessment = None

if(completed_assessment_id):
updated_completed_assessment = replace_completed_assessment(request.json, completed_assessment_id)
updated_completed_assessment = replace_completed_assessment(assessment_data, completed_assessment_id)

else:
updated_completed_assessment = create_completed_assessment(request.json)
updated_completed_assessment = create_completed_assessment(assessment_data)

return create_good_response(completed_assessment_schema.dump(updated_completed_assessment), 201, "completed_assessments")

Expand Down

0 comments on commit 9af597a

Please sign in to comment.