diff --git a/games/static/js/src/matching.js b/games/static/js/src/matching.js index 122aa2d..3cbd2a0 100644 --- a/games/static/js/src/matching.js +++ b/games/static/js/src/matching.js @@ -48,7 +48,6 @@ function GamesXBlockMatchingInit(runtime, element, pages, matching_key) { } function refreshGame() { - MatchInit = null; $.ajax({ type: 'GET', url: runtime.handlerUrl(element, 'refresh_game'), @@ -61,9 +60,22 @@ function GamesXBlockMatchingInit(runtime, element, pages, matching_key) { var scriptContent = decoderScript.text(); decoderScript.remove(); try { - eval(scriptContent); - if (typeof MatchingInit === 'function') { - MatchingInit(runtime, element); + var match = scriptContent.match(/function\s+(\w+)\s*\(/); + if (match) { + var initFuncName = match[1]; + eval(scriptContent); + if (typeof window[initFuncName] === 'function') { + window[initFuncName](runtime, element); + setTimeout(function() { + $('.matching-start-button', element).click(); + }, 100); + } else { + console.error('Init function not found:', initFuncName); + window.location.reload(); + } + } else { + console.error('Could not extract function name'); + window.location.reload(); } } catch (err) { console.error('Failed to initialize game:', err); diff --git a/setup.py b/setup.py index bd30ea3..5ed83a5 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,7 @@ def package_data(pkg, roots): setup( name="edx-games", - version="1.0.8", + version="1.0.9", description="Interactive games XBlock for Open edX - Create flashcards and matching games with image support", author="edX", author_email="edx@edx.org",