Add rating field to entries (1-10 scale) with UI display and module averages

This commit is contained in:
dev
2026-12-05 17:33:37 +03:00
parent df721c13f2
commit 84ca5a3d8c
4 changed files with 31 additions and 6 deletions
+1 -1
View File
@@ -189,7 +189,7 @@ nav a:hover{color:var(--text)}
</div>
<div class="field" id="ratingField" style="display:none">
<label>Рейтинг занятия</label>
<label>Оценка занятию</label>
<div class="rating-scale" id="ratingScale">
<label class="rating-opt"><input type="radio" name="rating" value="1"><span>1</span></label>
<label class="rating-opt"><input type="radio" name="rating" value="2"><span>2</span></label>
+21
View File
@@ -141,6 +141,12 @@
.cpu-enhance-actions { grid-template-columns: 1fr; }
}
.photo-thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); display: block; }
.edit-rating { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.edit-rate-opt { position: relative; display: block; }
.edit-rate-opt input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; padding: 0; cursor: pointer; }
.edit-rate-opt span { display: flex; align-items: center; justify-content: center; height: 40px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); font-size: .82rem; font-weight: 600; color: var(--muted); transition: border-color .15s, background .15s, color .15s; pointer-events: none; }
.edit-rate-opt input:checked + span { border-color: var(--accent); background: var(--accent); color: #fff; }
.edit-rate-opt input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 800px) {
.enhance-body { flex-direction: column; }
.enhance-sliders { flex: 1 1 auto; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
@@ -212,6 +218,21 @@
<input type="text" id="editModule" class="settings-input" list="editModuleList" placeholder="Начните вводить название..." autocomplete="off">
<datalist id="editModuleList"></datalist>
</div>
<div class="settings-field">
<label>Оценка ученика</label>
<div class="edit-rating" id="editRatingScale">
<label class="edit-rate-opt"><input type="radio" name="editRating" value="1"><span>1</span></label>
<label class="edit-rate-opt"><input type="radio" name="editRating" value="2"><span>2</span></label>
<label class="edit-rate-opt"><input type="radio" name="editRating" value="3"><span>3</span></label>
<label class="edit-rate-opt"><input type="radio" name="editRating" value="4"><span>4</span></label>
<label class="edit-rate-opt"><input type="radio" name="editRating" value="5"><span>5</span></label>
<label class="edit-rate-opt"><input type="radio" name="editRating" value="6"><span>6</span></label>
<label class="edit-rate-opt"><input type="radio" name="editRating" value="7"><span>7</span></label>
<label class="edit-rate-opt"><input type="radio" name="editRating" value="8"><span>8</span></label>
<label class="edit-rate-opt"><input type="radio" name="editRating" value="9"><span>9</span></label>
<label class="edit-rate-opt"><input type="radio" name="editRating" value="10"><span>10</span></label>
</div>
</div>
<div class="settings-field full">
<label>Что делала(а) <span style="color:#ef4444">*</span>
<button type="button" id="aiCorrectBtn" class="ai-btn" title="Исправить ошибки ИИ">✨</button>
+9
View File
@@ -888,6 +888,7 @@ async function openEdit(id) {
document.getElementById('editName').value = e.student_name;
document.getElementById('editDesc').value = e.description;
renderEditAiStatus(e);
setEditRating(e.rating);
const sel = document.getElementById('editGroup');
if (!editGroups.length) {
const res = await fetch(`${API}/api/groups`, { headers: hdr() });
@@ -901,6 +902,11 @@ async function openEdit(id) {
document.getElementById('editModal').classList.add('open');
}
function setEditRating(v) {
const val = v === null || v === undefined ? '' : String(v);
document.querySelectorAll('input[name="editRating"]').forEach(r => { r.checked = r.value === val; });
}
function renderEditPhotos(photos, mainPath) {
const preview = document.getElementById('editPhotoPreview');
preview.innerHTML = '';
@@ -974,6 +980,7 @@ function closeEdit() {
document.getElementById('editPhoto').value = '';
document.getElementById('editPhotoPreview').innerHTML = '';
document.getElementById('editAiStatus').style.display = 'none';
setEditRating('');
editId = null;
editDeletePhoto = false;
}
@@ -2652,6 +2659,8 @@ async function saveEdit() {
formData.append('group_id', group_id);
formData.append('description', description);
formData.append('module_id', moduleId);
const ratingInput = document.querySelector('input[name="editRating"]:checked');
formData.append('rating', ratingInput ? ratingInput.value : '');
formData.append('edit_source', editSourceFor(description));
const photoFiles = document.getElementById('editPhoto').files;