Procházet zdrojové kódy

fix: correct moodle detection, grade evaluation and anchor errors on text elements

priscila.snl před 1 týdnem
rodič
revize
e1b0be4d04
4 změnil soubory, kde provedl 9 přidání a 19 odebrání
  1. 6 2
      index.html
  2. 1 7
      js/games/circleOne.js
  3. 0 6
      js/games/squareOne.js
  4. 2 4
      js/globals/globals_control.js

+ 6 - 2
index.html

@@ -45,7 +45,7 @@
 
     <!-- Information -->
 
-    <div class="panel panel-info">
+    <div id="info-panel-en" class="panel panel-info">
       <div class="panel-heading ifr-cardInfo__heading">
         <span>
           🇺🇸&nbsp;&nbsp;More information about the iFractions Project
@@ -71,7 +71,7 @@
       </div>
     </div>
 
-    <div class="panel panel-info">
+    <div id="info-panel-pt" class="panel panel-info">
       <div class="panel-heading ifr-cardInfo__heading">
         <span>🇧🇷&nbsp;&nbsp;Mais informações sobre o Projeto iFrações</span>
         <img src="./assets/img/info_cards/mini_games.png" width="100px" title="Examples of iFractions mini-games" />
@@ -115,6 +115,10 @@
     <script src="./js/globals/globals_debug.js"></script>
 
     <script>
+      if (moodle) {
+        document.getElementById('info-panel-en').style.display = 'none';
+        document.getElementById('info-panel-pt').style.display = 'none';
+      }
 
       const defaultWidth = 1920; // Default width for the Canvas
       const defaultHeight = 1080; // Default height for the Canvas

+ 1 - 7
js/games/circleOne.js

@@ -622,7 +622,6 @@ const circleOne = {
         withNewlines(game.lang.c1_challenge_title),
         { ...textStyles.h2_, fill: colors.white, font: 'bold ' + textStyles.h2_.font }
       );
-      self.ui.challenge.title.anchor(0.5, 0.5);
 
       const ribbonBottom = ribbonY + ribbonH;
       const subtitleLines = withNewlines(game.lang.c1_challenge_subtitle).split('\n');
@@ -631,13 +630,11 @@ const circleOne = {
         subtitleLines[0] || '',
         { ...textStyles.h4_, fill: colors.blueDark, font: 'bold ' + textStyles.h4_.font }
       );
-      self.ui.challenge.subtitleTop.anchor(0.5, 0.5);
       self.ui.challenge.subtitleBottom = game.add.text(
         cx, ribbonBottom + 100,
         subtitleLines.slice(1).join('\n'),
         { ...textStyles.h3_, fill: colors.blue }
       );
-      self.ui.challenge.subtitleBottom.anchor(0.5, 0.5);
 
       const topCircleY = self.road.defaultY + 20 - 5 - self.circles.diameter / 2
         - (self.circles.list.length - 1) * self.circles.diameter;
@@ -648,7 +645,6 @@ const circleOne = {
         withNewlines(game.lang.c1_circles_label),
         { ...textStyles.h4_, fill: colors.blueDark, font: 'bold ' + textStyles.h4_.font }
       );
-      self.ui.challenge.circlesLabel.anchor(0.5, 0.5);
 
       const cardW = 580; const cardH = 260;
       const cardX = cx;
@@ -672,7 +668,6 @@ const circleOne = {
         { ...textStyles.h3_, fill: colors.blueDark, font: `bold ${qFontSize}px ${font.families.default}` },
         qLineH
       );
-      self.ui.challenge.question.anchor(0.5, 0.5);
 
       {
         // Builds equation string
@@ -759,7 +754,6 @@ const circleOne = {
         withNewlines(game.lang.c1_challenge_accept),
         textStyles.btn
       );
-      self.ui.challenge.buttonText.anchor(0.5, 0.5);
 
       self.control.showChallenge = true;
     },
@@ -1153,7 +1147,7 @@ const circleOne = {
         const displayVal = gameOperation === 'minus' ? (i - 5) : i;
         game.add.text(markerCX - 20, markerCY - 11, String(displayVal),
           { ...textStyles.p_, fill: colors.blueDark, font: `bold 22px ${font.families.default}` }
-        ).anchor(0.5, 0.5);
+        );
       }
 
       // Orange label at answer position

+ 0 - 6
js/games/squareOne.js

@@ -561,7 +561,6 @@ const squareOne = {
         withNewlines(game.lang.s1_challenge_title),
         { ...textStyles.h2_, fill: colors.white, font: 'bold ' + textStyles.h2_.font }
       );
-      self.ui.challenge.title.anchor(0.5, 0.5);
 
       // Subtitle lines below the ribbon
       const ribbonBottom = ribbonY + ribbonH;
@@ -571,14 +570,12 @@ const squareOne = {
         subtitleLines[0] || '',
         { ...textStyles.h4_, fill: colors.blueDark, font: 'bold ' + textStyles.h4_.font }
       );
-      self.ui.challenge.subtitleTop.anchor(0.5, 0.5);
 
       self.ui.challenge.subtitleBottom = game.add.text(
         cx, ribbonBottom + 100,
         subtitleLines.slice(1).join('\n'),
         { ...textStyles.h3_, fill: colors.blue }
       );
-      self.ui.challenge.subtitleBottom.anchor(0.5, 0.5);
 
       // "Blocos a carregar:" label above the stacked blocks
       const stackTopY = self.default.y0 - self.stack.list.length * self.default.height;
@@ -589,7 +586,6 @@ const squareOne = {
         withNewlines(game.lang.s1_blocks_label),
         { ...textStyles.h4_, fill: colors.blueDark, font: 'bold ' + textStyles.h4_.font }
       );
-      self.ui.challenge.blocksLabel.anchor(0.5, 0.5);
 
       // question-mark-with-arrow.png is 1230×864px; scale 0.20 → 246×173px
       // Placed at the correct floor hole position, bottom of image at floor level
@@ -628,7 +624,6 @@ const squareOne = {
         { ...textStyles.h3_, fill: colors.blueDark, font: `bold ${qFontSize}px ${font.families.default}` },
         qLineH
       );
-      self.ui.challenge.question.anchor(0.5, 0.5);
 
       // Fraction equation: "1 + ½ + ... =" as text, then circle — group centered at cardX
       // Show only the blocks that will fill the hole (0 → stack.correctIndex) in both modes
@@ -695,7 +690,6 @@ const squareOne = {
         withNewlines(game.lang.s1_challenge_accept),
         textStyles.btn
       );
-      self.ui.challenge.buttonText.anchor(0.5, 0.5);
 
       self.control.showChallenge = true;
     },

+ 2 - 4
js/globals/globals_control.js

@@ -33,11 +33,9 @@
 /** FOR MOODLE <br>
  *
  * iFractions can run on a server or inside moodle through iAssign. <br>
- * This variable should be set according to where it is suposed to run: <br>
- * - if true, on moodle <br>
- * - if false, on a server
+ * Detected automatically: true if iAssign passes iLM_PARAM_SendAnswer in the URL.
  */
-const moodle = false;
+const moodle = new URLSearchParams(window.location.search).has('iLM_PARAM_SendAnswer');
 
 let moodleVar = {
   hits: [0, 0, 0, 0],