|
533 | 533 | - <plain>bar |
534 | 534 | """ |
535 | 535 |
|
| 536 | +INLINE_MULTI_MARKDOWN_BLOCK_BLANKS = """ |
| 537 | +type: InlineMultiQuestion |
| 538 | +id: inlinemulti |
| 539 | +value: 10 |
| 540 | +prompt: | |
| 541 | +
|
| 542 | + # An InlineMultiQuestion example |
| 543 | +
|
| 544 | + Questions with blanks on their own paragraphs. |
| 545 | +
|
| 546 | +question: | |
| 547 | +
|
| 548 | + Text before the first blank. |
| 549 | +
|
| 550 | + [[blank1]] |
| 551 | +
|
| 552 | + Text between the two blanks. |
| 553 | +
|
| 554 | + [[blank2]] |
| 555 | +
|
| 556 | +answers: |
| 557 | +
|
| 558 | + blank1: |
| 559 | + type: ShortAnswer |
| 560 | + width: 4em |
| 561 | + correct_answer: |
| 562 | + - <plain> FOO |
| 563 | + - <plain>foo |
| 564 | +
|
| 565 | + blank2: |
| 566 | + type: ShortAnswer |
| 567 | + width: 4em |
| 568 | + correct_answer: |
| 569 | + - <plain> BAR |
| 570 | + - <plain>bar |
| 571 | +
|
| 572 | +""" |
| 573 | + |
536 | 574 | INLINE_MULTI_MARKDOWN_NO_ANSWER_FIELD = """ |
537 | 575 | type: InlineMultiQuestion |
538 | 576 | id: inlinemulti |
@@ -817,6 +855,54 @@ def test_embedded_question_no_extra_html(self): |
817 | 855 | # There's no html string between rendered blank1 field and blank2 field |
818 | 856 | self.assertIn('</div> <div id="div_id_blank2"', resp.content.decode()) |
819 | 857 |
|
| 858 | + def test_block_blank_no_flex_container_on_text_paragraphs(self): |
| 859 | + """Regression test: text-only paragraphs must not be wrapped in a |
| 860 | + flex (``input-group``) container when blanks appear on their own |
| 861 | + paragraphs (i.e. separated from surrounding text by blank lines).""" |
| 862 | + markdown = INLINE_MULTI_MARKDOWN_BLOCK_BLANKS |
| 863 | + resp = self.get_page_sandbox_preview_response(markdown) |
| 864 | + self.assertEqual(resp.status_code, 200) |
| 865 | + self.assertSandboxHasValidPage(resp) |
| 866 | + |
| 867 | + content = resp.content.decode() |
| 868 | + |
| 869 | + # Text-only paragraphs must keep their <p> wrapper and must NOT |
| 870 | + # be placed inside an ``input-group`` flex container. |
| 871 | + self.assertIn("<p>Text before the first blank.</p>", content) |
| 872 | + self.assertIn("<p>Text between the two blanks.</p>", content) |
| 873 | + |
| 874 | + # The text paragraphs must not be inside flex containers. |
| 875 | + self.assertNotIn( |
| 876 | + 'class="input-group gap-1 align-items-center">' |
| 877 | + "Text before the first blank.", |
| 878 | + content) |
| 879 | + self.assertNotIn( |
| 880 | + 'class="input-group gap-1 align-items-center">' |
| 881 | + "Text between the two blanks.", |
| 882 | + content) |
| 883 | + |
| 884 | + # The form fields must still be present. |
| 885 | + self.assertIn('id="div_id_blank1"', content) |
| 886 | + self.assertIn('id="div_id_blank2"', content) |
| 887 | + |
| 888 | + # Submitting correct answers should work normally. |
| 889 | + resp = self.get_page_sandbox_submit_answer_response( |
| 890 | + markdown, |
| 891 | + answer_data={"blank1": "foo", "blank2": "bar"}) |
| 892 | + self.assertResponseContextAnswerFeedbackCorrectnessEquals(resp, 1) |
| 893 | + |
| 894 | + def test_inline_blank_uses_flex_container(self): |
| 895 | + """Blanks appearing inline with text (on the same paragraph line) |
| 896 | + must still be wrapped in a flex container for proper inline layout.""" |
| 897 | + markdown = INLINE_MULTI_MARKDOWN_SINGLE |
| 898 | + resp = self.get_page_sandbox_preview_response(markdown) |
| 899 | + self.assertEqual(resp.status_code, 200) |
| 900 | + self.assertSandboxHasValidPage(resp) |
| 901 | + |
| 902 | + content = resp.content.decode() |
| 903 | + # The paragraph with an inline blank should be wrapped in a flex container. |
| 904 | + self.assertIn('class="input-group gap-1 align-items-center', content) |
| 905 | + |
820 | 906 | def test_embedded_weight_count(self): |
821 | 907 | markdown = (INLINE_MULTI_MARKDOWN_EMBEDDED_ATTR_PATTERN |
822 | 908 | % {"attr1": "weight: 15", |
|
0 commit comments