mirror of
https://github.com/olehomelchenko/minivlat-local-ua.git
synced 2025-12-21 21:22:24 +00:00
init
This commit is contained in:
30
src/js/results.js
Normal file
30
src/js/results.js
Normal file
@@ -0,0 +1,30 @@
|
||||
const resultsContainer = document.getElementById('results');
|
||||
const resultsHeader = document.getElementById('results-header');
|
||||
const resultsTableBody = document.getElementById('results-table-body');
|
||||
|
||||
const allQuizzes = JSON.parse(localStorage.getItem('allQuizzes') || '{}');
|
||||
const quizData = allQuizzes['quiz'];
|
||||
|
||||
function displayResults() {
|
||||
const totalQuestions = quizData.totalQuestions;
|
||||
const correctAnswers = quizData.score;
|
||||
const percentage = ((correctAnswers / totalQuestions) * 100).toFixed(2);
|
||||
|
||||
resultsHeader.textContent = `Результати тесту: ${correctAnswers}/${totalQuestions}, ${percentage}%`;
|
||||
|
||||
let resultsHTML = '';
|
||||
|
||||
quizData.answers.forEach(answer => {
|
||||
resultsHTML += `
|
||||
<tr>
|
||||
<td>${answer.question}</td>
|
||||
<td>${answer.chartTypeUk}</td>
|
||||
<td>${answer.isCorrect ? '✅' : '❌'}</td>
|
||||
</tr>
|
||||
`;
|
||||
});
|
||||
|
||||
resultsTableBody.innerHTML = resultsHTML;
|
||||
}
|
||||
|
||||
window.onload = displayResults;
|
||||
Reference in New Issue
Block a user