Skip to content

fix: Feat/flash cards UI#12

Merged
papphelix merged 8 commits intomainfrom
feat/flash-cards-ui
Nov 26, 2025
Merged

fix: Feat/flash cards UI#12
papphelix merged 8 commits intomainfrom
feat/flash-cards-ui

Conversation

@papphelix
Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings November 25, 2025 06:26

This comment was marked as resolved.

Copilot AI review requested due to automatic review settings November 25, 2025 06:33

This comment was marked as resolved.

Copilot AI review requested due to automatic review settings November 25, 2025 07:08

This comment was marked as resolved.

Copilot AI review requested due to automatic review settings November 25, 2025 11:24

This comment was marked as resolved.

Comment thread games/handlers/common.py
Comment thread games/handlers/common.py Outdated
Comment thread games/handlers/flashcards.py
Comment thread games/handlers/flashcards.py Outdated
Comment thread games/static/css/flashcards.css Outdated
Comment thread games/static/css/flashcards.css Outdated
Comment thread games/static/css/flashcards.css
Comment thread games/static/html/flashcards.html
Comment thread games/static/css/matching.css
Copilot AI review requested due to automatic review settings November 25, 2025 14:14

This comment was marked as resolved.

@papphelix papphelix requested a review from Faraz32123 November 26, 2025 05:39
Copilot AI review requested due to automatic review settings November 26, 2025 08:23
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 8 comments.

Comments suppressed due to low confidence (2)

games/static/js/src/matching.js:113

  • The matching boxes only support mouse clicks but lack keyboard event handlers. For accessibility, keyboard navigation should be added to support users who rely on keyboards or assistive technologies. Consider adding keydown event handlers that allow Enter or Space to select boxes, similar to how flashcards.js implements keyboard navigation (lines 100-119).
    $('.matching-box', element).off('click').on('click', function() {
        const box = $(this);
        const text = box.text().trim();
        if (matched.has(text)) return; // already matched

        // Toggle off if re-click first
        if (firstSelection && firstSelection[0].is(box)) {
            clearSelectionVisual(box);
            firstSelection = null;
            return;
        }

        box.addClass('selected');

        if (!firstSelection) {
            firstSelection = [box, text];
            return;
        }

        // Second selection
        const [prevBox, prevText] = firstSelection;
        firstSelection = null;
        if (prevText === text) {
            clearSelectionVisual(prevBox);
            clearSelectionVisual(box);
            return;
        }
        const mapped = matchMap.get(prevText);
        if (mapped && mapped === text) {
            markMatch(prevBox, box);
        } else {
            markIncorrect(prevBox, box);
        }
    });

games/static/css/matching.css:179

  • This .matching-footer style block is a duplicate of lines 28-34. The duplicate definition should be removed to avoid confusion and potential maintenance issues.
.matching-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    align-self: stretch;
    margin-top: 24px;
}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

Comment thread games/handlers/common.py Outdated
Comment thread games/static/html/matching.html
Comment thread games/static/html/matching.html
Comment thread games/static/css/matching.css Outdated
Comment thread games/static/html/matching.html
Comment thread games/static/html/matching.html Outdated
Comment thread games/static/html/matching.html Outdated
Comment thread games/handlers/common.py Outdated
@papphelix papphelix changed the title Feat/flash cards UI fix: Feat/flash cards UI Nov 26, 2025
Copilot AI review requested due to automatic review settings November 26, 2025 10:49
@papphelix papphelix merged commit 8ff7ba2 into main Nov 26, 2025
6 checks passed
@papphelix papphelix deleted the feat/flash-cards-ui branch November 26, 2025 10:50
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

Comment thread games/handlers/common.py
validated_cards = []
for card in new_cards:
if not isinstance(card, dict):
if not isinstance(card, Dict):
Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The isinstance(card, Dict) check is incorrect. Dict is imported from xblock.fields and is a field type class, not a runtime type. This check will always fail because card is a plain Python dictionary from the JSON data, not an XBlock field instance.

This should be isinstance(card, dict) (lowercase) to check if it's a standard Python dictionary.

Suggested change
if not isinstance(card, Dict):
if not isinstance(card, dict):

Copilot uses AI. Check for mistakes.

function GamesXBlockFlashcardsInit(runtime, element, cards) {
'use strict';

Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing guard against multiple initializations. Similar to the matching game (lines 6-11 in matching.js), this function should check if it's already been initialized to prevent duplicate event handlers from being attached. Without this guard, if the initialization function is called multiple times, it will:

  1. Attach duplicate click handlers to the card and buttons
  2. Attach duplicate keydown handlers

Consider adding at the start:

var $element = $(element);
if ($element.data('gx_flashcards_initialized')) {
    return;
}
$element.data('gx_flashcards_initialized', true);
Suggested change
// Guard against multiple initializations
var $element = $(element);
if ($element.data('gx_flashcards_initialized')) {
return;
}
$element.data('gx_flashcards_initialized', true);

Copilot uses AI. Check for mistakes.
$card.removeClass(flipClassName);
} else {
$card.addClass(flipClassName);
}
Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The aria-pressed attribute on the flashcard element (defined in flashcards.html line 15) should be updated to reflect the flip state for screen readers. When the card is flipped, set it to "true", and when unflipped, set it to "false".

Add this to the flipCard() function:

$card.attr('aria-pressed', $card.hasClass(flipClassName) ? 'true' : 'false');
Suggested change
}
}
$card.attr('aria-pressed', $card.hasClass(flipClassName) ? 'true' : 'false');

Copilot uses AI. Check for mistakes.
Comment on lines 68 to 69
stroke-dasharray: 339.292;
stroke-dashoffset: 339.292;
Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hardcoded stroke-dasharray: 339.292 value doesn't match the actual circle's circumference. The circle now has r=25.0213 (from matching.html line 35), which gives a circumference of approximately 157.28 (2 × π × 25.0213), not 339.292.

While the JavaScript dynamically sets this value correctly (matching.js lines 42-45), having an incorrect fallback value in the CSS is misleading and could cause issues if the JavaScript fails to load. Update this to match the actual circle dimensions or remove it since JavaScript handles it dynamically.

Suggested change
stroke-dasharray: 339.292;
stroke-dashoffset: 339.292;
stroke-dasharray: 157.28;
stroke-dashoffset: 157.28;

Copilot uses AI. Check for mistakes.
Comment thread games/handlers/common.py
Comment on lines +13 to 14
from xblock.fields import Set, Dict

Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'Set' is not used.

Suggested change
from xblock.fields import Set, Dict

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants