Download index.html from Docav127/av127: direct link, hf CLI and curl.
- Browser
- Download file 77.5 kB
-
https://huggingface.co/spaces/Docav127/av127/resolve/main/index.html
- Command line
-
hf download hf://spaces/Docav127/av127/index.html
-
curl -L -o index.html https://huggingface.co/spaces/Docav127/av127/resolve/main/index.html
77.5 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Exam Item Analyzer</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
.chart-container {
position: relative;
height: 300px;
width: 100%;
}
/* Custom scrollbar */
::-webkit-scrollbar {
width: 8px;
height: 8px;
}
::-webkit-scrollbar-track {
background: #f1f1f1;
}
::-webkit-scrollbar-thumb {
background: #888;
border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
background: #555;
}
/* Animation for results */
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
.animate-fade-in {
animation: fadeIn 0.5s ease-out forwards;
}
/* Difficulty rating colors */
.difficulty-easy {
background-color: #4ade80;
}
.difficulty-medium {
background-color: #fbbf24;
}
.difficulty-hard {
background-color: #f87171;
}
.discrimination-high {
background-color: #60a5fa;
}
.discrimination-low {
background-color: #c084fc;
}
</style>
</head>
<body class="bg-gray-50 font-sans">
<div class="container mx-auto px-4 py-8 max-w-7xl">
<header class="mb-10">
<div class="flex items-center justify-between">
<div>
<h1 class="text-3xl font-bold text-blue-800">
<i class="fas fa-chart-pie mr-2"></i>Exam Item Analyzer
</h1>
<p class="text-gray-600 mt-1">Analyze multiple choice exam questions for validity and effectiveness</p>
</div>
<div class="flex space-x-2">
<button id="help-btn" class="bg-gray-200 hover:bg-gray-300 text-gray-800 px-3 py-2 rounded-lg transition">
<i class="fas fa-question-circle"></i> Help
</button>
<button id="sample-data-btn" class="bg-blue-100 hover:bg-blue-200 text-blue-800 px-3 py-2 rounded-lg transition">
<i class="fas fa-file-alt"></i> Load Sample Data
</button>
</div>
</div>
<div class="mt-4 flex border-b border-gray-200">
<button data-tab="input" class="tab-btn py-2 px-4 font-medium border-b-2 border-blue-500 text-blue-600">
<i class="fas fa-keyboard mr-2"></i>Input Data
</button>
<button data-tab="results" class="tab-btn py-2 px-4 font-medium text-gray-500 hover:text-gray-700">
<i class="fas fa-chart-bar mr-2"></i>Analysis Results
</button>
<button data-tab="export" class="tab-btn py-2 px-4 font-medium text-gray-500 hover:text-gray-700">
<i class="fas fa-file-export mr-2"></i>Export
</button>
</div>
</header>
<!-- Input Section -->
<div id="input-section" class="tab-content block">
<div class="bg-white rounded-xl shadow-md p-6 mb-6">
<div class="flex justify-between items-center mb-4">
<h2 class="text-xl font-semibold text-gray-800">
<i class="fas fa-info-circle text-blue-500 mr-2"></i>Exam Information
</h2>
</div>
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Exam Title</label>
<input type="text" id="exam-title" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Number of Questions</label>
<input type="number" id="num-questions" min="1" value="10" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Number of Choices per Question</label>
<input type="number" id="num-choices" min="2" max="10" value="4" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
</div>
</div>
<div class="bg-white rounded-xl shadow-md p-6 mb-6">
<div class="flex justify-between items-center mb-4">
<h2 class="text-xl font-semibold text-gray-800">
<i class="fas fa-users text-blue-500 mr-2"></i>Student Responses
</h2>
<div>
<button id="add-student-btn" class="bg-blue-500 hover:bg-blue-600 text-white px-3 py-1 rounded-md text-sm transition">
<i class="fas fa-plus mr-1"></i>Add Student
</button>
</div>
</div>
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Student ID
</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Score
</th>
<th id="responses-header" class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Responses (Q1, Q2, ...)
</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Actions
</th>
</tr>
</thead>
<tbody id="student-responses" class="bg-white divide-y divide-gray-200">
<!-- Student rows will be added here -->
<tr>
<td colspan="4" class="px-4 py-4 text-center text-sm text-gray-500">
No student data entered yet. Click "Add Student" to begin.
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="bg-white rounded-xl shadow-md p-6">
<div class="flex justify-between items-center mb-4">
<h2 class="text-xl font-semibold text-gray-800">
<i class="fas fa-check-circle text-blue-500 mr-2"></i>Correct Answers Key
</h2>
</div>
<div id="answer-key-container" class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-4">
<!-- Answer key fields will be added here -->
<div class="answer-key-item">
<label class="block text-sm font-medium text-gray-700 mb-1">Q1 Correct Answer</label>
<select class="block w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
<option>A</option>
<option>B</option>
<option>C</option>
<option>D</option>
</select>
</div>
</div>
<div class="mt-6 flex justify-end">
<button id="analyze-btn" class="bg-green-500 hover:bg-green-600 text-white px-6 py-2 rounded-md text-lg font-medium transition shadow-md transform hover:scale-105">
<i class="fas fa-chart-line mr-2"></i>Analyze Data
</button>
</div>
</div>
</div>
<!-- Results Section -->
<div id="results-section" class="tab-content hidden">
<div id="exam-summary" class="bg-white rounded-xl shadow-md p-6 mb-6 animate-fade-in">
<div class="flex justify-between items-center mb-4">
<h2 class="text-xl font-semibold text-gray-800">
<i class="fas fa-poll text-blue-500 mr-2"></i>Exam Summary
</h2>
<span class="text-sm bg-blue-100 text-blue-800 px-3 py-1 rounded-full">
<span id="report-date">Report generated: Today</span>
</span>
</div>
<div class="grid grid-cols-1 md:grid-cols-3 gap-4 mb-6">
<div class="bg-blue-50 rounded-lg p-4">
<h3 class="text-sm font-medium text-blue-800">Number of Students</h3>
<p id="num-students" class="text-3xl font-bold text-blue-600 mt-2">0</p>
</div>
<div class="bg-green-50 rounded-lg p-4">
<h3 class="text-sm font-medium text-green-800">Average Score</h3>
<p id="average-score" class="text-3xl font-bold text-green-600 mt-2">0</p>
</div>
<div class="bg-purple-50 rounded-lg p-4">
<h3 class="text-sm font-medium text-purple-800">Standard Deviation</h3>
<p id="std-dev" class="text-3xl font-bold text-purple-600 mt-2">0</p>
</div>
</div>
<div class="mb-6">
<h3 class="text-lg font-medium text-gray-800 mb-3">Score Distribution</h3>
<div class="chart-container">
<canvas id="score-distribution-chart"></canvas>
</div>
</div>
</div>
<div id="item-analysis" class="bg-white rounded-xl shadow-md p-6 mb-6 animate-fade-in">
<div class="flex justify-between items-center mb-4">
<h2 class="text-xl font-semibold text-gray-800">
<i class="fas fa-question-circle text-blue-500 mr-2"></i>Item Analysis
</h2>
<div class="flex items-center">
<span class="text-sm text-gray-600 mr-3">Filter:</span>
<select id="item-filter" class="block w-32 px-3 py-1 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 text-sm">
<option value="all">All Items</option>
<option value="difficulty">By Difficulty</option>
<option value="discrimination">By Discrimination</option>
<option value="problematic">Problematic Items</option>
</select>
</div>
</div>
<div class="overflow-x-auto mb-6">
<table class="min-w-full">
<thead class="bg-gray-50">
<tr>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Question
</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Difficulty
</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Discrimination
</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Correct Answer
</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Distractors
</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Action
</th>
</tr>
</thead>
<tbody id="item-analysis-results" class="bg-white divide-y divide-gray-200">
<!-- Analysis results will be added here -->
<tr>
<td colspan="6" class="px-4 py-4 text-center text-sm text-gray-500">
No analysis data available. Click "Analyze Data" first.
</td>
</tr>
</tbody>
</table>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div>
<h3 class="text-lg font-medium text-gray-800 mb-3">Difficulty Index Distribution (p-value)</h3>
<div class="chart-container">
<canvas id="difficulty-chart"></canvas>
</div>
</div>
<div>
<h3 class="text-lg font-medium text-gray-800 mb-3">Discrimination Index Distribution</h3>
<div class="chart-container">
<canvas id="discrimination-chart"></canvas>
</div>
</div>
</div>
</div>
<div id="detailed-analysis" class="bg-white rounded-xl shadow-md p-6 animate-fade-in">
<div class="flex justify-between items-center mb-4">
<h2 class="text-xl font-semibold text-gray-800">
<i class="fas fa-search text-blue-500 mr-2"></i>Detailed Question Analysis
</h2>
</div>
<div class="flex items-center mb-4">
<span class="text-sm text-gray-600 mr-2">Select question:</span>
<select id="question-selector" class="block px-3 py-1 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 w-16">
<!-- Options will be added dynamically -->
</select>
</div>
<div class="grid grid-cols-1 md:grid-cols-3 gap-4 mb-6">
<div class="bg-blue-50 rounded-lg p-4">
<h3 class="text-sm font-medium text-blue-800">Difficulty Index (p-value)</h3>
<p id="detailed-p-value" class="text-3xl font-bold text-blue-600 mt-2">-</p>
<p id="p-value-interpretation" class="text-xs mt-1"></p>
</div>
<div class="bg-green-50 rounded-lg p-4">
<h3 class="text-sm font-medium text-green-800">Discrimination Index</h3>
<p id="detailed-discrimination" class="text-3xl font-bold text-green-600 mt-2">-</p>
<p id="discrimination-interpretation" class="text-xs mt-1"></p>
</div>
<div class="bg-purple-50 rounded-lg p-4">
<h3 class="text-sm font-medium text-purple-800">Point-Biserial</h3>
<p id="detailed-point-biserial" class="text-3xl font-bold text-purple-600 mt-2">-</p>
<p id="point-biserial-interpretation" class="text-xs mt-1"></p>
</div>
</div>
<div>
<h3 class="text-lg font-medium text-gray-800 mb-3">Response Distribution</h3>
<div class="chart-container">
<canvas id="detailed-question-chart"></canvas>
</div>
</div>
</div>
</div>
<!-- Export Section -->
<div id="export-section" class="tab-content hidden">
<div class="bg-white rounded-xl shadow-md p-6">
<div class="flex justify-between items-center mb-4">
<h2 class="text-xl font-semibold text-gray-800">
<i class="fas fa-file-export text-blue-500 mr-2"></i>Export Data
</h2>
</div>
<div class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-8">
<div class="border border-gray-200 rounded-lg p-4 hover:shadow-md transition">
<div class="text-center mb-3">
<i class="fas fa-file-excel text-green-500 text-4xl"></i>
</div>
<h3 class="text-center font-medium text-gray-800 mb-2">Export to Excel</h3>
<p class="text-center text-sm text-gray-600 mb-3">Download complete analysis in Excel format</p>
<button id="export-excel-btn" class="w-full bg-green-500 hover:bg-green-600 text-white py-2 rounded-md transition">
Export Data
</button>
</div>
<div class="border border-gray-200 rounded-lg p-4 hover:shadow-md transition">
<div class="text-center mb-3">
<i class="fas fa-file-pdf text-red-500 text-4xl"></i>
</div>
<h3 class="text-center font-medium text-gray-800 mb-2">Export to PDF</h3>
<p class="text-center text-sm text-gray-600 mb-3">Generate a PDF report of the analysis</p>
<button id="export-pdf-btn" class="w-full bg-red-500 hover:bg-red-600 text-white py-2 rounded-md transition">
Export Report
</button>
</div>
<div class="border border-gray-200 rounded-lg p-4 hover:shadow-md transition">
<div class="text-center mb-3">
<i class="fas fa-file-csv text-blue-500 text-4xl"></i>
</div>
<h3 class="text-center font-medium text-gray-800 mb-2">Export Raw Data</h3>
<p class="text-center text-sm text-gray-600 mb-3">Download the raw student response data</p>
<button id="export-csv-btn" class="w-full bg-blue-500 hover:bg-blue-600 text-white py-2 rounded-md transition">
Export CSV
</button>
</div>
</div>
<div class="bg-gray-50 p-4 rounded-lg">
<h3 class="text-lg font-medium text-gray-800 mb-3">Share Results</h3>
<div class="flex flex-wrap gap-3 items-center">
<input type="text" id="share-link" class="flex-grow px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="Shareable link will appear here...">
<button id="copy-link-btn" class="bg-gray-200 hover:bg-gray-300 text-gray-800 px-4 py-2 rounded-md transition">
<i class="fas fa-copy mr-2"></i>Copy Link
</button>
<button id="email-results-btn" class="bg-blue-100 hover:bg-blue-200 text-blue-800 px-4 py-2 rounded-md transition">
<i class="fas fa-envelope mr-2"></i>Email Results
</button>
</div>
</div>
</div>
</div>
</div>
<!-- Help Modal -->
<div id="help-modal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
<div class="bg-white rounded-xl p-6 w-full max-w-3xl max-h-[80vh] overflow-y-auto">
<div class="flex justify-between items-center mb-4">
<h3 class="text-xl font-semibold text-gray-800">Help - Exam Item Analyzer</h3>
<button id="close-help-modal" class="text-gray-500 hover:text-gray-700">
<i class="fas fa-times"></i>
</button>
</div>
<div class="space-y-4">
<div>
<h4 class="font-medium text-gray-800">What is Item Analysis?</h4>
<p class="text-sm text-gray-600 mt-1">
Item analysis is a statistical technique used to evaluate the quality of multiple-choice test questions.
It helps identify questions that might be too easy, too difficult, or not effectively discriminating
between high and low performing students.
</p>
</div>
<div>
<h4 class="font-medium text-gray-800">Key Metrics</h4>
<ul class="list-disc pl-5 text-sm text-gray-600 mt-1 space-y-2">
<li>
<span class="font-medium">Difficulty Index (p-value):</span>
The proportion of students who answered the question correctly. Range: 0 (very hard) to 1 (very easy)
</li>
<li>
<span class="font-medium">Discrimination Index:</span>
Measures how well a question differentiates between high and low performers. Range: -1.0 to +1.0
</li>
<li>
<span class="font-medium">Point-Biserial Correlation:</span>
Correlation between answering the question correctly and total test score
</li>
<li>
<span class="font-medium">Distractor Analysis:</span>
Evaluates how attractive each wrong option is to students
</li>
</ul>
</div>
<div>
<h4 class="font-medium text-gray-800">Interpretation Guidelines</h4>
<div class="mt-2 grid grid-cols-1 md:grid-cols-2 gap-3">
<div class="border border-gray-200 p-3 rounded">
<h5 class="font-medium text-sm">Difficulty Index</h5>
<table class="w-full text-xs mt-1">
<tr>
<td class="py-1">0.85 - 1.00</td>
<td class="py-1">Too easy</td>
</tr>
<tr>
<td class="py-1">0.60 - 0.84</td>
<td class="py-1">Optimal difficulty</td>
</tr>
<tr>
<td class="py-1">0.30 - 0.59</td>
<td class="py-1">Hard</td>
</tr>
<tr>
<td class="py-1">0.00 - 0.29</td>
<td class="py-1">Too hard</td>
</tr>
</table>
</div>
<div class="border border-gray-200 p-3 rounded">
<h5 class="font-medium text-sm">Discrimination Index</h5>
<table class="w-full text-xs mt-1">
<tr>
<td class="py-1">0.40+</td>
<td class="py-1">Very good</td>
</tr>
<tr>
<td class="py-1">0.30 - 0.39</td>
<td class="py-1">Good</td>
</tr>
<tr>
<td class="py-1">0.20 - 0.29</td>
<td class="py-1">Marginal</td>
</tr>
<tr>
<td class="py-1">Below 0.19</td>
<td class="py-1">Poor</td>
</tr>
<tr>
<td class="py-1">Negative</td>
<td class="py-1">Problematic</td>
</tr>
</table>
</div>
</div>
</div>
<div>
<h4 class="font-medium text-gray-800">How to Use This Tool</h4>
<ol class="list-decimal pl-5 text-sm text-gray-600 mt-1 space-y-2">
<li>Enter exam details (title, number of questions, choices per question)</li>
<li>Add student responses (either manually or upload CSV)</li>
<li>Set the correct answer key for each question</li>
<li>Click "Analyze Data" to calculate statistics</li>
<li>Review results on the analysis tabs</li>
<li>Export reports or share results as needed</li>
</ol>
</div>
</div>
<div class="mt-6 flex justify-end">
<button id="close-help-modal-bottom" class="bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded-md transition">
I Understand
</button>
</div>
</div>
</div>
<!-- Email Modal -->
<div id="email-modal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
<div class="bg-white rounded-xl p-6 w-full max-w-md">
<div class="flex justify-between items-center mb-4">
<h3 class="text-xl font-semibold text-gray-800">Email Results</h3>
<button id="close-email-modal" class="text-gray-500 hover:text-gray-700">
<i class="fas fa-times"></i>
</button>
</div>
<div class="space-y-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Recipient Email(s)</label>
<input type="text" placeholder="Enter email addresses, separated by commas" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Subject</label>
<input type="text" id="email-subject" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" value="Exam Item Analysis Report">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Message</label>
<textarea rows="4" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">Please find attached the item analysis report for your review. Let me know if you have any questions.</textarea>
</div>
<div class="pt-2">
<label class="inline-flex items-center">
<input type="checkbox" checked class="rounded border-gray-300 text-blue-600 shadow-sm focus:border-blue-300 focus:ring focus:ring-blue-200 focus:ring-opacity-50">
<span class="ml-2 text-sm text-gray-700">Include full report as PDF attachment</span>
</label>
</div>
</div>
<div class="mt-6 flex justify-end space-x-3">
<button id="cancel-email-btn" class="bg-gray-200 hover:bg-gray-300 text-gray-800 px-4 py-2 rounded-md transition">
Cancel
</button>
<button id="send-email-btn" class="bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded-md transition">
<i class="fas fa-paper-plane mr-2"></i>Send Email
</button>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
// Global variables
let students = [];
let answerKey = [];
let analysisResults = [];
let charts = {};
// DOM elements
const elements = {
tabBtns: document.querySelectorAll('.tab-btn'),
tabContents: document.querySelectorAll('.tab-content'),
numQuestionsInput: document.getElementById('num-questions'),
numChoicesInput: document.getElementById('num-choices'),
studentResponsesTable: document.getElementById('student-responses'),
answerKeyContainer: document.getElementById('answer-key-container'),
addStudentBtn: document.getElementById('add-student-btn'),
analyzeBtn: document.getElementById('analyze-btn'),
itemFilter: document.getElementById('item-filter'),
questionSelector: document.getElementById('question-selector'),
helpBtn: document.getElementById('help-btn'),
helpModal: document.getElementById('help-modal'),
closeHelpModalBtns: document.querySelectorAll('#close-help-modal, #close-help-modal-bottom'),
sampleDataBtn: document.getElementById('sample-data-btn'),
emailResultsBtn: document.getElementById('email-results-btn'),
emailModal: document.getElementById('email-modal'),
closeEmailModalBtn: document.getElementById('close-email-modal'),
cancelEmailBtn: document.getElementById('cancel-email-btn'),
sendEmailBtn: document.getElementById('send-email-btn'),
};
// Initialize the app
function init() {
setupEventListeners();
updateAnswerKeyFields();
}
// Set up event listeners
function setupEventListeners() {
// Tab switching
elements.tabBtns.forEach(btn => {
btn.addEventListener('click', () => {
const tabId = btn.getAttribute('data-tab');
switchTab(tabId);
});
});
// Input field changes
elements.numQuestionsInput.addEventListener('change', updateAnswerKeyFields);
elements.numChoicesInput.addEventListener('change', updateAnswerKeyFields);
// Button clicks
elements.addStudentBtn.addEventListener('click', addStudentRow);
elements.analyzeBtn.addEventListener('click', analyzeData);
elements.itemFilter.addEventListener('change', filterItemAnalysis);
elements.questionSelector.addEventListener('change', showDetailedQuestionAnalysis);
elements.helpBtn.addEventListener('click', () => elements.helpModal.classList.remove('hidden'));
elements.closeHelpModalBtns.forEach(btn => {
btn.addEventListener('click', () => elements.helpModal.classList.add('hidden'));
});
elements.sampleDataBtn.addEventListener('click', loadSampleData);
elements.emailResultsBtn.addEventListener('click', () => elements.emailModal.classList.remove('hidden'));
elements.closeEmailModalBtn.addEventListener('click', () => elements.emailModal.classList.add('hidden'));
elements.cancelEmailBtn.addEventListener('click', () => elements.emailModal.classList.add('hidden'));
elements.sendEmailBtn.addEventListener('click', sendEmailResults);
// Initialize charts
initializeCharts();
}
// Switch between tabs
function switchTab(tabId) {
elements.tabBtns.forEach(btn => {
if (btn.getAttribute('data-tab') === tabId) {
btn.classList.add('border-blue-500', 'text-blue-600');
btn.classList.remove('text-gray-500', 'hover:text-gray-700');
} else {
btn.classList.remove('border-blue-500', 'text-blue-600');
btn.classList.add('text-gray-500', 'hover:text-gray-700');
}
});
elements.tabContents.forEach(content => {
if (content.id === `${tabId}-section`) {
content.classList.remove('hidden');
content.classList.add('block');
if (tabId === 'results' && students.length > 0 && answerKey.length > 0 && analysisResults.length === 0) {
analyzeData();
}
} else {
content.classList.add('hidden');
content.classList.remove('block');
}
});
}
// Update answer key fields based on number of questions
function updateAnswerKeyFields() {
const numQuestions = parseInt(elements.numQuestionsInput.value) || 1;
const numChoices = parseInt(elements.numChoicesInput.value) || 4;
// Update responses header
const responsesHeader = document.getElementById('responses-header');
responsesHeader.textContent = `Responses (${Array(numQuestions).fill().map((_, i) => `Q${i+1}`).join(', ')})`;
// Update answer key fields
elements.answerKeyContainer.innerHTML = '';
for (let i = 0; i < numQuestions; i++) {
const div = document.createElement('div');
div.className = 'answer-key-item';
div.innerHTML = `
<label class="block text-sm font-medium text-gray-700 mb-1">Q${i+1} Correct Answer</label>
<select class="block w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 answer-key-select">
${Array(numChoices).fill().map((_, j) =>
`<option value="${String.fromCharCode(65 + j)}">${String.fromCharCode(65 + j)}</option>`
).join('')}
</select>
`;
elements.answerKeyContainer.appendChild(div);
}
// Update student rows if any exist
const studentRows = elements.studentResponsesTable.querySelectorAll('tr[data-student-id]');
if (studentRows.length > 0) {
studentRows.forEach(row => {
const responsesInput = row.querySelector('input.responses-input');
if (responsesInput) {
responsesInput.placeholder = `Enter ${numQuestions} letters (A-${String.fromCharCode(65 + numChoices - 1)})`;
}
});
}
}
// Add a new student row
function addStudentRow() {
const numQuestions = parseInt(elements.numQuestionsInput.value) || 1;
const numChoices = parseInt(elements.numChoicesInput.value) || 4;
const studentId = `S${students.length + 1}`;
const newStudent = {
id: studentId,
responses: Array(numQuestions).fill(''),
score: 0
};
students.push(newStudent);
// If the table has the "no data" row, remove it
const noDataRow = elements.studentResponsesTable.querySelector('td[colspan="4"]');
if (noDataRow) {
noDataRow.closest('tr').remove();
}
const row = document.createElement('tr');
row.setAttribute('data-student-id', studentId);
row.className = 'student-row';
row.innerHTML = `
<td class="px-4 py-3 whitespace-nowrap">
<input type="text" value="${studentId}" class="w-full px-2 py-1 border border-transparent hover:border-gray-300 rounded focus:outline-none focus:border-blue-500 student-id-input">
</td>
<td class="px-4 py-3 whitespace-nowrap">
<input type="text" value="0" readonly class="w-full px-2 py-1 border border-transparent text-center score-input">
</td>
<td class="px-4 py-3 whitespace-nowrap">
<input type="text" placeholder="Enter ${numQuestions} letters (A-${String.fromCharCode(65 + numChoices - 1)})" class="w-full px-2 py-1 border border-gray-300 rounded responses-input">
</td>
<td class="px-4 py-3 whitespace-nowrap text-right text-sm font-medium">
<button class="delete-student-btn text-red-600 hover:text-red-900">
<i class="fas fa-trash-alt"></i>
</button>
</td>
`;
elements.studentResponsesTable.appendChild(row);
// Set up event listeners for the new row
const idInput = row.querySelector('.student-id-input');
const responsesInput = row.querySelector('.responses-input');
const deleteBtn = row.querySelector('.delete-student-btn');
idInput.addEventListener('change', (e) => {
const student = students.find(s => s.id === studentId);
if (student) student.id = e.target.value;
row.setAttribute('data-student-id', e.target.value);
});
responsesInput.addEventListener('input', (e) => {
const student = students.find(s => s.id === studentId);
if (student) {
// Limit to correct number of characters and allowed options
const allowedChars = Array(numChoices).fill().map((_, i) => String.fromCharCode(65 + i));
student.responses = e.target.value.toUpperCase().split('').slice(0, numQuestions)
.filter(c => allowedChars.includes(c));
e.target.value = student.responses.join('');
if (answerKey.length === numQuestions) {
updateStudentScore(student);
updateStudentDisplay(row, student);
}
}
});
deleteBtn.addEventListener('click', () => {
students = students.filter(s => s.id !== studentId);
row.remove();
if (students.length === 0) {
elements.studentResponsesTable.innerHTML = `
<tr>
<td colspan="4" class="px-4 py-4 text-center text-sm text-gray-500">
No student data entered yet. Click "Add Student" to begin.
</td>
</tr>
`;
}
});
}
// Update student's score based on responses and answer key
function updateStudentScore(student) {
student.score = student.responses.reduce((score, response, index) => {
return score + (response === answerKey[index] ? 1 : 0);
}, 0);
}
// Update the display for a student row
function updateStudentDisplay(row, student) {
const scoreInput = row.querySelector('.score-input');
if (scoreInput) {
scoreInput.value = student.score;
scoreInput.className = `w-full px-2 py-1 border border-transparent text-center score-input ${
student.score / answerKey.length >= 0.8 ? 'text-green-600 font-bold' :
student.score / answerKey.length >= 0.6 ? 'text-blue-600' :
student.score / answerKey.length >= 0.4 ? 'text-yellow-600' : 'text-red-600'
}`;
}
}
// Analyze the exam data
function analyzeData() {
// Get answer key
answerKey = Array.from(document.querySelectorAll('.answer-key-select')).map(
select => select.value
);
// If no students, alert user
if (students.length === 0) {
alert('Please add student data before analyzing.');
return;
}
// If answer key doesn't match question count, alert user
if (answerKey.length !== parseInt(elements.numQuestionsInput.value)) {
alert('Please set the correct answer key for all questions.');
return;
}
// Calculate statistics
calculateItemAnalysis();
// Update summary
updateExamSummary();
// Update item analysis table
updateItemAnalysisTable();
// Switch to results tab
switchTab('results');
}
// Calculate item analysis statistics
function calculateItemAnalysis() {
const numQuestions = parseInt(elements.numQuestionsInput.value) || 1;
analysisResults = [];
// Sort students by score in descending order
const sortedStudents = [...students].sort((a, b) => b.score - a.score);
// Split students into upper and lower groups (27% each)
const groupSize = Math.floor(sortedStudents.length * 0.27);
const upperGroup = sortedStudents.slice(0, groupSize);
const lowerGroup = sortedStudents.slice(-groupSize);
for (let q = 0; q < numQuestions; q++) {
const correctAnswer = answerKey[q];
const totalStudents = students.length;
let correctCount = 0;
let upperCorrect = 0;
let lowerCorrect = 0;
let pointBiserialNumerator = 0;
let pointBiserialDenominator = 0;
// Count correct responses in each group
students.forEach(student => {
const isCorrect = student.responses.length > q && student.responses[q] === correctAnswer;
if (isCorrect) correctCount++;
});
upperGroup.forEach(student => {
if (student.responses.length > q && student.responses[q] === correctAnswer) {
upperCorrect++;
}
});
lowerGroup.forEach(student => {
if (student.responses.length > q && student.responses[q] === correctAnswer) {
lowerCorrect++;
}
});
// Calculate difficulty index (p-value)
const difficulty = correctCount / totalStudents;
// Calculate discrimination index
const discrimination = (upperCorrect - lowerCorrect) / groupSize;
// Calculate point-biserial correlation (simplified)
const meanScoreCorrect = students
.filter(student => student.responses.length > q && student.responses[q] === correctAnswer)
.reduce((sum, student) => sum + student.score, 0) / correctCount || 0;
const meanScoreIncorrect = students
.filter(student => student.responses.length <= q || student.responses[q] !== correctAnswer)
.reduce((sum, student) => sum + student.score, 0) / (totalStudents - correctCount) || 0;
const stdDev = Math.sqrt(
students.reduce((sum, student) => sum + Math.pow(student.score - (meanScoreCorrect * correctCount + meanScoreIncorrect * (totalStudents - correctCount)) / totalStudents, 2), 0) / (totalStudents - 1)
);
const pointBiserial = ((meanScoreCorrect - meanScoreIncorrect) / stdDev) *
Math.sqrt((correctCount * (totalStudents - correctCount)) / (totalStudents * totalStudents));
// Calculate distractor analysis (which wrong options were selected by upper vs lower group)
const distractorAnalysis = {};
const allOptions = Array(parseInt(elements.numChoicesInput.value)).fill().map((_, i) => String.fromCharCode(65 + i));
allOptions.forEach(option => {
if (option !== correctAnswer) {
distractorAnalysis[option] = {
upper: upperGroup.filter(student =>
student.responses.length > q && student.responses[q] === option
).length,
lower: lowerGroup.filter(student =>
student.responses.length > q && student.responses[q] === option
).length,
total: students.filter(student =>
student.responses.length > q && student.responses[q] === option
).length
};
}
});
analysisResults.push({
question: q + 1,
correctAnswer,
difficulty,
discrimination,
pointBiserial,
distractorAnalysis
});
}
console.log('Analysis results:', analysisResults);
}
// Update exam summary section
function updateExamSummary() {
const totalStudents = students.length;
const totalQuestions = parseInt(elements.numQuestionsInput.value) || 1;
// Calculate average score and standard deviation
const avgScore = students.reduce((sum, student) => sum + student.score, 0) / totalStudents;
const stdDev = Math.sqrt(
students.reduce((sum, student) => sum + Math.pow(student.score - avgScore, 2), 0) / (totalStudents - 1)
) || 0;
// Update summary elements
document.getElementById('num-students').textContent = totalStudents;
document.getElementById('average-score').textContent = avgScore.toFixed(2) + ` (${(avgScore / totalQuestions * 100).toFixed(1)}%)`;
document.getElementById('std-dev').textContent = stdDev.toFixed(2);
// Update report date
const now = new Date();
document.getElementById('report-date').textContent = `Report generated: ${now.toLocaleDateString()} at ${now.toLocaleTimeString()}`;
// Update score distribution chart
updateScoreDistributionChart();
}
// Update item analysis table
function updateItemAnalysisTable() {
const tableBody = document.getElementById('item-analysis-results');
tableBody.innerHTML = '';
analysisResults.forEach(item => {
const row = document.createElement('tr');
row.className = 'item-analysis-row';
row.innerHTML = `
<td class="px-4 py-3 whitespace-nowrap">
<span class="font-medium">Question ${item.question}</span>
</td>
<td class="px-4 py-3 whitespace-nowrap">
<span class="difficulty-badge px-2 py-1 rounded-full text-xs font-medium ${
item.difficulty >= 0.85 ? 'difficulty-easy' :
item.difficulty >= 0.6 ? 'difficulty-medium' : 'difficulty-hard'
}">
${item.difficulty.toFixed(2)}
</span>
</td>
<td class="px-4 py-3 whitespace-nowrap">
<span class="discrimination-badge px-2 py-1 rounded-full text-xs font-medium ${
item.discrimination >= 0.4 ? 'discrimination-high' : 'discrimination-low'
}">
${item.discrimination.toFixed(2)}
</span>
</td>
<td class="px-4 py-3 whitespace-nowrap text-center">
<span class="bg-green-100 text-green-800 px-2 py-1 rounded-full text-xs font-bold">
${item.correctAnswer}
</span>
</td>
<td class="px-4 py-3">
<div class="distractor-analysis flex flex-wrap gap-1">
${Object.entries(item.distractorAnalysis).map(([option, stat]) => `
<span class="px-2 py-1 rounded-full text-xs flex items-center ${
stat.upper > stat.lower ? 'bg-red-100 text-red-800' : 'bg-yellow-100 text-yellow-800'
}" title="Upper group: ${stat.upper}, Lower group: ${stat.lower}">
${option}: ${stat.total}
${stat.upper > stat.lower ? '<i class="fas fa-arrow-up ml-1 text-xs"></i>' :
stat.lower > stat.upper ? '<i class="fas fa-arrow-down ml-1 text-xs"></i>' : ''}
</span>
`).join('')}
</div>
</td>
<td class="px-4 py-3 whitespace-nowrap text-right text-sm font-medium">
<button class="view-details-btn text-blue-600 hover:text-blue-900" data-question="${item.question}">
<i class="fas fa-search"></i> Details
</button>
</td>
`;
tableBody.appendChild(row);
});
// Add event listeners to details buttons
document.querySelectorAll('.view-details-btn').forEach(btn => {
btn.addEventListener('click', () => {
const questionNum = parseInt(btn.getAttribute('data-question'));
showDetailedQuestionAnalysis(questionNum);
});
});
// Update question selector for detailed view
updateQuestionSelector();
// Update charts
updateDifficultyChart();
updateDiscriminationChart();
}
// Update question selector dropdown
function updateQuestionSelector() {
const selector = elements.questionSelector;
selector.innerHTML = '';
analysisResults.forEach(item => {
const option = document.createElement('option');
option.value = item.question;
option.textContent = `Q${item.question}`;
selector.appendChild(option);
});
// Select the first question by default
if (analysisResults.length > 0) {
selector.value = analysisResults[0].question;
showDetailedQuestionAnalysis(analysisResults[0].question);
}
}
// Show detailed analysis for a specific question
function showDetailedQuestionAnalysis(questionNum) {
if (typeof questionNum === 'object') {
// Coming from event listener
questionNum = parseInt(elements.questionSelector.value);
} else if (typeof questionNum === 'string') {
questionNum = parseInt(questionNum);
}
const item = analysisResults.find(item => item.question === questionNum);
if (!item) return;
// Update metrics
document.getElementById('detailed-p-value').textContent = item.difficulty.toFixed(2);
document.getElementById('detailed-discrimination').textContent = item.discrimination.toFixed(2);
document.getElementById('detailed-point-biserial').textContent = item.pointBiserial.toFixed(2);
// Update interpretations
const pValueInterpretation = document.getElementById('p-value-interpretation');
if (item.difficulty >= 0.85) {
pValueInterpretation.textContent = 'Too easy - Consider revising';
pValueInterpretation.className = 'text-xs mt-1 text-red-600';
} else if (item.difficulty >= 0.6) {
pValueInterpretation.textContent = 'Optimal difficulty';
pValueInterpretation.className = 'text-xs mt-1 text-green-600';
} else if (item.difficulty >= 0.3) {
pValueInterpretation.textContent = 'Hard - Review for fairness';
pValueInterpretation.className = 'text-xs mt-1 text-yellow-600';
} else {
pValueInterpretation.textContent = 'Too hard - Review carefully';
pValueInterpretation.className = 'text-xs mt-1 text-red-600';
}
const discriminationInterpretation = document.getElementById('discrimination-interpretation');
if (item.discrimination >= 0.4) {
discriminationInterpretation.textContent = 'Very good discrimination';
discriminationInterpretation.className = 'text-xs mt-1 text-green-600';
} else if (item.discrimination >= 0.3) {
discriminationInterpretation.textContent = 'Good discrimination';
discriminationInterpretation.className = 'text-xs mt-1 text-green-600';
} else if (item.discrimination >= 0.2) {
discriminationInterpretation.textContent = 'Marginal - Could be improved';
discriminationInterpretation.className = 'text-xs mt-1 text-yellow-600';
} else if (item.discrimination >= 0) {
discriminationInterpretation.textContent = 'Poor - Consider revising';
discriminationInterpretation.className = 'text-xs mt-1 text-red-600';
} else {
discriminationInterpretation.textContent = 'Negative - Problematic question';
discriminationInterpretation.className = 'text-xs mt-1 text-red-600 font-bold';
}
const pointBiserialInterpretation = document.getElementById('point-biserial-interpretation');
if (item.pointBiserial >= 0.4) {
pointBiserialInterpretation.textContent = 'Strong relationship with total score';
pointBiserialInterpretation.className = 'text-xs mt-1 text-green-600';
} else if (item.pointBiserial >= 0.2) {
pointBiserialInterpretation.textContent = 'Moderate relationship with total score';
pointBiserialInterpretation.className = 'text-xs mt-1 text-blue-600';
} else if (item.pointBiserial >= 0) {
pointBiserialInterpretation.textContent = 'Weak relationship with total score';
pointBiserialInterpretation.className = 'text-xs mt-1 text-yellow-600';
} else {
pointBiserialInterpretation.textContent = 'Negative relationship - Problematic';
pointBiserialInterpretation.className = 'text-xs mt-1 text-red-600 font-bold';
}
// Update detailed question chart
updateDetailedQuestionChart(questionNum);
}
// Filter item analysis table
function filterItemAnalysis() {
const filterValue = elements.itemFilter.value;
const rows = document.querySelectorAll('.item-analysis-row');
rows.forEach(row => {
row.style.display = 'table-row';
if (filterValue === 'all') {
return;
}
const difficulty = parseFloat(row.querySelector('.difficulty-badge').textContent);
const discrimination = parseFloat(row.querySelector('.discrimination-badge').textContent);
if (filterValue === 'difficulty') {
if (difficulty < 0.3 || difficulty > 0.85) {
row.style.display = 'none';
}
} else if (filterValue === 'discrimination') {
if (discrimination < 0.2) {
row.style.display = 'none';
}
} else if (filterValue === 'problematic') {
if (!(difficulty < 0.3 || difficulty > 0.85 || discrimination < 0.2 || discrimination < 0)) {
row.style.display = 'none';
}
}
});
}
// Initialize charts
function initializeCharts() {
// Score distribution chart
const scoreCtx = document.getElementById('score-distribution-chart').getContext('2d');
charts.scoreDistribution = new Chart(scoreCtx, {
type: 'bar',
data: {
labels: [],
datasets: [{
label: 'Number of Students',
backgroundColor: 'rgba(59, 130, 246, 0.5)',
borderColor: 'rgba(59, 130, 246, 1)',
borderWidth: 1,
data: []
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
scales: {
y: {
beginAtZero: true,
title: {
display: true,
text: 'Number of Students'
}
},
x: {
title: {
display: true,
text: 'Score Range'
}
}
}
}
});
// Difficulty index chart
const difficultyCtx = document.getElementById('difficulty-chart').getContext('2d');
charts.difficulty = new Chart(difficultyCtx, {
type: 'bar',
data: {
labels: ['0.00-0.29', '0.30-0.59', '0.60-0.84', '0.85-1.00'],
datasets: [{
label: 'Number of Questions',
backgroundColor: [
'rgba(239, 68, 68, 0.5)', // Red for too hard
'rgba(251, 191, 36, 0.5)', // Yellow for hard
'rgba(74, 222, 128, 0.5)', // Green for optimal
'rgba(239, 68, 68, 0.5)' // Red for too easy
],
borderColor: [
'rgba(239, 68, 68, 1)',
'rgba(251, 191, 36, 1)',
'rgba(74, 222, 128, 1)',
'rgba(239, 68, 68, 1)'
],
borderWidth: 1,
data: [0, 0, 0, 0]
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
scales: {
y: {
beginAtZero: true,
title: {
display: true,
text: 'Number of Questions'
}
},
x: {
title: {
display: true,
text: 'Difficulty Index (p-value) Range'
}
}
}
}
});
// Discrimination index chart
const discriminationCtx = document.getElementById('discrimination-chart').getContext('2d');
charts.discrimination = new Chart(discriminationCtx, {
type: 'bar',
data: {
labels: ['<0.0', '0.0-0.19', '0.20-0.29', '0.30-0.39', '≥0.40'],
datasets: [{
label: 'Number of Questions',
backgroundColor: [
'rgba(239, 68, 68, 0.5)', // Red for negative
'rgba(239, 68, 68, 0.5)', // Red for poor
'rgba(251, 191, 36, 0.5)', // Yellow for marginal
'rgba(96, 165, 250, 0.5)', // Blue for good
'rgba(74, 222, 128, 0.5)' // Green for very good
],
borderColor: [
'rgba(239, 68, 68, 1)',
'rgba(239, 68, 68, 1)',
'rgba(251, 191, 36, 1)',
'rgba(96, 165, 250, 1)',
'rgba(74, 222, 128, 1)'
],
borderWidth: 1,
data: [0, 0, 0, 0, 0]
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
scales: {
y: {
beginAtZero: true,
title: {
display: true,
text: 'Number of Questions'
}
},
x: {
title: {
display: true,
text: 'Discrimination Index Range'
}
}
}
}
});
// Detailed question chart
const detailedCtx = document.getElementById('detailed-question-chart').getContext('2d');
charts.detailedQuestion = new Chart(detailedCtx, {
type: 'bar',
data: {
labels: [],
datasets: [
{
label: 'Upper Group',
backgroundColor: 'rgba(74, 222, 128, 0.7)',
borderColor: 'rgba(74, 222, 128, 1)',
borderWidth: 1,
data: []
},
{
label: 'Lower Group',
backgroundColor: 'rgba(239, 68, 68, 0.7)',
borderColor: 'rgba(239, 68, 68, 1)',
borderWidth: 1,
data: []
}
]
},
options: {
responsive: true,
maintainAspectRatio: false,
scales: {
y: {
beginAtZero: true,
title: {
display: true,
text: 'Number of Students'
}
},
x: {
title: {
display: true,
text: 'Response Option'
}
}
}
}
});
}
// Update score distribution chart
function updateScoreDistributionChart() {
if (!charts.scoreDistribution) return;
const totalQuestions = parseInt(elements.numQuestionsInput.value) || 1;
const scoreBins = Array(totalQuestions + 1).fill(0);
students.forEach(student => {
scoreBins[student.score]++;
});
charts.scoreDistribution.data.labels = scoreBins.map((_, i) => i.toString());
charts.scoreDistribution.data.datasets[0].data = scoreBins;
charts.scoreDistribution.update();
}
// Update difficulty index chart
function updateDifficultyChart() {
if (!charts.difficulty || analysisResults.length === 0) return;
const counts = [0, 0, 0, 0]; // Too hard, hard, optimal, too easy
analysisResults.forEach(item => {
if (item.difficulty < 0.3) {
counts[0]++;
} else if (item.difficulty < 0.6) {
counts[1]++;
} else if (item.difficulty < 0.85) {
counts[2]++;
} else {
counts[3]++;
}
});
charts.difficulty.data.datasets[0].data = counts;
charts.difficulty.update();
}
// Update discrimination index chart
function updateDiscriminationChart() {
if (!charts.discrimination || analysisResults.length === 0) return;
const counts = [0, 0, 0, 0, 0]; // Negative, poor, marginal, good, very good
analysisResults.forEach(item => {
if (item.discrimination < 0) {
counts[0]++;
} else if (item.discrimination < 0.2) {
counts[1]++;
} else if (item.discrimination < 0.3) {
counts[2]++;
} else if (item.discrimination < 0.4) {
counts[3]++;
} else {
counts[4]++;
}
});
charts.discrimination.data.datasets[0].data = counts;
charts.discrimination.update();
}
// Update detailed question chart for a specific question
function updateDetailedQuestionChart(questionNum) {
if (!charts.detailedQuestion) return;
const item = analysisResults.find(item => item.question === questionNum);
if (!item) return;
const allOptions = Array(parseInt(elements.numChoicesInput.value)).fill().map((_, i) => String.fromCharCode(65 + i));
charts.detailedQuestion.data.labels = allOptions;
// Upper group counts
const upperCounts = allOptions.map(option => {
if (option === item.correctAnswer) {
return item.discrimination * Math.floor(students.length * 0.27) +
item.distractorAnalysis[1]?.upper || 0;
} else {
return item.distractorAnalysis[option]?.upper || 0;
}
});
// Lower group counts
const lowerCounts = allOptions.map(option => {
if (option === item.correctAnswer) {
return (1 - item.difficulty) * Math.floor(students.length * 0.27) +
item.distractorAnalysis[1]?.lower || 0;
} else {
return item.distractorAnalysis[option]?.lower || 0;
}
});
charts.detailedQuestion.data.datasets[0].data = upperCounts;
charts.detailedQuestion.data.datasets[1].data = lowerCounts;
charts.detailedQuestion.update();
}
// Load sample data
function loadSampleData() {
// Set exam details
document.getElementById('exam-title').value = 'Sample Midterm Exam';
elements.numQuestionsInput.value = 10;
elements.numChoicesInput.value = 4;
// Update answer key fields
updateAnswerKeyFields();
// Set some random correct answers
const answerSelects = document.querySelectorAll('.answer-key-select');
answerSelects.forEach(select => {
const randomChoice = Math.floor(Math.random() * 4) + 1;
select.selectedIndex = randomChoice - 1;
});
// Generate sample student data
students = [];
elements.studentResponsesTable.innerHTML = '';
const numStudents = 50;
const numQuestions = 10;
for (let i = 0; i < numStudents; i++) {
const studentId = `S${i + 1}`;
const responses = [];
// Generate responses with some correlation to ability
const ability = Math.random(); // Random ability level for the student
for (let q = 0; q < numQuestions; q++) {
const difficulty = Math.random() * 0.7 + 0.15; // Random difficulty between 0.15 and 0.85
const correctAnswer = answerSelects[q].value;
// Higher ability students more likely to answer correctly
if (Math.random() < ability * (1 - difficulty * 0.7)) {
responses.push(correctAnswer);
} else {
// Choose a wrong answer randomly
const wrongOptions = ['A', 'B', 'C', 'D'].filter(opt => opt !== correctAnswer);
const randomWrong = wrongOptions[Math.floor(Math.random() * wrongOptions.length)];
responses.push(randomWrong);
}
}
const student = {
id: studentId,
responses,
score: responses.reduce((score, response, idx) =>
score + (response === answerSelects[idx].value ? 1 : 0), 0)
};
students.push(student);
// Add to table
const row = document.createElement('tr');
row.setAttribute('data-student-id', studentId);
row.className = 'student-row';
row.innerHTML = `
<td class="px-4 py-3 whitespace-nowrap">
<input type="text" value="${studentId}" class="w-full px-2 py-1 border border-transparent hover:border-gray-300 rounded focus:outline-none focus:border-blue-500 student-id-input">
</td>
<td class="px-4 py-3 whitespace-nowrap">
<input type="text" value="${student.score}" readonly class="w-full px-2 py-1 border border-transparent text-center score-input ${
student.score / numQuestions >= 0.8 ? 'text-green-600 font-bold' :
student.score / numQuestions >= 0.6 ? 'text-blue-600' :
student.score / numQuestions >= 0.4 ? 'text-yellow-600' : 'text-red-600'
}">
</td>
<td class="px-4 py-3 whitespace-nowrap">
<input type="text" value="${responses.join('')}" class="w-full px-2 py-1 border border-gray-300 rounded responses-input">
</td>
<td class="px-4 py-3 whitespace-nowrap text-right text-sm font-medium">
<button class="delete-student-btn text-red-600 hover:text-red-900">
<i class="fas fa-trash-alt"></i>
</button>
</td>
`;
elements.studentResponsesTable.appendChild(row);
// Set up event listeners for the new row
const idInput = row.querySelector('.student-id-input');
const responsesInput = row.querySelector('.responses-input');
const deleteBtn = row.querySelector('.delete-student-btn');
idInput.addEventListener('change', (e) => {
const student = students.find(s => s.id === studentId);
if (student) student.id = e.target.value;
row.setAttribute('data-student-id', e.target.value);
});
responsesInput.addEventListener('change', (e) => {
const student = students.find(s => s.id === studentId);
if (student) {
student.responses = e.target.value.split('');
student.score = student.responses.reduce((score, response, idx) =>
score + (response === answerSelects[idx].value ? 1 : 0), 0);
row.querySelector('.score-input').value = student.score;
}
});
deleteBtn.addEventListener('click', () => {
students = students.filter(s => s.id !== studentId);
row.remove();
});
}
// Show message that sample data is loaded
alert('Sample data loaded successfully. You can now click "Analyze Data" to see results.');
}
// Send email with results (simulated)
function sendEmailResults() {
alert('Email functionality is simulated in this demo. In a real application, this would send the report to the specified recipients.');
elements.emailModal.classList.add('hidden');
}
// Initialize the app when the DOM is loaded
document.addEventListener('DOMContentLoaded', init);
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - <a href="https://enzostvs-deepsite.hf.space?remix=Docav127/av127" style="color: #fff;text-decoration: underline;" target="_blank" >🧬 Remix</a></p></body>
</html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Exam Item Analyzer</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
.chart-container {
position: relative;
height: 300px;
width: 100%;
}
/* Custom scrollbar */
::-webkit-scrollbar {
width: 8px;
height: 8px;
}
::-webkit-scrollbar-track {
background: #f1f1f1;
}
::-webkit-scrollbar-thumb {
background: #888;
border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
background: #555;
}
/* Animation for results */
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
.animate-fade-in {
animation: fadeIn 0.5s ease-out forwards;
}
/* Difficulty rating colors */
.difficulty-easy {
background-color: #4ade80;
}
.difficulty-medium {
background-color: #fbbf24;
}
.difficulty-hard {
background-color: #f87171;
}
.discrimination-high {
background-color: #60a5fa;
}
.discrimination-low {
background-color: #c084fc;
}
</style>
</head>
<body class="bg-gray-50 font-sans">
<div class="container mx-auto px-4 py-8 max-w-7xl">
<header class="mb-10">
<div class="flex items-center justify-between">
<div>
<h1 class="text-3xl font-bold text-blue-800">
<i class="fas fa-chart-pie mr-2"></i>Exam Item Analyzer
</h1>
<p class="text-gray-600 mt-1">Analyze multiple choice exam questions for validity and effectiveness</p>
</div>
<div class="flex space-x-2">
<button id="help-btn" class="bg-gray-200 hover:bg-gray-300 text-gray-800 px-3 py-2 rounded-lg transition">
<i class="fas fa-question-circle"></i> Help
</button>
<button id="sample-data-btn" class="bg-blue-100 hover:bg-blue-200 text-blue-800 px-3 py-2 rounded-lg transition">
<i class="fas fa-file-alt"></i> Load Sample Data
</button>
</div>
</div>
<div class="mt-4 flex border-b border-gray-200">
<button data-tab="input" class="tab-btn py-2 px-4 font-medium border-b-2 border-blue-500 text-blue-600">
<i class="fas fa-keyboard mr-2"></i>Input Data
</button>
<button data-tab="results" class="tab-btn py-2 px-4 font-medium text-gray-500 hover:text-gray-700">
<i class="fas fa-chart-bar mr-2"></i>Analysis Results
</button>
<button data-tab="export" class="tab-btn py-2 px-4 font-medium text-gray-500 hover:text-gray-700">
<i class="fas fa-file-export mr-2"></i>Export
</button>
</div>
</header>
<!-- Input Section -->
<div id="input-section" class="tab-content block">