Spaces:
Sleeping
Sleeping
Commit ·
e9a56db
1
Parent(s): 46354f6
feat: show answer and hint text inline in question table
Browse files
main.py
CHANGED
|
@@ -1807,13 +1807,29 @@ async def latest_questions_page(courseId: int, chapterId: Optional[int] = None,
|
|
| 1807 |
def _row(q):
|
| 1808 |
is_dup = q.get("id") in dup_ids
|
| 1809 |
has_ans = bool((q.get("expectedAnswerText") or "").strip())
|
|
|
|
| 1810 |
row_cls = "q-row dup-row" if is_dup else "q-row"
|
| 1811 |
dup_marker = '<span class="dup-marker" title="Duplicate">⚠</span>' if is_dup else ""
|
| 1812 |
-
ans_badge = '<span class="badge badge-green">yes</span>' if has_ans else '<span class="badge badge-gray">no</span>'
|
| 1813 |
qtext = q.get("questionText") or ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1814 |
return (
|
| 1815 |
f"<tr class='{row_cls}'"
|
| 1816 |
-
f" data-id='{
|
| 1817 |
f" data-type='{html.escape(str(q.get('questionType') or '').lower())}'"
|
| 1818 |
f" data-diff='{html.escape(str(q.get('difficulty') or '').lower())}'"
|
| 1819 |
f" data-bloom='{html.escape(str(q.get('bloomLevel') or '').lower())}'"
|
|
@@ -1822,13 +1838,14 @@ async def latest_questions_page(courseId: int, chapterId: Optional[int] = None,
|
|
| 1822 |
f" data-dup='{'yes' if is_dup else 'no'}'"
|
| 1823 |
f" data-text='{html.escape(qtext.lower()[:400])}'"
|
| 1824 |
f">"
|
| 1825 |
-
f"<td><span class='badge badge-gray'>{
|
| 1826 |
f"<td>{type_badge(q.get('questionType'))}</td>"
|
| 1827 |
f"<td>{diff_badge(q.get('difficulty'))}</td>"
|
| 1828 |
f"<td><span class='badge badge-gray'>{html.escape(str(q.get('bloomLevel', '') or ''))}</span></td>"
|
| 1829 |
f"<td>{status_badge(q.get('status'))}</td>"
|
| 1830 |
f"<td class='img-cell'>{img_tag(q)}</td>"
|
| 1831 |
-
f"<td>{
|
|
|
|
| 1832 |
f"<td class='text-cell' title='{html.escape(qtext)}'>{html.escape(trunc(qtext))}</td>"
|
| 1833 |
f"</tr>"
|
| 1834 |
)
|
|
@@ -1849,7 +1866,7 @@ async def latest_questions_page(courseId: int, chapterId: Optional[int] = None,
|
|
| 1849 |
<div class="tbl-wrap">
|
| 1850 |
<table>
|
| 1851 |
<thead><tr>
|
| 1852 |
-
<th>ID</th><th>Type</th><th>Difficulty</th><th>Bloom</th><th>Status</th><th>Image</th><th>Answer</th><th>Question text</th>
|
| 1853 |
</tr></thead>
|
| 1854 |
<tbody>{q_rows}</tbody>
|
| 1855 |
</table>
|
|
@@ -1982,6 +1999,11 @@ async def latest_questions_page(courseId: int, chapterId: Optional[int] = None,
|
|
| 1982 |
.badge-red {{ background: #fee2e2; color: #dc2626; }}
|
| 1983 |
/* Image cell */
|
| 1984 |
.img-cell img {{ max-width: 120px; max-height: 90px; border: 1px solid #e2e8f0; border-radius: 5px; display: block; cursor: zoom-in; object-fit: contain; }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1985 |
/* Batch groups */
|
| 1986 |
.batch-block {{ margin-bottom: 16px; }}
|
| 1987 |
.batch-header {{ display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }}
|
|
|
|
| 1807 |
def _row(q):
|
| 1808 |
is_dup = q.get("id") in dup_ids
|
| 1809 |
has_ans = bool((q.get("expectedAnswerText") or "").strip())
|
| 1810 |
+
has_hint = bool((q.get("hints") or "").strip())
|
| 1811 |
row_cls = "q-row dup-row" if is_dup else "q-row"
|
| 1812 |
dup_marker = '<span class="dup-marker" title="Duplicate">⚠</span>' if is_dup else ""
|
|
|
|
| 1813 |
qtext = q.get("questionText") or ""
|
| 1814 |
+
ans_text = html.escape(q.get("expectedAnswerText") or "")
|
| 1815 |
+
hint_text = html.escape(q.get("hints") or "")
|
| 1816 |
+
rid = q.get("id")
|
| 1817 |
+
|
| 1818 |
+
# Answer cell: show text inline if present, else muted dash
|
| 1819 |
+
if has_ans:
|
| 1820 |
+
ans_cell = f'<div class="ans-text">{ans_text}</div>'
|
| 1821 |
+
else:
|
| 1822 |
+
ans_cell = '<span class="muted">—</span>'
|
| 1823 |
+
|
| 1824 |
+
# Hint cell
|
| 1825 |
+
if has_hint:
|
| 1826 |
+
hint_cell = f'<div class="hint-text">{hint_text}</div>'
|
| 1827 |
+
else:
|
| 1828 |
+
hint_cell = '<span class="muted">—</span>'
|
| 1829 |
+
|
| 1830 |
return (
|
| 1831 |
f"<tr class='{row_cls}'"
|
| 1832 |
+
f" data-id='{rid}'"
|
| 1833 |
f" data-type='{html.escape(str(q.get('questionType') or '').lower())}'"
|
| 1834 |
f" data-diff='{html.escape(str(q.get('difficulty') or '').lower())}'"
|
| 1835 |
f" data-bloom='{html.escape(str(q.get('bloomLevel') or '').lower())}'"
|
|
|
|
| 1838 |
f" data-dup='{'yes' if is_dup else 'no'}'"
|
| 1839 |
f" data-text='{html.escape(qtext.lower()[:400])}'"
|
| 1840 |
f">"
|
| 1841 |
+
f"<td><span class='badge badge-gray'>{rid}</span>{dup_marker}</td>"
|
| 1842 |
f"<td>{type_badge(q.get('questionType'))}</td>"
|
| 1843 |
f"<td>{diff_badge(q.get('difficulty'))}</td>"
|
| 1844 |
f"<td><span class='badge badge-gray'>{html.escape(str(q.get('bloomLevel', '') or ''))}</span></td>"
|
| 1845 |
f"<td>{status_badge(q.get('status'))}</td>"
|
| 1846 |
f"<td class='img-cell'>{img_tag(q)}</td>"
|
| 1847 |
+
f"<td class='ans-cell'>{ans_cell}</td>"
|
| 1848 |
+
f"<td class='hint-cell'>{hint_cell}</td>"
|
| 1849 |
f"<td class='text-cell' title='{html.escape(qtext)}'>{html.escape(trunc(qtext))}</td>"
|
| 1850 |
f"</tr>"
|
| 1851 |
)
|
|
|
|
| 1866 |
<div class="tbl-wrap">
|
| 1867 |
<table>
|
| 1868 |
<thead><tr>
|
| 1869 |
+
<th>ID</th><th>Type</th><th>Difficulty</th><th>Bloom</th><th>Status</th><th>Image</th><th>Answer</th><th>Hint</th><th>Question text</th>
|
| 1870 |
</tr></thead>
|
| 1871 |
<tbody>{q_rows}</tbody>
|
| 1872 |
</table>
|
|
|
|
| 1999 |
.badge-red {{ background: #fee2e2; color: #dc2626; }}
|
| 2000 |
/* Image cell */
|
| 2001 |
.img-cell img {{ max-width: 120px; max-height: 90px; border: 1px solid #e2e8f0; border-radius: 5px; display: block; cursor: zoom-in; object-fit: contain; }}
|
| 2002 |
+
/* Answer / hint cells */
|
| 2003 |
+
.ans-cell, .hint-cell {{ max-width: 260px; }}
|
| 2004 |
+
.ans-text, .hint-text {{ font-size: 0.78rem; line-height: 1.6; white-space: pre-wrap; overflow-x: auto; }}
|
| 2005 |
+
.hint-text {{ color: #64748b; font-style: italic; }}
|
| 2006 |
+
body.dark .hint-text {{ color: #475569; }}
|
| 2007 |
/* Batch groups */
|
| 2008 |
.batch-block {{ margin-bottom: 16px; }}
|
| 2009 |
.batch-header {{ display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }}
|