Zheng Qu
commited on
Commit
•
e2f2b83
1
Parent(s):
f762ad9
Changes to be committed:
Browse filesmodified: app_utils.py
modified: student_tab.py
- app_utils.py +3 -3
- student_tab.py +15 -7
app_utils.py
CHANGED
@@ -63,13 +63,13 @@ def get_all_students():
|
|
63 |
def get_student_submissions(name):
|
64 |
query = Query()
|
65 |
submissions = submissions_table.search(query.name == name)
|
66 |
-
submissions.sort(key=lambda x: x['timestamp'], reverse=True)
|
67 |
return submissions
|
68 |
|
69 |
def export_submissions():
|
70 |
try:
|
71 |
submissions = submissions_table.all()
|
72 |
-
submissions.sort(key=lambda x: x['timestamp'], reverse=True)
|
73 |
data = json.dumps(submissions, indent=2)
|
74 |
|
75 |
# Create a temporary file and write the data to it
|
@@ -83,5 +83,5 @@ def export_submissions():
|
|
83 |
|
84 |
def refresh_submissions():
|
85 |
submissions = submissions_table.all()
|
86 |
-
submissions.sort(key=lambda x: x['timestamp'], reverse=True)
|
87 |
return submissions
|
|
|
63 |
def get_student_submissions(name):
|
64 |
query = Query()
|
65 |
submissions = submissions_table.search(query.name == name)
|
66 |
+
submissions.sort(key=lambda x: datetime.datetime.fromisoformat(x['timestamp']), reverse=True)
|
67 |
return submissions
|
68 |
|
69 |
def export_submissions():
|
70 |
try:
|
71 |
submissions = submissions_table.all()
|
72 |
+
submissions.sort(key=lambda x: datetime.datetime.fromisoformat(x['timestamp']), reverse=True)
|
73 |
data = json.dumps(submissions, indent=2)
|
74 |
|
75 |
# Create a temporary file and write the data to it
|
|
|
83 |
|
84 |
def refresh_submissions():
|
85 |
submissions = submissions_table.all()
|
86 |
+
submissions.sort(key=lambda x: datetime.datetime.fromisoformat(x['timestamp']), reverse=True)
|
87 |
return submissions
|
student_tab.py
CHANGED
@@ -87,22 +87,30 @@ def create_student_tab(problems):
|
|
87 |
submit_all = gr.Button("Submit All")
|
88 |
submit_status = gr.Markdown()
|
89 |
|
|
|
|
|
90 |
def submit_all_problems(values):
|
91 |
-
|
|
|
|
|
|
|
|
|
|
|
92 |
if not name or not email:
|
93 |
return "Please enter your name and email before submitting."
|
94 |
|
95 |
-
# Create
|
96 |
codes = {prob_id: code for prob_id, code in zip(code_boxes.keys(), code_values)}
|
97 |
-
hints = {prob_id:
|
98 |
|
99 |
return save_all_submissions(name, email, codes, hints)
|
100 |
-
|
101 |
-
#
|
102 |
-
all_inputs = [name, email] + list(code_boxes.values())
|
103 |
-
|
104 |
submit_all.click(
|
105 |
fn=lambda *args: submit_all_problems(args),
|
106 |
inputs=all_inputs,
|
107 |
outputs=submit_status
|
108 |
)
|
|
|
|
87 |
submit_all = gr.Button("Submit All")
|
88 |
submit_status = gr.Markdown()
|
89 |
|
90 |
+
|
91 |
+
# Modified version
|
92 |
def submit_all_problems(values):
|
93 |
+
# Calculate where hints start in the values list
|
94 |
+
num_problems = len(code_boxes)
|
95 |
+
name, email = values[0], values[1]
|
96 |
+
code_values = values[2:2+num_problems]
|
97 |
+
hint_values = values[2+num_problems:]
|
98 |
+
|
99 |
if not name or not email:
|
100 |
return "Please enter your name and email before submitting."
|
101 |
|
102 |
+
# Create dictionaries of latest values
|
103 |
codes = {prob_id: code for prob_id, code in zip(code_boxes.keys(), code_values)}
|
104 |
+
hints = {prob_id: hint for prob_id, hint in zip(hint_states.keys(), hint_values)}
|
105 |
|
106 |
return save_all_submissions(name, email, codes, hints)
|
107 |
+
|
108 |
+
# Modify the click event to include hint states
|
109 |
+
all_inputs = [name, email] + list(code_boxes.values()) + list(hint_states.values())
|
110 |
+
|
111 |
submit_all.click(
|
112 |
fn=lambda *args: submit_all_problems(args),
|
113 |
inputs=all_inputs,
|
114 |
outputs=submit_status
|
115 |
)
|
116 |
+
|