Add rating field to entries (1-10 scale) with UI display and module averages
This commit is contained in:
@@ -188,6 +188,15 @@ body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;b
|
||||
.journal-card .no-photo svg *{fill:currentColor}
|
||||
.journal-card .body{padding:12px 14px;display:flex;flex-direction:column;gap:6px;flex:1;min-width:0}
|
||||
.journal-card .name{font-weight:600;font-size:.95rem}
|
||||
.entry-rating{display:flex;flex-wrap:wrap;gap:6px;align-items:center}
|
||||
.entry-rate{display:inline-flex;align-items:center;gap:4px;font-size:.72rem;font-weight:600;line-height:1.3;padding:2px 8px;border-radius:999px;background:var(--bg);border:1px solid var(--border);color:var(--muted)}
|
||||
.entry-rate-avg{color:#b45309;background:rgba(245,158,11,.12);border-color:rgba(245,158,11,.35)}
|
||||
.entry-rate-mine{color:var(--accent);background:rgba(37,99,235,.1);border-color:rgba(37,99,235,.3)}
|
||||
.journal-card .entry-rating{position:absolute;inset:0;z-index:2;display:block;pointer-events:none}
|
||||
.journal-card .entry-rate{position:absolute;max-width:calc(50% - 16px);padding:3px 9px;border:1px solid rgba(255,255,255,.28);background:transparent;color:#fff;text-shadow:0 1px 2px rgba(0,0,0,.45);backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;pointer-events:auto}
|
||||
.journal-card .entry-rate-mine{left:8px;top:34px}
|
||||
.journal-card .entry-rate-avg{right:8px;top:34px}
|
||||
.module-rating{color:#b45309;font-weight:600}
|
||||
.journal-card .desc{color:var(--muted);font-size:.85rem;line-height:1.4;white-space:pre-wrap;overflow-wrap:anywhere;word-break:break-word;flex:1}
|
||||
.journal-card .foot{display:flex;justify-content:space-between;align-items:center;gap:8px;padding:10px 14px;border-top:1px solid var(--border);color:var(--muted);font-size:.75rem}
|
||||
.journal-card .foot .edit,.journal-card .foot .del{background:none;border:none;color:var(--muted);cursor:pointer;font-size:1rem;padding:4px}
|
||||
|
||||
@@ -55,6 +55,13 @@ h1{font-size:1.5rem;font-weight:600;margin-bottom:8px;letter-spacing:-.02em;text
|
||||
.fields-row{display:grid;grid-template-columns:1fr 1fr;gap:20px}
|
||||
@media(max-width:520px){.fields-row{grid-template-columns:1fr}}
|
||||
.field{display:flex;flex-direction:column;gap:6px}
|
||||
.rating-scale{display:flex;flex-wrap:wrap;justify-content:space-between;gap:8px}
|
||||
.rating-opt{position:relative;display:inline-flex}
|
||||
.rating-opt input{position:absolute;inset:0;width:100%;height:100%;opacity:0;margin:0;padding:0;cursor:pointer}
|
||||
.rating-opt span{display:flex;align-items:center;justify-content:center;width:42px;height:42px;border:1px solid var(--border);border-radius:10px;background:var(--card);font-size:.9rem;font-weight:600;color:var(--muted);text-transform:none;letter-spacing:0;transition:border-color .15s,background .15s,color .15s;pointer-events:none}
|
||||
.rating-opt input:checked + span{border-color:var(--accent);background:var(--accent);color:#fff}
|
||||
.rating-opt input:focus-visible + span{outline:2px solid var(--accent);outline-offset:2px}
|
||||
.req{color:#ef4444}
|
||||
label{font-size:.8rem;font-weight:500;color:var(--muted);text-transform:uppercase;letter-spacing:.04em}
|
||||
input,select,textarea{background:var(--card);border:1px solid var(--border);color:var(--text);border-radius:var(--radius);padding:14px 16px;font-size:.95rem;outline:none;transition:border .15s}
|
||||
input:focus,select:focus,textarea:focus{border-color:var(--accent)}
|
||||
@@ -181,6 +188,22 @@ nav a:hover{color:var(--text)}
|
||||
<datalist id="moduleInputList"></datalist>
|
||||
</div>
|
||||
|
||||
<div class="field" id="ratingField" style="display:none">
|
||||
<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>
|
||||
<label class="rating-opt"><input type="radio" name="rating" value="3"><span>3</span></label>
|
||||
<label class="rating-opt"><input type="radio" name="rating" value="4"><span>4</span></label>
|
||||
<label class="rating-opt"><input type="radio" name="rating" value="5"><span>5</span></label>
|
||||
<label class="rating-opt"><input type="radio" name="rating" value="6"><span>6</span></label>
|
||||
<label class="rating-opt"><input type="radio" name="rating" value="7"><span>7</span></label>
|
||||
<label class="rating-opt"><input type="radio" name="rating" value="8"><span>8</span></label>
|
||||
<label class="rating-opt"><input type="radio" name="rating" value="9"><span>9</span></label>
|
||||
<label class="rating-opt"><input type="radio" name="rating" value="10"><span>10</span></label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label>Что сделал</label>
|
||||
<textarea id="descInput" maxlength="300" placeholder="Опиши, что проходил, что делал на занятии..." required></textarea>
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -446,6 +446,22 @@ const AI_STATUS_ICONS = {
|
||||
reverted: 'undo',
|
||||
};
|
||||
|
||||
function fmtRating(v) {
|
||||
const n = Number(v);
|
||||
return Number.isFinite(n) ? n.toFixed(1).replace('.', ',') : '';
|
||||
}
|
||||
|
||||
function entryRatingHTML(e) {
|
||||
const parts = [];
|
||||
if (e.module_name && e.module_rating_avg !== null && e.module_rating_avg !== undefined) {
|
||||
parts.push(`<span class="entry-rate entry-rate-avg" title="Средний рейтинг модуля">Модуль ★ ${esc(fmtRating(e.module_rating_avg))}</span>`);
|
||||
}
|
||||
if (e.rating !== null && e.rating !== undefined && e.rating !== '') {
|
||||
parts.push(`<span class="entry-rate entry-rate-mine" title="Оценка ученика">Оценка ${esc(String(e.rating))}/10</span>`);
|
||||
}
|
||||
return parts.length ? `<div class="entry-rating">${parts.join('')}</div>` : '';
|
||||
}
|
||||
|
||||
function aiBadge(e) {
|
||||
if (!e || !e.ai_status) return '';
|
||||
const st = e.ai_status;
|
||||
@@ -485,6 +501,7 @@ function gridEntryHTML(e) {
|
||||
<div class="info">
|
||||
<div class="name">${esc(e.student_name)}</div>
|
||||
<div class="group">${esc(e.group_name)}${e.module_name ? ' · ' + esc(e.module_name) : ''}</div>
|
||||
${entryRatingHTML(e)}
|
||||
<div class="desc">${esc(e.description)}${aiBadge(e)}</div>
|
||||
${filesHTML(e.files)}
|
||||
<div class="time">${fmtFull(e.created_at)}</div>
|
||||
@@ -509,6 +526,7 @@ function cardEntryHTML(e) {
|
||||
${e.module_name ? `<span class="group-badge" style="left:auto;right:8px;background:rgba(37,99,235,.8)" title="Модуль: ${esc(e.module_name)}">${esc(e.module_name)}</span>` : ''}
|
||||
<div class="body">
|
||||
<div class="name">${esc(e.student_name)}</div>
|
||||
${entryRatingHTML(e)}
|
||||
<div class="desc">${esc(e.description)}${aiBadge(e)}</div>
|
||||
${filesHTML(e.files)}
|
||||
</div>
|
||||
|
||||
@@ -55,7 +55,7 @@ function renderModules(total) {
|
||||
${m.photo_path ? `<img class="module-thumb" src="${thumbSrc(m.photo_path)}" alt="" data-img="${esc(API + m.photo_path)}">` : ''}
|
||||
<div class="module-info">
|
||||
<div class="module-name">${esc(m.name)}${m.has_attachments ? ' <span class="module-badge module-badge-attach">Вложения</span>' : ''}${m.is_active ? '' : ' <span class="module-badge">Отключён</span>'}</div>
|
||||
<div class="module-meta">${m.lessons_count} ${mPlural(m.lessons_count, 'занятие', 'занятия', 'занятий')} · ${m.entries_count} ${mPlural(m.entries_count, 'запись', 'записи', 'записей')}</div>
|
||||
<div class="module-meta">${m.lessons_count} ${mPlural(m.lessons_count, 'занятие', 'занятия', 'занятий')} · ${m.entries_count} ${mPlural(m.entries_count, 'запись', 'записи', 'записей')}${m.rating_avg != null ? ` · <span class="module-rating" title="Средний рейтинг модуля">★ ${Number(m.rating_avg).toFixed(1).replace('.', ',')}${m.rating_count ? ` (${m.rating_count})` : ''}</span>` : ''}</div>
|
||||
</div>
|
||||
<div class="student-actions">
|
||||
${m.is_active
|
||||
|
||||
Reference in New Issue
Block a user