diff --git a/src/pages/cross/cross_phonics_v1.astro b/src/pages/cross/cross_phonics_v1.astro
index 0046685..3239177 100644
--- a/src/pages/cross/cross_phonics_v1.astro
+++ b/src/pages/cross/cross_phonics_v1.astro
@@ -153,7 +153,7 @@ import Layout from "../../layouts/Layout.astro";
let maxScore = 6;
let progress = 0;
const progressBar = document.createElement('div');
-
+ let totalCorrectFromApi = 0;
fetch(`https://game-du.teachertrainingkolkata.in/items/cross_phonics_option_6/${encodeURIComponent(gameId)}?filter[status][_eq]=published`)
.then(res => res.json())
.then(data => {
@@ -285,17 +285,25 @@ import Layout from "../../layouts/Layout.astro";
totalPoints += 1;
}
});
-
- let starValue = Math.round((totalPoints / maxScore) * 10);
- starValue = starValue === 0 ? 3 : starValue;
+ const answersList = ['a1', 'a2', 'a3', 'a4', 'a5', 'a6'];
+ answersList.forEach((answer) => {
+ if (gameData[answer] === true) {
+ totalCorrectFromApi++;
+ }
+ });
+ let afterNegative = totalPoints - wrongCount;
+ let percentage = Math.round((afterNegative / totalCorrectFromApi ) * 10);
+ if(percentage <= 3){
+ percentage = 3
+ }
let feedbackMessage = '';
- if (starValue >= 1 && starValue <= 3) {
+ if (percentage >= 1 && percentage <= 3) {
feedbackMessage = "You're making progress! Let's keep going!";
- } else if (starValue >= 4 && starValue <= 6) {
+ } else if (percentage >= 4 && percentage <= 6) {
feedbackMessage = "Nice work! You're improving every day!";
- } else if (starValue >= 7 && starValue <= 8) {
+ } else if (percentage >= 7 && percentage <= 8) {
feedbackMessage = "Amazing work! Keep it up!";
- } else if (starValue >= 9 && starValue <= 10) {
+ } else if (percentage >= 9 && percentage <= 10) {
feedbackMessage = "Outstanding! You're a true superstar!";
} else {
feedbackMessage = "Invalid star value.";
@@ -416,7 +424,7 @@ import Layout from "../../layouts/Layout.astro";
'userId': userId,
'gameTime': timeDifferenceInSeconds,
'score': totalPoints,
- 'gameStar': starValue
+ 'gameStar': percentage
};
fetch(`https://api.teachertrainingkolkata.in/api/saveGameScore2`, {
method: 'POST',
@@ -436,7 +444,7 @@ import Layout from "../../layouts/Layout.astro";
starContainer.style.display = 'flex';
starContainer.style.flexDirection = 'row';
document.getElementById('starFeedbackMessage').innerHTML = feedbackMessage;
- document.getElementById('get-star-value').innerHTML = starValue;
+ document.getElementById('get-star-value').innerHTML = percentage;
scoreBoard.style.display = 'flex';
}
} else {
diff --git a/src/pages/cross/cross_phonics_v2.astro b/src/pages/cross/cross_phonics_v2.astro
index 930d760..81c9a67 100644
--- a/src/pages/cross/cross_phonics_v2.astro
+++ b/src/pages/cross/cross_phonics_v2.astro
@@ -161,7 +161,7 @@ import Layout from "../../layouts/Layout.astro";
let maxScore = 9;
let progress = 0;
const progressBar = document.createElement('div');
-
+ let totalCorrectFromApi = 0;
fetch(`https://game-du.teachertrainingkolkata.in/items/cross_phonics_option_9/${encodeURIComponent(gameId)}?filter[status][_eq]=published`)
.then(res => res.json())
.then(data => {
@@ -284,17 +284,6 @@ import Layout from "../../layouts/Layout.astro";
const endTime = Date.now();
const timeDifference = endTime - startTime;
const timeDifferenceInSeconds = timeDifference / 1000;
- // const checkboxValues = {
- // a1: document.getElementById('a1').checked,
- // a2: document.getElementById('a2').checked,
- // a3: document.getElementById('a3').checked,
- // a4: document.getElementById('a4').checked,
- // a5: document.getElementById('a5').checked,
- // a6: document.getElementById('a6').checked,
- // a7: document.getElementById('a7').checked,
- // a8: document.getElementById('a8').checked,
- // a9: document.getElementById('a9').checked,
- // };
const checkboxValues = checkboxes.map(id => {
const checkbox = document.getElementById(id);
const element = document.getElementById('image' + id.slice(-1));
@@ -312,16 +301,26 @@ import Layout from "../../layouts/Layout.astro";
}
});
- let starValue = Math.round((totalPoints / maxScore) * 10);
- starValue = starValue === 0 ? 3 : starValue;
+ const answersList = ['a1', 'a2', 'a3', 'a4', 'a5', 'a6'];
+ answersList.forEach((answer) => {
+ if (gameData[answer] === true) {
+ totalCorrectFromApi++;
+ }
+ });
+
+ let afterNegative = totalPoints - wrongCount;
+ let percentage = Math.round((afterNegative / totalCorrectFromApi ) * 10);
+ if(percentage <= 3){
+ percentage = 3
+ }
let feedbackMessage = '';
- if (starValue >= 1 && starValue <= 3) {
+ if (percentage >= 1 && percentage <= 3) {
feedbackMessage = "You're making progress! Let's keep going!";
- } else if (starValue >= 4 && starValue <= 6) {
+ } else if (percentage >= 4 && percentage <= 6) {
feedbackMessage = "Nice work! You're improving every day!";
- } else if (starValue >= 7 && starValue <= 8) {
+ } else if (percentage >= 7 && percentage <= 8) {
feedbackMessage = "Amazing work! Keep it up!";
- } else if (starValue >= 9 && starValue <= 10) {
+ } else if (percentage >= 9 && percentage <= 10) {
feedbackMessage = "Outstanding! You're a true superstar!";
} else {
feedbackMessage = "Invalid star value.";
@@ -330,9 +329,7 @@ import Layout from "../../layouts/Layout.astro";
progressIncrement();
addStarScalingStyles();
showClipArt();
- const blankStar = ``
- const starSVG = ``;
const starContainer = document.getElementById('star-container');
let scoreBoard = document.getElementById('scoreBoard');
let loadingMainContainer = document.getElementById('loadingMainContainer');
@@ -442,7 +439,7 @@ import Layout from "../../layouts/Layout.astro";
'userId': userId,
'gameTime': timeDifferenceInSeconds,
'score': totalPoints,
- 'gameStar': starValue
+ 'gameStar': percentage
};
fetch(`https://api.teachertrainingkolkata.in/api/saveGameScore2`, {
method: 'POST',
@@ -462,7 +459,7 @@ import Layout from "../../layouts/Layout.astro";
starContainer.style.display = 'flex';
starContainer.style.flexDirection = 'row';
document.getElementById('starFeedbackMessage').innerHTML = feedbackMessage;
- document.getElementById('get-star-value').innerHTML = starValue;
+ document.getElementById('get-star-value').innerHTML = percentage;
scoreBoard.style.display = 'flex';
}
} else {
diff --git a/src/pages/cross/v1.astro b/src/pages/cross/v1.astro
index a8d8724..3dc1245 100644
--- a/src/pages/cross/v1.astro
+++ b/src/pages/cross/v1.astro
@@ -153,7 +153,7 @@ import Layout from "../../layouts/Layout.astro";
let maxScore = 6;
let progress = 0;
const progressBar = document.createElement('div');
-
+ let totalCorrectFromApi = 0;
fetch(`https://game-du.teachertrainingkolkata.in/items/game_cross_varient1/${encodeURIComponent(gameId)}?filter[status][_eq]=published`)
.then(res => res.json())
@@ -288,16 +288,26 @@ import Layout from "../../layouts/Layout.astro";
}
});
- let starValue = Math.round((totalPoints / maxScore) * 10);
- starValue = starValue === 0 ? 3 : starValue;
+ const answersList = ['a1', 'a2', 'a3', 'a4', 'a5', 'a6'];
+ answersList.forEach((answer) => {
+ if (gameData[answer] === true) {
+ totalCorrectFromApi++;
+ }
+ });
+
+ let afterNegative = totalPoints - wrongCount;
+ let percentage = Math.round((afterNegative / totalCorrectFromApi ) * 10);
+ if(percentage <= 3){
+ percentage = 3
+ }
let feedbackMessage = '';
- if (starValue >= 1 && starValue <= 3) {
+ if (percentage >= 1 && percentage <= 3) {
feedbackMessage = "You're making progress! Let's keep going!";
- } else if (starValue >= 4 && starValue <= 6) {
+ } else if (percentage >= 4 && percentage <= 6) {
feedbackMessage = "Nice work! You're improving every day!";
- } else if (starValue >= 7 && starValue <= 8) {
+ } else if (percentage >= 7 && percentage <= 8) {
feedbackMessage = "Amazing work! Keep it up!";
- } else if (starValue >= 9 && starValue <= 10) {
+ } else if (percentage >= 9 && percentage <= 10) {
feedbackMessage = "Outstanding! You're a true superstar!";
} else {
feedbackMessage = "Invalid star value.";
@@ -418,7 +428,7 @@ import Layout from "../../layouts/Layout.astro";
'userId': userId,
'gameTime': timeDifferenceInSeconds,
'score': totalPoints,
- 'gameStar': starValue
+ 'gameStar': percentage
};
fetch(`https://api.teachertrainingkolkata.in/api/saveGameScore2`, {
method: 'POST',
@@ -438,7 +448,7 @@ import Layout from "../../layouts/Layout.astro";
starContainer.style.display = 'flex';
starContainer.style.flexDirection = 'row';
document.getElementById('starFeedbackMessage').innerHTML = feedbackMessage;
- document.getElementById('get-star-value').innerHTML = starValue;
+ document.getElementById('get-star-value').innerHTML = percentage;
scoreBoard.style.display = 'flex';
}
} else {
diff --git a/src/pages/cross/v2.astro b/src/pages/cross/v2.astro
index fbd97eb..ada50b2 100644
--- a/src/pages/cross/v2.astro
+++ b/src/pages/cross/v2.astro
@@ -157,7 +157,7 @@ import Layout from "../../layouts/Layout.astro";
let maxScore = 9;
let progress = 0;
const progressBar = document.createElement('div');
-
+ let totalCorrectFromApi = 0;
fetch(`https://game-du.teachertrainingkolkata.in/items/game_cross_varient2/${encodeURIComponent(gameId)}?filter[status][_eq]=published`)
.then(res => res.json())
.then(data => {
@@ -297,16 +297,26 @@ import Layout from "../../layouts/Layout.astro";
});
- let starValue = Math.round((totalPoints / maxScore) * 10);
- starValue = starValue === 0 ? 3 : starValue;
+ const answersList = ['a1', 'a2', 'a3', 'a4', 'a5', 'a6', 'a7', 'a8', 'a9'];
+ answersList.forEach((answer) => {
+ if (gameData[answer] === true) {
+ totalCorrectFromApi++;
+ }
+ });
+
+ let afterNegative = totalPoints - wrongCount;
+ let percentage = Math.round((afterNegative / totalCorrectFromApi ) * 10);
+ if(percentage <= 3){
+ percentage = 3
+ }
let feedbackMessage = '';
- if (starValue >= 1 && starValue <= 3) {
+ if (percentage >= 1 && percentage <= 3) {
feedbackMessage = "You're making progress! Let's keep going!";
- } else if (starValue >= 4 && starValue <= 6) {
+ } else if (percentage >= 4 && percentage <= 6) {
feedbackMessage = "Nice work! You're improving every day!";
- } else if (starValue >= 7 && starValue <= 8) {
+ } else if (percentage >= 7 && percentage <= 8) {
feedbackMessage = "Amazing work! Keep it up!";
- } else if (starValue >= 9 && starValue <= 10) {
+ } else if (percentage >= 9 && percentage <= 10) {
feedbackMessage = "Outstanding! You're a true superstar!";
} else {
feedbackMessage = "Invalid star value.";
@@ -315,9 +325,6 @@ import Layout from "../../layouts/Layout.astro";
progressIncrement();
addStarScalingStyles();
showClipArt();
- const blankStar = ``
-
- const starSVG = ``;
const starContainer = document.getElementById('star-container');
let scoreBoard = document.getElementById('scoreBoard');
let loadingMainContainer = document.getElementById('loadingMainContainer');
@@ -427,7 +434,7 @@ import Layout from "../../layouts/Layout.astro";
'userId': userId,
'gameTime': timeDifferenceInSeconds,
'score': totalPoints,
- 'gameStar': starValue
+ 'gameStar': percentage
};
fetch(`https://api.teachertrainingkolkata.in/api/saveGameScore2`, {
method: 'POST',
@@ -447,7 +454,7 @@ import Layout from "../../layouts/Layout.astro";
starContainer.style.display = 'flex';
starContainer.style.flexDirection = 'row';
document.getElementById('starFeedbackMessage').innerHTML = feedbackMessage;
- document.getElementById('get-star-value').innerHTML = starValue;
+ document.getElementById('get-star-value').innerHTML = percentage;
scoreBoard.style.display = 'flex';
}
} else {
diff --git a/src/pages/cross/v3.astro b/src/pages/cross/v3.astro
index 94b0fbd..2290311 100644
--- a/src/pages/cross/v3.astro
+++ b/src/pages/cross/v3.astro
@@ -124,14 +124,13 @@ import Layout from "../../layouts/Layout.astro";
let startTime = Date.now();
let gameData = null;
let totalPoints = 0;
- let starValue;
+ let wrongCount = 0;
let url = window.location.href;
let urlSplit = url.split('/');
// let gameName = urlSplit[3] + '-' + urlSplit[4].split('?')[0];
- let maxScore = 3;
let progress = 0;
const progressBar = document.createElement('div');
-
+ let totalCorrectFromApi = 0;
fetch(`https://game-du.teachertrainingkolkata.in/items/game_cross_varient3/${encodeURIComponent(gameId)}?filter[status][_eq]=published`)
.then(res => res.json())
.then(data => {
@@ -148,18 +147,7 @@ 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++) {
@@ -170,11 +158,11 @@ import Layout from "../../layouts/Layout.astro";
}
});
function showClipArt() {
- const clipArtContainer = document.querySelector('.clip-art-container');
+ const clipArtContainer = document.querySelector('.clip-art-container');
- clipArtContainer.classList.remove('hidden');
- clipArtContainer.classList.add('slide-in');
- }
+ clipArtContainer.classList.remove('hidden');
+ clipArtContainer.classList.add('slide-in');
+ }
function addStarScalingStyles() {
const style = document.createElement('style');
@@ -217,6 +205,7 @@ import Layout from "../../layouts/Layout.astro";
element.classList.add('redBorder');
} else {
element.classList.add('greenBorder');
+ wrongCount += 1;
}
} else {
wrongCount -= 1;
@@ -249,16 +238,26 @@ import Layout from "../../layouts/Layout.astro";
}
});
- let starValue = Math.round((totalPoints / maxScore) * 10);
- starValue = starValue === 0 ? 3 : starValue;
+ const answersList = ['a1', 'a2', 'a3'];
+ answersList.forEach((answer) => {
+ if (gameData[answer] === true) {
+ totalCorrectFromApi++;
+ }
+ });
+
+ let afterNegative = totalPoints - wrongCount;
+ let percentage = Math.round((afterNegative / totalCorrectFromApi ) * 10);
+ if(percentage <= 3){
+ percentage = 3
+ }
let feedbackMessage = '';
- if (starValue >= 1 && starValue <= 3) {
+ if (percentage >= 1 && percentage <= 3) {
feedbackMessage = "You're making progress! Let's keep going!";
- } else if (starValue >= 4 && starValue <= 6) {
+ } else if (percentage >= 4 && percentage <= 6) {
feedbackMessage = "Nice work! You're improving every day!";
- } else if (starValue >= 7 && starValue <= 8) {
+ } else if (percentage >= 7 && percentage <= 8) {
feedbackMessage = "Amazing work! Keep it up!";
- } else if (starValue >= 9 && starValue <= 10) {
+ } else if (percentage >= 9 && percentage <= 10) {
feedbackMessage = "Outstanding! You're a true superstar!";
} else {
feedbackMessage = "Invalid star value.";
@@ -266,9 +265,7 @@ import Layout from "../../layouts/Layout.astro";
progressIncrement();
addStarScalingStyles();
showClipArt();
- const blankStar = ``
-
- const starSVG = ``;
+
const starContainer = document.getElementById('star-container');
let scoreBoard = document.getElementById('scoreBoard');
let loadingMainContainer = document.getElementById('loadingMainContainer');
@@ -378,7 +375,7 @@ import Layout from "../../layouts/Layout.astro";
'userId': userId,
'gameTime': timeDifferenceInSeconds,
'score': totalPoints,
- 'gameStar': starValue
+ 'gameStar': percentage
};
fetch(`https://api.teachertrainingkolkata.in/api/saveGameScore2`, {
method: 'POST',
@@ -398,7 +395,7 @@ import Layout from "../../layouts/Layout.astro";
starContainer.style.display = 'flex';
starContainer.style.flexDirection = 'row';
document.getElementById('starFeedbackMessage').innerHTML = feedbackMessage;
- document.getElementById('get-star-value').innerHTML = starValue;
+ document.getElementById('get-star-value').innerHTML = percentage;
scoreBoard.style.display = 'flex';
}
} else {
diff --git a/src/pages/tick/tick_phonics_v1.astro b/src/pages/tick/tick_phonics_v1.astro
index ccade0a..b456745 100644
--- a/src/pages/tick/tick_phonics_v1.astro
+++ b/src/pages/tick/tick_phonics_v1.astro
@@ -149,15 +149,13 @@ import Layout from "../../layouts/Layout.astro";
let startTime = Date.now();
let gameData = null;
let wrongCount = 0;
- let starValue;
let totalPoints = 0;
let url = window.location.href;
let urlSplit = url.split('/');
// let gameName = urlSplit[3] + '-' + urlSplit[4].split('?')[0];
- let maxScore = 6;
let progress = 0;
const progressBar = document.createElement('div');
-
+ let totalCorrectFromApi = 0;
function showClipArt() {
const clipArtContainer = document.querySelector('.clip-art-container');
@@ -244,9 +242,10 @@ import Layout from "../../layouts/Layout.astro";
element.classList.add('greenBorder');
} else {
element.classList.add('redBorder');
+ wrongCount += 1;
}
} else {
- wrongCount -= 1;
+ wrongCount += 1;
element.classList.remove('greenBorder', 'redBorder');
}
}
@@ -287,28 +286,41 @@ import Layout from "../../layouts/Layout.astro";
totalPoints += 1;
}
});
+ const answersList = ['a1', 'a2', 'a3', 'a4', 'a5', 'a6'];
+ answersList.forEach((answer) => {
+ if (gameData[answer] === true) {
+ totalCorrectFromApi++;
+ }
+ });
- let starValue = Math.round((totalPoints / maxScore) * 10);
- starValue = starValue === 0 ? 3 : starValue;
+ let afterNegative = totalPoints - wrongCount;
+ let percentage = Math.round((afterNegative / totalCorrectFromApi ) * 10);
+ if(percentage <= 3){
+ percentage = 3
+ }
let feedbackMessage = '';
- if (starValue >= 1 && starValue <= 3) {
+ if (percentage >= 1 && percentage <= 3) {
feedbackMessage = "You're making progress! Let's keep going!";
- } else if (starValue >= 4 && starValue <= 6) {
+ } else if (percentage >= 4 && percentage <= 6) {
feedbackMessage = "Nice work! You're improving every day!";
- } else if (starValue >= 7 && starValue <= 8) {
+ } else if (percentage >= 7 && percentage <= 8) {
feedbackMessage = "Amazing work! Keep it up!";
- } else if (starValue >= 9 && starValue <= 10) {
+ } else if (percentage >= 9 && percentage <= 10) {
feedbackMessage = "Outstanding! You're a true superstar!";
} else {
feedbackMessage = "Invalid star value.";
}
+ // console.log('totalCorrectFromApi', totalCorrectFromApi)
+ // console.log('totalPoints', totalPoints)
+ // console.log('wrongCount', wrongCount);
+ // console.log('afterNegative', afterNegative);
+ // console.log('percentage', percentage)
+
progressIncrement();
addStarScalingStyles();
showClipArt();
- const blankStar = ``
-
- const starSVG = ``;
+
const starContainer = document.getElementById('star-container');
let scoreBoard = document.getElementById('scoreBoard');
let loadingMainContainer = document.getElementById('loadingMainContainer');
@@ -419,7 +431,7 @@ import Layout from "../../layouts/Layout.astro";
'userId': userId,
'gameTime': timeDifferenceInSeconds,
'score': totalPoints,
- 'gameStar': starValue
+ 'gameStar': percentage
};
fetch(`https://api.teachertrainingkolkata.in/api/saveGameScore2`, {
method: 'POST',
@@ -438,7 +450,7 @@ import Layout from "../../layouts/Layout.astro";
starContainer.style.display = 'flex';
starContainer.style.flexDirection = 'row';
document.getElementById('starFeedbackMessage').innerHTML = feedbackMessage;
- document.getElementById('get-star-value').innerHTML = starValue;
+ document.getElementById('get-star-value').innerHTML = percentage;
scoreBoard.style.display = 'flex';
}
} else {
diff --git a/src/pages/tick/tick_phonics_v2.astro b/src/pages/tick/tick_phonics_v2.astro
index 2d1dd31..40099d0 100644
--- a/src/pages/tick/tick_phonics_v2.astro
+++ b/src/pages/tick/tick_phonics_v2.astro
@@ -179,7 +179,7 @@ import Layout from "../../layouts/Layout.astro";
let maxScore = 6;
let progress = 0;
const progressBar = document.createElement('div');
-
+ let totalCorrectFromApi = 0;
function showClipArt() {
const clipArtContainer = document.querySelector('.clip-art-container');
@@ -274,6 +274,7 @@ import Layout from "../../layouts/Layout.astro";
element.classList.add('greenBorder');
} else {
element.classList.add('redBorder');
+ wrongCount += 1;
}
} else {
wrongCount -= 1;
@@ -316,16 +317,26 @@ import Layout from "../../layouts/Layout.astro";
totalPoints += 1;
}
});
- let starValue = Math.round((totalPoints / maxScore) * 10);
- starValue = starValue === 0 ? 3 : starValue;
+ const answersList = ['a1', 'a2', 'a3', 'a4', 'a5', 'a6', 'a7', 'a8', 'a9'];
+ answersList.forEach((answer) => {
+ if (gameData[answer] === true) {
+ totalCorrectFromApi++;
+ }
+ });
+
+ let afterNegative = totalPoints - wrongCount;
+ let percentage = Math.round((afterNegative / totalCorrectFromApi ) * 10);
+ if(percentage <= 3){
+ percentage = 3
+ }
let feedbackMessage = '';
- if (starValue >= 1 && starValue <= 3) {
+ if (percentage >= 1 && percentage <= 3) {
feedbackMessage = "You're making progress! Let's keep going!";
- } else if (starValue >= 4 && starValue <= 6) {
+ } else if (percentage >= 4 && percentage <= 6) {
feedbackMessage = "Nice work! You're improving every day!";
- } else if (starValue >= 7 && starValue <= 8) {
+ } else if (percentage >= 7 && percentage <= 8) {
feedbackMessage = "Amazing work! Keep it up!";
- } else if (starValue >= 9 && starValue <= 10) {
+ } else if (percentage >= 9 && percentage <= 10) {
feedbackMessage = "Outstanding! You're a true superstar!";
} else {
feedbackMessage = "Invalid star value.";
@@ -447,7 +458,7 @@ import Layout from "../../layouts/Layout.astro";
'userId': userId,
'gameTime': timeDifferenceInSeconds,
'score': totalPoints,
- 'gameStar': starValue
+ 'gameStar': percentage
};
fetch(`https://api.teachertrainingkolkata.in/api/saveGameScore2`, {
@@ -467,7 +478,7 @@ import Layout from "../../layouts/Layout.astro";
starContainer.style.display = 'flex';
starContainer.style.flexDirection = 'row';
document.getElementById('starFeedbackMessage').innerHTML = feedbackMessage;
- document.getElementById('get-star-value').innerHTML = starValue;
+ document.getElementById('get-star-value').innerHTML = percentage;
scoreBoard.style.display = 'flex';
}
} else {
diff --git a/src/pages/tick/tick_phonics_v3.astro b/src/pages/tick/tick_phonics_v3.astro
index ecb4779..3f750fa 100644
--- a/src/pages/tick/tick_phonics_v3.astro
+++ b/src/pages/tick/tick_phonics_v3.astro
@@ -128,15 +128,14 @@ import Layout from "../../layouts/Layout.astro";
const worksheetId = params.get('worksheetId');
let startTime = Date.now();
let gameData = null;
- let starValue;
let url = window.location.href;
let urlSplit = url.split('/');
// let gameName = urlSplit[3] + '-' + urlSplit[4].split('?')[0];
let totalPoints = 0;
- let maxScore = 3;
+ let wrongCount = 0;
let progress = 0;
const progressBar = document.createElement('div');
-
+ let totalCorrectFromApi = 0;
function showClipArt() {
const clipArtContainer = document.querySelector('.clip-art-container');
@@ -211,9 +210,10 @@ import Layout from "../../layouts/Layout.astro";
element.classList.add('greenBorder');
} else {
element.classList.add('redBorder');
+ wrongCount += 1;
}
} else {
- wrongCount -= 1;
+ wrongCount += 1;
element.classList.remove('greenBorder', 'redBorder');
}
}
@@ -242,26 +242,35 @@ import Layout from "../../layouts/Layout.astro";
totalPoints += 1;
}
});
- let starValue = Math.round((totalPoints / maxScore) * 10);
- starValue = starValue === 0 ? 3 : starValue;
+ const answersList = ['a1', 'a2', 'a3'];
+ answersList.forEach((answer) => {
+ if (gameData[answer] === true) {
+ totalCorrectFromApi++;
+ }
+ });
+
+ let afterNegative = totalPoints - wrongCount;
+ let percentage = Math.round((afterNegative / totalCorrectFromApi ) * 10);
+ if(percentage <= 3){
+ percentage = 3
+ }
let feedbackMessage = '';
- if (starValue >= 1 && starValue <= 3) {
+ if (percentage >= 1 && percentage <= 3) {
feedbackMessage = "You're making progress! Let's keep going!";
- } else if (starValue >= 4 && starValue <= 6) {
+ } else if (percentage >= 4 && percentage <= 6) {
feedbackMessage = "Nice work! You're improving every day!";
- } else if (starValue >= 7 && starValue <= 8) {
+ } else if (percentage >= 7 && percentage <= 8) {
feedbackMessage = "Amazing work! Keep it up!";
- } else if (starValue >= 9 && starValue <= 10) {
+ } else if (percentage >= 9 && percentage <= 10) {
feedbackMessage = "Outstanding! You're a true superstar!";
} else {
feedbackMessage = "Invalid star value.";
}
+
progressIncrement();
addStarScalingStyles();
showClipArt();
- const blankStar = ``
-
- const starSVG = ``;
+
const starContainer = document.getElementById('star-container');
let scoreBoard = document.getElementById('scoreBoard');
let loadingMainContainer = document.getElementById('loadingMainContainer');
@@ -373,7 +382,7 @@ import Layout from "../../layouts/Layout.astro";
'userId': userId,
'gameTime': timeDifferenceInSeconds,
'score': totalPoints,
- 'gameStar': starValue
+ 'gameStar': percentage
};
fetch(`https://api.teachertrainingkolkata.in/api/saveGameScore2`, {
method: 'POST',
@@ -392,7 +401,7 @@ import Layout from "../../layouts/Layout.astro";
starContainer.style.display = 'flex';
starContainer.style.flexDirection = 'row';
document.getElementById('starFeedbackMessage').innerHTML = feedbackMessage;
- document.getElementById('get-star-value').innerHTML = starValue;
+ document.getElementById('get-star-value').innerHTML = percentage;
scoreBoard.style.display = 'flex';
}
} else {
diff --git a/src/pages/tick/v1.astro b/src/pages/tick/v1.astro
index a0322af..a40a4a0 100644
--- a/src/pages/tick/v1.astro
+++ b/src/pages/tick/v1.astro
@@ -152,15 +152,15 @@ import Layout from "../../layouts/Layout.astro";
let urlSplit = url.split('/');
// let gameName = urlSplit[3] + '-' + urlSplit[4].split('?')[0];
let wrongCount = 0;
- let starValue;
- let maxScore = 6;
let progress = 0;
const progressBar = document.createElement('div');
-
+ let totalCorrectFromApi = 0;
fetch(`https://game-du.teachertrainingkolkata.in/items/game_tick_variant1/${encodeURIComponent(gameId)}?filter[status][_eq]=published`)
.then(res => res.json())
.then(data => {
- gameData = data.data;
+ gameData = data.data;
+ // console.log('totalCorrectFromApi', totalCorrectFromApi) gameData
+
let audioLink = `https://game-du.teachertrainingkolkata.in/assets/${gameData.instruction}.mp3`;
document.getElementById('instrucAudio1').src = audioLink;
document.getElementById('instrucAudio2').src = audioLink;
@@ -236,7 +236,6 @@ import Layout from "../../layouts/Layout.astro";
function checkResult2(id) {
const checkbox = document.getElementById('a' + id.slice(-1));
const element = document.getElementById(id);
-
if (checkbox.checked) {
if (gameData[id.replace('image', 'a')] === true) {
element.classList.add('greenBorder');
@@ -285,16 +284,27 @@ import Layout from "../../layouts/Layout.astro";
totalPoints += 1;
}
});
- let starValue = Math.round((totalPoints / maxScore) * 10);
- starValue = starValue === 0 ? 3 : starValue;
+ // console.log('totalCorrectFromApi', gameData);
+ const answersList = ['a1', 'a2', 'a3', 'a4', 'a5', 'a6'];
+ answersList.forEach((answer) => {
+ if (gameData[answer] === true) {
+ totalCorrectFromApi++;
+ }
+ });
+
+ let afterNegative = totalPoints - wrongCount;
+ let percentage = Math.round((afterNegative / totalCorrectFromApi ) * 10);
+ if(percentage <= 3){
+ percentage = 3
+ }
let feedbackMessage = '';
- if (starValue >= 1 && starValue <= 3) {
+ if (percentage >= 1 && percentage <= 3) {
feedbackMessage = "You're making progress! Let's keep going!";
- } else if (starValue >= 4 && starValue <= 6) {
+ } else if (percentage >= 4 && percentage <= 6) {
feedbackMessage = "Nice work! You're improving every day!";
- } else if (starValue >= 7 && starValue <= 8) {
+ } else if (percentage >= 7 && percentage <= 8) {
feedbackMessage = "Amazing work! Keep it up!";
- } else if (starValue >= 9 && starValue <= 10) {
+ } else if (percentage >= 9 && percentage <= 10) {
feedbackMessage = "Outstanding! You're a true superstar!";
} else {
feedbackMessage = "Invalid star value.";
@@ -412,7 +422,7 @@ import Layout from "../../layouts/Layout.astro";
'userId': userId,
'gameTime': timeDifferenceInSeconds,
'score': totalPoints,
- 'gameStar': starValue
+ 'gameStar': percentage
};
fetch(`https://api.teachertrainingkolkata.in/api/saveGameScore2`, {
method: 'POST',
@@ -432,7 +442,7 @@ import Layout from "../../layouts/Layout.astro";
starContainer.style.display = 'flex';
starContainer.style.flexDirection = 'row';
document.getElementById('starFeedbackMessage').innerHTML = feedbackMessage;
- document.getElementById('get-star-value').innerHTML = starValue;
+ document.getElementById('get-star-value').innerHTML = percentage;
scoreBoard.style.display = 'flex';
}
} else {
diff --git a/src/pages/tick/v2.astro b/src/pages/tick/v2.astro
index b13fd27..29a6035 100644
--- a/src/pages/tick/v2.astro
+++ b/src/pages/tick/v2.astro
@@ -166,15 +166,13 @@ import Layout from "../../layouts/Layout.astro";
const worksheetId = params.get('worksheetId');
let startTime = Date.now();
let wrongCount = 0;
- let starValue;
let url = window.location.href;
let urlSplit = url.split('/');
let gameData = null;
// let gameName = urlSplit[3] + '-' + urlSplit[4].split('?')[0];
- let maxScore = 9;
let progress = 0;
const progressBar = document.createElement('div');
-
+ let totalCorrectFromApi = 0;
function showClipArt() {
const clipArtContainer = document.querySelector('.clip-art-container');
@@ -269,10 +267,10 @@ import Layout from "../../layouts/Layout.astro";
} else {
element.classList.add('redBorder');
wrongCount += 1;
- console.log("Wrong Count ", wrongCount)
+ // console.log("Wrong Count ", wrongCount)
}
} else {
- wrongCount -= 1;
+ wrongCount += 1;
element.classList.remove('greenBorder', 'redBorder');
}
}
@@ -294,17 +292,6 @@ import Layout from "../../layouts/Layout.astro";
const endTime = Date.now();
const timeDifference = endTime - startTime;
const timeDifferenceInSeconds = timeDifference / 1000;
- // const checkboxValues = {
- // a1: document.getElementById('a1').checked,
- // a2: document.getElementById('a2').checked,
- // a3: document.getElementById('a3').checked,
- // a4: document.getElementById('a4').checked,
- // a5: document.getElementById('a5').checked,
- // a6: document.getElementById('a6').checked,
- // a7: document.getElementById('a7').checked,
- // a8: document.getElementById('a8').checked,
- // a9: document.getElementById('a9').checked,
- // };
const checkboxValues = checkboxes.map(id => {
const checkbox = document.getElementById(id);
const element = document.getElementById('image' + id.slice(-1));
@@ -323,20 +310,31 @@ import Layout from "../../layouts/Layout.astro";
}
});
- let starValue = Math.round((totalPoints / maxScore) * 10);
- starValue = starValue === 0 ? 3 : starValue;
+ const answersList = ['a1', 'a2', 'a3', 'a4', 'a5', 'a6', 'a7', 'a8', 'a9'];
+ answersList.forEach((answer) => {
+ if (gameData[answer] === true) {
+ totalCorrectFromApi++;
+ }
+ });
+
+ let afterNegative = totalPoints - wrongCount;
+ let percentage = Math.round((afterNegative / totalCorrectFromApi) * 10);
+ // percentage = Math.max(3, Math.min(percentage, 10));
+ if(percentage <= 3){
+ percentage = 3
+ }
let feedbackMessage = '';
- if (starValue >= 1 && starValue <= 3) {
+ if (percentage >= 1 && percentage <= 3) {
feedbackMessage = "You're making progress! Let's keep going!";
- } else if (starValue >= 4 && starValue <= 6) {
+ } else if (percentage >= 4 && percentage <= 6) {
feedbackMessage = "Nice work! You're improving every day!";
- } else if (starValue >= 7 && starValue <= 8) {
+ } else if (percentage >= 7 && percentage <= 8) {
feedbackMessage = "Amazing work! Keep it up!";
- } else if (starValue >= 9 && starValue <= 10) {
+ } else if (percentage >= 9 && percentage <= 10) {
feedbackMessage = "Outstanding! You're a true superstar!";
- } else {
+ } else {
feedbackMessage = "Invalid star value.";
- }
+ }
progressIncrement();
addStarScalingStyles();
@@ -453,7 +451,7 @@ import Layout from "../../layouts/Layout.astro";
'userId': userId,
'gameTime': timeDifferenceInSeconds,
'score': totalPoints,
- 'gameStar': starValue
+ 'gameStar': percentage
};
fetch(`https://api.teachertrainingkolkata.in/api/saveGameScore2`, {
method: 'POST',
@@ -472,7 +470,7 @@ import Layout from "../../layouts/Layout.astro";
starContainer.style.display = 'flex';
starContainer.style.flexDirection = 'row';
document.getElementById('starFeedbackMessage').innerHTML = feedbackMessage;
- document.getElementById('get-star-value').innerHTML = starValue;
+ document.getElementById('get-star-value').innerHTML = percentage;
scoreBoard.style.display = 'flex';
}
} else {
diff --git a/src/pages/tick/v3.astro b/src/pages/tick/v3.astro
index 9b117c8..6d969f8 100644
--- a/src/pages/tick/v3.astro
+++ b/src/pages/tick/v3.astro
@@ -129,15 +129,14 @@ import Layout from "../../layouts/Layout.astro";
const worksheetId = params.get('worksheetId');
let startTime = Date.now();
let gameData = null;
- let starValue;
let url = window.location.href;
let urlSplit = url.split('/');
// let gameName = urlSplit[3] + '-' + urlSplit[4].split('?')[0];
let totalPoints = 0;
- let maxScore = 3;
+ let wrongCount = 0;
let progress = 0;
const progressBar = document.createElement('div');
-
+ let totalCorrectFromApi = 0;
function showClipArt() {
const clipArtContainer = document.querySelector('.clip-art-container');
clipArtContainer.classList.remove('hidden');
@@ -223,9 +222,10 @@ import Layout from "../../layouts/Layout.astro";
element.classList.add('greenBorder');
} else {
element.classList.add('redBorder');
+ wrongCount += 1;
}
} else {
- wrongCount -= 1;
+ wrongCount += 1;
element.classList.remove('greenBorder', 'redBorder');
}
}
@@ -254,19 +254,30 @@ import Layout from "../../layouts/Layout.astro";
totalPoints += 1;
}
});
- let starValue = Math.round((totalPoints / maxScore) * 10);
- starValue = starValue === 0 ? 3 : starValue;
+ const answersList = ['a1', 'a2', 'a3'];
+ answersList.forEach((answer) => {
+ if (gameData[answer] === true) {
+ totalCorrectFromApi++;
+ }
+ });
+
+ let afterNegative = totalPoints - wrongCount;
+ let percentage = Math.round((afterNegative / totalCorrectFromApi ) * 10);
+ percentage = Math.max(3, Math.min(percentage, 10));
+ if(percentage <= 3){
+ percentage = 3
+ }
let feedbackMessage = '';
- if (starValue >= 1 && starValue <= 3) {
+ if (percentage >= 1 && percentage <= 3) {
feedbackMessage = "You're making progress! Let's keep going!";
- } else if (starValue >= 4 && starValue <= 6) {
- feedbackMessage = "Nice work! You're improving every day!";
- } else if (starValue >= 7 && starValue <= 8) {
- feedbackMessage = "Amazing work! Keep it up!";
- } else if (starValue >= 9 && starValue <= 10) {
- feedbackMessage = "Outstanding! You're a true superstar!";
+ } else if (percentage >= 4 && percentage <= 6) {
+ feedbackMessage = "Nice work! You're improving every day!";
+ } else if (percentage >= 7 && percentage <= 8) {
+ feedbackMessage = "Amazing work! Keep it up!";
+ } else if (percentage >= 9 && percentage <= 10) {
+ feedbackMessage = "Outstanding! You're a true superstar!";
} else {
- feedbackMessage = "Invalid star value.";
+ feedbackMessage = "Invalid star value.";
}
progressIncrement();
@@ -382,7 +393,7 @@ import Layout from "../../layouts/Layout.astro";
'userId': userId,
'gameTime': timeDifferenceInSeconds,
'score': totalPoints,
- 'gameStar': starValue
+ 'gameStar': percentage
};
fetch(`https://api.teachertrainingkolkata.in/api/saveGameScore2`, {
method: 'POST',
@@ -401,7 +412,7 @@ import Layout from "../../layouts/Layout.astro";
starContainer.style.display = 'flex';
starContainer.style.flexDirection = 'row';
document.getElementById('starFeedbackMessage').innerHTML = feedbackMessage;
- document.getElementById('get-star-value').innerHTML = starValue;
+ document.getElementById('get-star-value').innerHTML = percentage;
scoreBoard.style.display = 'flex';
}
} else {