Тесты и опросы: критерии оценки, génération ИИ, улучшения конструктора и прохождения
- lib/quizzes.js: система criterial-оценки (quiz_grade_scales/quiz_grade_ranges), подсчёт баллов, попытки, anon-опросы, системные поля, доступ по коду - lib/quiz-grades.js: CRUD критериев оценки, диапазоны, картинки - lib/quiz-ai.js: генерация черновика теста через ИИ - server.js: роуты тестов, критериев, медиа-ассетов, попыток - db/init.sql + db/migration.sql: таблицы quizzes*, валидация и индексы - public/: конструктор, прохождение, публичная страница, список, критерии оценки - quiz.selftest.js, quiz-ai.selftest.js: юнит-проверки
This commit is contained in:
@@ -9,6 +9,16 @@
|
||||
return esc(String(s == null ? '' : s)).replace(/"/g, '"');
|
||||
}
|
||||
|
||||
function canManage(s) {
|
||||
if (!s || typeof currentUser === 'undefined' || !currentUser) return false;
|
||||
if (currentUser.role === 'admin') return true;
|
||||
return s.created_by != null && Number(s.created_by) === Number(currentUser.id);
|
||||
}
|
||||
|
||||
function isAdmin() {
|
||||
return typeof currentUser !== 'undefined' && !!currentUser && currentUser.role === 'admin';
|
||||
}
|
||||
|
||||
function openModal(id) {
|
||||
const node = el(id);
|
||||
if (node) node.classList.add('open');
|
||||
@@ -46,16 +56,19 @@
|
||||
const ranges = (s.ranges || []).map(r =>
|
||||
`<span class="qs-range-chip">${esc(String(r.min_score))}–${esc(String(r.max_score))}: ${esc(r.label || '')}</span>`
|
||||
).join('');
|
||||
const acts = canManage(s)
|
||||
? `<div class="qs-item-acts">
|
||||
<button type="button" class="btn-link" data-qs-edit="${s.id}">Изменить</button>
|
||||
<button type="button" class="btn-link danger" data-qs-del="${s.id}">Удалить</button>
|
||||
</div>`
|
||||
: '';
|
||||
return `<div class="qs-item">
|
||||
<div class="qs-item-head">
|
||||
<div class="qs-item-main">
|
||||
<div class="qs-item-name">${esc(s.name || '')}</div>
|
||||
<div class="qs-item-name">${esc(s.name || '')}${s.is_shared ? ' <span class="qs-tag">Доступна всем</span>' : ''}</div>
|
||||
${s.description ? `<div class="qs-item-desc">${esc(s.description)}</div>` : ''}
|
||||
</div>
|
||||
<div class="qs-item-acts">
|
||||
<button type="button" class="btn-link" data-qs-edit="${s.id}">Изменить</button>
|
||||
<button type="button" class="btn-link danger" data-qs-del="${s.id}">Удалить</button>
|
||||
</div>
|
||||
${acts}
|
||||
</div>
|
||||
<div class="qs-item-ranges">${ranges || '<span class="qs-range-chip">нет диапазонов</span>'}</div>
|
||||
</div>`;
|
||||
@@ -68,6 +81,7 @@
|
||||
name: '',
|
||||
description: '',
|
||||
sort_order: 0,
|
||||
is_shared: false,
|
||||
ranges: [{ min_score: 0, max_score: '', label: '', image_path: null }],
|
||||
};
|
||||
}
|
||||
@@ -93,6 +107,8 @@
|
||||
el('qsName').value = d.name;
|
||||
el('qsDesc').value = d.description;
|
||||
el('qsSort').value = d.sort_order;
|
||||
el('qsPublicField').hidden = !isAdmin();
|
||||
el('qsPublic').checked = isAdmin() && d.is_shared === true;
|
||||
el('qsEditorTitle').textContent = d.id ? 'Изменить критерий' : 'Новый критерий оценки';
|
||||
renderRanges();
|
||||
}
|
||||
@@ -111,6 +127,7 @@
|
||||
name: s.name || '',
|
||||
description: s.description || '',
|
||||
sort_order: Number(s.sort_order) || 0,
|
||||
is_shared: s.is_shared === true,
|
||||
ranges: (s.ranges || []).map(r => ({
|
||||
min_score: Number(r.min_score),
|
||||
max_score: Number(r.max_score),
|
||||
@@ -143,6 +160,7 @@
|
||||
name,
|
||||
description: el('qsDesc').value.trim(),
|
||||
sort_order: Number(el('qsSort').value) || 0,
|
||||
is_shared: el('qsPublic').checked === true,
|
||||
ranges,
|
||||
};
|
||||
const btn = el('qsSaveBtn');
|
||||
|
||||
Reference in New Issue
Block a user