Add 2 files
Browse filesFiles changed (2)
- README.md+7-5
- index.html+1534-19
12345678910---title: Av127emoji: 📊colorFrom: graycolorTo: bluesdk: staticpinned: false---Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference123456789101112---title: av127emoji: 🐳colorFrom: bluecolorTo: redsdk: staticpinned: falsetags:- deepsite---Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
12345678910111213141516171819<!doctype html><html><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width" /><title>My static Space</title><link rel="stylesheet" href="style.css" /></head><body><div class="card"><h1>Welcome to your static Space!</h1><p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p><p>Also don't forget to check the<a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.</p></div></body></html>1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534<!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 discriminatingbetween 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 variableslet students = [];let answerKey = [];let analysisResults = [];let charts = {};// DOM elementsconst 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 appfunction init() {setupEventListeners();updateAnswerKeyFields();}// Set up event listenersfunction setupEventListeners() {// Tab switchingelements.tabBtns.forEach(btn => {btn.addEventListener('click', () => {const tabId = btn.getAttribute('data-tab');switchTab(tabId);});});// Input field changeselements.numQuestionsInput.addEventListener('change', updateAnswerKeyFields);elements.numChoicesInput.addEventListener('change', updateAnswerKeyFields);// Button clickselements.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 chartsinitializeCharts();}// Switch between tabsfunction 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 questionsfunction updateAnswerKeyFields() {const numQuestions = parseInt(elements.numQuestionsInput.value) || 1;const numChoices = parseInt(elements.numChoicesInput.value) || 4;// Update responses headerconst responsesHeader = document.getElementById('responses-header');responsesHeader.textContent = `Responses (${Array(numQuestions).fill().map((_, i) => `Q${i+1}`).join(', ')})`;// Update answer key fieldselements.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 existconst 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 rowfunction 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 itconst 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 rowconst 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 optionsconst 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 keyfunction updateStudentScore(student) {student.score = student.responses.reduce((score, response, index) => {return score + (response === answerKey[index] ? 1 : 0);}, 0);}// Update the display for a student rowfunction 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 datafunction analyzeData() {// Get answer keyanswerKey = Array.from(document.querySelectorAll('.answer-key-select')).map(select => select.value);// If no students, alert userif (students.length === 0) {alert('Please add student data before analyzing.');return;}// If answer key doesn't match question count, alert userif (answerKey.length !== parseInt(elements.numQuestionsInput.value)) {alert('Please set the correct answer key for all questions.');return;}// Calculate statisticscalculateItemAnalysis();// Update summaryupdateExamSummary();// Update item analysis tableupdateItemAnalysisTable();// Switch to results tabswitchTab('results');}// Calculate item analysis statisticsfunction calculateItemAnalysis() {const numQuestions = parseInt(elements.numQuestionsInput.value) || 1;analysisResults = [];// Sort students by score in descending orderconst 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 groupstudents.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 indexconst 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 sectionfunction updateExamSummary() {const totalStudents = students.length;const totalQuestions = parseInt(elements.numQuestionsInput.value) || 1;// Calculate average score and standard deviationconst 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 elementsdocument.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 dateconst now = new Date();document.getElementById('report-date').textContent = `Report generated: ${now.toLocaleDateString()} at ${now.toLocaleTimeString()}`;// Update score distribution chartupdateScoreDistributionChart();}// Update item analysis tablefunction 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 buttonsdocument.querySelectorAll('.view-details-btn').forEach(btn => {btn.addEventListener('click', () => {const questionNum = parseInt(btn.getAttribute('data-question'));showDetailedQuestionAnalysis(questionNum);});});// Update question selector for detailed viewupdateQuestionSelector();// Update chartsupdateDifficultyChart();updateDiscriminationChart();}// Update question selector dropdownfunction 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 defaultif (analysisResults.length > 0) {selector.value = analysisResults[0].question;showDetailedQuestionAnalysis(analysisResults[0].question);}}// Show detailed analysis for a specific questionfunction showDetailedQuestionAnalysis(questionNum) {if (typeof questionNum === 'object') {// Coming from event listenerquestionNum = parseInt(elements.questionSelector.value);} else if (typeof questionNum === 'string') {questionNum = parseInt(questionNum);}const item = analysisResults.find(item => item.question === questionNum);if (!item) return;// Update metricsdocument.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 interpretationsconst 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 chartupdateDetailedQuestionChart(questionNum);}// Filter item analysis tablefunction 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 chartsfunction initializeCharts() {// Score distribution chartconst 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 chartconst 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 chartconst 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 chartconst 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 chartfunction 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 chartfunction updateDifficultyChart() {if (!charts.difficulty || analysisResults.length === 0) return;const counts = [0, 0, 0, 0]; // Too hard, hard, optimal, too easyanalysisResults.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 chartfunction updateDiscriminationChart() {if (!charts.discrimination || analysisResults.length === 0) return;const counts = [0, 0, 0, 0, 0]; // Negative, poor, marginal, good, very goodanalysisResults.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 questionfunction 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 countsconst 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 countsconst 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 datafunction loadSampleData() {// Set exam detailsdocument.getElementById('exam-title').value = 'Sample Midterm Exam';elements.numQuestionsInput.value = 10;elements.numChoicesInput.value = 4;// Update answer key fieldsupdateAnswerKeyFields();// Set some random correct answersconst answerSelects = document.querySelectorAll('.answer-key-select');answerSelects.forEach(select => {const randomChoice = Math.floor(Math.random() * 4) + 1;select.selectedIndex = randomChoice - 1;});// Generate sample student datastudents = [];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 abilityconst ability = Math.random(); // Random ability level for the studentfor (let q = 0; q < numQuestions; q++) {const difficulty = Math.random() * 0.7 + 0.15; // Random difficulty between 0.15 and 0.85const correctAnswer = answerSelects[q].value;// Higher ability students more likely to answer correctlyif (Math.random() < ability * (1 - difficulty * 0.7)) {responses.push(correctAnswer);} else {// Choose a wrong answer randomlyconst 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 tableconst 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 rowconst 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 loadedalert('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 loadeddocument.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>
README.md+7-5
index.html+1534-19