Spaces:
Sleeping
Sleeping
encoded_student_id_url = urllib.parse.quote(student_id, safe='')
Browse files- assignment_service.py +5 -2
- submission_service.py +4 -1
assignment_service.py
CHANGED
@@ -2,6 +2,7 @@ import uuid
|
|
2 |
import json
|
3 |
import gradio as gr
|
4 |
from datetime import datetime
|
|
|
5 |
|
6 |
|
7 |
class AssignmentService:
|
@@ -82,7 +83,8 @@ class AssignmentService:
|
|
82 |
"assignment_type": assignment_data["assignment_type"],
|
83 |
"timestamp": assignment_data["timestamp"]
|
84 |
}
|
85 |
-
|
|
|
86 |
|
87 |
def get_assignment(self, assignment_id):
|
88 |
try:
|
@@ -100,7 +102,8 @@ class AssignmentService:
|
|
100 |
|
101 |
def get_user_assignments(self, user_id):
|
102 |
try:
|
103 |
-
|
|
|
104 |
user_assignments = json.loads(user_assignments_json)
|
105 |
except Exception as e:
|
106 |
print(f"Error: {e}")
|
|
|
2 |
import json
|
3 |
import gradio as gr
|
4 |
from datetime import datetime
|
5 |
+
import urllib.parse
|
6 |
|
7 |
|
8 |
class AssignmentService:
|
|
|
83 |
"assignment_type": assignment_data["assignment_type"],
|
84 |
"timestamp": assignment_data["timestamp"]
|
85 |
}
|
86 |
+
encoded_user_id_url = urllib.parse.quote(student_id, safe='')
|
87 |
+
self.gcs_service.upload_json_string(self.bucket_name, f"users/{encoded_user_id_url}/assignments.json", json.dumps(user_assignments))
|
88 |
|
89 |
def get_assignment(self, assignment_id):
|
90 |
try:
|
|
|
102 |
|
103 |
def get_user_assignments(self, user_id):
|
104 |
try:
|
105 |
+
encoded_user_id_url = urllib.parse.quote(user_id, safe='')
|
106 |
+
user_assignments_json = self.gcs_service.download_as_string(self.bucket_name, f"users/{encoded_user_id_url}/assignments.json")
|
107 |
user_assignments = json.loads(user_assignments_json)
|
108 |
except Exception as e:
|
109 |
print(f"Error: {e}")
|
submission_service.py
CHANGED
@@ -2,6 +2,8 @@ import uuid
|
|
2 |
import json
|
3 |
import gradio as gr
|
4 |
from datetime import datetime
|
|
|
|
|
5 |
|
6 |
|
7 |
class SubmissionService:
|
@@ -67,7 +69,8 @@ class SubmissionService:
|
|
67 |
|
68 |
def save_user_submissions_to_gcs(self, student_id, submission_data):
|
69 |
try:
|
70 |
-
|
|
|
71 |
user_submissions = json.loads(user_submissions_json)
|
72 |
except Exception as e:
|
73 |
print(f"Error: {e}")
|
|
|
2 |
import json
|
3 |
import gradio as gr
|
4 |
from datetime import datetime
|
5 |
+
import urllib.parse
|
6 |
+
|
7 |
|
8 |
|
9 |
class SubmissionService:
|
|
|
69 |
|
70 |
def save_user_submissions_to_gcs(self, student_id, submission_data):
|
71 |
try:
|
72 |
+
encoded_student_id_url = urllib.parse.quote(student_id, safe='')
|
73 |
+
user_submissions_json = self.gcs_service.download_as_string(self.bucket_name, f"users/{encoded_student_id_url}/submissions.json")
|
74 |
user_submissions = json.loads(user_submissions_json)
|
75 |
except Exception as e:
|
76 |
print(f"Error: {e}")
|