score
All checks were successful
Deploy to Server / deploy (push) Successful in 17s

This commit is contained in:
jeremygan2021
2026-03-20 15:51:59 +08:00
parent 8bc06b0423
commit 0274e59fd9
2 changed files with 23 additions and 6 deletions

View File

@@ -432,6 +432,9 @@ def project_detail_api(request, project_id):
if ai_count > 0:
ai_score_avg = round(ai_total / ai_count, 2)
# 判断是否为选手查看自己的项目
is_own_project = role == 'contestant' and project.contestant.user == user
data = {
'id': project.id,
'title': project.title,
@@ -443,19 +446,20 @@ def project_detail_api(request, project_id):
'ai_result': ai_data,
'audio_url': audio_url,
'can_grade': role == 'judge' or (role == 'contestant' and project.contestant.user != user),
# 评分细项(仅评委和嘉宾可见)
'is_own_project': is_own_project,
# 评分细项(评委、嘉宾可见,选手查看自己的项目时也可见)
'score_details': {
'judge_score': judge_score_avg,
'peer_score': peer_score_avg,
'ai_score': ai_score_avg,
'final_score': final_score
} if role in ['judge', 'guest'] else None,
# 评分公式信息
} if role in ['judge', 'guest'] or is_own_project else None,
# 评分公式信息(评委、嘉宾可见,选手查看自己的项目时也可见)
'formula_info': {
'name': project.competition.active_formula.name if project.competition.active_formula else None,
'formula': project.competition.active_formula.formula if project.competition.active_formula else None,
'preview': project.competition.active_formula.get_formula_preview() if project.competition.active_formula else None
} if project.competition.score_calculation_type == 'formula' else None
} if project.competition.score_calculation_type == 'formula' and (role in ['judge', 'guest'] or is_own_project) else None
}
# Specifically for guest: can_grade is False

View File

@@ -177,7 +177,7 @@
</div>
<div class="bg-white rounded-lg p-3 border border-gray-100 shadow-sm">
<div class="flex items-center justify-between mb-1">
<span class="text-xs font-semibold text-gray-500 uppercase">最终平均</span>
<span class="text-xs font-semibold text-gray-500 uppercase">最终</span>
<i class="fas fa-star text-yellow-400 text-sm"></i>
</div>
<span id="finalScoreValue" class="text-2xl font-bold text-yellow-600">--</span>
@@ -701,6 +701,20 @@ async function viewProject(id) {
if (!readOnlyMsg) {
readOnlyMsg = document.createElement('div');
readOnlyMsg.id = 'readOnlyMsg';
readOnlyMsg.className = 'text-center py-10 bg-white rounded-lg border border-dashed border-gray-300 mt-4';
gradingContainer.appendChild(readOnlyMsg);
}
if (data.is_own_project) {
readOnlyMsg.className = 'text-center py-10 bg-white rounded-lg border border-dashed border-blue-300 mt-4';
readOnlyMsg.innerHTML = `
<div class="mx-auto h-12 w-12 bg-blue-50 rounded-full flex items-center justify-center mb-3">
<i class="fas fa-info-circle text-2xl text-blue-400"></i>
</div>
<h3 class="text-base font-medium text-gray-900">查看自己的项目</h3>
<p class="mt-1 text-sm text-gray-500">无法对自己的项目进行评分,但可以查看详细评分</p>
`;
} else {
readOnlyMsg.className = 'text-center py-10 bg-white rounded-lg border border-dashed border-gray-300 mt-4';
readOnlyMsg.innerHTML = `
<div class="mx-auto h-12 w-12 bg-gray-50 rounded-full flex items-center justify-center mb-3">
@@ -709,7 +723,6 @@ async function viewProject(id) {
<h3 class="text-base font-medium text-gray-900">仅浏览模式</h3>
<p class="mt-1 text-sm text-gray-500">当前身份无法进行评分</p>
`;
gradingContainer.appendChild(readOnlyMsg);
}
if (data.can_grade) {