youngtsai commited on
Commit
5ffa4f4
·
1 Parent(s): da6f9f2

def update_assignment_data_html(assignment_data):

Browse files
Files changed (1) hide show
  1. assignment_ui.py +94 -73
assignment_ui.py CHANGED
@@ -150,105 +150,122 @@ def create_assignment_ui(user_data, assignment_service, submission_service):
150
  <div style="background-color: #f8f9fa; padding: 30px; border-radius: 15px; font-family: 'Helvetica', sans-serif;">
151
  <h2 style="color: #007bff; font-size: 28px; margin-bottom: 20px;">📝 學生回傳作業</h2>
152
  <div style="background-color: white; border-radius: 10px; padding: 20px; box-shadow: 0 2px 4px rgba(0,0,0,0.05);">
153
- <div style="margin-bottom: 20px;">
154
- <div style="font-weight: bold; color: #6c757d; margin-bottom: 5px;">👤 學生姓名</div>
155
- <div style="background-color: #f8f9fa; padding: 10px 15px; border-radius: 5px;">
156
- {submission_json.get('student_name', '未提供')}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
  </div>
158
- </div>
159
- <div style="margin-bottom: 20px;">
160
- <div style="font-weight: bold; color: #6c757d; margin-bottom: 5px;">🆔 學生ID</div>
161
- <div style="background-color: #f8f9fa; padding: 10px 15px; border-radius: 5px;">
162
- {submission_json.get('student_id', '未提供')}
163
- </div>
164
- </div>
165
- <div style="margin-bottom: 20px;">
166
- <div style="font-weight: bold; color: #6c757d; margin-bottom: 5px;">🕒 繳交時間</div>
167
- <div style="background-color: #f8f9fa; padding: 10px 15px; border-radius: 5px;">{submission_json.get('timestamp', '未提供')}</div>
168
- </div>
169
- <div style="margin-bottom: 20px;">
170
- <div style="font-weight: bold; color: #28a745; margin-bottom: 5px;">📄 輸入段落全文</div>
171
- <div style="background-color: #f8f9fa; padding: 10px 15px; border-radius: 5px; white-space: pre-wrap;">{content.get('chinese_full_paragraph_input', '未提供')}</div>
172
- </div>
173
 
174
- <div style="margin-bottom: 20px;">
175
- <div style="font-weight: bold; color: #17a2b8; margin-bottom: 5px;">📊 段落全文分析</div>
176
- <div style="background-color: #f8f9fa; padding: 10px 15px; border-radius: 5px; white-space: pre-wrap;">{content.get('chinese_full_paragraph_evaluate_output_text', '未提供')}</div>
177
- </div>
 
 
 
 
 
 
 
 
178
  """
179
 
180
  if 'chinese_full_paragraph_evaluate_output_table' in content:
181
  html += """
182
- <div style="margin-bottom: 20px;">
183
- <div style="font-weight: bold; color: #dc3545; margin-bottom: 5px;">📊 評分結果</div>
184
- <div style="background-color: #f8f9fa; padding: 10px 15px; border-radius: 5px;">
185
- <table style="width: 100%; border-collapse: collapse;">
186
- <tr style="background-color: #e9ecef;">
187
- <th style="padding: 10px; border: 1px solid #dee2e6;">評分項目</th>
188
- <th style="padding: 10px; border: 1px solid #dee2e6;">分數</th>
189
- <th style="padding: 10px; border: 1px solid #dee2e6;">評語</th>
190
- </tr>
191
  """
192
  for item in content['chinese_full_paragraph_evaluate_output_table']:
193
  html += f"""
194
- <tr>
195
- <td style='padding: 10px; border: 1px solid #dee2e6;'>{item.get('架構', '')}</td>
196
- <td style='padding: 10px; border: 1px solid #dee2e6;'>{item.get('評分', '')}</td>
197
- <td style='padding: 10px; border: 1px solid #dee2e6;'>{item.get('解釋', '')}</td>
198
- </tr>
199
  """
200
  html += """
201
- </table>
202
- </div>
203
- </div>
204
  """
205
 
 
 
 
 
 
 
 
 
 
206
  html += f"""
207
- <div style="margin-bottom: 20px;">
208
- <div style="font-weight: bold; color: #6610f2; margin-bottom: 5px;">🔄 段落改善建議 輸入</div>
209
- <div style="background-color: #f8f9fa; padding: 10px 15px; border-radius: 5px; white-space: pre-wrap;">{content.get('chinese_full_paragraph_refine_input', '未提供')}</div>
210
- </div>
211
-
212
- <div style="margin-bottom: 20px;">
213
- <div style="font-weight: bold; color: #fd7e14; margin-bottom: 5px;">🔄 段落改善建議</div>
214
- <div style="background-color: #f8f9fa; padding: 10px 15px; border-radius: 5px; white-space: pre-wrap;">{content.get('chinese_full_paragraph_refine_output_text', '未提供')}</div>
215
- </div>
216
  """
217
 
218
  if 'chinese_full_paragraph_refine_output_table' in content:
219
  html += """
220
- <div style="margin-bottom: 20px;">
221
- <div style="font-weight: bold; color: #20c997; margin-bottom: 5px;">📊 修改後評分</div>
222
- <div style="background-color: #f8f9fa; padding: 10px 15px; border-radius: 5px;">
223
- <table style="width: 100%; border-collapse: collapse;">
224
- <tr style="background-color: #e9ecef;">
225
- <th style="padding: 10px; border: 1px solid #dee2e6;">評分項目</th>
226
- <th style="padding: 10px; border: 1px solid #dee2e6;">分數</th>
227
- <th style="padding: 10px; border: 1px solid #dee2e6;">評語</th>
228
- </tr>
229
  """
230
  for item in content['chinese_full_paragraph_refine_output_table']:
231
  html += f"""
232
- <tr>
233
- <td style='padding: 10px; border: 1px solid #dee2e6;'>{item.get('架構', '')}</td>
234
- <td style='padding: 10px; border: 1px solid #dee2e6;'>{item.get('評分', '')}</td>
235
- <td style='padding: 10px; border: 1px solid #dee2e6;'>{item.get('解釋', '')}</td>
236
- </tr>
237
  """
238
  html += """
239
- </table>
240
- </div>
241
- </div>
242
  """
243
 
244
  html += f"""
245
- <div style="margin-bottom: 20px;">
246
- <div style="font-weight: bold; color: #20c997; margin-bottom: 5px;">📝 修改結果</div>
247
- <div style="background-color: #f8f9fa; padding: 10px 15px; border-radius: 5px; white-space: pre-wrap;">{content.get('chinese_full_paragraph_save_output', '未提供')}</div>
248
- </div>
249
- """
250
-
251
- html += """
252
  </div>
253
  </div>
254
  """
@@ -262,6 +279,10 @@ def create_assignment_ui(user_data, assignment_service, submission_service):
262
  html = generate_submission_html(submission_json)
263
  return gr.update(value=html)
264
 
 
 
 
 
265
  get_all_assignments_button.click(
266
  assignment_service.update_assignment_list,
267
  inputs=[user_data],
 
150
  <div style="background-color: #f8f9fa; padding: 30px; border-radius: 15px; font-family: 'Helvetica', sans-serif;">
151
  <h2 style="color: #007bff; font-size: 28px; margin-bottom: 20px;">📝 學生回傳作業</h2>
152
  <div style="background-color: white; border-radius: 10px; padding: 20px; box-shadow: 0 2px 4px rgba(0,0,0,0.05);">
153
+ <details>
154
+ <summary style="cursor: pointer; font-weight: bold; color: #6c757d; padding: 10px; background-color: #e9ecef; border-radius: 5px;">學生資訊</summary>
155
+ <div style="margin-top: 10px;">
156
+ <div style="margin-bottom: 20px;">
157
+ <div style="font-weight: bold; color: #6c757d; margin-bottom: 5px;">👤 學生姓名</div>
158
+ <div style="background-color: #f8f9fa; padding: 10px 15px; border-radius: 5px;">
159
+ {submission_json.get('student_name', '未提供')}
160
+ </div>
161
+ </div>
162
+ <div style="margin-bottom: 20px;">
163
+ <div style="font-weight: bold; color: #6c757d; margin-bottom: 5px;">🆔 學生ID</div>
164
+ <div style="background-color: #f8f9fa; padding: 10px 15px; border-radius: 5px;">
165
+ {submission_json.get('student_id', '未提供')}
166
+ </div>
167
+ </div>
168
+ <div style="margin-bottom: 20px;">
169
+ <div style="font-weight: bold; color: #6c757d; margin-bottom: 5px;">🕒 繳交時間</div>
170
+ <div style="background-color: #f8f9fa; padding: 10px 15px; border-radius: 5px;">{submission_json.get('timestamp', '未提供')}</div>
171
+ </div>
172
  </div>
173
+ </details>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
174
 
175
+ <details open>
176
+ <summary style="cursor: pointer; font-weight: bold; color: #28a745; padding: 10px; background-color: #e9ecef; border-radius: 5px; margin-top: 20px;">原文</summary>
177
+ <div style="margin-top: 10px;">
178
+ <div style="margin-bottom: 20px;">
179
+ <div style="font-weight: bold; color: #28a745; margin-bottom: 5px;">📄 輸入段落全文</div>
180
+ <div style="background-color: #f8f9fa; padding: 10px 15px; border-radius: 5px; white-space: pre-wrap;">{content.get('chinese_full_paragraph_input', '未提供')}</div>
181
+ </div>
182
+
183
+ <div style="margin-bottom: 20px;">
184
+ <div style="font-weight: bold; color: #17a2b8; margin-bottom: 5px;">📊 段落全文分析</div>
185
+ <div style="background-color: #f8f9fa; padding: 10px 15px; border-radius: 5px; white-space: pre-wrap;">{content.get('chinese_full_paragraph_evaluate_output_text', '未提供')}</div>
186
+ </div>
187
  """
188
 
189
  if 'chinese_full_paragraph_evaluate_output_table' in content:
190
  html += """
191
+ <div style="margin-bottom: 20px;">
192
+ <div style="font-weight: bold; color: #dc3545; margin-bottom: 5px;">📊 評分結果</div>
193
+ <div style="background-color: #f8f9fa; padding: 10px 15px; border-radius: 5px;">
194
+ <table style="width: 100%; border-collapse: collapse;">
195
+ <tr style="background-color: #e9ecef;">
196
+ <th style="padding: 10px; border: 1px solid #dee2e6;">評分項目</th>
197
+ <th style="padding: 10px; border: 1px solid #dee2e6;">分數</th>
198
+ <th style="padding: 10px; border: 1px solid #dee2e6;">評語</th>
199
+ </tr>
200
  """
201
  for item in content['chinese_full_paragraph_evaluate_output_table']:
202
  html += f"""
203
+ <tr>
204
+ <td style='padding: 10px; border: 1px solid #dee2e6;'>{item.get('架構', '')}</td>
205
+ <td style='padding: 10px; border: 1px solid #dee2e6;'>{item.get('評分', '')}</td>
206
+ <td style='padding: 10px; border: 1px solid #dee2e6;'>{item.get('解釋', '')}</td>
207
+ </tr>
208
  """
209
  html += """
210
+ </table>
211
+ </div>
212
+ </div>
213
  """
214
 
215
+ html += """
216
+ </div>
217
+ </details>
218
+
219
+ <details>
220
+ <summary style="cursor: pointer; font-weight: bold; color: #6610f2; padding: 10px; background-color: #e9ecef; border-radius: 5px; margin-top: 20px;">第二次修改</summary>
221
+ <div style="margin-top: 10px;">
222
+ """
223
+
224
  html += f"""
225
+ <div style="margin-bottom: 20px;">
226
+ <div style="font-weight: bold; color: #6610f2; margin-bottom: 5px;">🔄 段落改善建議 輸入</div>
227
+ <div style="background-color: #f8f9fa; padding: 10px 15px; border-radius: 5px; white-space: pre-wrap;">{content.get('chinese_full_paragraph_refine_input', '未提供')}</div>
228
+ </div>
229
+
230
+ <div style="margin-bottom: 20px;">
231
+ <div style="font-weight: bold; color: #fd7e14; margin-bottom: 5px;">🔄 段落改善建議</div>
232
+ <div style="background-color: #f8f9fa; padding: 10px 15px; border-radius: 5px; white-space: pre-wrap;">{content.get('chinese_full_paragraph_refine_output_text', '未提供')}</div>
233
+ </div>
234
  """
235
 
236
  if 'chinese_full_paragraph_refine_output_table' in content:
237
  html += """
238
+ <div style="margin-bottom: 20px;">
239
+ <div style="font-weight: bold; color: #20c997; margin-bottom: 5px;">📊 修改後評分</div>
240
+ <div style="background-color: #f8f9fa; padding: 10px 15px; border-radius: 5px;">
241
+ <table style="width: 100%; border-collapse: collapse;">
242
+ <tr style="background-color: #e9ecef;">
243
+ <th style="padding: 10px; border: 1px solid #dee2e6;">評分項目</th>
244
+ <th style="padding: 10px; border: 1px solid #dee2e6;">分數</th>
245
+ <th style="padding: 10px; border: 1px solid #dee2e6;">評語</th>
246
+ </tr>
247
  """
248
  for item in content['chinese_full_paragraph_refine_output_table']:
249
  html += f"""
250
+ <tr>
251
+ <td style='padding: 10px; border: 1px solid #dee2e6;'>{item.get('架構', '')}</td>
252
+ <td style='padding: 10px; border: 1px solid #dee2e6;'>{item.get('評分', '')}</td>
253
+ <td style='padding: 10px; border: 1px solid #dee2e6;'>{item.get('解釋', '')}</td>
254
+ </tr>
255
  """
256
  html += """
257
+ </table>
258
+ </div>
259
+ </div>
260
  """
261
 
262
  html += f"""
263
+ <div style="margin-bottom: 20px;">
264
+ <div style="font-weight: bold; color: #20c997; margin-bottom: 5px;">📝 修改結果</div>
265
+ <div style="background-color: #f8f9fa; padding: 10px 15px; border-radius: 5px; white-space: pre-wrap;">{content.get('chinese_full_paragraph_save_output', '未提供')}</div>
266
+ </div>
267
+ </div>
268
+ </details>
 
269
  </div>
270
  </div>
271
  """
 
279
  html = generate_submission_html(submission_json)
280
  return gr.update(value=html)
281
 
282
+ def update_submission_data_html(submission_json):
283
+ html = generate_submission_html(submission_json)
284
+ return gr.update(value=html)
285
+
286
  get_all_assignments_button.click(
287
  assignment_service.update_assignment_list,
288
  inputs=[user_data],