Skip to content

Commit cabe0d9

Browse files
committed
reset emotion endpoint added
1 parent 6f361d9 commit cabe0d9

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

flaskAIservices/src/controllers/EmotionDetectionController.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,3 +330,31 @@ def send_report():
330330
except Exception as e:
331331
print(f"Error in send_report: {str(e)}")
332332
return jsonify({"error": str(e)}), 500
333+
334+
@emotion_detection_route.route("/reset", methods=["POST"])
335+
def reset_emotion_data():
336+
try:
337+
# Get student ID and activity ID from headers
338+
student_id = request.headers.get('Student-Id')
339+
activity_id = request.headers.get('Activity-Id')
340+
341+
if not student_id or not activity_id:
342+
return jsonify({"error": "Student ID and Activity ID are required"}), 400
343+
344+
# Delete all emotion data for this student and activity
345+
collection.delete_many({
346+
"StudentId": student_id,
347+
"ActivityId": activity_id
348+
})
349+
350+
return jsonify({
351+
"message": "Emotion data reset successfully",
352+
"percentages": {
353+
"frustration": 0,
354+
"distraction": 0,
355+
"engagement": 0
356+
}
357+
}), 200
358+
359+
except Exception as e:
360+
return jsonify({"error": str(e)}), 500

0 commit comments

Comments
 (0)