Skip to content

Commit

Permalink
qst: add showResult markup option
Browse files Browse the repository at this point in the history
The new markup option allows to hide the results of the question (the explanations and points) but still allow showing points. This may be needed in courses where a student has one chance to answer the question and see the points, but not see the correct result.
  • Loading branch information
dezhidki committed Nov 13, 2024
1 parent e5945fc commit a697237
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions timApp/plugin/qst/qst.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ class Meta:
# TODO: Convert old QST formats to the new format in production
json: dict[Any, Any] | None | Missing = missing
title: str | None | Missing = missing
showResult: bool | None | Missing = missing


QstBasicState = list[list[str]]
Expand Down Expand Up @@ -250,7 +251,14 @@ def qst_answer_jso(m: QstAnswerModel):
show_points = (
info.show_points if info is not None and info.show_points is not None else True
)
if not show_points:
show_result = True
if isinstance(m.markup.showResult, bool) and not m.markup.showResult:
show_result = False

if not show_result:
result = False

if not show_points or not show_result:
jsonmarkup.pop("expl", None)
jsonmarkup.pop("points", None)
jsonmarkup.pop("defaultPoints", None)
Expand Down Expand Up @@ -723,7 +731,8 @@ def qst_try_hide_points(jso):
info, "earlier_answers", 0
)
show_points = info.get("show_points", True) if info is not None else True
if not limit_reached or not show_points:
show_result = markup.get("showResult", True)
if not show_result or not limit_reached or not show_points:
markup.pop("points", None)
markup.pop("expl", None)
markup.pop("defaultPoints", None)
Expand Down

0 comments on commit a697237

Please sign in to comment.