NexIMPERA
would // otherwise terminate this block and execute for every quiz taker. const QUIZ_DATA = {"quiz":{"id":"3","title":"Future of Finance: FinTech, AI \u0026 Macro Trends","slug":"future-of-finance-fintech-ai-macro-trends","description":"Test your knowledge at the intersection of modern technology and global finance. This expertly curated quiz covers algorithmic trading, decentralized finance, macroeconomic indicators, and the impact of artificial intelligence on wealth management.","cover_image":null,"category":"FinTech \u0026 Innovation","difficulty":"medium","time_limit":"12","passing_score":"70","max_attempts":"0","is_active":"1","approval_status":"approved","approved_by":null,"approved_at":null,"rejection_note":null,"is_featured":"1","show_answers":"1","randomize_questions":"0","created_by":"1","created_at":"2026-07-12 09:09:20","updated_at":"2026-07-14 12:35:11"},"questions":[{"id":"45","quiz_id":"3","question":"In the context of modern finance, what does \u0022DeFi\u0022 stand for?","question_type":"single","explanation":"DeFi stands for Decentralized Finance, an emerging financial technology based on secure distributed ledgers similar to those used by cryptocurrencies.","points":"2","order_num":"1","created_at":"2026-07-12 09:09:20","is_deleted":"0","options":[{"id":"243","question_id":"45","option_text":"Digital Enterprise Financial Institutions","is_correct":"0","order_num":"1","is_deleted":"0"},{"id":"244","question_id":"45","option_text":"Decentralized Finance","is_correct":"1","order_num":"2","is_deleted":"0"},{"id":"245","question_id":"45","option_text":"Derivative Exchange Fund Index","is_correct":"0","order_num":"3","is_deleted":"0"},{"id":"246","question_id":"45","option_text":"Deferred Equity Financing","is_correct":"0","order_num":"4","is_deleted":"0"}]},{"id":"46","quiz_id":"3","question":"In macroeconomic terms, what does \u0022Quantitative Tightening\u0022 (QT) generally involve?","question_type":"single","explanation":"Quantitative Tightening is a contractionary monetary policy used by central banks to decrease the amount of liquidity within the economy, typically by allowing bonds to mature and shrinking their balance sheets.","points":"2","order_num":"2","created_at":"2026-07-12 09:09:20","is_deleted":"0","options":[{"id":"247","question_id":"46","option_text":"Lowering corporate tax rates to stimulate business growth","is_correct":"0","order_num":"1","is_deleted":"0"},{"id":"248","question_id":"46","option_text":"Central banks purchasing government bonds to increase market liquidity","is_correct":"0","order_num":"2","is_deleted":"0"},{"id":"249","question_id":"46","option_text":"Central banks reducing the money supply by shrinking their balance sheets","is_correct":"1","order_num":"3","is_deleted":"0"},{"id":"250","question_id":"46","option_text":"Strictly regulating international trade tariffs","is_correct":"0","order_num":"4","is_deleted":"0"}]},{"id":"47","quiz_id":"3","question":"What is the primary purpose of a \u0022Smart Contract\u0022 on a blockchain network?","question_type":"single","explanation":"Smart contracts are self-executing contracts with the terms of the agreement directly written into lines of code, removing the need for traditional intermediaries.","points":"2","order_num":"3","created_at":"2026-07-12 09:09:20","is_deleted":"0","options":[{"id":"251","question_id":"47","option_text":"To act as a legally binding document generated by AI lawyers","is_correct":"0","order_num":"1","is_deleted":"0"},{"id":"252","question_id":"47","option_text":"To automatically execute and enforce agreement terms via blockchain code","is_correct":"1","order_num":"2","is_deleted":"0"},{"id":"253","question_id":"47","option_text":"To track the carbon footprint of digital transactions","is_correct":"0","order_num":"3","is_deleted":"0"},{"id":"254","question_id":"47","option_text":"To protect traditional bank accounts from cyber-attacks","is_correct":"0","order_num":"4","is_deleted":"0"}]},{"id":"48","quiz_id":"3","question":"Which of the following best describes an \u0022ESG\u0022 investment mandate?","question_type":"single","explanation":"ESG stands for Environmental, Social, and Governance. Investors use these non-financial factors as part of their analysis process to identify material risks and growth opportunities.","points":"2","order_num":"4","created_at":"2026-07-12 09:09:20","is_deleted":"0","options":[{"id":"255","question_id":"48","option_text":"Equities, Stocks, and Gold","is_correct":"0","order_num":"1","is_deleted":"0"},{"id":"256","question_id":"48","option_text":"Electronic Systematic Growth","is_correct":"0","order_num":"2","is_deleted":"0"},{"id":"257","question_id":"48","option_text":"Environmental, Social, and Governance criteria","is_correct":"1","order_num":"3","is_deleted":"0"},{"id":"258","question_id":"48","option_text":"Enterprise Strategic Goals","is_correct":"0","order_num":"4","is_deleted":"0"}]},{"id":"49","quiz_id":"3","question":"What does the financial technology acronym \u0022CBDC\u0022 represent?","question_type":"single","explanation":"Central Bank Digital Currency (CBDC) is the digital form of a country\u0027s fiat currency that is a direct liability of the central bank.","points":"2","order_num":"5","created_at":"2026-07-12 09:09:20","is_deleted":"0","options":[{"id":"259","question_id":"49","option_text":"Central Bank Digital Currency","is_correct":"1","order_num":"1","is_deleted":"0"},{"id":"260","question_id":"49","option_text":"Crypto-Backed Derivative Contract","is_correct":"0","order_num":"2","is_deleted":"0"},{"id":"261","question_id":"49","option_text":"Corporate Banking Data Center","is_correct":"0","order_num":"3","is_deleted":"0"},{"id":"262","question_id":"49","option_text":"Commercial Bond Depository Certificate","is_correct":"0","order_num":"4","is_deleted":"0"}]},{"id":"50","quiz_id":"3","question":"In algorithmic trading, what does \u0022HFT\u0022 stand for?","question_type":"single","explanation":"High-Frequency Trading (HFT) is an automated trading platform that employs powerful computers to transact a large number of orders at extremely high speeds.","points":"2","order_num":"6","created_at":"2026-07-12 09:09:20","is_deleted":"0","options":[{"id":"263","question_id":"50","option_text":"Hedge Fund Transacting","is_correct":"0","order_num":"1","is_deleted":"0"},{"id":"264","question_id":"50","option_text":"High-Frequency Trading","is_correct":"1","order_num":"2","is_deleted":"0"},{"id":"265","question_id":"50","option_text":"Hyper-Financial Technology","is_correct":"0","order_num":"3","is_deleted":"0"},{"id":"266","question_id":"50","option_text":"Hybrid Fiat Token","is_correct":"0","order_num":"4","is_deleted":"0"}]},{"id":"51","quiz_id":"3","question":"When an economy experiences stagnant economic growth combined with high structural inflation, it is known as:","question_type":"single","explanation":"Stagflation is an economic cycle characterized by slow growth, high unemployment, and accompanied by inflation.","points":"2","order_num":"7","created_at":"2026-07-12 09:09:20","is_deleted":"0","options":[{"id":"267","question_id":"51","option_text":"Deflation","is_correct":"0","order_num":"1","is_deleted":"0"},{"id":"268","question_id":"51","option_text":"Hyperinflation","is_correct":"0","order_num":"2","is_deleted":"0"},{"id":"269","question_id":"51","option_text":"Stagflation","is_correct":"1","order_num":"3","is_deleted":"0"},{"id":"270","question_id":"51","option_text":"Disinflation","is_correct":"0","order_num":"4","is_deleted":"0"}]},{"id":"52","quiz_id":"3","question":"What is the primary function of \u0022Asset Tokenization\u0022 in real estate and traditional finance?","question_type":"single","explanation":"Tokenization is the process of converting rights to an asset into a digital token on a blockchain, allowing for fractional ownership, higher liquidity, and global market access.","points":"2","order_num":"8","created_at":"2026-07-12 09:09:20","is_deleted":"0","options":[{"id":"271","question_id":"52","option_text":"Eliminating property taxes entirely","is_correct":"0","order_num":"1","is_deleted":"0"},{"id":"272","question_id":"52","option_text":"Converting physical assets into digital tokens on a blockchain for fractional ownership","is_correct":"1","order_num":"2","is_deleted":"0"},{"id":"273","question_id":"52","option_text":"Creating a virtual reality simulation of a physical property","is_correct":"0","order_num":"3","is_deleted":"0"},{"id":"274","question_id":"52","option_text":"Replacing fiat currency with cryptocurrency for real estate purchases","is_correct":"0","order_num":"4","is_deleted":"0"}]},{"id":"53","quiz_id":"3","question":"Which technology is currently driving the rapid expansion of automated financial advisory and dynamic market summaries?","question_type":"single","explanation":"Generative Artificial Intelligence (GenAI), utilizing Large Language Models (LLMs), is revolutionizing how financial data is synthesized and delivered to investors in real-time.","points":"2","order_num":"9","created_at":"2026-07-12 09:09:20","is_deleted":"0","options":[{"id":"275","question_id":"53","option_text":"Generative Artificial Intelligence (LLMs)","is_correct":"1","order_num":"1","is_deleted":"0"},{"id":"276","question_id":"53","option_text":"Quantum Computing","is_correct":"0","order_num":"2","is_deleted":"0"},{"id":"277","question_id":"53","option_text":"Augmented Reality (AR)","is_correct":"0","order_num":"3","is_deleted":"0"},{"id":"278","question_id":"53","option_text":"5G Wireless Networks","is_correct":"0","order_num":"4","is_deleted":"0"}]},{"id":"54","quiz_id":"3","question":"What does a \u0022Yield Curve Inversion\u0022 (when short-term treasury yields rise above long-term yields) historically signal to economists?","question_type":"single","explanation":"An inverted yield curve has historically been viewed as an indicator of a pending economic recession, signaling that investors expect interest rates to fall in the future due to economic slowdown.","points":"2","order_num":"10","created_at":"2026-07-12 09:09:20","is_deleted":"0","options":[{"id":"279","question_id":"54","option_text":"An impending period of rapid economic expansion","is_correct":"0","order_num":"1","is_deleted":"0"},{"id":"280","question_id":"54","option_text":"A sudden surge in corporate dividend payouts","is_correct":"0","order_num":"2","is_deleted":"0"},{"id":"281","question_id":"54","option_text":"An impending economic recession","is_correct":"1","order_num":"3","is_deleted":"0"},{"id":"282","question_id":"54","option_text":"A transition to a gold-backed currency system","is_correct":"0","order_num":"4","is_deleted":"0"}]}]}; const SITE_URL = 'https://neximpera.com'; const USER_ID = null; // Unlimited label generator: A,B...Z,AA,AB...ZZ,AAA... function indexToLabel(i) { const alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; if (i < 26) return alpha[i]; let label = ''; i++; while (i > 0) { i--; label = alpha[i % 26] + label; i = Math.floor(i / 26); } return label; } let currentQ = 0; let answers = {}; // { question_id: { selected: [optId, ...] } } let attemptId = null; let startTime = null; let timerInterval = null; let userInfo = {}; document.getElementById('userInfoForm').addEventListener('submit', async (e) => { e.preventDefault(); const form = e.target; userInfo = { name: form.name.value.trim(), email: form.email.value.trim(), phone: form.phone.value.trim(), city: form.city.value.trim(), occupation: form.occupation.value.trim(), experience: form.experience.value, quiz_id: QUIZ_DATA.quiz.id, user_id: USER_ID }; const btn = document.getElementById('startQuizBtn'); btn.disabled = true; btn.textContent = 'Starting…'; try { const res = await fetch(SITE_URL + '/api/quiz.php?action=start', { method: 'POST', headers: {'Content-Type':'application/json'}, body: JSON.stringify(userInfo) }); const data = await res.json(); if (data.success) { attemptId = data.attempt_id; startTime = Date.now(); document.getElementById('userInfoModal').classList.remove('active'); document.getElementById('quizInterface').style.display = 'block'; renderQuestion(); if (QUIZ_DATA.quiz.time_limit > 0) startTimer(QUIZ_DATA.quiz.time_limit * 60); } else { showToast(data.error || 'Error starting quiz', 'error'); btn.disabled = false; btn.textContent = ' Start Quiz'; } } catch(err) { showToast('Network error. Please try again.', 'error'); btn.disabled = false; btn.textContent = ' Start Quiz'; } }); function renderQuestion() { const q = QUIZ_DATA.questions[currentQ]; const total = QUIZ_DATA.questions.length; document.getElementById('questionNum').textContent = `Question ${currentQ + 1} of ${total}`; document.getElementById('questionCounter').textContent = `Q${currentQ+1}/${total}`; document.getElementById('questionText').textContent = q.question; document.getElementById('progressFill').style.width = (currentQ / total * 100) + '%'; // Type hint const hint = document.getElementById('questionTypeHint'); if (q.question_type === 'multiple') { hint.textContent = ' Select all correct answers'; hint.style.display = 'block'; } else { hint.style.display = 'none'; } const list = document.getElementById('optionsList'); list.innerHTML = ''; q.options.forEach((opt, i) => { const div = document.createElement('div'); div.className = 'quiz-option'; div.dataset.id = opt.id; const label = indexToLabel(i); // A, B, C ... Z, AA, AB ... div.innerHTML = `
${escapeHtml(label)}
${escapeHtml(opt.option_text)}
`; // Restore prior selection if (answers[q.id] && answers[q.id].selected.includes(opt.id)) { div.classList.add('selected'); } div.addEventListener('click', () => selectOption(div, opt.id, q)); list.appendChild(div); }); const expBox = document.getElementById('explanation'); if (answers[q.id]) { showExplanation(q); markOptions(q); } else { expBox.style.display = 'none'; } // Dot nav const dots = document.getElementById('dotNav'); dots.innerHTML = ''; const maxDots = Math.min(total, 20); for (let i = 0; i < maxDots; i++) { const d = document.createElement('div'); d.style.cssText = `width:8px;height:8px;border-radius:50%;transition:all 0.25s;cursor:pointer;background:${i===currentQ?'var(--gold)':answers[QUIZ_DATA.questions[i].id]?'var(--teal)':'var(--border-subtle)'}`; d.title = `Question ${i+1}`; const idx = i; d.onclick = () => { currentQ = idx; renderQuestion(); }; dots.appendChild(d); } if (total > 20) { const more = document.createElement('span'); more.style.cssText = 'font-size:11px;color:var(--text-muted);padding:0 4px'; more.textContent = `+${total - 20} more`; dots.appendChild(more); } document.getElementById('prevBtn').style.visibility = currentQ > 0 ? 'visible' : 'hidden'; const nextBtn = document.getElementById('nextBtn'); nextBtn.textContent = currentQ === total - 1 ? 'Submit Quiz ✓' : 'Next →'; } function selectOption(div, optId, q) { if (answers[q.id]) return; // already answered if (q.question_type === 'multiple') { // Toggle for multiple choice if (!answers[q.id]) answers[q.id] = { selected: [] }; const idx = answers[q.id].selected.indexOf(optId); if (idx === -1) { answers[q.id].selected.push(optId); div.classList.add('selected'); } else { answers[q.id].selected.splice(idx, 1); div.classList.remove('selected'); } // For multiple: don't lock until Next is clicked return; } // Single / true_false: lock immediately document.querySelectorAll('.quiz-option').forEach(o => o.classList.remove('selected')); div.classList.add('selected'); answers[q.id] = { selected: [optId] }; showExplanation(q); markOptions(q); } function markOptions(q) { const ans = answers[q.id]; if (!ans) return; const correctIds = q.options.filter(o => parseInt(o.is_correct)).map(o => o.id); document.querySelectorAll('.quiz-option').forEach(opt => { const id = parseInt(opt.dataset.id); const isSelected = ans.selected.includes(id); const isCorrect = correctIds.includes(id); opt.classList.remove('selected'); if (isSelected && isCorrect) opt.classList.add('correct'); else if (isSelected) opt.classList.add('wrong'); else if (isCorrect) opt.classList.add('correct'); }); } function showExplanation(q) { if (q.explanation && QUIZ_DATA.quiz.show_answers === '1') { document.getElementById('explanationText').textContent = q.explanation; document.getElementById('explanation').style.display = 'block'; } } function prevQuestion() { if (currentQ > 0) { currentQ--; renderQuestion(); } } async function nextQuestion() { const q = QUIZ_DATA.questions[currentQ]; const isMultiple = q.question_type === 'multiple'; // For multiple-choice, lock & mark on Next if (isMultiple && !answers[q.id]) { const selected = [...document.querySelectorAll('.quiz-option.selected')].map(d => parseInt(d.dataset.id)); if (!selected.length) { showToast('Select at least one answer', 'info'); return; } answers[q.id] = { selected }; markOptions(q); showExplanation(q); return; // let them see feedback before moving } if (!answers[q.id] && !isMultiple) { showToast('Please select an answer', 'info'); return; } if (currentQ < QUIZ_DATA.questions.length - 1) { currentQ++; renderQuestion(); } else { await submitQuiz(); } } async function submitQuiz() { if (timerInterval) clearInterval(timerInterval); const timeTaken = Math.round((Date.now() - startTime) / 1000); try { const res = await fetch(SITE_URL + '/api/quiz.php?action=submit', { method: 'POST', headers: {'Content-Type':'application/json'}, body: JSON.stringify({ attempt_id: attemptId, answers, time_taken: timeTaken }) }); const data = await res.json(); if (data.success) showResults(data, timeTaken); else showToast(data.error || 'Submit failed', 'error'); } catch(e) { showToast('Error submitting. Try again.', 'error'); } } function showResults(data, timeTaken) { document.getElementById('quizInterface').style.display = 'none'; document.getElementById('resultsPanel').style.display = 'block'; const score = Math.round(data.score); const passed = score >= parseInt(QUIZ_DATA.quiz.passing_score); // innerHTML, not textContent - these are SVG fragments, and textContent // would render the markup as visible source. document.getElementById('resultEmoji').innerHTML = score >= 80 ? "<\/svg>" : score >= 60 ? "<\/svg>" : "<\/svg>"; document.getElementById('scoreDisplay').textContent = score + '%'; document.getElementById('scoreCircle').style.setProperty('--score-pct', score + '%'); document.getElementById('resultTitle').textContent = passed ? 'Congratulations! You Passed!' : 'Keep Practicing!'; document.getElementById('resultDesc').textContent = passed ? `You scored ${score}% — excellent financial knowledge!` : `You scored ${score}%. Passing score is ${QUIZ_DATA.quiz.passing_score}%. Review and try again!`; document.getElementById('correctCount').textContent = data.correct; document.getElementById('wrongCount').textContent = data.wrong; const m = Math.floor(timeTaken/60), s = timeTaken%60; document.getElementById('timeTaken').textContent = m > 0 ? `${m}m ${s}s` : `${s}s`; document.getElementById('progressFill').style.width = '100%'; if (QUIZ_DATA.quiz.show_answers === '1') { const review = document.getElementById('answerReview'); review.innerHTML = '

Answer Review

'; QUIZ_DATA.questions.forEach((q, i) => { const ans = answers[q.id]; const selectedIds = ans?.selected || []; const correctOpts = q.options.filter(o => parseInt(o.is_correct)); const isCorrect = correctOpts.length && correctOpts.every(co => selectedIds.includes(co.id)) && selectedIds.every(sid => correctOpts.some(co => co.id === sid)); review.innerHTML += `
${isCorrect?'':''}
Q${i+1}: ${escapeHtml(q.question)}
${q.options.map((opt, oi) => { const isSel = selectedIds.includes(opt.id); const isC = parseInt(opt.is_correct); let s = `background:${isSel&&isC?'rgba(45,212,191,0.08)':isSel?'rgba(251,113,133,0.08)':isC?'rgba(45,212,191,0.04)':'transparent'};border:1px solid ${isSel&&isC?'rgba(45,212,191,0.3)':isSel?'rgba(251,113,133,0.3)':isC?'rgba(45,212,191,0.2)':'var(--border-subtle)'};`; return `
${indexToLabel(oi)} ${escapeHtml(opt.option_text)} ${isSel ? `${isC?'✓ Correct':'✗ Wrong'}` : ''} ${!isSel && isC ? `Correct Answer` : ''}
`; }).join('')} ${q.explanation ? `
${escapeHtml(q.explanation)}
` : ''}
`; }); } } function startTimer(seconds) { let rem = seconds; const el = document.getElementById('quizTimer'); timerInterval = setInterval(() => { rem--; const m = Math.floor(rem/60).toString().padStart(2,'0'); const s = (rem%60).toString().padStart(2,'0'); el.textContent = `${m}:${s}`; if (rem <= 60) el.style.color = 'var(--rose)'; if (rem <= 0) { clearInterval(timerInterval); submitQuiz(); } }, 1000); } function escapeHtml(s) { return String(s).replace(/&/g,'&').replace(//g,'>').replace(/"/g,'"'); }