Skip to content

Commit

Permalink
Hot fix on MySQL Foreign key constraint causing assessment tasks to n…
Browse files Browse the repository at this point in the history
…ot save.
  • Loading branch information
sah0017 committed Dec 2, 2024
1 parent 850826b commit d15d106
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions BackEndFlask/controller/Routes/Completed_assessment_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,17 +159,20 @@ def get_completed_assessment_by_team_or_user_id():
def add_completed_assessment():
try:
assessment_data = request.json

team_id = int(assessment_data["team_id"])
if (team_id == -1):
assessment_data["team_id"] = None
assessment_task_id = int(request.args.get("assessment_task_id"))
user_id = int(assessment_data["user_id"])
if (user_id == -1):
assessment_data["user_id"] = None

completed = completed_assessment_exists(team_id, assessment_task_id, user_id)

if completed:
completed = replace_completed_assessment(request.json, completed.completed_assessment_id)
completed = replace_completed_assessment(assessment_data, completed.completed_assessment_id)
else:
completed = create_completed_assessment(request.json)
completed = create_completed_assessment(assessment_data)

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

Expand Down

0 comments on commit d15d106

Please sign in to comment.