Browse Source

fix: set new variable gameId when on Moodle

lairaalmas 1 year ago
parent
commit
5d0f274757
1 changed files with 18 additions and 6 deletions
  1. 18 6
      js/moodle/integrationFunctions.js

+ 18 - 6
js/moodle/integrationFunctions.js

@@ -237,6 +237,24 @@ const breakString = function (text) {
 const updateGlobalVariables = function (infoGame, infoResults) {
   // Update game variables to content received from game file
   gameName = infoGame['gameName'];
+  if (infoGame['gameID']) {
+    gameId = infoGame['gameId'];
+  } else {
+    switch (gameName) {
+      case 'squareOne':
+        gameId = 0;
+        break;
+      case 'circleOne':
+        gameId = 1;
+        break;
+      case 'squareTwo':
+        gameId = 2;
+        break;
+      default:
+        gameId = 0;
+    }
+  }
+
   gameShape = infoGame['gameShape'];
   gameMode = infoGame['gameMode'];
   gameOperation = infoGame['gameOperation'];
@@ -260,9 +278,3 @@ const updateGlobalVariables = function (infoGame, infoResults) {
     game.state.start('customMenu');
   }
 };
-
-moodleVar = {
-  hits: [0, 0, 0, 0],
-  errors: [0, 0, 0, 0],
-  time: [0, 0, 0, 0],
-};