File size: 1,030 Bytes
ac459f7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Global functions and event listeners
document.addEventListener('DOMContentLoaded', () => {
    // Initialize tooltips
    const tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));
    tooltipTriggerList.map(function (tooltipTriggerEl) {
        return new bootstrap.Tooltip(tooltipTriggerEl);
    });

    // Track user progress (mock function)
    if (localStorage.getItem('userProgress')) {
        const progress = JSON.parse(localStorage.getItem('userProgress'));
        console.log('User progress loaded:', progress);
    } else {
        localStorage.setItem('userProgress', JSON.stringify({
            scores: [],
            weakTopics: [],
            lastSession: null
        }));
    }
});

// Shared utility functions
function formatTime(seconds) {
    const mins = Math.floor(seconds / 60);
    const secs = seconds % 60;
    return `${mins}:${secs < 10 ? '0' : ''}${secs}`;
}

function calculatePercentage(score, total) {
    return Math.round((score / total) * 100);
}