s1
This commit is contained in:
@@ -6,9 +6,8 @@
|
||||
const userId = urlParams.get('userId');
|
||||
const gameVersion = urlParams.get('gameName');
|
||||
const gameId = urlParams.get('id');
|
||||
const spriteName = urlParams.get('spriteName');
|
||||
let submitNotic;
|
||||
|
||||
console.log(userId);
|
||||
let startTime = Date.now();
|
||||
|
||||
|
||||
@@ -39,6 +38,7 @@
|
||||
// console.log(gameVersion)
|
||||
let imageCode;
|
||||
let gameScore;
|
||||
let timeDifferenceInSeconds;
|
||||
|
||||
// if(scoreTotal){
|
||||
// gameScore = scoreTotal;
|
||||
@@ -49,6 +49,9 @@
|
||||
|
||||
function submitUserData(drawingZone) {
|
||||
submitButton.setVisible(false);
|
||||
galleryButton.setVisible(false);
|
||||
customCursor.setVisible(false);
|
||||
snapshotButton.setVisible(false);
|
||||
if(!gameType[0] === 'guided-tracing'){
|
||||
snapshotButton.setVisible(false);
|
||||
customCursor.setVisible(false);
|
||||
@@ -59,13 +62,16 @@ function submitUserData(drawingZone) {
|
||||
|
||||
const endTime = Date.now();
|
||||
const timeDifference = endTime - startTime;
|
||||
const timeDifferenceInSeconds = timeDifference / 1000;
|
||||
timeDifferenceInSeconds = timeDifference / 1000;
|
||||
// console.log(`Time difference: ${timeDifferenceInSeconds} seconds`);
|
||||
|
||||
|
||||
// console.log('This is from main point', scoreTotal);
|
||||
drawingZone.renderer.snapshot((image) => {
|
||||
submitButton.setVisible(true);
|
||||
galleryButton.setVisible(true);
|
||||
customCursor.setVisible(true);
|
||||
snapshotButton.setVisible(true);
|
||||
if(!gameType[0] == "guided-tracing"){
|
||||
snapshotButton.setVisible(true);
|
||||
customCursor.setVisible(true);
|
||||
@@ -117,7 +123,23 @@ function submitUserData(drawingZone) {
|
||||
'gameTime' : timeDifferenceInSeconds
|
||||
|
||||
};
|
||||
console.log(userData);
|
||||
console.log('userData', userData)
|
||||
fetch(`http://localhost:5175/api/saveGalleryImage`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type' : 'application/json'
|
||||
},
|
||||
body: JSON.stringify(userData)
|
||||
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
console.log('data from save gallery', data);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('An error occured', error);
|
||||
})
|
||||
// console.log(userData);
|
||||
fetch(`https://api.teachertrainingkolkata.in/api/saveGameScore2`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
@@ -129,10 +151,15 @@ function submitUserData(drawingZone) {
|
||||
setTimeout(() => {
|
||||
if (response.ok) {
|
||||
if (response.status == 200) {
|
||||
console.log(response.status, " Data Saved Succesfully");
|
||||
document.getElementById('saved-toast').classList.remove('hidden');
|
||||
setTimeout(() => {
|
||||
document.getElementById('saved-toast').classList.add('hidden');
|
||||
}, 2000);
|
||||
|
||||
// console.log(response.status, " Data Saved Succesfully");
|
||||
}
|
||||
} else {
|
||||
console.log('Something went wrong', response);
|
||||
// console.log('Something went wrong', response);
|
||||
}
|
||||
}, 100);
|
||||
})
|
||||
@@ -142,13 +169,15 @@ function submitUserData(drawingZone) {
|
||||
|
||||
// Clear the drawing
|
||||
// graphics.clear();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
};
|
||||
|
||||
function calculateFromAI(){
|
||||
let progress = 0;
|
||||
let starValue = 4;
|
||||
let maxStarValue = 5;
|
||||
function calculateFromAI(){
|
||||
let progress = 0;
|
||||
let starValue;
|
||||
let maxStarValue = 5;
|
||||
|
||||
function progressIncrement() {
|
||||
const interval = setInterval(() => {
|
||||
@@ -234,10 +263,14 @@ function calculateFromAI(){
|
||||
calculationText.style.color = 'rgba(0, 0, 0, 0.38)';
|
||||
containerDiv.appendChild(calculationText);
|
||||
let userData = {
|
||||
'name' : 'Worksheet Name Here'
|
||||
gameName: gameVersion,
|
||||
userId: userId,
|
||||
gameID: gameId,
|
||||
gameTime: timeDifferenceInSeconds,
|
||||
screenShot: imageCode
|
||||
};
|
||||
console.log(userData);
|
||||
fetch(`https://game-du.teachertrainingkolkata.in/items/test`, {
|
||||
// console.log(userData);
|
||||
fetch(`https://api.teachertrainingkolkata.in/api/aiEvaluateImageToStar`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
@@ -245,35 +278,51 @@ function calculateFromAI(){
|
||||
body: JSON.stringify(userData)
|
||||
})
|
||||
.then(response => {
|
||||
setTimeout(() => {
|
||||
if (response.ok) {
|
||||
if (response.status == 200) {
|
||||
loadingMainContainer.style.display = 'none';
|
||||
loadingDiv.style.display = 'none';
|
||||
starContainer.style.display = 'flex';
|
||||
starContainer.style.flexDirection = 'row';
|
||||
document.getElementById('countStar').innerHTML = starValue;
|
||||
for (let i = 0; i < starValue; i++) {
|
||||
const starDiv = document.createElement('div');
|
||||
starDiv.innerHTML = starSVG;
|
||||
starDiv.classList.add('star');
|
||||
starContainer.appendChild(starDiv);
|
||||
setTimeout(() => {
|
||||
starDiv.style.opacity = '1';
|
||||
starDiv.style.animationDelay = `${i * 0.5}s`;
|
||||
}, i * 500);
|
||||
}
|
||||
for (let i = 0; i < maxStarValue - starValue; i++) {
|
||||
const starDiv = document.createElement('div');
|
||||
starDiv.innerHTML = blankStar;
|
||||
starContainer.appendChild(starDiv);
|
||||
}
|
||||
scoreBoard.style.display = 'flex';
|
||||
if(!response.ok){
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
} else {
|
||||
console.log('Something went wrong', response);
|
||||
}
|
||||
}, 100);
|
||||
return response.json()
|
||||
})
|
||||
.then(data => {
|
||||
// console.log('data', data.data.score);
|
||||
setTimeout(() => {
|
||||
if (data && data.message === "Game data saved successfully") {
|
||||
starValue = data.data.score;
|
||||
loadingMainContainer.style.display = 'none';
|
||||
loadingDiv.style.display = 'none';
|
||||
starContainer.style.display = 'flex';
|
||||
starContainer.style.flexDirection = 'row';
|
||||
document.getElementById('countStar').innerHTML = starValue;
|
||||
for (let i = 0; i < starValue; i++) {
|
||||
const starDiv = document.createElement('div');
|
||||
starDiv.innerHTML = starSVG;
|
||||
starDiv.classList.add('star');
|
||||
starContainer.appendChild(starDiv);
|
||||
setTimeout(() => {
|
||||
starDiv.style.opacity = '1';
|
||||
starDiv.style.animationDelay = `${i * 0.5}s`;
|
||||
}, i * 500);
|
||||
}
|
||||
for (let i = 0; i < maxStarValue - starValue; i++) {
|
||||
const starDiv = document.createElement('div');
|
||||
starDiv.innerHTML = blankStar;
|
||||
starContainer.appendChild(starDiv);
|
||||
}
|
||||
scoreBoard.style.display = 'flex';
|
||||
if (scoreBoard.style.display === 'flex') {
|
||||
const bottomAnimateClipart = document.getElementById('bottomAnimateClipart');
|
||||
bottomAnimateClipart.classList.remove('hidden');
|
||||
bottomAnimateClipart.classList.add('-translate-x-full');
|
||||
bottomAnimateClipart.classList.add('transition-transform', 'duration-700');
|
||||
setTimeout(() => {
|
||||
bottomAnimateClipart.classList.add('hidden');
|
||||
bottomAnimateClipart.classList.remove('translate-x-full');
|
||||
}, 100);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}, 100);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('An error occurred', error);
|
||||
|
||||
Reference in New Issue
Block a user