Parcourir la source

Fixed bug in automatic submission
Fixed bug in student report screen

laira il y a 3 ans
Parent
commit
f5b4a83c12
4 fichiers modifiés avec 24 ajouts et 8 suppressions
  1. 20 3
      js/globals.js
  2. 2 3
      js/integrationFunctions.js
  3. 1 1
      js/map.js
  4. 1 1
      js/studentReport.js

+ 20 - 3
js/globals.js

@@ -597,9 +597,26 @@ const sendToDB = function (extraData) {
 
     moodleVar.time[mapPosition - 1] += game.timer.elapsed;
 
-    getAnswer();
-    
-    getEvaluation();
+    const url = iLMparameters.iLM_PARAM_ServerToGetAnswerURL;
+    const grade = '' + getEvaluation();
+    const report = getAnswer();
+    const data = 'return_get_answer=1'+
+    '&iLM_PARAM_ActivityEvaluation='+encodeURIComponent(grade)+
+    '&iLM_PARAM_ArchiveContent='+encodeURIComponent(report);
+
+    const init = { method: 'POST', body: data, headers: { 'Content-type': 'application/x-www-form-urlencoded; charset=UTF-8' } };
+
+    fetch(url, init)
+      .then(response => {
+        if (response.ok) {
+          if (debugMode) console.log("Processing...");
+        } else {
+          console.error("Game error: Network response was not ok.");
+        }
+      })
+      .catch(error => {
+        console.error('Game error: problem with fetch operation - ' + error.message + '.');
+      });
 
   } else {
 

+ 2 - 3
js/integrationFunctions.js

@@ -67,7 +67,7 @@ function getAnswer() {
       + '\ngameDifficulty:' + gameDifficulty
       + '\nfractionLabel:' + fractionLabel;
   }
-
+  
   return str;
 };
 
@@ -79,7 +79,7 @@ function getAnswer() {
  *
  * @returns {number} student's grade for the current assignment : real number between 0.0 and 1.0
  */
-function getEvaluation() {
+ function getEvaluation() {
   if (iLMparameters.iLM_PARAM_SendAnswer == 'false') { // Student
     let i;
     for (i = 0; i < moodleVar.hits.length && moodleVar.hits[i] == 1; i++);
@@ -150,7 +150,6 @@ const getiLMContent = function () {
  * @param {string} text content of the .frc file
  */
 const breakString = function (text) {
-
   let gameInfo = {}, results;
   const lines = text.split('\n'); // Break by line
 

+ 1 - 1
js/map.js

@@ -352,7 +352,7 @@ const endState = {
           game.state.start('menu');
         } else {
           // FOR MOODLE
-          parent.location.reload(true);
+          parent.location.reload(true);          
         }
 
       }

+ 1 - 1
js/studentReport.js

@@ -46,7 +46,7 @@ const studentReport = {
     y = defaultHeight - 200;
     for (let i = 0; i < 4; i++, x += offsetW) {
       // If level wasnt completed, show broken sign
-      if (moodleVar.hits[i] == 0) {
+      if (moodleVar.hits[i] == 0 && moodleVar.errors[i] == 0) {
         const sign = game.add.image(x, defaultHeight - 100, 'broken_sign', 0.7);
         sign.anchor(0.5, 0.5);
       } else {