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
+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;