Skip to content

Commit

Permalink
chore(routes): implementing name logic in assignment routes
Browse files Browse the repository at this point in the history
  • Loading branch information
superiorsd10 committed May 2, 2024
1 parent f2d92e6 commit c2df79d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 4 additions & 1 deletion server/app/celery/tasks/assignment_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,10 @@ def process_automatic_grading_and_feedback(create_assignment_uuid: str) -> None:
for email, response in responses:
scored_points, feedback = generate_grade_and_feedback(answer, response)
scored_points_dict[email] = scored_points
assignment_marks_dict[email] = scored_points
user_name_key = f"user_name_{email}"
name = redis_client.get(user_name_key)
assignment_marks_dict_key = f"{email}:{name}"
assignment_marks_dict[assignment_marks_dict_key] = scored_points
feedback_dict[email] = feedback

user_assignment = UserEmbeddedAssignment(
Expand Down
9 changes: 7 additions & 2 deletions server/app/routes/assignment_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from datetime import datetime
import uuid
from bson import ObjectId
from flask import Blueprint, request, jsonify
from flask import Blueprint, request, jsonify, current_app
from app.auth.firebase_auth import firebase_token_required
from app.enums import StatusCode
from app.core import limiter
Expand Down Expand Up @@ -780,10 +780,15 @@ def submit_assignment(assignment_id):
email = request.args.get("email")
response = data.get("response")

redis_client = current_app.redis_client
user_name_key = f"user_name_{email}"
name = redis_client.get(user_name_key)
assignment_marks_dict_key = f"{email}:{name}"

assignment_object_id = decode_base64_to_objectid(base64_encoded=assignment_id)

Assignment.objects(id=assignment_object_id).update_one(
push__responses={email: response}
push__responses={assignment_marks_dict_key: response}
)

return (
Expand Down

0 comments on commit c2df79d

Please sign in to comment.