Skip to content

Commit

Permalink
refactor: QuestionDisplayOptions.feedback renamed to specific_feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinGauk committed Oct 29, 2024
1 parent 3f8a855 commit 340be86
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion questionpy_sdk/webserver/attempt.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def get_attempt_render_context(
context["general_feedback"] = html
if errors:
context["render_errors"]["General Feedback"] = errors
if display_options.feedback and attempt.ui.specific_feedback:
if display_options.specific_feedback and attempt.ui.specific_feedback:
html, errors = QuestionUIRenderer(attempt.ui.specific_feedback, *renderer_args).render()
context["specific_feedback"] = html
if errors:
Expand Down
4 changes: 2 additions & 2 deletions questionpy_sdk/webserver/question_ui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class QuestionDisplayRole(StrEnum):

class QuestionDisplayOptions(BaseModel):
general_feedback: bool = True
feedback: bool = True
specific_feedback: bool = True
right_answer: bool = True
roles: set[QuestionDisplayRole] = {
QuestionDisplayRole.DEVELOPER,
Expand Down Expand Up @@ -323,7 +323,7 @@ def _hide_unwanted_feedback(self) -> None:
# Check conditions to remove the element
if not (
(feedback_type == "general" and self._options.general_feedback)
or (feedback_type == "specific" and self._options.feedback)
or (feedback_type == "specific" and self._options.specific_feedback)
):
_remove_element(element)

Expand Down
2 changes: 1 addition & 1 deletion questionpy_sdk/webserver/routes/attempt.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ async def get_attempt(request: web.Request) -> web.Response:
if not score:
# TODO: Allow manually set display options to override this.
display_options.readonly = False
display_options.general_feedback = display_options.feedback = display_options.right_answer = False
display_options.general_feedback = display_options.specific_feedback = display_options.right_answer = False

context = get_attempt_render_context(
attempt,
Expand Down
2 changes: 1 addition & 1 deletion tests/questionpy_sdk/webserver/test_question_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def test_should_resolve_placeholders(renderer: QuestionUIRenderer) -> None:


@pytest.mark.ui_file("feedbacks")
@pytest.mark.render_params(options=QuestionDisplayOptions(general_feedback=False, feedback=False))
@pytest.mark.render_params(options=QuestionDisplayOptions(general_feedback=False, specific_feedback=False))
def test_should_hide_inline_feedback(renderer: QuestionUIRenderer) -> None:
expected = """
<div>
Expand Down

0 comments on commit 340be86

Please sign in to comment.