submit user data in all games
This commit is contained in:
@@ -26,7 +26,7 @@ import Layout from "../../layouts/Layout.astro";
|
||||
<!-- <p id="LearningSubArea"></p> -->
|
||||
</div>
|
||||
<div class="flex flex-col justify-center place-items-center">
|
||||
<img class="lg:w-[50%]" draggable="false" id="descImage" src="" alt="" />
|
||||
<img class="md:w-[80%] lg:w-[35%]" draggable="false" id="descImage" src="" alt="" />
|
||||
<p class="text-2xl lg:text-4xl text-center font-[600] text-[#7c4c23] mb-0 select-none " id="gameLabel"></p>
|
||||
</div>
|
||||
<form id="contactForm" class="">
|
||||
@@ -67,10 +67,12 @@ import Layout from "../../layouts/Layout.astro";
|
||||
</Layout>
|
||||
<script is:inline>
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const paramsID = params.get('id');
|
||||
const gameId = params.get('id');
|
||||
const userId = params.get('userid');
|
||||
let startTime = Date.now();
|
||||
let gameData = null;
|
||||
|
||||
fetch(`https://game-du.teachertrainingkolkata.in/items/game_tick_v3_phonics/${encodeURIComponent(paramsID)}?filter[status][_eq]=published`)
|
||||
fetch(`https://game-du.teachertrainingkolkata.in/items/game_tick_v3_phonics/${encodeURIComponent(gameId)}?filter[status][_eq]=published`)
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
gameData = data.data;
|
||||
@@ -82,18 +84,6 @@ import Layout from "../../layouts/Layout.astro";
|
||||
document.getElementById("label2").innerHTML = gameData.label2;
|
||||
document.getElementById("label3").innerHTML = gameData.label3;
|
||||
}
|
||||
// if(gameData.label1){
|
||||
// document.getElementById("label1").innerHTML = gameData.label1;
|
||||
// }
|
||||
// if(gameData.label2){
|
||||
// document.getElementById("label2").innerHTML = gameData.label2;
|
||||
// }
|
||||
// if(gameData.label3){
|
||||
// document.getElementById("label3").innerHTML = gameData.label3;
|
||||
// }
|
||||
// document.getElementById('LearningArea').innerHTML = gameData.LearningArea;
|
||||
// document.getElementById('LearningSubArea').innerHTML = gameData.LearningSubArea;
|
||||
|
||||
const assetsURL = 'https://game-du.teachertrainingkolkata.in/assets/';
|
||||
document.getElementById('descImage').src = assetsURL + gameData.descript_img;
|
||||
for (let i = 1; i <= 3; i++) {
|
||||
@@ -121,14 +111,12 @@ import Layout from "../../layouts/Layout.astro";
|
||||
let url = window.location.href;
|
||||
let urlSplit = url.split('/');
|
||||
let gameName = urlSplit[3] + '-' + urlSplit[4];
|
||||
let formatedDateTime;
|
||||
|
||||
window.onload = function () {
|
||||
let currentTime = new Date();
|
||||
formatedDateTime = currentTime.toLocaleString();
|
||||
};
|
||||
|
||||
function saveUserData() {
|
||||
const endTime = Date.now();
|
||||
const timeDifference = endTime - startTime;
|
||||
const timeDifferenceInSeconds = timeDifference / 1000;
|
||||
|
||||
// Get checkbox values and corresponding elements
|
||||
const checkboxes = ['a1', 'a2', 'a3'];
|
||||
const checkboxValues = checkboxes.map(id => {
|
||||
@@ -150,13 +138,14 @@ import Layout from "../../layouts/Layout.astro";
|
||||
});
|
||||
|
||||
let userData = {
|
||||
'user': 'tick-v1@beanstalkedu.com',
|
||||
'game_name': gameName,
|
||||
'starts': formatedDateTime,
|
||||
'score': totalPoints, // Include the totalPoints in the userData
|
||||
'gameName': gameName,
|
||||
'gameID': gameId,
|
||||
'userId': userId,
|
||||
'gameTime': timeDifferenceInSeconds,
|
||||
'score': totalPoints,
|
||||
};
|
||||
console.log(userData);
|
||||
fetch(`https://2016.dev2-cs.siliconpin.com/save/`, {
|
||||
fetch(`https://phaser-game-api.s38.siliconpin.com/save-data`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
|
||||
Reference in New Issue
Block a user