Browse Source

changed the object/state 'studentReport' to its own file (/js/studentReport.js)
some variable/obj name refactoring
game.add.graphic -> game.add.geom (to create geometric figures)
gameMode, gameModeUrl and gameOperation (now without the 'Type')
fixed some images on menu that where presenting the wrong info to the user
fixed some output messages that where only in pt-br

laira 3 years ago
parent
commit
add997bd9b

BIN
assets/img/info_box/s2-A-h.png


BIN
assets/img/info_box/s2-B-h.png


BIN
assets/img/info_box/s2.png


+ 2 - 0
assets/lang/en_US

@@ -7,6 +7,8 @@ difficulties=Difficulties
 difficulty=Difficulty
 empty_name=You forgot to type your name
 equals=Equality
+error_moodle_file_ext=empty (File with extension .frc not found)
+error_must_select_game=You must select at least one game!
 game=Game
 game_mode=Game Mode
 game_modes=Game Modes

+ 2 - 0
assets/lang/es_PE

@@ -7,6 +7,8 @@ difficulties=Dificultades
 difficulty=Dificultade
 empty_name=Usted ha olvidado de escribir su nombre
 equals=Igualdad
+error_moodle_file_ext=vacío (archivo con extensión .frc no encontrado) 
+error_must_select_game=Debes seleccionar al menos un juego! 
 game=Juego
 game_mode=Modo de Juego
 game_modes=Modos de Juego

+ 2 - 0
assets/lang/fr_FR

@@ -7,6 +7,8 @@ difficulties=Difficultés
 difficulty=Difficulté
 empty_name=Vous avez oublié de taper votre nom
 equals=Égalité
+error_moodle_file_ext=empty (Fichier avec extension .frc introuvable)
+error_must_select_game=vous devez sélectionner au moins un jeu!
 game=Jeu
 game_mode=Mode de Jeu
 game_modes=Modes de Jeu

+ 2 - 0
assets/lang/it_IT

@@ -7,6 +7,8 @@ difficulties=Difficoltà
 difficulty=Difficoltà
 empty_name=Ti sei dimenticato di digitare il tuo nome
 equals=Uguaglianza
+error_moodle_file_ext=vuoto (File con estensione .frc non trovato) 
+error_must_select_game=Devi selezionare almeno un gioco!
 game=Gioco
 game_mode=Modalità di Gioco
 game_modes=Modalità di Gioco

File diff suppressed because it is too large
+ 5 - 3
assets/lang/pt_BR


+ 9 - 4
index.html

@@ -16,6 +16,11 @@ www.usp.br/line
   <link rel="stylesheet" href="css/bootstrap.min.css">
 
   <style>
+    /*
+    body, .panel-body {
+      background-color: #313857;
+    }
+    */
     #iFractions-canvas {
       padding: 0 auto 0 auto;
       margin-left: auto;
@@ -144,11 +149,11 @@ www.usp.br/line
     <script src="js/circleOne.js"></script>
     <script src="js/squareOne.js"></script>
     <script src="js/squareTwo.js"></script>
+    <script src="js/stundentReport.js"></script> <!-- FOR MOODLE -->
+    <script src="js/integrationFunctions.js"></script> <!-- FOR MOODLE -->
     <script src="js/gameMechanics.js"></script>
     <script src="js/globals.js"></script>
-    <!-- MOODLE -->
-    <script src="js/integrationFunctions.js"></script>
-
+    
     <script>
       const displayFps = document.getElementById("display-fps");
 
@@ -176,7 +181,7 @@ www.usp.br/line
       game.state.add('circleOne', circleOne);
       game.state.add('squareTwo', squareTwo);
 
-      // MOODLE
+      // FOR MOODLE
       game.state.add('studentReport', studentReport);
 
       // CALLING FIRST GAME STATE

+ 41 - 41
js/circleOne.js

@@ -12,14 +12,14 @@
  *
  * # of different difficulties : 5
  *
- * Game modes can be : 'A' or 'B' (in variable 'gameModeType')
+ * Game modes can be : 'A' or 'B' (in variable 'gameMode')
  *
  *   A : Player can place balloon position
  *       Place balloon in position (so the kid can get to it)
  *   B : Player can select # of circles
  *       Selects number of circles (that represent distance kid needs to walk to get to the balloon)
  *
- * Operations can be : 'Plus', 'Minus' or 'Mixed' (in variable 'gameOperationType')
+ * Operations can be : 'Plus', 'Minus' or 'Mixed' (in variable 'gameOperation')
  *
  *   Plus : addition of fractions
  *     Represented by : kid going to the right (floor positions 0..5)
@@ -30,7 +30,7 @@
  *
  * @namespace
  */
- const circleOne = {
+const circleOne = {
 
   /**
    * Main code
@@ -50,7 +50,7 @@
 
     let hasBaseDifficulty = false; // Will validate that level isnt too easy (has at least one '1/difficulty' fraction)
 
-    const startX = (gameOperationType == 'Minus') ? 66 + 5 * 156 : 66;  // Initial 'x' coordinate for the kid and the baloon
+    const startX = (gameOperation == 'Minus') ? 66 + 5 * 156 : 66;  // Initial 'x' coordinate for the kid and the baloon
     this.correctX = startX; // Ending position, accumulative
 
     // BACKGROUND
@@ -63,7 +63,7 @@
     game.add.image(110, 85, 'cloud', 0.8);
 
     // Add floor of grass
-    for (let i = 0; i < 9; i++) { game.add.image(i * 100, 501, 'floor'); }
+    for (let i = 0; i < 9; i++) { game.add.image(i * 100, defaultHeight - 100, 'floor'); }
 
     // Road
     this.road = game.add.image(47, 515, 'road', 1.01, 0.94);
@@ -76,12 +76,12 @@
       game.add.text(66 + i * distanceBetweenPoints, 560, i, textStyles.h2_blue);
     }
 
-    this.trace = game.add.graphic.rect(startX - 1, 526, 1, 1, undefined, 1);
+    this.trace = game.add.geom.rect(startX - 1, 526, 1, 1, undefined, 1);
     this.trace.alpha = 0;
 
     // Calls function that loads navigation icons
 
-    // MOODLE
+    // FOR MOODLE
     if (moodle) {
       navigationIcons.func_addIcons(
         false, false, false, // Left buttons
@@ -114,16 +114,16 @@
     this.balloonPlace = defaultWidth / 2; // Balloon place
 
     // Number of circles
-    const max = (gameOperationType == 'Mixed' || gameModeType == 'B') ? 6 : mapPosition + 1;
-    const min = (gameOperationType == 'Mixed' && mapPosition < 2) ? 2 : mapPosition; // Mixed level has at least 2 fractions
+    const max = (gameOperation == 'Mixed' || gameMode == 'B') ? 6 : mapPosition + 1;
+    const min = (gameOperation == 'Mixed' && mapPosition < 2) ? 2 : mapPosition; // Mixed level has at least 2 fractions
     const total = game.math.randomInRange(min, max); // Total number of circles
 
-    // gameModeType 'B' exclusive variables
+    // gameMode 'B' exclusive variables
     this.fractionIndex = -1; // Index of clicked circle (game B)
     this.numberOfPlusFractions = game.math.randomInRange(1, total - 1);
 
     // CIRCLES
-    const levelDirection = (gameOperationType == 'Minus') ? -1 : 1;
+    const levelDirection = (gameOperation == 'Minus') ? -1 : 1;
     const x = startX + 65 * levelDirection;
 
     for (let i = 0; i < total; i++) {
@@ -137,7 +137,7 @@
       // Set each circle direction
       let direction;
 
-      switch (gameOperationType) {
+      switch (gameOperation) {
         case 'Plus': direction = 'Right'; break;
         case 'Minus': direction = 'Left'; break;
         case 'Mixed':
@@ -165,7 +165,7 @@
       let circle, label = [];
 
       if (divisor == 1) {
-        circle = game.add.graphic.circle(startX, 490 - i * this.circles.diameter, this.circles.diameter,
+        circle = game.add.geom.circle(startX, 490 - i * this.circles.diameter, this.circles.diameter,
           lineColor, 2, colors.white, 1);
 
         circle.anticlockwise = anticlockwise;
@@ -181,7 +181,7 @@
 
         if (direction == 'Right') degree = 360 - degree; // Anticlockwise equivalent
 
-        circle = game.add.graphic.arc(startX, 490 - i * this.circles.diameter, this.circles.diameter,
+        circle = game.add.geom.arc(startX, 490 - i * this.circles.diameter, this.circles.diameter,
           0, game.math.degreeToRad(degree), anticlockwise,
           lineColor, 2, colors.white, 1);
 
@@ -198,7 +198,7 @@
       circle.rotate = 90;
 
       // If game is type B (select fractions)
-      if (gameModeType == 'B') {
+      if (gameMode == 'B') {
         circle.alpha = 0.5;
         circle.index = i;
       }
@@ -220,7 +220,7 @@
     }
 
     // If game is type B, selectiong a random balloon place
-    if (gameModeType == 'B') {
+    if (gameMode == 'B') {
       this.balloonPlace = startX;
       this.endIndex = game.math.randomInRange(this.numberOfPlusFractions, this.circles.all.length);
 
@@ -240,7 +240,7 @@
 
     this.kid = game.add.sprite(startX, 495 - this.circles.all.length * this.circles.diameter, 'kid_walk', 0, 0.8);
     this.kid.anchor(0.5, 0.8);
-    if (gameOperationType == 'Minus') {
+    if (gameOperation == 'Minus') {
       this.kid.animation = this.availableAnimations['Left'];
       this.kid.curFrame = 23;
     } else {
@@ -276,23 +276,23 @@
     // Start animation
     if (self.animate) {
       let cur = self.circles.cur;
-      let DIREC = self.circles.direc[cur];
+      let direc = self.circles.direc[cur];
 
       if (self.count % 2 == 0) { // Lowers animation
         // Move kid
-        self.kid.x += 2 * DIREC;
+        self.kid.x += 2 * direc;
 
         // Move circles
         for (let i in self.circles.all) {
-          self.circles.all[i].x += 2 * DIREC;
+          self.circles.all[i].x += 2 * direc;
         }
 
         // Manage line on the floor
-        self.trace.width += 2 * DIREC;
+        self.trace.width += 2 * direc;
         self.trace.lineColor = self.circles.all[cur].lineColor;
 
         // Change angle of current arc
-        self.circles.angle[cur] += 4.6 * DIREC;
+        self.circles.angle[cur] += 4.6 * direc;
         self.circles.all[cur].angleEnd = game.math.degreeToRad(self.circles.angle[cur]);
 
         // When finish current circle
@@ -332,9 +332,9 @@
           self.circles.cur++; // Update current circle
 
           cur = self.circles.cur;
-          DIREC = self.circles.direc[cur];
+          direc = self.circles.direc[cur];
 
-          self.nextX += self.circles.distance[cur] * DIREC; // Update next position
+          self.nextX += self.circles.distance[cur] * direc; // Update next position
         }
 
         // When finish all circles (final position)
@@ -403,7 +403,7 @@
     const y = mouseEvent.offsetY;
 
     // GAME MODE A : click road
-    if (gameModeType == 'A') {
+    if (gameMode == 'A') {
       const cur = self.road;
 
       const valid = y > 60 && (x >= cur.xWithAnchor && x <= (cur.xWithAnchor + cur.width * cur.scale));
@@ -411,7 +411,7 @@
     }
 
     // GAME MODE B : click circle
-    if (gameModeType == 'B') {
+    if (gameMode == 'B') {
       self.circles.all.forEach(cur => {
         const valid = game.math.distanceToPointer(x, cur.xWithAnchor, y, cur.yWithAnchor) <= (cur.diameter / 2) * cur.scale;
         if (valid) self.func_clicked(cur);
@@ -434,7 +434,7 @@
     let flag = false;
 
     // GAME MODE A : balloon follow mouse
-    if (gameModeType == 'A' && !self.hasClicked) {
+    if (gameMode == 'A' && !self.hasClicked) {
       if (game.math.distanceToPointer(x, self.balloon.x, y, self.balloon.y) > 8) {
         self.balloon.x = x;
         self.basket.x = x;
@@ -444,7 +444,7 @@
     }
 
     // GAME MODE B : hover circle
-    if (gameModeType == 'B' && !self.hasClicked) {
+    if (gameMode == 'B' && !self.hasClicked) {
       self.circles.all.forEach(cur => {
         const valid = game.math.distanceToPointer(x, cur.xWithAnchor, y, cur.yWithAnchor) <= (cur.diameter / 2) * cur.scale;
         if (valid) {
@@ -463,7 +463,7 @@
   /* CALLED BY EVENT HANDLER */
 
   /**
-   * (in gameModeType 'B') <br>
+   * (in gameMode 'B') <br>
    * 
    * Function called when cursor is over a valid circle
    * 
@@ -479,7 +479,7 @@
   },
 
   /**
-   * (in gameModeType 'B') <br>
+   * (in gameMode 'B') <br>
    * 
    * Function called when cursor is out of a valid circle
    */
@@ -493,7 +493,7 @@
   },
 
   /**
-   * (in gameModeType 'B') <br>
+   * (in gameMode 'B') <br>
    * 
    * Function called when player clicked over a valid circle
    * 
@@ -502,13 +502,13 @@
   func_clicked: function (cur) {
     if (!self.hasClicked) {
 
-      // On gameModeType A
-      if (gameModeType == 'A') {
+      // On gameMode A
+      if (gameMode == 'A') {
         self.balloon.x = cur;
         self.basket.x = cur;
-        // On gameModeType B
+        // On gameMode B
       }
-      else if (gameModeType == 'B') {
+      else if (gameMode == 'B') {
 
         document.body.style.cursor = 'auto';
 
@@ -568,11 +568,11 @@
    */
   func_viewHelp: function () {
     if (!self.hasClicked) {
-      // On gameModeType A
-      if (gameModeType == 'A') {
+      // On gameMode A
+      if (gameMode == 'A') {
         self.help.x = self.correctX;
         self.help.y = 490;
-        // On gameModeType B
+        // On gameMode B
       } else {
         self.help.x = self.circles.all[self.endIndex - 1].x;
         self.help.y = self.circles.all[self.endIndex - 1].y - self.circles.diameter / 2;
@@ -592,8 +592,8 @@
   postScore: function () {
     // Creates string that is going to be sent to db
     const data = '&line_game=' + gameShape
-      + '&line_mode=' + gameModeType
-      + '&line_oper=' + gameOperationType
+      + '&line_mode=' + gameMode
+      + '&line_oper=' + gameOperation
       + '&line_leve=' + gameDifficulty
       + '&line_posi=' + mapPosition
       + '&line_resu=' + self.result
@@ -604,7 +604,7 @@
       + ' balloonX: ' + self.basket.x
       + ', selIndex: ' + self.fractionIndex;
 
-    // MOODLE
+    // FOR MOODLE
     if (moodle) sendToDB(data, self.result, game.timer.elapsed);
     else sendToDB(data);
   }

+ 50 - 50
js/customMenu.js

@@ -21,7 +21,7 @@ const customMenuState = {
    */
   create: function () {
 
-    // MOODLE
+    // FOR MOODLE
     if (moodle && iLMparameters.iLM_PARAM_SendAnswer == 'false') {
       game.state.start('map');
     } else {
@@ -31,9 +31,9 @@ const customMenuState = {
       this.menuIcons = [];
 
       // Background color
-      game.add.graphic.rect(0, 0, 900, 600, undefined, 0, colors.blueBckg, 1);
+      game.add.geom.rect(0, 0, defaultWidth, defaultHeight, undefined, 0, colors.blueBckg, 1);
       // Floor
-      for (let i = 0; i < defaultWidth / 100; i++) { game.add.image(i * 100, 501, 'floor'); }
+      for (let i = 0; i < defaultWidth / 100; i++) { game.add.image(i * 100, defaultHeight - 100, 'floor'); }
 
       // Overtitle : Selected game
       game.add.text(defaultWidth / 2, 40, game.lang.game.toUpperCase() + ": " + menuState.menuIcons, textStyles.h4_brown);
@@ -81,15 +81,15 @@ const customMenuState = {
       this.menuIcons.push(infoIcon);
 
       // Horizontal line
-      game.add.graphic.rect(x - 25, y + 10, 600 + 50, width, undefined, 0, colors.blueMenuLine).anchor(0, 0.5);
+      game.add.geom.rect(x - 25, y + 10, 600 + 50, width, undefined, 0, colors.blueMenuLine).anchor(0, 0.5);
       // Vertical lines
-      game.add.graphic.rect(x + 2 * offsetW, y - 25, width, height, undefined, 0, colors.blueMenuLine).anchor(0.5, 0);
-      game.add.graphic.rect(x + 4 * offsetW, y - 25, width, height, undefined, 0, colors.blueMenuLine).anchor(0.5, 0);
+      game.add.geom.rect(x + 2 * offsetW, y - 25, width, height, undefined, 0, colors.blueMenuLine).anchor(0.5, 0);
+      game.add.geom.rect(x + 4 * offsetW, y - 25, width, height, undefined, 0, colors.blueMenuLine).anchor(0.5, 0);
 
       // --------------------------- TURN ON/OFF FRACTION LABELS / RECTANGLE GUIDE
 
       // Horizontal line
-      game.add.graphic.rect(x + 4 * offsetW, y + 136, 200 + 25, width, undefined, 0, colors.blueMenuLine).anchor(0, 0.5);
+      game.add.geom.rect(x + 4 * offsetW, y + 136, 200 + 25, width, undefined, 0, colors.blueMenuLine).anchor(0, 0.5);
 
       // Label 'Show Fractions / Auxiliar rectangles'
       game.add.text(x + 5 * offsetW, y + 102, game.lang.show, textStyles.h4_blue_2);
@@ -122,16 +122,16 @@ const customMenuState = {
 
       x = 150 + offsetW;
       y = baseY;
-      offsetH = this.func_getOffset(height, info[gameTypeString].gameModeType.length);
+      offsetH = this.func_getOffset(height, info[gameTypeString].gameMode.length);
 
-      for (let i = 0; i < info[gameTypeString].gameModeTypeUrl.length; i++, y += offsetH) {
-        const icon = game.add.sprite(x, y, info[gameTypeString].gameModeTypeUrl[i], 0, iconScale, 1);
+      for (let i = 0; i < info[gameTypeString].gameModeUrl.length; i++, y += offsetH) {
+        const icon = game.add.sprite(x, y, info[gameTypeString].gameModeUrl[i], 0, iconScale, 1);
         icon.anchor(0.5, 0.5);
 
-        icon.gameModeType = info[gameTypeString].gameModeType[i];
+        icon.gameMode = info[gameTypeString].gameMode[i];
         icon.iconType = 'gameMode';
         if (i == 0) {
-          gameModeType = icon.gameModeType;
+          gameMode = icon.gameMode;
           icon.curFrame = 1;
         }
 
@@ -142,7 +142,7 @@ const customMenuState = {
 
       x += 2 * offsetW;
       y = baseY;
-      offsetH = this.func_getOffset(height, info[gameTypeString].gameOperationType.length);
+      offsetH = this.func_getOffset(height, info[gameTypeString].gameOperation.length);
 
       let icon;
       let aux = [];
@@ -164,11 +164,11 @@ const customMenuState = {
         icon = game.add.sprite(x, y, aux[gameTypeString][i][0], 0, iconScale, 1);
         icon.anchor(0.5, 0.5);
 
-        icon.gameOperationType = aux[gameTypeString][i][1];
+        icon.gameOperation = aux[gameTypeString][i][1];
         icon.iconType = 'gameOperation';
 
         if (i == 0) {
-          gameOperationType = icon.gameOperationType;
+          gameOperation = icon.gameOperation;
           icon.curFrame = 1;
         }
 
@@ -185,7 +185,7 @@ const customMenuState = {
         const curX = x + (30 + 10) * i;
 
         // Difficulty menuIcons
-        const icon = game.add.graphic.rect(curX, y, 30, 30, undefined, 0, colors.gray, 1);
+        const icon = game.add.geom.rect(curX, y, 30, 30, undefined, 0, colors.gray, 1);
         icon.anchor(0.5, 0.5);
         icon.difficulty = i + 1;
         icon.iconType = 'difficulty';
@@ -202,7 +202,7 @@ const customMenuState = {
 
       // --------------------------- ENTER ICON
 
-      // MOODLE
+      // FOR MOODLE
       if (!moodle) {
 
         x = defaultWidth - 100;
@@ -242,63 +242,63 @@ const customMenuState = {
             body: game.lang.infoBox_mode,
             img: '<table> <tr> <td> <b>A)</b> ' + game.lang.infoBox_mode_s1_A +
               ' </td> <td> <b>B)</b> ' + game.lang.infoBox_mode_s1_B +
-              ' </td> </tr> <tr> <td> <img width=100% src="'+game.image['s1-A-h'].src+'"> ' +
-              ' </td> <td> <img width=100% src="'+game.image['s1-B-h'].src+'"> </td> </tr> <table>'
+              ' </td> </tr> <tr> <td> <img width=100% src="' + game.image['s1-A-h'].src + '"> ' +
+              ' </td> <td> <img width=100% src="' + game.image['s1-B-h'].src + '"> </td> </tr> <table>'
           },
           circleOne: {
             title: '<b>' + game.lang.game_modes + '</b>',
             body: game.lang.infoBox_mode,
-            img: '<table> <tr style="border-bottom: 5px solid white"> <td width=70%> <img width=100% src="'+game.image['c1-A-h'].src+'">' +
-            ' </td> <td> &nbsp; <b>A)</b> ' + game.lang.infoBox_mode_c1_A +
-            ' </td> </tr> </tr> <td> <img width=100% src="'+game.image['c1-B-h'].src+'"> ' +
-            ' </td> <td> &nbsp; <b>B)</b> ' + game.lang.infoBox_mode_c1_B +'</td> </tr> <table>'
+            img: '<table> <tr style="border-bottom: 5px solid white"> <td width=70%> <img width=100% src="' + game.image['c1-A-h'].src + '">' +
+              ' </td> <td> &nbsp; <b>A)</b> ' + game.lang.infoBox_mode_c1_A +
+              ' </td> </tr> </tr> <td> <img width=100% src="' + game.image['c1-B-h'].src + '"> ' +
+              ' </td> <td> &nbsp; <b>B)</b> ' + game.lang.infoBox_mode_c1_B + '</td> </tr> <table>'
           },
           squareTwo: {
             title: '<b>' + game.lang.game_modes + '</b>',
             body: game.lang.infoBox_mode,
             img: '<center> <table> <tr> <td> <b>A)</b> ' + game.lang.infoBox_mode_s2_A +
-            ' </td> <td> <b>B)</b> ' + game.lang.infoBox_mode_s2_B +
-            ' </td> </tr> <tr> <td> <img width=98% src="'+game.image['s2-A-h'].src+'"> ' +
-            ' </td> <td> <img width=98% src="'+game.image['s2-B-h'].src+'"> </td> </tr> <table> </center>'
+              ' </td> <td> <b>B)</b> ' + game.lang.infoBox_mode_s2_B +
+              ' </td> </tr> <tr> <td> <img width=98% src="' + game.image['s2-A-h'].src + '"> ' +
+              ' </td> <td> <img width=98% src="' + game.image['s2-B-h'].src + '"> </td> </tr> <table> </center>'
           }
         },
 
         gameOperation: {
           title: '<b>' + game.lang.operation_math + '</b>',
           body: game.lang.infoBox_oper,
-          img: '<center> <table> <tr style="border-bottom: 5px solid white"> <td> <img width=50 src="'+game.image['operation_plus'].src+'"> ' + game.lang.plus +
-            ' </td> <td> <img width=50 src="'+game.image['operation_mixed'].src+'"> ' + game.lang.mixed +
-            ' </td> </tr> <tr> <td><img width=50 src="'+game.image['operation_minus'].src+'"> ' + game.lang.minus +
-            ' &nbsp; </td> <td> <img width=50 src="'+game.image['operation_equals'].src+'"> ' + game.lang.equals + ' </td> </tr> <table> <center>',
+          img: '<center> <table> <tr style="border-bottom: 5px solid white"> <td> <img width=50 src="' + game.image['operation_plus'].src + '"> ' + game.lang.plus +
+            ' </td> <td> <img width=50 src="' + game.image['operation_mixed'].src + '"> ' + game.lang.mixed +
+            ' </td> </tr> <tr> <td><img width=50 src="' + game.image['operation_minus'].src + '"> ' + game.lang.minus +
+            ' &nbsp; </td> <td> <img width=50 src="' + game.image['operation_equals'].src + '"> ' + game.lang.equals + ' </td> </tr> <table> <center>',
         },
 
         gameDifficulty: {
           squareOne: {
             title: '<b>' + game.lang.difficulties + '</b>',
-            body: game.lang.infoBox_diff + '<br>' + game.lang.infoBox_diff_obs,
+            body: game.lang.infoBox_diff + ' ' + game.lang.infoBox_diff_obs,
             img: '<table> <tr> <td> <b>' + game.lang.difficulty + ':</b> 1' +
-            ' </td> <td> <b>' + game.lang.difficulty + ':</b> 3'+
-            ' </td> </tr> <tr> <td> <img width=100% src="'+game.image['s1-diff-1'].src+'"> ' +
-            ' </td> <td style="border-left: 4px solid white"> <img width=100% src="'+game.image['s1-diff-3'].src+'"> </td> </tr> </table> <br>' +
-            game.lang.infoBox_diff_aux + '<center> <img width=50% src="'+game.image['map-s1'].src+'"> </center>'
+              ' </td> <td> <b>' + game.lang.difficulty + ':</b> 3' +
+              ' </td> </tr> <tr> <td> <img width=100% src="' + game.image['s1-diff-1'].src + '"> ' +
+              ' </td> <td style="border-left: 4px solid white"> <img width=100% src="' + game.image['s1-diff-3'].src + '"> </td> </tr> </table> <br>' +
+              game.lang.infoBox_diff_aux + '<center> <img width=50% src="' + game.image['map-s1'].src + '"> </center>'
           },
           circleOne: {
             title: '<b>' + game.lang.difficulties + '</b>',
-            body: game.lang.infoBox_diff + '<br>' + game.lang.infoBox_diff_obs,
+            body: game.lang.infoBox_diff + ' ' + game.lang.infoBox_diff_obs,
             img: '<center> <table> <tr> <td style="border-right: 4px solid white"> <b>' + game.lang.difficulty + ':</b> 1' +
-            ' </td> <td> <b>' + game.lang.difficulty + ':</b> 5'+
-            ' </td> </tr> <tr> <td> <img width=100% src="'+game.image['c1-diff-1'].src+'"> ' +
-            ' </td> <td style="border-left: 4px solid white"> <img width=100% src="'+game.image['c1-diff-5'].src+'"> </td> </tr> </table> <center> <br>' +
-            game.lang.infoBox_diff_aux + '<center> <img width=50% src="'+game.image['map-c1s2'].src+'"> </center>'
+              ' </td> <td> <b>' + game.lang.difficulty + ':</b> 5' +
+              ' </td> </tr> <tr> <td> <img width=100% src="' + game.image['c1-diff-1'].src + '"> ' +
+              ' </td> <td style="border-left: 4px solid white"> <img width=100% src="' + game.image['c1-diff-5'].src + '"> </td> </tr> </table> <center> <br>' +
+              game.lang.infoBox_diff_aux + '<center> <img width=50% src="' + game.image['map-c1s2'].src + '"> </center>'
           },
           squareTwo: {
             title: '<b>' + game.lang.difficulties + '</b>',
             body: game.lang.infoBox_diff,
             img: '<table> <tr> <td> <b>' + game.lang.difficulty + ':</b> 1' +
-            ' </td> <td> <b>' + game.lang.difficulty + ':</b> 5'+
-            ' </td> </tr> <tr> <td> <img width=100% src="'+game.image['s2-diff-1'].src+'"> ' +
-            ' </td> <td style="border-left: 4px solid white"> <img width=100% src="'+game.image['s2-diff-5'].src+'"> </td> </tr> </table> <br>' +
-            game.lang.infoBox_diff_aux + '<center> <img width=50% src="'+game.image['map-c1s2'].src+'"> </center>'
+              ' </td> <td> <b>' + game.lang.difficulty + ':</b> 5' +
+              ' </td> </tr> <tr> <td> <img width=100% src="' + game.image['s2-diff-1'].src + '"> ' +
+              ' </td> <td style="border-left: 4px solid white"> <img width=100% src="' + game.image['s2-diff-5'].src + '"> </td> </tr> </table> <br>' +
+              game.lang.infoBox_diff_aux + '<center> <img width=50% src="' + game.image['map-c1s2'].src + '"> </center>'
           },
         },
 
@@ -306,17 +306,17 @@ const customMenuState = {
           squareOne: {
             title: '<b>' + game.lang.show + ' ' + auxText + '</b>',
             body: game.lang.infoBox_misc_label,
-            img: '<center> <img width=80% src="'+game.image['s1-label'].src+'"> </center>',
+            img: '<center> <img width=80% src="' + game.image['s1-label'].src + '"> </center>',
           },
           circleOne: {
             title: '<b>' + game.lang.show + ' ' + auxText + '</b>',
             body: game.lang.infoBox_misc_label,
-            img: '<center> <img width=60% src="'+game.image['c1-label'].src+'"> </center>',
+            img: '<center> <img width=60% src="' + game.image['c1-label'].src + '"> </center>',
           },
           squareTwo: {
             title: '<b>' + game.lang.show + ' ' + auxText + '</b>',
             body: game.lang.infoBox_misc_rect,
-            img: '<center> <img width=100% src="'+game.image['s2-label'].src+'"> </center>',
+            img: '<center> <img width=100% src="' + game.image['s2-label'].src + '"> </center>',
           }
         }
 
@@ -358,8 +358,8 @@ const customMenuState = {
 
     const type = icon.iconType;
     switch (type) {
-      case 'gameMode': gameModeType = icon.gameModeType; break;
-      case 'gameOperation': gameOperationType = icon.gameOperationType; break;
+      case 'gameMode': gameMode = icon.gameMode; break;
+      case 'gameOperation': gameOperation = icon.gameOperation; break;
       case 'difficulty': gameDifficulty = icon.difficulty; break;
       case 'infoIcon': self.func_showInfoBox(icon); break;
       case 'selectionBox':
@@ -373,7 +373,7 @@ const customMenuState = {
         game.render.all();
         break;
       case 'enter':
-        if (debugMode) console.log('Game State: ' + gameTypeString + ', ' + gameModeType);
+        if (debugMode) console.log('Game State: ' + gameTypeString + ', ' + gameMode);
         mapPosition = 0;      // Map position
         mapMove = true;       // Move no next point
         completedLevels = 0;  // Reset the game progress when entering a new level

+ 20 - 20
js/gameMechanics.js

@@ -324,15 +324,15 @@ const game = {
      * Adds geometric shapes
      * @namespace
      */
-    graphic: {
+    geom: {
       /**
        * Adds rectangle to media queue <br><br>
        * 
-       * game.add.graphic.rect(x, y, width, height) <br>
-       * game.add.graphic.rect(x, y, width, height, lineColor) <br>
-       * game.add.graphic.rect(x, y, width, height, lineColor, lineWidth) <br>
-       * game.add.graphic.rect(x, y, width, height, lineColor, lineWidth, fillColor) <br>
-       * game.add.graphic.rect(x, y, width, height, lineColor, lineWidth, fillColor, alpha) 
+       * game.add.geom.rect(x, y, width, height) <br>
+       * game.add.geom.rect(x, y, width, height, lineColor) <br>
+       * game.add.geom.rect(x, y, width, height, lineColor, lineWidth) <br>
+       * game.add.geom.rect(x, y, width, height, lineColor, lineWidth, fillColor) <br>
+       * game.add.geom.rect(x, y, width, height, lineColor, lineWidth, fillColor, alpha) 
        * 
        * @param {number} x default x coordinate for top left corner of the rectangle
        * @param {number} y default y coordinate for top left corner of the rectangle
@@ -389,11 +389,11 @@ const game = {
       /**
        * Adds circle to media queue <br><br>
        * 
-       * game.add.graphic.circle(x, y, diameter) <br>
-       * game.add.graphic.circle(x, y, diameter, lineColor) <br>
-       * game.add.graphic.circle(x, y, diameter, lineColor, lineWidth) <br>
-       * game.add.graphic.circle(x, y, diameter, lineColor, lineWidth, fillColor) <br>
-       * game.add.graphic.circle(x, y, diameter, lineColor, lineWidth, fillColor, alpha)
+       * game.add.geom.circle(x, y, diameter) <br>
+       * game.add.geom.circle(x, y, diameter, lineColor) <br>
+       * game.add.geom.circle(x, y, diameter, lineColor, lineWidth) <br>
+       * game.add.geom.circle(x, y, diameter, lineColor, lineWidth, fillColor) <br>
+       * game.add.geom.circle(x, y, diameter, lineColor, lineWidth, fillColor, alpha)
        * 
        * @param {number} x default x coordinate for the circle center
        * @param {number} y default y coordinate for the circle center
@@ -459,12 +459,12 @@ const game = {
       /**
        * Adds arc to media queue <br><br>
        * 
-       * game.add.graphic.arc(x, y, diameter, angleStart, angleEnd) <br>
-       * game.add.graphic.arc(x, y, diameter, angleStart, angleEnd, anticlockWise) <br>
-       * game.add.graphic.arc(x, y, diameter, angleStart, angleEnd, anticlockWise, lineColor) <br>
-       * game.add.graphic.arc(x, y, diameter, angleStart, angleEnd, anticlockWise, lineColor, lineWidth) <br>
-       * game.add.graphic.arc(x, y, diameter, angleStart, angleEnd, anticlockWise, lineColor, lineWidth, fillColor) <br>
-       * game.add.graphic.arc(x, y, diameter, angleStart, angleEnd, anticlockWise, lineColor, lineWidth, fillColor, alpha)
+       * game.add.geom.arc(x, y, diameter, angleStart, angleEnd) <br>
+       * game.add.geom.arc(x, y, diameter, angleStart, angleEnd, anticlockWise) <br>
+       * game.add.geom.arc(x, y, diameter, angleStart, angleEnd, anticlockWise, lineColor) <br>
+       * game.add.geom.arc(x, y, diameter, angleStart, angleEnd, anticlockWise, lineColor, lineWidth) <br>
+       * game.add.geom.arc(x, y, diameter, angleStart, angleEnd, anticlockWise, lineColor, lineWidth, fillColor) <br>
+       * game.add.geom.arc(x, y, diameter, angleStart, angleEnd, anticlockWise, lineColor, lineWidth, fillColor, alpha)
        * 
        * @param {number} x default x coordinate for the arc center
        * @param {number} y default y coordinate for the arc center
@@ -661,7 +661,7 @@ const game = {
      * 
      * @namespace
      */
-    _graphic: {
+    _geom: {
       /**
        * Renders rectangle on canvas
        * 
@@ -745,8 +745,8 @@ const game = {
           case 'image': this._image(cur); break;
           case 'sprite': this._sprite(cur); break;
           case 'text': this._text(cur); break;
-          case 'rect': this._graphic._rect(cur); break;
-          case 'arc': this._graphic._arc(cur); break;
+          case 'rect': this._geom._rect(cur); break;
+          case 'arc': this._geom._arc(cur); break;
         }
       });
     },

+ 35 - 23
js/globals.js

@@ -1,21 +1,33 @@
 // LInE - Free Education, Private Data.
 
 /*
+
+Generating game levels in menu:
+
 ..................................................... 
 ...............square....................circle...... }				        	} (gameShape)
 .........../...........\....................|........ } game (gameType)
 ........One.............Two................One....... }
 ......./...\.........../...\............./....\...... 
-......A.....B.........A.....B...........A......B..... } game mode (gameModeType)
-.(floor)..(stack)..(top)..(bottom)..(floor)..(stack). } 
+......A.....B.........A.....B...........A......B..... } game mode (gameMode)
+.(floor)..(stack)..(top)..(bottom)..(floor)..(stack).
 .......\./.............\./................\./........ 
 ........|...............|..................|......... 
 ......./.\..............|................/.|.\....... 
-...Plus...Minus.......Equals........Plus.Minus.Mixed. } game math operation (gameOperationType)
+...Plus...Minus.......Equals........Plus.Minus.Mixed. } game math operation (gameOperation)
 .......\./..............|................\.|./....... 
 ........|...............|..................|......... 
-......1,2,3.........1,2,3,4,5..........1,2,3,4,5..... } difficulty (gameDifficulty)
+......1,2,3.........1,2,3,4,5..........1,2,3,4,5..... } difficulty level (gameDifficulty)
 ..................................................... 
+
+About levels in map:
+
+..................(game.levels)......................
+......................__|__..........................
+.....................|.|.|.|.........................
+...................0,1,2,3,4,5....................... } mapPositions (mapPosition)
+...................|.........|.......................
+................(start)....(end).....................
 */
 
 /**
@@ -23,7 +35,7 @@
  * @type {boolean}
  */
 const debugMode = false;
-// MOODLE
+// FOR MOODLE
 /**
  * defines if the game is suposed to run online or on moodle <br>
  * - if true, on moodle <br>
@@ -71,7 +83,7 @@ let gameShape;
  * 
  * @type {string}
  */
-let gameModeType;
+let gameMode;
 /**
  * Holds game math operation.<br>
  * In squareOne     can be: 'Plus' (green tractor goes right) or 'Minus' (red tractor goes left).<br>
@@ -80,7 +92,7 @@ let gameModeType;
  * 
  * @type {string}
  */
-let gameOperationType;
+let gameOperation;
 /**
  * Holds game overall difficulty. 1 (easier) -> n (harder).<br> 
  * In squareOne             can be: 1..3.<br>
@@ -143,9 +155,9 @@ const info = {
     gameShape: 'square',
     gameType: 'squareOne',
     gameTypeUrl: 'game0',
-    gameModeType: ['A', 'B'],
-    gameModeTypeUrl: ['mode0', 'mode1'],
-    gameOperationType: ['Plus', 'Minus'],
+    gameMode: ['A', 'B'],
+    gameModeUrl: ['mode0', 'mode1'],
+    gameOperation: ['Plus', 'Minus'],
     gameDifficulty: 3
   },
 
@@ -153,9 +165,9 @@ const info = {
     gameShape: 'circle',
     gameType: 'circleOne',
     gameTypeUrl: 'game1',
-    gameModeType: ['A', 'B'],
-    gameModeTypeUrl: ['mode2', 'mode3'],
-    gameOperationType: ['Plus', 'Minus', 'Mixed'],
+    gameMode: ['A', 'B'],
+    gameModeUrl: ['mode2', 'mode3'],
+    gameOperation: ['Plus', 'Minus', 'Mixed'],
     gameDifficulty: 5
   },
 
@@ -163,18 +175,18 @@ const info = {
     gameShape: 'square',
     gameType: 'squareTwo',
     gameTypeUrl: 'game2',
-    gameModeType: ['A', 'B'],
-    gameModeTypeUrl: ['mode4', 'mode5'],
-    gameOperationType: ['Equals'],
+    gameMode: ['A', 'B'],
+    gameModeUrl: ['mode4', 'mode5'],
+    gameOperation: ['Equals'],
     gameDifficulty: 5
   },
 
   gameShape: [],
   gameType: [],
   gameTypeUrl: [],
-  gameModeType: [],
-  gameModeTypeUrl: [],
-  gameOperationType: [],
+  gameMode: [],
+  gameModeUrl: [],
+  gameOperation: [],
   gameDifficulty: [],
 
   /**
@@ -200,11 +212,11 @@ const info = {
       info.squareTwo.gameTypeUrl
     ];
 
-    info.gameModeType = info.squareOne.gameModeType.concat(info.circleOne.gameModeType, info.squareTwo.gameModeType);
+    info.gameMode = info.squareOne.gameMode.concat(info.circleOne.gameMode, info.squareTwo.gameMode);
 
-    info.gameModeTypeUrl = info.squareOne.gameModeTypeUrl.concat(info.circleOne.gameModeTypeUrl, info.squareTwo.gameModeTypeUrl);
+    info.gameModeUrl = info.squareOne.gameModeUrl.concat(info.circleOne.gameModeUrl, info.squareTwo.gameModeUrl);
 
-    info.gameOperationType = info.squareOne.gameOperationType.concat(info.circleOne.gameOperationType, info.squareTwo.gameOperationType);
+    info.gameOperation = info.squareOne.gameOperation.concat(info.circleOne.gameOperation, info.squareTwo.gameOperation);
 
     info.gameDifficulty = [
       info.squareOne.gameDifficulty,
@@ -571,7 +583,7 @@ const navigationIcons = {
  */
 const sendToDB = function (extraData) {
 
-  // MOODLE
+  // FOR MOODLE
   if (moodle) {
 
     if (self.result) moodleVar.hits[mapPosition - 1]++;

+ 10 - 82
js/integrationFunctions.js

@@ -1,4 +1,4 @@
-/* MOODLE
+/* FOR MOODLE
  * 
  * These functions are used exclusively when iFractions is runnign inside Moodle as an iAssign module. <br>
  * In this case, the global variable 'moodle' must be 'true' (globals.js) <br> 
@@ -48,13 +48,12 @@ function getParameterByName(name) {
  * Para ambos os casos, o retorno deste método será recebido pelo iTarefa e será armazenado no banco de dados.
  */
 function getAnswer() {
-  if (debugMode) console.log("(integrationFunctions.js) start getAnswer()");
   let str = '';
   if (iLMparameters.iLM_PARAM_SendAnswer == 'false') { // Student - sending results
     str += 'gameTypeString:' + gameTypeString
       + '\ngameShape:' + gameShape
-      + '\ngameModeType:' + gameModeType
-      + '\ngameOperationType:' + gameOperationType
+      + '\ngameMode:' + gameMode
+      + '\ngameOperation:' + gameOperation
       + '\ngameDifficulty:' + gameDifficulty
       + '\nfractionLabel:' + fractionLabel
       + '\nresults:';
@@ -67,7 +66,7 @@ function getAnswer() {
     }
   } else { // Professor - creating new assignment
     if (!gameType) {
-      alert("Erro: Você precisa escolher pelo menos um jogo");
+      alert(game.lang.error_must_select_game);
       return x;
     }
     moodleVar.hits = [0, 0, 0, 0];
@@ -75,17 +74,12 @@ function getAnswer() {
     moodleVar.time = [0, 0, 0, 0];
     str += 'gameTypeString:' + gameTypeString
       + '\ngameShape:' + gameShape
-      + '\ngameModeType:' + gameModeType
-      + '\ngameOperationType:' + gameOperationType
+      + '\ngameMode:' + gameMode
+      + '\ngameOperation:' + gameOperation
       + '\ngameDifficulty:' + gameDifficulty
       + '\nfractionLabel:' + fractionLabel;
   }
 
-  if (debugMode) {
-    console.log(str);
-    console.log("(integrationFunctions.js) end getAnswer()");
-  }
-
   return str;
 }
 
@@ -108,15 +102,11 @@ function getEvaluation() {
 
 function getiLMContent() {
 
-  if (debugMode) console.log("(integrationFunctions.js) getiLMContent(): start.");
-
   const url = iLMparameters.iLM_PARAM_Assignment;
 
   if (url == null) {
-    console.error("Error: (integrationFunctions.js) getiLMContent(): NAO existe arquivo FRC para ser carregado (iLMparameters.iLM_PARAM_Assignment vazio), finalize.");
+    console.error("[integrationFunctions.js] getiLMContent(): iLMparameters.iLM_PARAM_Assignment " + game.lang.error_moodle_file_ext);
     return;
-  } else {
-    if (debugMode) console.log("(integrationFunctions.js) getiLMContent(): try to get file in " + url);
   }
 
   let xhr = new XMLHttpRequest();
@@ -130,15 +120,14 @@ function getiLMContent() {
     }
   }
 
-  if (debugMode) console.log("(integrationFunctions.js) getiLMContent(): end.");
 }
 
 function updateGlobalVariables(info, infoResults) {
   // Update new values
   gameTypeString = info['gameTypeString'];
   gameShape = info['gameShape'];
-  gameModeType = info['gameModeType'];
-  gameOperationType = info['gameOperationType'];
+  gameMode = info['gameMode'];
+  gameOperation = info['gameOperation'];
   gameDifficulty = parseInt(info['gameDifficulty']);
   fractionLabel = info['fractionLabel'];
 
@@ -181,7 +170,7 @@ function breakString(text) {
     results = { l1: {}, l2: {}, l3: {}, l4: {} };
     let i = 1;
     curLevel.forEach(cur => {
-      cur = cur.substring(1); // Remove {
+      cur = cur.slice(1); // Remove {
       cur = cur.split(','); // Break by line
       cur.forEach(cur => {
         try {
@@ -203,65 +192,4 @@ const moodleVar = {
   hits: [0, 0, 0, 0],
   errors: [0, 0, 0, 0],
   time: [0, 0, 0, 0]
-}
-
-function convertTime(s) {
-  let h = 0, m = 0;
-
-  if (s > 1200) {
-    h = s / 1200;
-    s = s % 1200;
-  }
-
-  if (s > 60) {
-    m = s / 60;
-    s = s % 60;
-  }
-
-  h = '' + h;
-  m = '' + m;
-  s = '' + s;
-
-  if (h.length < 2) h = '0' + h;
-  if (m.length < 2) m = '0' + m;
-  if (s.length < 2) s = '0' + s;
-
-  return h + ':' + m + ':' + s;
-
-}
-
-const studentReport = {
-  create: function () {
-    const offsetW = defaultWidth / 4;
-    let x = offsetW / 2;
-    let y = defaultHeight/2 - 50;
-    game.add.graphic.rect(0, 0, 900, 600, undefined, 0, colors.blueBckg, 1);
-    game.add.image(300, 100, 'cloud');
-    game.add.image(660, 80, 'cloud');
-    game.add.image(110, 85, 'cloud', 0.8);
-    for (let i = 0; i < 9; i++) { game.add.image(i * 100, 501, 'floor'); }
-    game.add.text(defaultWidth / 2, 80, game.lang.results, textStyles.h1_green);
-    game.add.image(x - 40, y - 70, info[gameTypeString].gameTypeUrl, 0.8);
-    text = game.lang[gameShape].charAt(0).toUpperCase() + game.lang[gameShape].slice(1);
-    text = game.lang.game + ': ' + text + ((gameTypeString.substring(-3) == 'One') ? ' I' :' II');
-    game.add.text(190, y - 50, text, textStyles.h4_brown).align = 'left';
-    game.add.text(190, y - 25, game.lang.game_mode + ': ' + gameModeType, textStyles.h4_brown).align = 'left';
-    game.add.text(190, y, game.lang.operation + ': ' + gameOperationType, textStyles.h4_brown).align = 'left';
-    game.add.text(190, y + 25, game.lang.difficulty + ': ' + gameDifficulty, textStyles.h4_brown).align = 'left';
-    y = defaultHeight - 200;
-    for (let i = 0; i < 4; i++, x += offsetW) {
-      if (moodleVar.hits[i] == 0) {
-        const sign = game.add.image(x, defaultHeight - 100, 'broken_sign', 0.7);
-        sign.anchor(0.5, 0.5);
-        continue;
-      }
-      const sign = game.add.image(x, defaultHeight - 100, 'sign', 0.7);
-      sign.anchor(0.5, 0.5)
-      game.add.text(x, defaultHeight - 100, '' + (i + 1), textStyles.h2_white);
-      game.add.graphic.rect(x - 55, y - 40, 5, 135, undefined, 0, colors.blueMenuLine)//.anchor(0, 0.5);
-      game.add.text(x - 40, y - 25, game.lang.time + ': ' + convertTime(moodleVar.time[i]), textStyles.h4_brown).align = 'left';
-      game.add.text(x - 40, y, game.lang.hits + ': ' + moodleVar.hits[i], textStyles.h4_brown).align = 'left';
-      game.add.text(x - 40, y + 25, game.lang.errors + ': ' + moodleVar.errors[i], textStyles.h4_brown).align = 'left';
-    }
-  }
 }

+ 12 - 12
js/map.js

@@ -11,14 +11,14 @@ const mapState = {
   create: function () {
 
     // Background color
-    game.add.graphic.rect(0, 0, 900, 600, undefined, 0, colors.blueBckg, 1);
+    game.add.geom.rect(0, 0, defaultWidth, defaultHeight, undefined, 0, colors.blueBckg, 1);
 
     // Map
     game.add.image(0, 40, 'bgmap');
 
     // Calls function that loads navigation icons
 
-    // MOODLE
+    // FOR MOODLE
     if (moodle) {
       navigationIcons.func_addIcons(
         false, false, false, // Left icons
@@ -34,10 +34,10 @@ const mapState = {
     // Progress bar
     const percentText = 4 * 25;
 
-    if (completedLevels == 4) game.add.graphic.rect(660, 10, completedLevels * 37.5, 35, undefined, 0, colors.intenseGreen, 0.5);
-    else game.add.graphic.rect(660, 10, completedLevels * 37.5, 35, undefined, 0, colors.yellow, 0.9);
+    if (completedLevels == 4) game.add.geom.rect(660, 10, completedLevels * 37.5, 35, undefined, 0, colors.intenseGreen, 0.5);
+    else game.add.geom.rect(660, 10, completedLevels * 37.5, 35, undefined, 0, colors.yellow, 0.9);
 
-    game.add.graphic.rect(661, 11, 149, 34, colors.blue, 3, undefined, 1);
+    game.add.geom.rect(661, 11, 149, 34, colors.blue, 3, undefined, 1);
     game.add.text(820, 38, percentText + '%', textStyles.h2_blue, 'left');
     game.add.text(650, 38, game.lang.difficulty + ' ' + gameDifficulty, textStyles.h2_blue, 'right');
 
@@ -102,7 +102,7 @@ const mapState = {
     // Game Character 
     if (gameTypeString == 'squareOne') {
 
-      if (gameOperationType == 'Plus') {
+      if (gameOperation == 'Plus') {
         this.character = game.add.sprite(this.points.x[mapPosition], this.points.y[mapPosition], 'tractor', 0, 0.5);
         this.character.animation = ['green_tractor', [0, 1, 2, 3, 4], 3];
       } else {
@@ -229,7 +229,7 @@ const endState = {
     self.animate = true;
 
     // Background color
-    game.add.graphic.rect(0, 0, 900, 600, undefined, 0, colors.blueBckg, 1);
+    game.add.geom.rect(0, 0, defaultWidth, defaultHeight, undefined, 0, colors.blueBckg, 1);
 
     // Background
     game.add.image(0, 0, 'bgimage');
@@ -240,11 +240,11 @@ const endState = {
     game.add.image(110, 85, 'cloud', 0.8);
 
     // Floor
-    for (let i = 0; i < 9; i++) { game.add.image(i * 100, 501, 'floor'); }
+    for (let i = 0; i < 9; i++) { game.add.image(i * 100, defaultHeight - 100, 'floor'); }
 
     // Progress bar
-    game.add.graphic.rect(660, 10, 4 * 37.5, 35, undefined, 0, colors.intenseGreen, 0.5); // Progress
-    game.add.graphic.rect(661, 11, 149, 34, colors.blue, 3, undefined, 1); // Box
+    game.add.geom.rect(660, 10, 4 * 37.5, 35, undefined, 0, colors.intenseGreen, 0.5); // Progress
+    game.add.geom.rect(661, 11, 149, 34, colors.blue, 3, undefined, 1); // Box
     game.add.text(820, 38, '100%', textStyles.h2_blue, 'left');
     game.add.text(650, 38, game.lang.difficulty + ' ' + gameDifficulty, textStyles.h2_blue, 'right');
 
@@ -295,7 +295,7 @@ const endState = {
         // Tractor
         this.character = game.add.sprite(0, 490, 'tractor', 0, 0.7);
         this.character.anchor(0.5, 0.5);
-        if (gameOperationType == 'Plus') {
+        if (gameOperation == 'Plus') {
           this.character.animation = ['move', [0, 1, 2, 3, 4], 4];
         } else {
           this.character.curFrame = 10;
@@ -353,7 +353,7 @@ const endState = {
         completedLevels = 0;
         game.animation.stop(self.character.animation[0]);
 
-        // MOODLE
+        // FOR MOODLE
         if (!moodle) game.state.start('menu');
 
       }

+ 6 - 13
js/menu.js

@@ -21,7 +21,7 @@ const menuState = {
    */
   create: function () {
 
-    // MOODLE
+    // FOR MOODLE
     if (moodle && iLMparameters.iLM_PARAM_SendAnswer == 'false') {
 
       playerName = 'Aluno'; // TODO pegar o nome do aluno no bd do moodle
@@ -29,13 +29,13 @@ const menuState = {
 
     } else {
 
-      // MOODLE
+      // FOR MOODLE
       if (moodle && iLMparameters.iLM_PARAM_SendAnswer == 'true') playerName = 'Professor';
 
       // Background color
-      game.add.graphic.rect(0, 0, 900, 600, undefined, 0, colors.blueBckg, 1);
+      game.add.geom.rect(0, 0, defaultWidth, defaultHeight, undefined, 0, colors.blueBckg, 1);
       // Floor
-      for (let i = 0; i < defaultWidth / 100; i++) { game.add.image(i * 100, 501, 'floor'); }
+      for (let i = 0; i < defaultWidth / 100; i++) { game.add.image(i * 100, defaultHeight - 100, 'floor'); }
 
       // Overtitle: Welcome, <player name>!
       game.add.text(defaultWidth / 2, 40, game.lang.welcome + ', ' + playerName + '!', textStyles.h4_brown);
@@ -170,16 +170,9 @@ const menuState = {
    */
   func_showTitle: function (icon) {
 
-    let title = game.lang[icon.gameShape];
+    const number = (icon.gameType.slice(-3) == 'One') ? 'I' : 'II';
 
-    const type = icon.gameType.substring(-3);
-
-    switch (type) {
-      case 'One': title += ' I'; break;
-      case 'Two': title += ' II'; break;
-    }
-
-    self.lbl_game.name = title;
+    self.lbl_game.name = game.lang[icon.gameShape] + ' ' + number;
 
   },
 

+ 10 - 10
js/preMenu.js

@@ -21,16 +21,16 @@ const bootState = {
 
     // Calls first screen seen by the player
 
-    // MOODLE
+    // FOR MOODLE
     if (moodle) {
       loadLangState.firstTime = false;
       const moodleLang = iLMparameters.lang;
       switch (moodleLang) {
-        case 'en' : langString = 'en_US'; break;
-        case 'pt' : langString = 'pt_BR'; break;
-        case 'fr' : langString = 'fr_FR'; break;
-        case 'es' : langString = 'es_PE'; break;
-        case 'it' : langString = 'it_IT'; break;
+        case 'en': langString = 'en_US'; break;
+        case 'pt': langString = 'pt_BR'; break;
+        case 'fr': langString = 'fr_FR'; break;
+        case 'es': langString = 'es_PE'; break;
+        case 'it': langString = 'it_IT'; break;
         default: langString = 'en_US';
       }
       game.state.start('loadLang');
@@ -52,7 +52,7 @@ const langState = {
    */
   create: function () {
     // Background color
-    game.add.graphic.rect(0, 0, 900, 600, colors.white, 0, colors.blueBckg, 1);
+    game.add.geom.rect(0, 0, defaultWidth, defaultHeight, colors.white, 0, colors.blueBckg, 1);
 
     // Parameters for the elements on the screen
     this.listOfFlags = [];
@@ -191,7 +191,7 @@ const nameState = {
   create: function () {
 
     // Background color
-    game.add.graphic.rect(0, 0, 900, 600, colors.white, 0, colors.blueBckg, 1);
+    game.add.geom.rect(0, 0, defaultWidth, defaultHeight, colors.white, 0, colors.blueBckg, 1);
 
     // Set title and warning text
 
@@ -200,7 +200,7 @@ const nameState = {
     this.warningEmptyName = game.add.text(defaultWidth / 2, defaultHeight / 2 - 70, '', textStyles.h4_brown);
 
     // Set 'ok' button that gets player's information
-    this.okBtn = game.add.graphic.rect(defaultWidth / 2 - 84, defaultHeight / 2 + 70, 168, 60, undefined, 0, colors.gray, 0.6);
+    this.okBtn = game.add.geom.rect(defaultWidth / 2 - 84, defaultHeight / 2 + 70, 168, 60, undefined, 0, colors.gray, 0.6);
 
     // Set button Text
     game.add.text(defaultWidth / 2 + 1, defaultHeight / 2 + 112, game.lang.ready, textStyles.h1_white);
@@ -295,7 +295,7 @@ const nameState = {
     if (audioStatus) game.audio.beepSound.play();
     if (debugMode) console.log('Username: ' + playerName);
 
-    // MOODLE
+    // FOR MOODLE
     // Calls 'menu' state
     if (!moodle) game.state.start('menu');
   }

+ 66 - 66
js/squareOne.js

@@ -12,14 +12,14 @@
  *
  * # of different difficulties : 3
  *
- * Game modes can be : 'A' or 'B' (in variable 'gameModeType')
+ * Game modes can be : 'A' or 'B' (in variable 'gameMode')
  *
  *   A : Player can select # of 'floor blocks' (hole in the ground)
  *       Selects size of hole to be made in the ground (to fill with the blocks in front of the truck)
  *   B : Player can select # of 'stacked blocks' (in front of the truck)
  *       Selects number of blocks in front of the truck (to fill the hole on the ground)
  *
- * Operations can be : 'Plus' or 'Minus' (in variable 'gameOperationType')
+ * Operations can be : 'Plus' or 'Minus' (in variable 'gameOperation')
  *
  *   Plus : addition of fractions
  *     Represented by : tractor going to the right (floor positions 0..8
@@ -44,14 +44,14 @@ const squareOne = {
 
     this.divisorsList = '';     // Hold the divisors for each fraction on stacked blocks (created for postScore())
 
-    this.DIREC_LEVEL = (gameOperationType == 'Minus') ? -1 : 1;    // Will be multiplied to values to easily change tractor direction when needed
-    this.animationSpeed = 2 * this.DIREC_LEVEL;   // X distance in which the tractor moves in each iteration of the animation
+    this.direc_level = (gameOperation == 'Minus') ? -1 : 1;    // Will be multiplied to values to easily change tractor direction when needed
+    this.animationSpeed = 2 * this.direc_level;   // X distance in which the tractor moves in each iteration of the animation
 
     // GAME VARIABLES
     this.defaultBlockWidth = 80;   // Base block width
     this.defaultBlockHeight = 40;  // Base block height
 
-    this.startX = (gameOperationType == 'Minus') ? 730 : 170; // Initial 'x' coordinate for the tractor and stacked blocks
+    this.startX = (gameOperation == 'Minus') ? 730 : 170; // Initial 'x' coordinate for the tractor and stacked blocks
 
     // BACKGROUND
 
@@ -64,11 +64,11 @@ const squareOne = {
     game.add.image(110, 85, 'cloud', 0.8);
 
     // Add floor of grass
-    for (let i = 0; i < 9; i++) { game.add.image(i * 100, 501, 'floor'); }
+    for (let i = 0; i < 9; i++) { game.add.image(i * 100, defaultHeight - 100, 'floor'); }
 
     // Calls function that loads navigation icons
 
-    // MOODLE
+    // FOR MOODLE
     if (moodle) {
       navigationIcons.func_addIcons(
         false, false, false, // Left icons
@@ -86,7 +86,7 @@ const squareOne = {
     // TRACTOR 
     this.tractor = game.add.sprite(this.startX, 445, 'tractor', 0, 0.8);
 
-    if (gameOperationType == 'Plus') {
+    if (gameOperation == 'Plus') {
       this.tractor.anchor(1, 0.5);
       this.tractor.animation = ['move', [0, 1, 2, 3, 4], 4];
     } else {
@@ -100,26 +100,26 @@ const squareOne = {
       blocks: [], // Group of 'stacked' block objects
       labels: [], // Group of fraction labels on the side of 'stacked' blocks
 
-      index: undefined, // (gameModeType 'B') index of 'stacked' block selected by player
+      index: undefined, // (gameMode 'B') index of 'stacked' block selected by player
 
       // Control variables for animation
       curIndex: 0, // (needs to be 0)
       curBlockEnd: undefined,
 
       // Correct values
-      correctIndex: undefined, // (gameModeType 'B') index of the CORRECT 'stacked' block
+      correctIndex: undefined, // (gameMode 'B') index of the CORRECT 'stacked' block
     };
 
     // FLOOR BLOCKS variables
     this.floor = {
       blocks: [], // Group of 'floor' block objects
-      index: undefined, // (gameModeType 'A') index of 'floor' block selected by player
+      index: undefined, // (gameMode 'A') index of 'floor' block selected by player
 
       // Control variables for animation
       curIndex: -1, // (needs to be -1)
 
       // Correct values
-      correctIndex: undefined, // (gameModeType 'A') index of the CORRECT 'floor' block
+      correctIndex: undefined, // (gameMode 'A') index of the CORRECT 'floor' block
       correctX: undefined,  // 'x' coordinate of CORRECT 'floor' block
       correctXA: undefined, // Temporary variable 
       correctXB: undefined, // Temporary variable
@@ -133,8 +133,8 @@ const squareOne = {
 
     // SELECTION ARROW
 
-    if (gameModeType == 'A') {
-      this.arrow = game.add.image(this.startX + this.defaultBlockWidth * this.DIREC_LEVEL, 480, 'arrow_down');
+    if (gameMode == 'A') {
+      this.arrow = game.add.image(this.startX + this.defaultBlockWidth * this.direc_level, 480, 'arrow_down');
       this.arrow.anchor(0.5, 0.5);
       this.arrow.alpha = 0.5;
     }
@@ -174,31 +174,31 @@ const squareOne = {
 
       // MANAGE BLOCKS AND FLOOR GAPS
       // If block is 1/n (not 1/1) there's an extra block space to go through before the start of next block
-      const restOfCurBlock = (self.defaultBlockWidth - stck.blocks[stck.curIndex].width) * self.DIREC_LEVEL;
+      const restOfCurBlock = (self.defaultBlockWidth - stck.blocks[stck.curIndex].width) * self.direc_level;
 
       // Check if block falls
-      if ((gameOperationType == 'Plus' && stck.blocks[0].x >= (stck.curBlockEnd + restOfCurBlock)) ||
-        (gameOperationType == 'Minus' && stck.blocks[0].x <= (stck.curBlockEnd + restOfCurBlock))) {
+      if ((gameOperation == 'Plus' && stck.blocks[0].x >= (stck.curBlockEnd + restOfCurBlock)) ||
+        (gameOperation == 'Minus' && stck.blocks[0].x <= (stck.curBlockEnd + restOfCurBlock))) {
 
         let lowerBlock = true;
 
-        const curEnd = stck.blocks[0].x + stck.blocks[stck.curIndex].width * self.DIREC_LEVEL;
+        const curEnd = stck.blocks[0].x + stck.blocks[stck.curIndex].width * self.direc_level;
 
         // If current index is (A) last stacked index (correct index - fixed)
         // If current index is (B) selected stacked index
         if (stck.curIndex == stck.index) {
           // floor.index : (A) selected floor index
           // floor.index : (B) last floor index (correct index - fixed)
-          const selectedEnd = floor.blocks[floor.index].x + floor.blocks[0].width * self.DIREC_LEVEL;
+          const selectedEnd = floor.blocks[floor.index].x + floor.blocks[0].width * self.direc_level;
 
           // (A) last stacked block (fixed) doesnt fit selected gap AKA NOT ENOUGH FLOOR BLOCKS (DOESNT CHECK TOO MANY)
           // (B) selected stacked index doesnt fit last floor gap (fixed) AKA TOO MANY STACKED BLOCKS (DOESNT CHECK NOT ENOUGH)
-          if ((gameOperationType == 'Plus' && curEnd > selectedEnd) || (gameOperationType == 'Minus' && curEnd < selectedEnd)) {
+          if ((gameOperation == 'Plus' && curEnd > selectedEnd) || (gameOperation == 'Minus' && curEnd < selectedEnd)) {
             lowerBlock = false;
           }
         } else {
           // Update to next block end
-          stck.curBlockEnd += stck.blocks[stck.curIndex + 1].width * self.DIREC_LEVEL;
+          stck.curBlockEnd += stck.blocks[stck.curIndex + 1].width * self.direc_level;
         }
 
         // Fill floor gap
@@ -207,7 +207,7 @@ const squareOne = {
           // Until (B) last floor index (correct index - fixed)
           // Updates floor index to be equivalent to stacked index (and change alpha so floor appears to be filled)
           for (let i = 0; i <= floor.index; i++) {
-            if ((gameOperationType == 'Plus' && floor.blocks[i].x < curEnd) || (gameOperationType == 'Minus' && floor.blocks[i].x > curEnd)) {
+            if ((gameOperation == 'Plus' && floor.blocks[i].x < curEnd) || (gameOperation == 'Minus' && floor.blocks[i].x > curEnd)) {
               floor.blocks[i].alpha = 0.2;
               floor.curIndex = i;
             }
@@ -234,7 +234,7 @@ const squareOne = {
 
       game.animation.stop(self.tractor.animation[0]);
 
-      if (gameModeType == 'A') {
+      if (gameMode == 'A') {
         self.result = self.floor.index == self.floor.correctIndex;
       } else {
         self.result = self.stck.index == self.stck.correctIndex;
@@ -296,7 +296,7 @@ const squareOne = {
     const x = mouseEvent.offsetX;
     const y = mouseEvent.offsetY;
 
-    if (gameModeType == 'A') {
+    if (gameMode == 'A') {
       self.floor.blocks.forEach(cur => {
         if (game.math.isOverIcon(x, y, cur)) self.func_clickSquare(cur);
       });
@@ -322,7 +322,7 @@ const squareOne = {
     let flagA = false;
     let flagB = false;
 
-    if (gameModeType == 'A') {
+    if (gameMode == 'A') {
       // Make arrow follow mouse
       if (!self.hasClicked && !self.animateEnding) {
         if (game.math.distanceToPointer(self.arrow.x, x, self.arrow.y, y) > 8) {
@@ -340,7 +340,7 @@ const squareOne = {
       if (!flagA) self.func_outSquare('A');
     }
 
-    if (gameModeType == 'B') {
+    if (gameMode == 'B') {
       self.stck.blocks.forEach(cur => {
         if (game.math.isOverIcon(x, y, cur)) {
           flagB = true;
@@ -368,8 +368,8 @@ const squareOne = {
     if (!self.hasClicked) {
       document.body.style.cursor = 'pointer';
 
-      // On gameModeType A
-      if (gameModeType == 'A') {
+      // On gameMode A
+      if (gameMode == 'A') {
         for (let i in self.floor.blocks) {
           self.floor.blocks[i].alpha = (i <= cur.index) ? 1 : 0.5;
         }
@@ -377,7 +377,7 @@ const squareOne = {
         // Saves the index of the selected 'floor' block
         self.floor.index = cur.index;
 
-        // On gameModeType B
+        // On gameMode B
       } else {
         for (let i in self.stck.blocks) {
           self.stck.blocks[i].alpha = (i <= cur.index) ? 0.5 : 0.2;
@@ -397,7 +397,7 @@ const squareOne = {
       document.body.style.cursor = 'auto';
 
       // On game mode A
-      if (gameModeType == 'A') {
+      if (gameMode == 'A') {
         for (let i in self.floor.blocks) {
           self.floor.blocks[i].alpha = 0.5; // Back to normal
         }
@@ -421,8 +421,8 @@ const squareOne = {
     if (!self.hasClicked && !self.animateEnding) {
       document.body.style.cursor = 'auto';
 
-      // On gameModeType A
-      if (gameModeType == 'A') {
+      // On gameMode A
+      if (gameMode == 'A') {
         // Turns selection arrow completely visible
         self.arrow.alpha = 1;
 
@@ -434,7 +434,7 @@ const squareOne = {
 
         // (FIXED : self.STCK.index) save the 'stacked' blocks index
         self.stck.index = self.stck.blocks.length - 1;
-        // On gameModeType B
+        // On gameMode B
       } else {
         for (let i in self.stck.blocks) {
           // (FIXED : self.STCK.index)
@@ -477,11 +477,11 @@ const squareOne = {
    */
   func_createStckBlocks: function () {
     let hasBaseDifficulty = false; // Will be true after next for loop if level has at least one '1/difficulty' fraction (if false, restart)
-    const max = (gameModeType == 'B') ? 10 : mapPosition + 4; // Maximum number of stacked blocks for the level
+    const max = (gameMode == 'B') ? 10 : mapPosition + 4; // Maximum number of stacked blocks for the level
 
     const total = game.math.randomInRange(mapPosition + 2, max); // Current number of stacked blocks for the level
 
-    self.floor.correctXA = self.startX + self.defaultBlockWidth * self.DIREC_LEVEL;
+    self.floor.correctXA = self.startX + self.defaultBlockWidth * self.direc_level;
 
     for (let i = 0; i < total; i++) { // For each stacked block
       let divisor = game.math.randomInRange(1, gameDifficulty); // Set divisor for fraction
@@ -491,12 +491,12 @@ const squareOne = {
 
       const curBlockWidth = self.defaultBlockWidth / divisor; // Current width is a fraction of the default
 
-      self.floor.correctXA += curBlockWidth * self.DIREC_LEVEL;
+      self.floor.correctXA += curBlockWidth * self.direc_level;
 
       // Create stacked block (close to tractor)
-      const lineColor = (gameOperationType == 'Minus') ? colors.red : colors.darkBlue;
+      const lineColor = (gameOperation == 'Minus') ? colors.red : colors.darkBlue;
       const lineSize = 2;
-      const block = game.add.graphic.rect(
+      const block = game.add.geom.rect(
         self.startX,
         462 - i * (self.defaultBlockHeight - lineSize),
         curBlockWidth - lineSize,
@@ -505,11 +505,11 @@ const squareOne = {
         lineSize,
         colors.white,
         1);
-      const anchor = (gameOperationType == 'Minus') ? 1 : 0;
+      const anchor = (gameOperation == 'Minus') ? 1 : 0;
       block.anchor(anchor, 0);
 
       // If game is type B, adding events to stacked blocks
-      if (gameModeType == 'B') {
+      if (gameMode == 'B') {
         block.alpha = 0.5;
         block.index = i;
       }
@@ -518,7 +518,7 @@ const squareOne = {
 
       // If 'show fractions' is turned on, create labels that display the fractions on the side of each block
       if (fractionLabel) {
-        const x = self.startX + (curBlockWidth + 15) * self.DIREC_LEVEL;
+        const x = self.startX + (curBlockWidth + 15) * self.direc_level;
         const y = self.defaultBlockHeight - lineSize;
 
         const label = [];
@@ -536,15 +536,15 @@ const squareOne = {
     }
 
     // Will be used as a counter in update, adding in the width of each stacked block to check if the end matches the floor selected position
-    self.stck.curBlockEnd = self.startX + self.stck.blocks[0].width * self.DIREC_LEVEL;
+    self.stck.curBlockEnd = self.startX + self.stck.blocks[0].width * self.direc_level;
 
     let restart = false;
 
     // Check for errors (level too easy for its difficulty or end position out of bounds)
     if (!hasBaseDifficulty ||
-      (gameOperationType == 'Plus' && (self.floor.correctXA < (self.startX + self.defaultBlockWidth) ||
+      (gameOperation == 'Plus' && (self.floor.correctXA < (self.startX + self.defaultBlockWidth) ||
         self.floor.correctXA > (self.startX + 8 * self.defaultBlockWidth))) ||
-      (gameOperationType == 'Minus' && (self.floor.correctXA < (self.startX - (8 * self.defaultBlockWidth)) ||
+      (gameOperation == 'Minus' && (self.floor.correctXA < (self.startX - (8 * self.defaultBlockWidth)) ||
         self.floor.correctXA > (self.startX - self.defaultBlockWidth)))
     ) {
       restart = true; // If any error is found restart the level
@@ -566,13 +566,13 @@ const squareOne = {
     const blockWidth = self.defaultBlockWidth / divisor; // Width of each floor block
 
     // If game is type B, selectiong a random floor x position
-    if (gameModeType == 'B') {
+    if (gameMode == 'B') {
       self.stck.correctIndex = game.math.randomInRange(0, (self.stck.blocks.length - 1)); // Correct stacked index
 
-      self.floor.correctXB = self.startX + self.defaultBlockWidth * self.DIREC_LEVEL;
+      self.floor.correctXB = self.startX + self.defaultBlockWidth * self.direc_level;
 
       for (let i = 0; i <= self.stck.correctIndex; i++) {
-        self.floor.correctXB += self.stck.blocks[i].width * self.DIREC_LEVEL; // Equivalent x position on the floor
+        self.floor.correctXB += self.stck.blocks[i].width * self.direc_level; // Equivalent x position on the floor
       }
     }
 
@@ -580,17 +580,17 @@ const squareOne = {
 
     for (let i = 0; i < total; i++) { // For each floor block
       // 'x' coordinate for floor block
-      const x = self.startX + (self.defaultBlockWidth + i * blockWidth) * self.DIREC_LEVEL;
+      const x = self.startX + (self.defaultBlockWidth + i * blockWidth) * self.direc_level;
 
-      if (flag && gameModeType == 'A') {
-        if ((gameOperationType == 'Plus' && x >= self.floor.correctXA) || (gameOperationType == 'Minus' && x <= self.floor.correctXA)) {
+      if (flag && gameMode == 'A') {
+        if ((gameOperation == 'Plus' && x >= self.floor.correctXA) || (gameOperation == 'Minus' && x <= self.floor.correctXA)) {
           self.floor.correctIndex = i - 1; // Set index of correct floor block
           flag = false;
         }
       }
 
-      if (gameModeType == 'B') {
-        if ((gameOperationType == 'Plus' && x >= self.floor.correctXB) || (gameOperationType == 'Minus' && x <= self.floor.correctXB)) {
+      if (gameMode == 'B') {
+        if ((gameOperation == 'Plus' && x >= self.floor.correctXB) || (gameOperation == 'Minus' && x <= self.floor.correctXB)) {
           total = i;
           break;
         }
@@ -598,7 +598,7 @@ const squareOne = {
 
       // Create floor block
       const lineSize = 0.9;
-      const block = game.add.graphic.rect(
+      const block = game.add.geom.rect(
         x,
         462 + self.defaultBlockHeight - lineSize,
         blockWidth - lineSize,
@@ -607,11 +607,11 @@ const squareOne = {
         lineSize,
         colors.blueBckgInsideLevel,
         1);
-      const anchor = (gameOperationType == 'Minus') ? 1 : 0;
+      const anchor = (gameOperation == 'Minus') ? 1 : 0;
       block.anchor(anchor, 0);
 
       // If game is type A, adding events to floor blocks
-      if (gameModeType == 'A') {
+      if (gameMode == 'A') {
         block.alpha = 0.5;
         block.index = i;
       }
@@ -620,12 +620,12 @@ const squareOne = {
       self.floor.blocks.push(block);
     }
 
-    if (gameModeType == 'A') self.floor.correctX = self.floor.correctXA;
-    else if (gameModeType == 'B') self.floor.correctX = self.floor.correctXB;
+    if (gameMode == 'A') self.floor.correctX = self.floor.correctXA;
+    else if (gameMode == 'B') self.floor.correctX = self.floor.correctXB;
 
     // Creates labels on the floor to display the numbers
     for (let i = 1; i < 10; i++) {
-      const x = self.startX + (i * self.defaultBlockWidth * self.DIREC_LEVEL);
+      const x = self.startX + (i * self.defaultBlockWidth * self.direc_level);
       game.add.text(x, 462 + self.defaultBlockHeight + 58, i - 1, textStyles.h2_blue);
     }
   },
@@ -635,15 +635,15 @@ const squareOne = {
    */
   func_viewHelp: function () {
     if (!self.hasClicked) {
-      // On gameModeType A
-      if (gameModeType == 'A') {
+      // On gameMode A
+      if (gameMode == 'A') {
         const aux = self.floor.blocks[0];
-        self.help.x = self.floor.correctX - aux.width / 2 * self.DIREC_LEVEL;
+        self.help.x = self.floor.correctX - aux.width / 2 * self.direc_level;
         self.help.y = 501;
-        // On gameModeType B
+        // On gameMode B
       } else {
         const aux = self.stck.blocks[self.stck.correctIndex];
-        self.help.x = aux.x + aux.width / 2 * self.DIREC_LEVEL;
+        self.help.x = aux.x + aux.width / 2 * self.direc_level;
         self.help.y = aux.y;
       }
 
@@ -664,8 +664,8 @@ const squareOne = {
   postScore: function () {
     // Creates string that is going to be sent to db
     const data = '&line_game=' + gameShape
-      + '&line_mode=' + gameModeType
-      + '&line_oper=' + gameOperationType
+      + '&line_mode=' + gameMode
+      + '&line_oper=' + gameOperation
       + '&line_leve=' + gameDifficulty
       + '&line_posi=' + mapPosition
       + '&line_resu=' + self.result
@@ -676,7 +676,7 @@ const squareOne = {
       + ' blockIndex: ' + self.stck.index
       + ', floorIndex: ' + self.floor.index;
 
-    // MOODLE  
+    // FOR MOODLE  
     if (moodle) sendToDB(data, self.result, game.timer.elapsed);
     else sendToDB(data);
   },

+ 12 - 12
js/squareTwo.js

@@ -12,14 +12,14 @@
  *
  * # of different difficulties : 5
  *
- * Game modes can be : 'A' or 'B' (in variable 'gameModeType')
+ * Game modes can be : 'A' or 'B' (in variable 'gameMode')
  * 
  *   A : equivalence of fractions 
  *       top has more subdivisions
  *   B : equivalence of fractions
  *       bottom has more subdivisions
  * 
- * Operations : 'Equals' (in variable 'gameOperationType')
+ * Operations : 'Equals' (in variable 'gameOperation')
  *
  *   Equals : Player selects equivalent fractions of both blocks 
  * 
@@ -68,11 +68,11 @@ const squareTwo = {
     game.add.image(110, 85, 'cloud', 0.8);
 
     // Add floor of grass
-    for (let i = 0; i < 9; i++) { game.add.image(i * 100, 501, 'floor'); }
+    for (let i = 0; i < 9; i++) { game.add.image(i * 100, defaultHeight - 100, 'floor'); }
 
     // Calls function that loads navigation icons
 
-    // MOODLE
+    // FOR MOODLE
     if (moodle) {
       navigationIcons.func_addIcons(
         false, false, false, // Left buttons
@@ -86,7 +86,7 @@ const squareTwo = {
     }
 
     // Add kid
-    this.kidAnimation = game.add.sprite(100, 470, 'kid_standing', 5, 0.8);
+    this.kidAnimation = game.add.sprite(100, defaultHeight - 128, 'kid_standing', 5, 0.8);
     this.kidAnimation.anchor(0.5, 0.7);
 
     // Width and Height of A and B
@@ -95,7 +95,7 @@ const squareTwo = {
 
     // Coordinates for A and B
     let xA, xB, yA, yB;
-    if (gameModeType != 'B') { // More subdivisions on B
+    if (gameMode != 'B') { // More subdivisions on B
       xA = 230;
       yA = 90;
       xB = xA;
@@ -134,7 +134,7 @@ const squareTwo = {
       const x = xA + i * blockWidth;
 
       // Blocks
-      const block = game.add.graphic.rect(x, yA, blockWidth, figureHeight, lineColor, 2, fillColor, 0.5);
+      const block = game.add.geom.rect(x, yA, blockWidth, figureHeight, lineColor, 2, fillColor, 0.5);
       block.figure = 'A';
       block.index = i;
       block.finalX = xA;
@@ -144,7 +144,7 @@ const squareTwo = {
       const alpha = (fractionLabel) ? 0.1 : 0;
 
       const yAux = yA + figureHeight + 10; // On the bottom of A
-      const auxBlock = game.add.graphic.rect(x, yAux, blockWidth, figureHeight, lineColor, 1, fillColor, alpha);
+      const auxBlock = game.add.geom.rect(x, yAux, blockWidth, figureHeight, lineColor, 1, fillColor, alpha);
       this.A.auxBlocks.push(auxBlock);
     }
 
@@ -174,7 +174,7 @@ const squareTwo = {
       const x = xB + i * blockWidth;
 
       // Blocks
-      const block = game.add.graphic.rect(x, yB, blockWidth, figureHeight, lineColor, 2, fillColor, 0.5);
+      const block = game.add.geom.rect(x, yB, blockWidth, figureHeight, lineColor, 2, fillColor, 0.5);
       block.figure = 'B';
       block.index = i;
       block.finalX = xB;
@@ -183,7 +183,7 @@ const squareTwo = {
       // Auxiliar blocks
       const alpha = (fractionLabel) ? 0.1 : 0;
       const yAux = yB + figureHeight + 10; // On the bottom of B
-      const auxBlock = game.add.graphic.rect(x, yAux, blockWidth, figureHeight, lineColor, 1, fillColor, alpha);
+      const auxBlock = game.add.geom.rect(x, yAux, blockWidth, figureHeight, lineColor, 1, fillColor, alpha);
       this.B.auxBlocks.push(auxBlock);
     }
 
@@ -459,7 +459,7 @@ const squareTwo = {
   postScore: function () {
     // Creates string that is going to be sent to db
     const data = '&line_game=' + gameShape
-      + '&line_mode=' + gameModeType
+      + '&line_mode=' + gameMode
       + '&line_oper=Equal'
       + '&line_leve=' + gameDifficulty
       + '&line_posi=' + mapPosition
@@ -471,7 +471,7 @@ const squareTwo = {
       + ', numBlocksB: ' + self.B.blocks.length
       + ', valueB: ' + self.B.selected;
 
-    // MOODLE
+    // FOR MOODLE
     if (moodle) sendToDB(data, self.result, game.timer.elapsed);
     else sendToDB(data);
   }

+ 80 - 0
js/stundentReport.js

@@ -0,0 +1,80 @@
+// FOR MOODLE 
+
+/**
+ * To be show on moodle
+ */
+const studentReport = {
+
+  create: function () {
+
+    const offsetW = defaultWidth / 4;
+    let x = offsetW / 2;
+    let y = defaultHeight / 2 - 50;
+
+    game.add.geom.rect(0, 0, defaultWidth, defaultHeight, undefined, 0, colors.blueBckg, 1);
+    game.add.image(300, 100, 'cloud');
+    game.add.image(660, 80, 'cloud');
+    game.add.image(110, 85, 'cloud', 0.8);
+
+    for (let i = 0; i < 9; i++) { game.add.image(i * 100, defaultHeight - 100, 'floor'); }
+
+    game.add.text(defaultWidth / 2, 80, game.lang.results, textStyles.h1_green);
+    game.add.image(x - 40, y - 70, info[gameTypeString].gameTypeUrl, 0.8);
+
+    text = game.lang[gameShape].charAt(0).toUpperCase() + game.lang[gameShape].slice(1);
+    text = game.lang.game + ': ' + text + ((gameTypeString.slice(-3) == 'One') ? ' I' : ' II');
+
+    game.add.text(190, y - 50, text, textStyles.h4_brown).align = 'left';
+    game.add.text(190, y - 25, game.lang.game_mode + ': ' + gameMode, textStyles.h4_brown).align = 'left';
+    game.add.text(190, y, game.lang.operation + ': ' + gameOperation, textStyles.h4_brown).align = 'left';
+    game.add.text(190, y + 25, game.lang.difficulty + ': ' + gameDifficulty, textStyles.h4_brown).align = 'left';
+
+    y = defaultHeight - 200;
+
+    for (let i = 0; i < 4; i++, x += offsetW) {
+
+      if (moodleVar.hits[i] == 0) {
+        const sign = game.add.image(x, defaultHeight - 100, 'broken_sign', 0.7);
+        sign.anchor(0.5, 0.5);
+        continue;
+      }
+
+      const sign = game.add.image(x, defaultHeight - 100, 'sign', 0.7);
+      sign.anchor(0.5, 0.5);
+      game.add.text(x, defaultHeight - 100, '' + (i + 1), textStyles.h2_white);
+
+      game.add.geom.rect(x - 55, y - 40, 5, 135, undefined, 0, colors.blueMenuLine);
+      game.add.text(x - 40, y - 25, game.lang.time + ': ' + convertTime(moodleVar.time[i]), textStyles.h4_brown).align = 'left';
+      game.add.text(x - 40, y, game.lang.hits + ': ' + moodleVar.hits[i], textStyles.h4_brown).align = 'left';
+      game.add.text(x - 40, y + 25, game.lang.errors + ': ' + moodleVar.errors[i], textStyles.h4_brown).align = 'left';
+    }
+
+  },
+
+  convertTime: function (s) {
+
+    let h = 0, m = 0;
+
+    if (s > 1200) {
+      h = s / 1200;
+      s = s % 1200;
+    }
+
+    if (s > 60) {
+      m = s / 60;
+      s = s % 60;
+    }
+
+    h = '' + h;
+    m = '' + m;
+    s = '' + s;
+
+    if (h.length < 2) h = '0' + h;
+    if (m.length < 2) m = '0' + m;
+    if (s.length < 2) s = '0' + s;
+
+    return h + ':' + m + ':' + s;
+
+  }
+
+}