Тесты и опросы: генерация ИИ, критерии оценки, версия 2.0
- ИИ-генерация черновиков тестов (lib/quiz-ai.js, quiz-ai-jobs, quiz-ai.selftest.js) - Критерии оценки (quiz_grade_scales/quiz_grade_ranges, lib/quiz-grades.js, public/js/grade-scales.js) - Версия 2.0 формата бэкапа, добавление таблиц тестов в BACKUP_TABLES - Обновление AGENTS.md под новый функционал тестов/опросов
This commit is contained in:
+28
-2
@@ -25,6 +25,7 @@ const BACKUP_TABLES = [
|
||||
'short_messages', 'feedbacks', 'feedback_versions', 'bookmarks', 'student_face_refs', 'photo_faces',
|
||||
'student_work_marks', 'achievement_types', 'student_achievements', 'doc_sections', 'doc_articles', 'doc_images', 'doc_files', 'sidebar_items', 'digests', 'digest_images', 'farewell_messages', 'calendar_events', 'calendar_action_log',
|
||||
'quizzes', 'quiz_questions', 'quiz_options', 'quiz_assets', 'quiz_attempts', 'quiz_attempt_answers',
|
||||
'quiz_grade_scales', 'quiz_grade_ranges',
|
||||
];
|
||||
const BACKUP_SEQUENCE_TABLES = [
|
||||
'groups', 'students', 'entries', 'project_files', 'branches', 'users', 'user_notes', 'group_photos',
|
||||
@@ -33,6 +34,7 @@ const BACKUP_SEQUENCE_TABLES = [
|
||||
'chat_attachments', 'short_messages', 'feedbacks', 'bookmarks', 'student_face_refs', 'photo_faces',
|
||||
'student_work_marks', 'achievement_types', 'student_achievements', 'doc_sections', 'doc_articles', 'doc_images', 'doc_files', 'sidebar_items', 'digests', 'digest_images', 'farewell_messages', 'calendar_events', 'calendar_action_log',
|
||||
'quizzes', 'quiz_questions', 'quiz_options', 'quiz_assets', 'quiz_attempts', 'quiz_attempt_answers',
|
||||
'quiz_grade_scales', 'quiz_grade_ranges',
|
||||
];
|
||||
|
||||
function isSupportedBackupVersion(data) {
|
||||
@@ -860,6 +862,27 @@ function normalizeRestoreData(data) {
|
||||
if (!Number.isFinite(n)) return def;
|
||||
return Math.min(hi, Math.max(lo, Math.trunc(n)));
|
||||
};
|
||||
const quizScore = v => Math.min(100000, Math.max(0, Math.round((Number(v) || 0) * 100) / 100));
|
||||
const gradeScales = (data.quiz_grade_scales || []).map(x => ({
|
||||
id: reqInt(x.id),
|
||||
name: optText(x.name, 200) || '',
|
||||
description: optText(x.description, 2000) || null,
|
||||
sort_order: optInt(x.sort_order, -100000, 100000) ?? 0,
|
||||
created_by: x.created_by == null ? null : reqInt(x.created_by),
|
||||
created_at: optTs(x.created_at),
|
||||
updated_at: optTs(x.updated_at),
|
||||
})).filter(x => x.id > 0);
|
||||
const restoredScaleIds = new Set(gradeScales.map(x => x.id));
|
||||
const gradeRanges = (data.quiz_grade_ranges || []).map(x => ({
|
||||
id: reqInt(x.id),
|
||||
scale_id: reqInt(x.scale_id),
|
||||
min_score: quizScore(x.min_score),
|
||||
max_score: quizScore(x.max_score),
|
||||
label: optText(x.label, 200) || '',
|
||||
image_path: optUploadPath(x.image_path, 300) || null,
|
||||
created_at: optTs(x.created_at),
|
||||
updated_at: optTs(x.updated_at),
|
||||
})).filter(x => x.id > 0 && restoredScaleIds.has(x.scale_id) && x.label);
|
||||
const quizzes = (data.quizzes || []).map(x => ({
|
||||
id: reqInt(x.id),
|
||||
title: optText(x.title, 200) || '',
|
||||
@@ -869,11 +892,13 @@ function normalizeRestoreData(data) {
|
||||
shuffle_questions: x.shuffle_questions === true,
|
||||
shuffle_options: x.shuffle_options === true,
|
||||
show_results: x.show_results !== false,
|
||||
show_answers: x.show_answers !== false,
|
||||
grade_scale_id: x.grade_scale_id == null ? null : reqInt(x.grade_scale_id),
|
||||
max_attempts: quizInt(x.max_attempts, 1, 1000),
|
||||
time_limit_min: quizInt(x.time_limit_min, 0, 1440, 0),
|
||||
pass_percent: quizInt(x.pass_percent, 0, 100, 60),
|
||||
cover_path: optUploadPath(x.cover_path, 300) || null,
|
||||
allow_anonymous: x.allow_anonymous === true && (quizKinds.includes(x.kind) ? x.kind : 'test') === 'survey',
|
||||
allow_anonymous: x.allow_anonymous === true,
|
||||
author_id: x.author_id == null ? null : reqInt(x.author_id),
|
||||
created_at: optTs(x.created_at),
|
||||
updated_at: optTs(x.updated_at),
|
||||
@@ -947,6 +972,7 @@ function normalizeRestoreData(data) {
|
||||
percent: Math.min(100, quizWeight(x.percent)),
|
||||
passed: x.passed == null ? null : x.passed === true,
|
||||
anon_token: null,
|
||||
guest_name: optText(x.guest_name, 120) || null,
|
||||
started_at: optTs(x.started_at),
|
||||
finished_at: optTs(x.finished_at),
|
||||
})).filter(x => x.quiz_id);
|
||||
@@ -962,7 +988,7 @@ function normalizeRestoreData(data) {
|
||||
score: quizWeight(x.score),
|
||||
max_score: quizWeight(x.max_score),
|
||||
})).filter(x => x.attempt_id);
|
||||
return { groups, students, entries, project_files, settings, branches, users, user_branches, user_settings, user_notes, entry_photos, student_photos, group_photos, share_links, modules, photo_jobs, lesson_reports, lesson_report_versions, audit_log, notifications, notification_reads, banned_ips, chat_threads, chat_messages, chat_attachments, short_messages, feedbacks, farewell_messages, bookmarks, calendar_events: calendarEvents, calendar_action_log: calendarActionLog, achievement_types: achievementTypes, student_achievements: studentAchievements, student_face_refs: faceRefs, photo_faces: faceRows, student_work_marks, doc_sections: docSections, doc_articles: docArticles, doc_images: docImages, doc_files: docFiles, sidebar_items: sidebarItems, digests, digest_images: digestImages, quizzes, quiz_questions: quizQuestions, quiz_options: quizOptions, quiz_assets: quizAssets, quiz_attempts: quizAttempts, quiz_attempt_answers: quizAttemptAnswers };
|
||||
return { groups, students, entries, project_files, settings, branches, users, user_branches, user_settings, user_notes, entry_photos, student_photos, group_photos, share_links, modules, photo_jobs, lesson_reports, lesson_report_versions, audit_log, notifications, notification_reads, banned_ips, chat_threads, chat_messages, chat_attachments, short_messages, feedbacks, farewell_messages, bookmarks, calendar_events: calendarEvents, calendar_action_log: calendarActionLog, achievement_types: achievementTypes, student_achievements: studentAchievements, student_face_refs: faceRefs, photo_faces: faceRows, student_work_marks, doc_sections: docSections, doc_articles: docArticles, doc_images: docImages, doc_files: docFiles, sidebar_items: sidebarItems, digests, digest_images: digestImages, quiz_grade_scales: gradeScales, quiz_grade_ranges: gradeRanges, quizzes, quiz_questions: quizQuestions, quiz_options: quizOptions, quiz_assets: quizAssets, quiz_attempts: quizAttempts, quiz_attempt_answers: quizAttemptAnswers };
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
Reference in New Issue
Block a user