Add rating field to entries (1-10 scale) with UI display and module averages
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user