s5
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user