feat: add support for TABLE_AUTO question type with table input rendering and auto-grading
This commit is contained in:
@@ -68,6 +68,17 @@ class AnswerInline(StackedInline):
|
||||
return ""
|
||||
if obj.question.question_type == 'TEXT_AUTO':
|
||||
return obj.text_answer or "Нет ответа"
|
||||
elif obj.question.question_type == 'TABLE_AUTO':
|
||||
import json
|
||||
try:
|
||||
data = json.loads(obj.text_answer)
|
||||
html = '<table style="border-collapse: collapse; margin-top: 4px;">'
|
||||
for row in data:
|
||||
html += f'<tr><td style="border: 1px solid #e5e7eb; padding: 4px 8px;">{row[0]}</td><td style="border: 1px solid #e5e7eb; padding: 4px 8px;">{row[1]}</td></tr>'
|
||||
html += '</table>'
|
||||
return format_html(html)
|
||||
except Exception:
|
||||
return obj.text_answer or "Нет ответа"
|
||||
else:
|
||||
if obj.file_answer:
|
||||
return format_html('<a href="{}" target="_blank">Скачать файл</a>', obj.file_answer.url)
|
||||
|
||||
Reference in New Issue
Block a user