diff --git a/public/saveGameData.js b/public/saveGameData.js
index 475aa0e..99d83a4 100644
--- a/public/saveGameData.js
+++ b/public/saveGameData.js
@@ -3,23 +3,8 @@ const urlParams = new URLSearchParams(queryString);
const userId = urlParams.get('userid');
const gameId = urlParams.get('id');
+let startTime = Date.now();
-// Get the current time
-let startTime = new Date();
-
-// Simulate some process with a delay
-setTimeout(() => {
- // Get the current time again
- let endTime = new Date();
-
- // Calculate the difference in milliseconds
- let timeDifference = endTime - startTime;
-
- // Convert milliseconds to seconds
- let timeDifferenceInSeconds = timeDifference / 1000;
-
- console.log(`Time difference: ${timeDifferenceInSeconds} seconds`);
-}, 3000); // 3-second delay
const url = window.location.href;
const gameName = url.split('/');
@@ -27,35 +12,52 @@ const gameType = gameName[3].split('?id=');
const gameVersion = gameType[0] + '-' + gameName[4];
+
+
function submitUserData(drawingZone) {
+ const endTime = Date.now();
+ const timeDifference = endTime - startTime;
+ const timeDifferenceInSeconds = timeDifference / 1000;
+ // console.log(`Time difference: ${timeDifferenceInSeconds} seconds`);
+
let imageCode;
- // console.log(drawingZone);
+ let gameScore;
+ let scoreTotal=0;
+ if(scoreTotal){
+ gameScore = scoreTotal;
+ }else{
+ gameScore = 0;
+ }
+ // console.log('This is from main point', scoreTotal);
drawingZone.renderer.snapshot((image) => {
- submitButton.setVisible(true);
- snapshotButton.setVisible(true);
- customCursor.setVisible(true);
- image.style.width = '160px';
- image.style.height = '120px';
- image.style.paddingLeft = '2px';
- document.body.appendChild(image);
- // Download the snapshot as an image
- const link = document.createElement('a');
- link.href = image.src;
- link.download = 'my_drawing.png';
- link.click();
- document.body.removeChild(image);
- imageCode = image.src;
+ if(gameType[0] == 'drawing'){
+ submitButton.setVisible(true);
+ snapshotButton.setVisible(true);
+ customCursor.setVisible(true);
+ image.style.width = '160px';
+ image.style.height = '120px';
+ image.style.paddingLeft = '2px';
+ document.body.appendChild(image);
+ // Download the snapshot as an image
+ const link = document.createElement('a');
+ link.href = image.src;
+ link.download = 'my_drawing.png';
+ link.click();
+ document.body.removeChild(image);
+ imageCode = image.src;
+ }
+
let userData = {
- 'gameName': gameVersion,
- 'gameID': gameId,
- 'screenShot': imageCode,
- 'userId' : userId,
- 'gameTime' : '10',
- 'score' : '100'
- // 'starts': formattedDateTime,
- // 'game_start' : gameStartTime,
+ 'gameName': gameVersion,
+ 'gameID': gameId,
+ 'screenShot': imageCode,
+ 'userId' : userId,
+ 'gameTime' : timeDifferenceInSeconds,
+ 'score' : scoreTotal
+ // 'starts': formattedDateTime,
+ // 'game_start' : gameStartTime,
};
console.log(userData);
diff --git a/src/pages/drag/dragdrop_phonics.astro b/src/pages/drag/dragdrop_phonics.astro
index e8841fd..27e0e54 100644
--- a/src/pages/drag/dragdrop_phonics.astro
+++ b/src/pages/drag/dragdrop_phonics.astro
@@ -49,6 +49,7 @@ import Layout from '../../layouts/Layout.astro';
+
+
+
+
+
+