Repository navigation
Conversation
|
Thanks for the pull request, @tecoholic! 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. 🔘 Update the status of your PRYour PR is currently marked as a draft. After completing the steps above, update its status by clicking "Ready for Review", or removing "WIP" from the title, as appropriate. Where 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. |
|
@tecoholic would you mind rebasing on #316 and configuring it on Github as a stacked PR (if it doesn't do it automatically)? That should make it easier to review the changes. :) There has also been some data structure changes yesterday (mostly just renaming). |
samuelallan72
left a comment
There was a problem hiding this comment.
@tecoholic I know this is still in draft, but while I was here, I did a bit of a code review pass. :)
49c67cd to
66c57b5
Compare
Migrate the XBlock from https://github.com/edx/gamesxblock to this repository. In the process, split them into two separate xblocks: matching and flashcards. Also do some rework on the new blocks to modernise the code, remove unused functions, etc. Private-ref: https://tasks.opencraft.com/browse/BB-11332
A Vite dev env is added to the "assets" directory of xblock_flashcards and is auto-loaded as an npm workspace to existing build pipeline. The Vite build is configured to emit `public/js/flashcard.js` and follows the same convention as existing npm build artifacts in the repository. The component can also be independently developed and test by using the vite development server via npm dev. Internal-ref: https://tasks.opencraft.com/browse/BB-11335
66c57b5 to
6767878
Compare
@samuelallan72 Unfortunately, Stacked PRs currently work only for the PRs created on the same fork and not across forks. So, this will have to be manually rebased. :( |
There was a problem hiding this comment.
@tecoholic thanks, this is working pretty well for me! I left several comments and requests though, please take a look. :)
Note that the core functionality was working well for me. I know we want to get this shipped for our client asap. The only strong functional blocking issue I found was that the js bundle must be committed to the repo, otherwise a clean install of the block will not have the bundle available. Everything else is general UI tweaks, code quality, improvements for maintainability, etc.
Feel free to resolve my comments from my previous review pass; I don't have permission.
| @@ -0,0 +1,57 @@ | |||
| # Flashcards XBlock frontend | |||
There was a problem hiding this comment.
I think this readme can be improved; I found it a little hard to follow.
| npm run format # oxfmt | ||
| ``` | ||
|
|
||
| The build output in `../public/` is git-ignored similar to other NPM workspaces. |
There was a problem hiding this comment.
The build output actually must not be gitignored - it must be committed, because there is currently no clean way to build the bundle when the xblock is installed. cc @Kelketek unless there have been recent developments?
I think here we'll need to:
- update the gitignores so this public dir is not gitignored
- build and commit the bundle
- add a step to the CI workflows that verifies the committed bundle is up to date with the source code.
There was a problem hiding this comment.
@samuelallan72 That's needed only for repos that doesn't have PyPI builds. For this repo the JS build files are explicitly ignored and built by the CI during a release.
There was a problem hiding this comment.
@tecoholic ah ok that's cool. What about for installing from a git ref though? 🤔
|
|
||
| ## Development | ||
|
|
||
| ```sh |
There was a problem hiding this comment.
Can we add a brief but helpful workflow for development maybe? This is mostly just a list of the available npm scripts, which will be outdated easily.
| <div className="flashcards-startpage"> | ||
| <h3>{formatMessage(messages.startMsg)}</h3> | ||
| <Button | ||
| variant="brand" |
There was a problem hiding this comment.
I think "primary" variant might work better here, and look closer to the existing games xblock?
| </div> | ||
| <Row className="flashcards-header"> | ||
| <Col> | ||
| <h1>{titleText}</h1> |
|
|
||
| .flashcard-wrapper { | ||
| position: relative; | ||
| min-height: 24rem; |
There was a problem hiding this comment.
Is this the equivalent to the 385px in App.css? If so, I think the value needs to be standardised and perhaps deduplicated
| expect(container.querySelector('.flashcard-wrapper')).toHaveClass( | ||
| 'flipped', | ||
| ); | ||
| expect(container.querySelector('.flashcard-front')).toHaveAttribute( | ||
| 'aria-hidden', | ||
| 'true', | ||
| ); | ||
| expect(container.querySelector('.flashcard-back')).toHaveAttribute( | ||
| 'aria-hidden', | ||
| 'false', | ||
| ); |
There was a problem hiding this comment.
Rather than query selectors, we should prefer selectors based on visual/textual information, such as what a user would see. Eg. here rather than looking for the "flipped" class or "aria-hidden", look for the absence or presence of expected card text.
| it('falls back to the default title when the display name is empty', () => { | ||
| renderApp({ displayName: '' }); |
There was a problem hiding this comment.
When would the displayname be empty? I think we can just rely on the displayname.
| @@ -0,0 +1,76 @@ | |||
| /** | |||
There was a problem hiding this comment.
Can we use https://github.com/open-craft/xblock-react-utils for managing the shadow root and such? Then we don't need to hand roll this again.
There was a problem hiding this comment.
Replaced the custom implementation with xblock-react-utils.
| * Rewrites a selector written for a document so that it applies inside a | ||
| * shadow root: `:root` and `html` become `:host`, `body` becomes the element | ||
| * React renders into. | ||
| */ | ||
| export const scopeSelector = (selector: string): string => | ||
| selector | ||
| .replace(/:root(?![\w-])/g, ':host') | ||
| .replace(/(^|[\s,>+~(])html(?![\w-])/g, '$1:host') |
There was a problem hiding this comment.
Just noting that this is being addressed in Paragon at openedx/paragon#4282 . https://github.com/open-craft/xblock-react-utils manages a workaround too I believe.
There was a problem hiding this comment.
The custom implementation was an experiment for 2 reasons:
- xblock-react-utils solves only 1 half of the problem - it allows the XBlock specific styles and paragon to be used in the xblock reliability. But it doesn't prevent the xblock using paragon from affecting the other blocks. See these 2 units side by side, the left one has a Keypoints Block and the right one doesn't. That's the only difference.
- the other utilities provided by the xblock-react-utils are focused on the Editor that this block doesn't ship from here.
So, this hand-rolled version was able to accomplish everything needed for this block without adding an external dependency. I have replaced it now with react-utils as I intend to "upstream" the style isolation fix.


follow up PR after #316
Testing instructions
Prerequisites
masterTutor devstack (with feat!: replace xblocks-contrib with xblocks-core 2.0.0 openedx-platform#38473). If updating from an existing devstack, uninstallxblocks-contrib(pip uninstall xblocks-contrib) to avoid conflicting entry points.Environment setup
xblocks-core(note that the Vite bundle insrc/xblock_flashcards/public/flashcards.jsis git-ignored and must be built before testing):xblocks-corein editable mode inlmsandcms:(If your devstack already has up-to-date
openedx-devandauthoring-devimages, you can usetutor config save && tutor dev start -dinstead oftutor dev launch -I.)Manual verification in Studio and LMS
"openedx_flashcards"to Settings -> Advanced Settings -> Advanced Module List.EnterandSpace—to confirm it flips cleanly between front and back and renders both text and images properly.ArrowLeft/ArrowRightkeys; verify thecurrent/totalcounter updates, previous/next buttons disable on the first/last card, and switching cards resets the card face to the front.?help icon in the bottom-right corner and verify the Paragon tooltip renders with styling inside the block.Automated tests
cd src/xblock_flashcards/assets && npm testpytest src/xblock_flashcards(ormake test)Merge checklist:
Check off if complete or not applicable: