Add rating field to entries (1-10 scale) with UI display and module averages
This commit is contained in:
@@ -407,11 +407,6 @@ DO $$ BEGIN
|
|||||||
ALTER TABLE entries ADD CONSTRAINT entries_rating_check CHECK (rating BETWEEN 1 AND 10);
|
ALTER TABLE entries ADD CONSTRAINT entries_rating_check CHECK (rating BETWEEN 1 AND 10);
|
||||||
EXCEPTION WHEN duplicate_object THEN NULL; END $$;
|
EXCEPTION WHEN duplicate_object THEN NULL; END $$;
|
||||||
CREATE INDEX IF NOT EXISTS idx_entries_module_id ON entries(module_id);
|
CREATE INDEX IF NOT EXISTS idx_entries_module_id ON entries(module_id);
|
||||||
UPDATE entries
|
|
||||||
SET rating = (7 + mod(abs(hashtext(to_char(created_at AT TIME ZONE 'UTC', 'YYYYMMDDHH24MISSMS'))::bigint), 4))::smallint
|
|
||||||
WHERE module_id IS NOT NULL
|
|
||||||
AND created_at IS NOT NULL
|
|
||||||
AND rating IS NULL;
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS student_photos (
|
CREATE TABLE IF NOT EXISTS student_photos (
|
||||||
id SERIAL PRIMARY KEY,
|
id SERIAL PRIMARY KEY,
|
||||||
|
|||||||
+1
-1
@@ -189,7 +189,7 @@ nav a:hover{color:var(--text)}
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="field" id="ratingField" style="display:none">
|
<div class="field" id="ratingField" style="display:none">
|
||||||
<label>Рейтинг занятия</label>
|
<label>Оценка занятию</label>
|
||||||
<div class="rating-scale" id="ratingScale">
|
<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="1"><span>1</span></label>
|
||||||
<label class="rating-opt"><input type="radio" name="rating" value="2"><span>2</span></label>
|
<label class="rating-opt"><input type="radio" name="rating" value="2"><span>2</span></label>
|
||||||
|
|||||||
@@ -141,6 +141,12 @@
|
|||||||
.cpu-enhance-actions { grid-template-columns: 1fr; }
|
.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; }
|
.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) {
|
@media (max-width: 800px) {
|
||||||
.enhance-body { flex-direction: column; }
|
.enhance-body { flex-direction: column; }
|
||||||
.enhance-sliders { flex: 1 1 auto; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
|
.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">
|
<input type="text" id="editModule" class="settings-input" list="editModuleList" placeholder="Начните вводить название..." autocomplete="off">
|
||||||
<datalist id="editModuleList"></datalist>
|
<datalist id="editModuleList"></datalist>
|
||||||
</div>
|
</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">
|
<div class="settings-field full">
|
||||||
<label>Что делала(а) <span style="color:#ef4444">*</span>
|
<label>Что делала(а) <span style="color:#ef4444">*</span>
|
||||||
<button type="button" id="aiCorrectBtn" class="ai-btn" title="Исправить ошибки ИИ">✨</button>
|
<button type="button" id="aiCorrectBtn" class="ai-btn" title="Исправить ошибки ИИ">✨</button>
|
||||||
|
|||||||
@@ -888,6 +888,7 @@ async function openEdit(id) {
|
|||||||
document.getElementById('editName').value = e.student_name;
|
document.getElementById('editName').value = e.student_name;
|
||||||
document.getElementById('editDesc').value = e.description;
|
document.getElementById('editDesc').value = e.description;
|
||||||
renderEditAiStatus(e);
|
renderEditAiStatus(e);
|
||||||
|
setEditRating(e.rating);
|
||||||
const sel = document.getElementById('editGroup');
|
const sel = document.getElementById('editGroup');
|
||||||
if (!editGroups.length) {
|
if (!editGroups.length) {
|
||||||
const res = await fetch(`${API}/api/groups`, { headers: hdr() });
|
const res = await fetch(`${API}/api/groups`, { headers: hdr() });
|
||||||
@@ -901,6 +902,11 @@ async function openEdit(id) {
|
|||||||
document.getElementById('editModal').classList.add('open');
|
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) {
|
function renderEditPhotos(photos, mainPath) {
|
||||||
const preview = document.getElementById('editPhotoPreview');
|
const preview = document.getElementById('editPhotoPreview');
|
||||||
preview.innerHTML = '';
|
preview.innerHTML = '';
|
||||||
@@ -974,6 +980,7 @@ function closeEdit() {
|
|||||||
document.getElementById('editPhoto').value = '';
|
document.getElementById('editPhoto').value = '';
|
||||||
document.getElementById('editPhotoPreview').innerHTML = '';
|
document.getElementById('editPhotoPreview').innerHTML = '';
|
||||||
document.getElementById('editAiStatus').style.display = 'none';
|
document.getElementById('editAiStatus').style.display = 'none';
|
||||||
|
setEditRating('');
|
||||||
editId = null;
|
editId = null;
|
||||||
editDeletePhoto = false;
|
editDeletePhoto = false;
|
||||||
}
|
}
|
||||||
@@ -2652,6 +2659,8 @@ async function saveEdit() {
|
|||||||
formData.append('group_id', group_id);
|
formData.append('group_id', group_id);
|
||||||
formData.append('description', description);
|
formData.append('description', description);
|
||||||
formData.append('module_id', moduleId);
|
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));
|
formData.append('edit_source', editSourceFor(description));
|
||||||
|
|
||||||
const photoFiles = document.getElementById('editPhoto').files;
|
const photoFiles = document.getElementById('editPhoto').files;
|
||||||
|
|||||||
Reference in New Issue
Block a user