Add rating field to entries (1-10 scale) with UI display and module averages
This commit is contained in:
@@ -7,6 +7,7 @@ const groupInput = document.getElementById('groupInput');
|
||||
const moduleInput = document.getElementById('moduleInput');
|
||||
const moduleInputList = document.getElementById('moduleInputList');
|
||||
const moduleField = document.getElementById('moduleField');
|
||||
const ratingField = document.getElementById('ratingField');
|
||||
const moduleNames = new Map();
|
||||
const moduleAttachments = new Map();
|
||||
let moduleSearchTimer = null;
|
||||
@@ -433,6 +434,7 @@ async function applyModuleTopicAutofill() {
|
||||
if (list.length) {
|
||||
moduleInput.required = true;
|
||||
moduleField.style.display = '';
|
||||
ratingField.style.display = '';
|
||||
}
|
||||
}
|
||||
} catch (e) { /* ignore */ }
|
||||
@@ -610,6 +612,18 @@ form.addEventListener('submit', async (e) => {
|
||||
}
|
||||
}
|
||||
|
||||
let rating = '';
|
||||
if (moduleField.style.display !== 'none') {
|
||||
const checked = form.querySelector('input[name="rating"]:checked');
|
||||
if (!checked) {
|
||||
toast.textContent = 'Поставьте оценку занятия от 1 до 10';
|
||||
toast.classList.add('show', 'error');
|
||||
setTimeout(() => toast.classList.remove('show', 'error'), 3200);
|
||||
return;
|
||||
}
|
||||
rating = checked.value;
|
||||
}
|
||||
|
||||
// Проверка: если модуль требует вложений, то файлы должны быть прикреплены
|
||||
const moduleAttachmentEnabled = moduleAttachments.get((moduleInput.value || '').trim().toLowerCase()) === true;
|
||||
if (moduleAttachmentEnabled && selectedFiles.length === 0) {
|
||||
@@ -630,6 +644,7 @@ form.addEventListener('submit', async (e) => {
|
||||
fd.append('student_name', studentName || document.getElementById('nameInput').value);
|
||||
fd.append('group_id', groupInput.value);
|
||||
fd.append('module_id', moduleId || '');
|
||||
fd.append('rating', rating);
|
||||
fd.append('description', document.getElementById('descInput').value);
|
||||
fd.append('website', document.getElementById('hpWebsite').value);
|
||||
fd.append('client_id', clientId);
|
||||
|
||||
Reference in New Issue
Block a user