Current Affairs Quiz 2025
Current Affairs Quiz 2025
Question of
क्विज परिणाम
कुल प्रश्न | प्रयास किए | सही उत्तर | गलत उत्तर | स्किप | स्कोर |
0 | 0 | 0 | 0 | 0 | 0 |
कोई प्रश्न नहीं जोड़े गए।
';
return;
}
listDiv.innerHTML = questions.map((q, i) => {
const opts = q.options.map((o, idx) => `
${String.fromCharCode(65+idx)}. ${o}`).join(' ');
return `
Q${i+1}: ${q.question}
${opts}
Hint: ${q.hint}
`;
}).join('');
}
// Question toolbox functions
function addQuestion() {
const lines = document.getElementById('questionInput').value.trim().split('\n').map(l=>l.trim()).filter(l=>l);
if(lines.length<6){alert('कृपया सही प्रारूप में प्रश्न, 4 विकल्प, उत्तर और हिंट दें।');return;}
const qText=lines[0], opts=lines.slice(1,5);
const ansChar=lines[5].trim().toUpperCase(), hintText=lines.slice(6).join(' ');
const ansIndex=ansChar.charCodeAt(0)-65;
questions.push({question:qText,options:opts,answer:ansIndex,hint:hintText});
localStorage.setItem('questions',JSON.stringify(questions));
document.getElementById('questionInput').value=''; renderQuestionList(); alert('प्रश्न सफलतापूर्वक जोड़ा गया!');
}
function editQuestion(index){const q=questions[index];const text=[q.question,...q.options,String.fromCharCode(65+q.answer),q.hint].join('\n');document.getElementById('questionInput').value=text;editingIndex=index;document.getElementById('addBtn').style.display='none';document.getElementById('updateBtn').style.display='inline-block';}
function updateQuestion(){if(editingIndex===null)return;const lines=document.getElementById('questionInput').value.trim().split('\n').map(l=>l.trim()).filter(l=>l);if(lines.length<6){alert('कृपया सही प्रारूप में प्रश्न, 4 विकल्प, उत्तर और हिंट दें।');return;}const qText=lines[0],opts=lines.slice(1,5),ansChar=lines[5].trim().toUpperCase(),hintText=lines.slice(6).join(' '),ansIndex=ansChar.charCodeAt(0)-65;questions[editingIndex]={question:qText,options:opts,answer:ansIndex,hint:hintText};localStorage.setItem('questions',JSON.stringify(questions));editingIndex=null;document.getElementById('questionInput').value='';document.getElementById('addBtn').style.display='inline-block';document.getElementById('updateBtn').style.display='none';renderQuestionList();alert('प्रश्न सफलतापूर्वक अपडेट किया गया!');}
function deleteQuestion(index){if(!confirm('क्या आप वाकई इस प्रश्न को हटाना चाहते हैं?'))return;questions.splice(index,1);localStorage.setItem('questions',JSON.stringify(questions));renderQuestionList();alert('प्रश्न हटा दिया गया।');}
function clearSavedQuestions(){if(!confirm('सभी प्रश्न हटाएं?'))return;questions=[];localStorage.removeItem('questions');renderQuestionList();alert('सारे प्रश्न हटाए गए');}
document.addEventListener('DOMContentLoaded', () => {
renderQuestionList();
userAnswers = Array(questions.length).fill(null);
});
// Quiz functions
function beginQuiz() {
if (questions.length === 0) { alert('कृपया कम से कम एक प्रश्न जोड़ें।'); return; }
document.getElementById('toolbox').style.display = 'none';
document.getElementById('startQuizBtn').style.display = 'none';
document.getElementById('quizBox').style.display = 'block';
document.querySelector('.total-question').innerText = questions.length;
totalTime = questions.length * 30;
startTimer();
showCurrentDateTime();
setInterval(showCurrentDateTime,1000);
loadQuestion();
}
function getOptionLabel(i){ return String.fromCharCode(65+i); }
function loadQuestion(){ const q=questions[currentQuestion]; document.querySelector('.question-num-value').innerText=currentQuestion+1; document.getElementById('question').innerText=`Q${currentQuestion+1}. ${q.question}`; document.getElementById('options').innerHTML=q.options.map((opt,i)=>{const sel=userAnswers[currentQuestion]===i?(i===q.answer?'correct':'wrong'):'';return `
${getOptionLabel(i)}. ${opt}
`;}).join(''); document.getElementById('hintContainer').style.display='none'; document.getElementById('submitBtn').style.display=currentQuestion===questions.length-1?'inline-block':'none'; document.getElementById('nextBtn').style.display=currentQuestion===questions.length-1?'none':'inline-block';}
function selectOption(i){ userAnswers[currentQuestion]=i; loadQuestion(); }
function prevQuestion(){ if(currentQuestion>0){ currentQuestion--; loadQuestion(); }}
function nextQuestion(){ if(currentQuestion
`Q${n+1}`).join(', '); }}
function submitQuiz(){ document.getElementById('quizBox').style.display='none'; document.getElementById('resultBox').style.display='block'; document.getElementById('resultTable').innerHTML=''; let skipCount=0; correct=0; wrong=0; attempted=0; userAnswers.forEach((ans,i)=>{ const q=questions[i]; let status='',rowClass='',yourAns=''; if(ans===null){ status='⏭ स्किप किया'; rowClass='row-skip'; yourAns='N/A'; skipCount++; } else if(ans===q.answer){ correct++; attempted++; status='✔ सही'; rowClass='row-correct'; yourAns=q.options[ans]; } else{ wrong++; attempted++; status='❌ गलत'; rowClass='row-wrong'; yourAns=`${q.options[ans]} (गलत)`; } const optsText=q.options.map((o,i)=>`${getOptionLabel(i)}. ${o}`).join('
'); document.getElementById('resultTable').innerHTML+=`Q${i+1}: ${q.question}
Options: ${optsText}
Your Answer: ${yourAns} Correct Answer: ${q.options[q.answer]} Status: ${status} Hint: ${q.hint} |
`; }); const penalty=Math.floor(wrong/3); const score=correct-penalty; const pct=Math.round((score/questions.length)*100); document.getElementById('totalQ').innerText=questions.length; document.getElementById('attemptedQ').innerText=attempted; document.getElementById('correctQ').innerText=correct; document.getElementById('wrongQ').innerText=wrong; document.getElementById('skipQ').innerText=skipCount; document.getElementById('scoreQ').innerText=`${score} (${pct}%)`; clearInterval(timerInterval); const now=new Date(); const fmt=now.toLocaleString('hi-IN',{weekday:'long',year:'numeric',month:'long',day:'numeric',hour:'numeric',minute:'numeric',second:'numeric'}); document.getElementById('resultDateTime').innerText=`आज का तिथि और समय: ${fmt}`; }
function startTimer(){ const end=Date.now()+totalTime*1000; timerInterval=setInterval(()=>{ const rem=Math.max(0,end-Date.now()); document.getElementById('timer').innerText=`समय बचा: ${new Date(rem).toISOString().substr(11,8)}`; if(rem<=0) submitQuiz(); },1000); }
function showCurrentDateTime(){ const now=new Date(); document.getElementById('currentDateTime').innerText=`दिनांक और समय: ${now.toLocaleString('hi-IN',{weekday:'long',year:'numeric',month:'long',day:'numeric',hour:'numeric',minute:'numeric',second:'numeric'})}`; }
function restartQuiz(){ correct=0; wrong=0; attempted=0; userAnswers=Array(questions.length).fill(null); currentQuestion=0; markedForReview=[]; document.getElementById('resultBox').style.display='none'; document.getElementById('startQuizBtn').style.display='inline-block'; document.getElementById('toolbox').style.display='block'; }
function openShareDialog(){ if(navigator.share){ navigator.share({title:'Current Affairs Quiz 2025',text:'Click Quiz!',url:window.location.href}).catch(console.error); } else alert('Sharing not supported on this device.'); }
function customPrint(){ window.print(); }