diff --git a/public/saveGameData.js b/public/saveGameData.js index 52938ad..843aa0e 100644 --- a/public/saveGameData.js +++ b/public/saveGameData.js @@ -13,19 +13,23 @@ const gameName = url.split('/'); const gameType = gameName[3].split('?id='); let gameVersion; +console.log("Here is game name ", gameName) if(gameType[0] == "guided-tracing"){ gameVersion = gameType[0].split('?')[0]; gameId = gameName[4]; + console.log('Type - 1'); } else if(gameName.length == 5){ gameVersion = gameName[3]; 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(gameType[0]) function submitUserData(drawingZone) { const endTime = Date.now(); @@ -74,8 +78,14 @@ function submitUserData(drawingZone) { 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, @@ -83,7 +93,8 @@ function submitUserData(drawingZone) { 'screenShot': imageCode, 'userId' : userId, 'gameTime' : timeDifferenceInSeconds, - 'score' : scoreTotal + 'score' : scoreTotal, + 'star' : starValue // 'starts': formattedDateTime, // 'game_start' : gameStartTime, }; diff --git a/src/pages/cross/cross_phonics_v1.astro b/src/pages/cross/cross_phonics_v1.astro index a527977..a3411d0 100644 --- a/src/pages/cross/cross_phonics_v1.astro +++ b/src/pages/cross/cross_phonics_v1.astro @@ -67,9 +67,9 @@ import Layout from "../../layouts/Layout.astro"; -