From b7ea06a9f2a86bd039294684c2c64aa958e6cb9c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 9 Jun 2026 12:36:11 +0000 Subject: [PATCH 1/5] Initial plan From d3ea11d5e066a79ee3f784b84fc46ae858eee50d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 9 Jun 2026 12:45:32 +0000 Subject: [PATCH 2/5] Create dedicated admin exams page --- static/admin-exams.html | 172 ++++++++ static/admin-questions.html | 3 +- static/admin-quizzes.html | 3 +- static/admin-topics.html | 3 +- static/admin.html | 3 +- static/dashboard.html | 2 +- static/instructor.html | 764 ---------------------------------- static/js/admin/exams-page.js | 322 ++++++++++++++ static/quiz.html | 2 +- 9 files changed, 504 insertions(+), 770 deletions(-) create mode 100644 static/admin-exams.html create mode 100644 static/js/admin/exams-page.js diff --git a/static/admin-exams.html b/static/admin-exams.html new file mode 100644 index 0000000..6dfde3b --- /dev/null +++ b/static/admin-exams.html @@ -0,0 +1,172 @@ + + +
+ + + + +Select categories and difficulty levels to randomly generate questions for a named exam. Default is 30 questions (configurable below).
+Select an exam and choose students to assign it to.
+Click Refresh to load status.
+Import questions from a JSON file to create a named, categorized quiz that can be assigned to students.
-{
- "topic": "Optional Topic Name",
- "questions": [
- {
- "text": "Question text?",
- "difficulty": 3,
- "tags": ["tag1"],
- "answers": [
- {"text": "Correct answer", "is_correct": true},
- {"text": "Wrong answer", "is_correct": false}
- ]
- }
- ]
-}
- Select a quiz and choose students to assign it to.
-Click Refresh to load status.
-Select categories and difficulty levels to randomly generate questions for a named exam. Default is 30 questions (configurable below).
-Select an exam and choose students to assign it to.
-Click Refresh to load status.
-Loading...
'; - try { - const response = await fetch('/instructor/assigned-quizzes/status', {headers: {'X-User-ID': userId}}); - const summaries = await response.json(); - - if (!summaries || summaries.length === 0) { - container.innerHTML = 'No quizzes have been assigned yet.
'; - return; - } - - let html = `| Quiz Name | Category | Description | -Assigned | Completed | Actions | -
|---|---|---|---|---|---|
| ${escapeHtml(s.quiz_name)} | -${escapeHtml(s.quiz_category || '')} | -${escapeHtml(s.quiz_description || '')} | -${s.assigned_count} | -${s.completed_count} / ${s.assigned_count} | -- |
Error loading quiz status: ' + e.message + '
'; - } - } - - async function showQuizDetail(quizId, quizName) { - const panel = document.getElementById('quizDetailPanel'); - const title = document.getElementById('quizDetailTitle'); - const content = document.getElementById('quizDetailContent'); - - title.textContent = `Results: ${quizName}`; - content.innerHTML = 'Loading...
'; - panel.style.display = 'block'; - panel.scrollIntoView({behavior: 'smooth'}); - - try { - const response = await fetch(`/instructor/assigned-quizzes/status/quiz?quiz_id=${quizId}`, {headers: {'X-User-ID': userId}}); - const status = await response.json(); - - if (!status.student_results || status.student_results.length === 0) { - content.innerHTML = 'No students assigned to this quiz.
'; - return; - } - - let html = `| Student | Assigned | Completed | Score | Correct | -
|---|---|---|---|---|
| ${escapeHtml(r.username)} | -${new Date(r.assigned_at).toLocaleDateString()} | -${completed} | -${scoreHtml} | -${correct} | -
Error loading results: ' + e.message + '
'; - } - } - - function hideQuizDetail() { - document.getElementById('quizDetailPanel').style.display = 'none'; - } - - // ============ Assigned Exams Functions ============ - - async function loadExamCategories() { - const container = document.getElementById('examCategoriesCheckboxes'); - try { - const response = await fetch('/instructor/exams/categories', {headers: {'X-User-ID': userId}}); - const categories = await response.json(); - if (!categories || categories.length === 0) { - container.innerHTML = 'No categories available.'; - return; - } - container.innerHTML = ''; - categories.forEach(cat => { - const div = document.createElement('div'); - div.className = 'form-check form-check-inline'; - div.innerHTML = ` - `; - container.appendChild(div); - }); - } catch (e) { - container.innerHTML = 'Error loading categories.'; - } - } - - async function generateExam() { - const name = document.getElementById('newExamName').value.trim(); - const resultDiv = document.getElementById('generateExamResult'); - - if (!name) { - alert('Exam name is required.'); - return; - } - - const checkedCats = Array.from(document.querySelectorAll('.exam-category-check:checked')).map(cb => cb.value); - if (checkedCats.length === 0) { - alert('Please select at least one category.'); - return; - } - - const checkedDiffs = Array.from(document.querySelectorAll('.exam-difficulty-check:checked')).map(cb => parseInt(cb.value)); - if (checkedDiffs.length === 0) { - alert('Please select at least one difficulty level.'); - return; - } - - const questionCount = parseInt(document.getElementById('examQuestionCount').value) || 30; - - resultDiv.style.display = 'none'; - try { - const response = await fetch('/instructor/exams/generate', { - method: 'POST', - headers: {'Content-Type': 'application/json', 'X-User-ID': userId}, - body: JSON.stringify({ - name: name, - categories: checkedCats, - difficulty_levels: checkedDiffs, - question_count: questionCount - }) - }); - const result = await response.json(); - - if (response.ok && result.success) { - const examUrl = window.location.origin + result.exam_url; - resultDiv.className = 'alert alert-success'; - resultDiv.innerHTML = `✅ Exam "${escapeHtml(result.exam_name)}" created with ${result.question_count} questions.Loading...
'; - try { - const response = await fetch('/instructor/exams', {headers: {'X-User-ID': userId}}); - const exams = await response.json(); - - if (!exams || exams.length === 0) { - container.innerHTML = 'No exams have been created yet.
'; - return; - } - - let html = `| Exam Name | Categories | Difficulty Levels | -Questions | Exam URL | Actions | -
|---|---|---|---|---|---|
| ${escapeHtml(e.name)} | -${escapeHtml(cats)} | -${escapeHtml(diffs)} | -${e.question_count} | -${escapeHtml(examUrl)} | -- |
Error loading exam status: ' + e.message + '
'; - } - } - - async function showExamDetail(examId, examName) { - const panel = document.getElementById('examDetailPanel'); - const title = document.getElementById('examDetailTitle'); - const content = document.getElementById('examDetailContent'); - - title.textContent = `Scores: ${examName}`; - content.innerHTML = 'Loading...
'; - panel.style.display = 'block'; - panel.scrollIntoView({behavior: 'smooth'}); - - try { - const response = await fetch(`/instructor/exams/status?exam_id=${examId}`, {headers: {'X-User-ID': userId}}); - const status = await response.json(); - - if (!status.student_results || status.student_results.length === 0) { - content.innerHTML = 'No students assigned to this exam yet.
'; - return; - } - - let html = `| Student | Assigned | Completed | Score | Correct / Total | -
|---|---|---|---|---|
| ${escapeHtml(r.username)} | -${new Date(r.assigned_at).toLocaleDateString()} | -${completed} | -${scoreHtml} | -${correct} | -
Error loading results: ' + e.message + '
'; - } - } - - function hideExamDetail() { - document.getElementById('examDetailPanel').style.display = 'none'; - }