Add inline full-content review panel for child variants before approval
This commit is contained in:
@@ -663,6 +663,26 @@ def _basis_item_workspace_body(
|
|||||||
variant_rows = []
|
variant_rows = []
|
||||||
for item in variants:
|
for item in variants:
|
||||||
usage = usage_by_item.get(item.id, {"impressions": 0.0, "unique_users": 0.0, "frequency": 0.0})
|
usage = usage_by_item.get(item.id, {"impressions": 0.0, "unique_users": 0.0, "frequency": 0.0})
|
||||||
|
options = item.options if isinstance(item.options, dict) else {}
|
||||||
|
options_rows = "".join(
|
||||||
|
f"<tr><td style=\"padding:6px 8px;border-bottom:1px solid #e5e7eb;\"><strong>{escape(str(key))}</strong></td>"
|
||||||
|
f"<td style=\"padding:6px 8px;border-bottom:1px solid #e5e7eb;\">{escape(str(value))}</td></tr>"
|
||||||
|
for key, value in options.items()
|
||||||
|
) or "<tr><td colspan=\"2\" style=\"padding:6px 8px;\">No options</td></tr>"
|
||||||
|
review_html = (
|
||||||
|
"<details style=\"margin-top:8px;\">"
|
||||||
|
"<summary style=\"cursor:pointer;color:#0f172a;font-weight:600;\">Review full content</summary>"
|
||||||
|
f"<div style=\"margin-top:8px;padding:10px;border:1px solid #e2e8f0;border-radius:8px;background:#f8fafc;\">"
|
||||||
|
f"<p style=\"margin:0 0 8px;\"><strong>Full Stem</strong><br>{escape(_html_to_text(item.stem))}</p>"
|
||||||
|
"<table style=\"margin:0 0 8px;width:100%;border-collapse:collapse;\">"
|
||||||
|
"<thead><tr><th style=\"text-align:left;padding:6px 8px;background:#eef2ff;\">Option</th><th style=\"text-align:left;padding:6px 8px;background:#eef2ff;\">Text</th></tr></thead>"
|
||||||
|
f"<tbody>{options_rows}</tbody>"
|
||||||
|
"</table>"
|
||||||
|
f"<p style=\"margin:0 0 6px;\"><strong>Correct Answer:</strong> {escape(item.correct_answer or '-')}</p>"
|
||||||
|
f"<p style=\"margin:0;\"><strong>Explanation:</strong> {escape(_html_to_text(item.explanation) or '-')}</p>"
|
||||||
|
"</div>"
|
||||||
|
"</details>"
|
||||||
|
)
|
||||||
variant_rows.append(
|
variant_rows.append(
|
||||||
"<tr>"
|
"<tr>"
|
||||||
f"<td><input type=\"checkbox\" name=\"item_ids\" value=\"{item.id}\"></td>"
|
f"<td><input type=\"checkbox\" name=\"item_ids\" value=\"{item.id}\"></td>"
|
||||||
@@ -674,7 +694,7 @@ def _basis_item_workspace_body(
|
|||||||
f"<td>{int(usage['impressions'])}</td>"
|
f"<td>{int(usage['impressions'])}</td>"
|
||||||
f"<td>{int(usage['unique_users'])}</td>"
|
f"<td>{int(usage['unique_users'])}</td>"
|
||||||
f"<td>{usage['frequency']:.2f}</td>"
|
f"<td>{usage['frequency']:.2f}</td>"
|
||||||
f"<td>{escape(_truncate(item.stem, 130))}</td>"
|
f"<td>{escape(_truncate(_html_to_text(item.stem), 130))}{review_html}</td>"
|
||||||
f"<td>{escape(str(item.created_at))}</td>"
|
f"<td>{escape(str(item.created_at))}</td>"
|
||||||
"</tr>"
|
"</tr>"
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user