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

This commit is contained in:
dev
2026-12-05 17:19:04 +03:00
parent 326dedc20f
commit df721c13f2
9 changed files with 128 additions and 10 deletions
+18
View File
@@ -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>