Untitled
Anonymous
plain_text
04/14/2026 4:07 AM
3.3 KB
10
Indexable
// Select all rows in the tbody of the table with id #tblObjection, skipping the first row
const rows = document.querySelectorAll('#tblObjection > tbody > tr:nth-child(n+2)');
// Initialize counters for Physics, Chemistry, and Mathematics
let correctAnswersPhysics = 0;
let wrongAnswersPhysics = 0;
let correctAnswersChemistry = 0;
let wrongAnswersChemistry = 0;
let correctAnswersMathematics = 0;
let wrongAnswersMathematics = 0;
// Iterate through each row
rows.forEach((row, index) => {
// Get the correct option and candidate response elements using the provided selectors
const correctOptionElement = row.querySelector('td:nth-child(3) > table.table.table-responsive.table-bordered.center > tbody > tr > td:nth-child(1) > span');
const candidateResponseElement = row.querySelector('td:nth-child(3) > table.table.table-responsive.table-bordered.center > tbody > tr > td:nth-child(2) > span');
// Check if both elements exist
if (correctOptionElement && candidateResponseElement) {
const correctOption = correctOptionElement.textContent.trim();
const candidateResponse = candidateResponseElement.textContent.trim();
// Determine the category based on the question index and compare answers
if (index < 50) {
// Physics
if (correctOption === candidateResponse) {
correctAnswersPhysics++;
} else {
wrongAnswersPhysics++;
}
} else if (index < 100) {
// Chemistry
if (correctOption === candidateResponse) {
correctAnswersChemistry++;
} else {
wrongAnswersChemistry++;
}
} else {
// Mathematics
if (correctOption === candidateResponse) {
correctAnswersMathematics++;
} else {
wrongAnswersMathematics++;
}
}
}
});
// Calculate total score
const totalScore = correctAnswersPhysics + correctAnswersChemistry + (correctAnswersMathematics * 2);
// Output the results
console.log(`Physics - Correct Answers: ${correctAnswersPhysics}, Wrong Answers: ${wrongAnswersPhysics}`);
console.log(`Chemistry - Correct Answers: ${correctAnswersChemistry}, Wrong Answers: ${wrongAnswersChemistry}`);
console.log(`Mathematics - Correct Answers: ${correctAnswersMathematics}, Wrong Answers: ${wrongAnswersMathematics}`);
console.log(`Total Score: ${totalScore} out of 200`);Editor is loading...
Leave a Comment