feat: add support for TABLE_AUTO question type with table input rendering and auto-grading

This commit is contained in:
Dmitry Belan
2026-09-19 12:19:02 +03:00
parent 9ee1788692
commit 46319def76
9 changed files with 157 additions and 19 deletions
+11
View File
@@ -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)