diff --git a/public/assets/svg/tracing-done.svg b/public/assets/svg/tracing-done.svg new file mode 100644 index 0000000..43c58d6 --- /dev/null +++ b/public/assets/svg/tracing-done.svg @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/public/saveGameAI.js b/public/saveGameAI.js index a3f0bec..6e01465 100644 --- a/public/saveGameAI.js +++ b/public/saveGameAI.js @@ -1,7 +1,6 @@ function retryGame(){ window.location.reload(); } - const queryString = window.location.search; const urlParams = new URLSearchParams(queryString); const userId = urlParams.get('userId'); diff --git a/public/saveTracingGameData.js b/public/saveTracingGameData.js new file mode 100644 index 0000000..4da6785 --- /dev/null +++ b/public/saveTracingGameData.js @@ -0,0 +1,134 @@ +function retryGame(){ + window.location.reload(); +} + +const queryString = window.location.search; +const urlParams = new URLSearchParams(queryString); +const userId = urlParams.get('userId'); +const gameVersion = urlParams.get('gameName'); +let gameId; +let submitNotic; + +console.log(userId); +let startTime = Date.now(); + + +const url = window.location.href; +const gameName = url.split('/'); +const gameType = gameName[3].split('?id='); +// let gameVersion; + +// console.log("Here is game name ", gameType[0]) + +// if(gameType[0] == "guided-tracing"){ +// gameVersion = gameType[0].split('?')[0]; +// gameId = gameName[4]; +// console.log('Type - 1'); + +// } else if(gameName.length == 4){ +// gameVersion = gameName[3].split('?')[0]; +// gameId = urlParams.get('id'); +// } +// else if(gameName.length == 5){ +// gameVersion = gameName[3] + '-' + gameName[4].split('?')[0]; +// gameId = urlParams.get('id'); +// console.log('Type - 2'); +// }else if(gameName.length == 6){ +// gameVersion = gameType[0] + '-' + gameName[4]; +// gameId = urlParams.get('id'); +// console.log('Type - 3'); +// } + +console.log(gameVersion) + +function submitUserData(drawingZone) { + const endTime = Date.now(); + const timeDifference = endTime - startTime; + const timeDifferenceInSeconds = timeDifference / 1000; + // console.log(`Time difference: ${timeDifferenceInSeconds} seconds`); + + let imageCode; + let gameScore; + + if(scoreTotal){ + gameScore = scoreTotal; + }else{ + gameScore = 0; + } + // console.log('This is from main point', scoreTotal); + drawingZone.renderer.snapshot((image) => { + 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; + }else if( gameType[0] == "guided-tracing"){ + // 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 = `guided-tracing-${gameId}.png`; + // link.click(); + document.body.removeChild(image); + imageCode = image.src; + } + let starValue; + if(scoreTotal === maxScore){ + starValue = 5; + } else if(scoreTotal === maxScore - 1){ + starValue = 4; + } else{ + starValue = 3; + } + let userData = { + 'gameName': gameVersion, + 'gameID': gameId, + 'screenShot': imageCode, + 'userId' : userId, + 'gameTime' : timeDifferenceInSeconds, + 'score' : scoreTotal, + 'gameStar' : starValue + }; + // console.log(userData); + fetch(`https://api.teachertrainingkolkata.in/api/saveGameScore`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(userData) + }) + .then(response => { + setTimeout(() => { + if (response.ok) { + if (response.status == 200) { + document.getElementById('wsSavedImg').classList.remove('-z-10'); + } + } else { + console.log('Something went wrong', response); + } + }, 100); + }) + .catch(error => { + console.error('An error occurred', error); + }); + + // Clear the drawing + // graphics.clear(); + }); +}; \ No newline at end of file diff --git a/src/pages/drag/index.astro b/src/pages/drag/index.astro index d771211..cfd45df 100644 --- a/src/pages/drag/index.astro +++ b/src/pages/drag/index.astro @@ -61,24 +61,24 @@ const numberOfTimes = starNumberOfTime; let cancelIconWidth; if(isMobile){ - topLogoWidth = 4.5; - muteIconWidth = 1.8; - resetIconWidth = 1.47; - tickIconWidth = 1.24; - cancelIconWidth = 1.08; - }else if(isTab){ - topLogoWidth = 4.5; - muteIconWidth = 1.6; - resetIconWidth = 1.43; - tickIconWidth = 1.29; - cancelIconWidth = 1.18; - }else{ - topLogoWidth = 6; - muteIconWidth = 1.3; - resetIconWidth = 1.26; - tickIconWidth = 1.222; - cancelIconWidth = 1.185; - } + topLogoWidth = 4.5; + muteIconWidth = 1.8; + resetIconWidth = 1.47; + tickIconWidth = 1.24; + cancelIconWidth = 1.08; + }else if(isTab){ + topLogoWidth = 4.5; + muteIconWidth = 1.6; + resetIconWidth = 1.43; + tickIconWidth = 1.29; + cancelIconWidth = 1.18; + }else{ + topLogoWidth = 6; + muteIconWidth = 1.3; + resetIconWidth = 1.26; + tickIconWidth = 1.222; + cancelIconWidth = 1.185; + } if(isMobile){ noticeWidth = 100; noticeHeight = 0; @@ -465,7 +465,7 @@ const numberOfTimes = starNumberOfTime; counter++; return 'borderCorrect'; } else { - console.log(`Score Total: ${scoreTotal}`); + // console.log(`Score Total: ${scoreTotal}`); return 'borderWrong'; } }; diff --git a/src/pages/drawing/drawing_phonics.astro b/src/pages/drawing/drawing_phonics.astro index e4af2b3..a4c279a 100644 --- a/src/pages/drawing/drawing_phonics.astro +++ b/src/pages/drawing/drawing_phonics.astro @@ -18,7 +18,7 @@ import Layout from '../../layouts/Layout.astro';
- +
diff --git a/src/pages/drawing/drawing_writo.astro b/src/pages/drawing/drawing_writo.astro index 0693aaf..b867681 100644 --- a/src/pages/drawing/drawing_writo.astro +++ b/src/pages/drawing/drawing_writo.astro @@ -18,7 +18,7 @@ import Layout from '../../layouts/Layout.astro';
- +
diff --git a/src/pages/drawing/index.astro b/src/pages/drawing/index.astro index bad587e..08366cb 100644 --- a/src/pages/drawing/index.astro +++ b/src/pages/drawing/index.astro @@ -18,7 +18,7 @@ import Layout from '../../layouts/Layout.astro';
- +
@@ -709,12 +709,14 @@ import Layout from '../../layouts/Layout.astro'; eraserButton.addEventListener('click', () => { isErasing = !isErasing; if (isErasing) { - eraserButton.style.border = '2px solid #0348A8'; + eraserButton.style.border = '3px solid #0348A8'; + eraserButton.style.backgroundColor = '#0348A820'; } else { // Return to drawing mode // eraserButton.style.backgroundColor = 'green'; // Restore eraser button color eraserButton.style.color = 'blue'; eraserButton.style.border = 'none'; + eraserButton.style.backgroundColor = 'transparent'; } }); // Add the Clear and Eraser buttons to the container diff --git a/src/pages/drawing/v2.astro b/src/pages/drawing/v2.astro index 114c6cd..b2ae208 100644 --- a/src/pages/drawing/v2.astro +++ b/src/pages/drawing/v2.astro @@ -18,7 +18,7 @@ import Layout from '../../layouts/Layout.astro';
- +
diff --git a/src/pages/drawing/v3.astro b/src/pages/drawing/v3.astro index 8000070..d306e8d 100644 --- a/src/pages/drawing/v3.astro +++ b/src/pages/drawing/v3.astro @@ -18,7 +18,7 @@ import Layout from '../../layouts/Layout.astro';
- +
diff --git a/src/pages/guided-tracing/A.astro b/src/pages/guided-tracing/A.astro index 4f00502..ac7de23 100644 --- a/src/pages/guided-tracing/A.astro +++ b/src/pages/guided-tracing/A.astro @@ -8,69 +8,20 @@ import Layout from "../../layouts/Layout.astro"; -