function WoWStudyFunction.SetupSpacedRepetitionPanel(menuFrame, menuPanel2)
    local spacedRepetitionPanel = CreateFrame("Frame", spacedRepetitionPanel, menuFrame, "ShadowOverlayTemplate")
    spacedRepetitionPanel:SetPoint("LEFT", menuPanel2, "RIGHT", 10, 0)
    spacedRepetitionPanel:SetSize(600, 489)
    spacedRepetitionPanel:Hide()

    local title = spacedRepetitionPanel:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
    title:SetPoint("TOP", spacedRepetitionPanel, "TOP", 10, -10)
    title:SetText("Spaced Repetition")

    local explanation = spacedRepetitionPanel:CreateFontString(nil, "OVERLAY", "GameFontNormal")
    explanation:SetPoint("TOPLEFT", spacedRepetitionPanel, "TOPLEFT", 10, -40)
    explanation:SetWidth(580)
    explanation:SetJustifyH("LEFT")
    explanation:SetJustifyV("TOP")
    explanation:SetText([[
Spaced Repetition uses time intervals to determine when flashcards should be shown based on their score. The thresholds for intervals are:

- Score 0: Immediately
- Score 1: After 10 minutes
- Score 2: After 20 minutes
- Score 3: After 40 minutes
- Score 4: After 80 minutes (1.33 hours)
- Score 5: After 160 minutes (2.67 hours)
- Score 6: After 320 minutes (5.33 hours)
- Score 7: After 640 minutes (10.67 hours)
- Score 8: After 21.33 hours
- Score 9: After 42.67 hours
- Score 10: After 85.33 hours
- Score 11: After 170.67 hours
- Score 12: After 341.33 hours
- Score 13: After 682.67 hours
- Score 14: After 1365.33 hours (approximately 57 days)
- Score 15: After 2730.67 hours (approximately 114 days)

The higher the score, the longer the interval before the card is shown again. The system ensures cards are presented at optimal intervals to improve retention. 
Currently when you get a card correct, it goes up a score, and when you get it wrong, it restarts at 0. This system will be improved in the future to be more accurate and efficient.]])

    return spacedRepetitionPanel
end

function WoWStudyFunction.SpacedRepetitionCheck(lastTime, currentTime, spacedRepetitionLevel)
    -- Define the thresholds in seconds with comments in hours
    local thresholds = {
        [0] = 0,              -- 0 minutes (0 hours)
        [1] = 600,            -- 10 minutes (0.17 hours)
        [2] = 1200,           -- 20 minutes (0.33 hours)
        [3] = 2400,           -- 40 minutes (0.67 hours)
        [4] = 4800,           -- 80 minutes (1.33 hours)
        [5] = 9600,           -- 160 minutes (2.67 hours)
        [6] = 19200,          -- 320 minutes (5.33 hours)
        [7] = 38400,          -- 640 minutes (10.67 hours)
        [8] = 76800,          -- 1280 minutes (21.33 hours)
        [9] = 153600,         -- 2560 minutes (42.67 hours)
        [10] = 307200,        -- 5120 minutes (85.33 hours)
        [11] = 614400,        -- 10240 minutes (170.67 hours)
        [12] = 1228800,       -- 20480 minutes (341.33 hours)
        [13] = 2457600,       -- 40960 minutes (682.67 hours)
        [14] = 4915200,       -- 81920 minutes (1365.33 hours)
        [15] = 9830400        -- 163840 minutes (2730.67 hours, above 1400 hours)
    }

    -- Check if the score has a valid threshold
    if thresholds[spacedRepetitionLevel] and (currentTime - lastTime > thresholds[spacedRepetitionLevel]) then
        return true
    end

    return false
end