Repository navigation
fix: close the Poll gaps from the built-in block - #364
irfanuddinahmad wants to merge 1 commit into
Conversation
- Escape the configuration JSON in the template and read it with .text() in poll.js. A question or answer with an HTML attribute, "<" or "&" broke JSON.parse, and the poll rendered empty. - Show answers as plain text and the question as HTML, as the built-in block did. - Restore the built-in stylesheet scoped to the block's root (div.poll_question). The unscoped copy made every <p> on the page bold and justified, and the scoped copy targeted the XModule wrapper, which the extracted block doesn't have. - Only reset a vote when the learner has voted and the poll allows it (reset="false"), as the built-in block did. Resetting before voting raised a KeyError. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for the pull request, @irfanuddinahmad! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
Summary
Changes
<or&poll.htmlno longer uses|safeon the configuration JSON, so Django escapes it;poll.jsreads and writes it with.text(). As in the built-in block, the question renders as HTML and answers as plain text.poll.cssis the built-in stylesheet with its.xmodule_display.xmodule_PollBlock div.poll_questionscope replaced by the block's own root,div.poll_questionhandle_reset_staterefuses ({"error": "Unknown Command!"}, as the built-in did) unless the learner has voted and the OLX doesn't setreset="false"Not changed (smaller differences from the built-in, left for a follow-up if wanted): the "XML data format changed" error when the answer list no longer matches stored votes, and
display_name's default ("poll_question"instead of none).Test plan
6 new tests in
src/xblock_poll_question/tests/test_poll.py. 5 fail onmain;test_reset_after_votechecks the happy path, which already worked.test_configuration_json_survives_htmlrendersstudent_viewwith a link,<and&, and parses the hidden div's text the waypoll.jsdoes.test_reset_after_vote,test_reset_without_vote,test_reset_disabled.test_js_reads_configuration_as_text,test_css_rules_are_scoped_to_the_block.pytest src: 870 passed.ruff check,ruff format --checkandpylint src/xblock_poll_questionare clean.Live in a local Tutor (platform master, xblocks-core 4.0.0 with this PR's four Poll files on top; Poll is unchanged between 4.0.0 and
main), as a learner, in a unit with a plain poll, a poll whose question has a link, and a Problem:<p>in the same unitfont-weight: 700,text-align: justify400,leftCloses #363. Part of the Slash-n-Burn Built-In XBlocks epic.
🤖 Generated with Claude Code