This commit is contained in:
@@ -192,9 +192,9 @@ class ScoreFormulaAdmin(ModelAdmin):
|
||||
|
||||
class Media:
|
||||
css = {
|
||||
'all': ('competition/admin/css/formula-editor.css',)
|
||||
'all': ('competition/admin/css/competition-admin.css',)
|
||||
}
|
||||
js = ('competition/admin/js/formula-editor.js',)
|
||||
js = ('competition/admin/js/competition-admin.js',)
|
||||
|
||||
|
||||
admin.site.register(ScoreFormula, ScoreFormulaAdmin)
|
||||
|
||||
@@ -339,14 +339,15 @@ def project_detail_api(request, project_id):
|
||||
final_score = float(project.final_score) if project.final_score else 0
|
||||
|
||||
if role in ['judge', 'guest']:
|
||||
# 评委评分:所有评委的平均分(不包括选手互评维度)
|
||||
competition = project.competition
|
||||
|
||||
# 评委评分:is_public=True 的维度(评委可见的维度)
|
||||
judge_dimensions = ScoreDimension.objects.filter(
|
||||
competition=project.competition,
|
||||
is_public=True,
|
||||
is_peer_review=False
|
||||
competition=competition,
|
||||
is_public=True
|
||||
)
|
||||
judge_enrollments = CompetitionEnrollment.objects.filter(
|
||||
competition=project.competition,
|
||||
competition=competition,
|
||||
role='judge'
|
||||
)
|
||||
|
||||
@@ -369,13 +370,14 @@ def project_detail_api(request, project_id):
|
||||
if judge_count > 0:
|
||||
judge_score_avg = round(judge_total / judge_count, 2)
|
||||
|
||||
# 选手互评分:所有选手的平均分(仅互评维度)
|
||||
# 选手互评分:allow_contestant_grading=True 且 is_peer_review=True 的维度
|
||||
if competition.allow_contestant_grading:
|
||||
peer_dimensions = ScoreDimension.objects.filter(
|
||||
competition=project.competition,
|
||||
competition=competition,
|
||||
is_peer_review=True
|
||||
)
|
||||
peer_enrollments = CompetitionEnrollment.objects.filter(
|
||||
competition=project.competition,
|
||||
competition=competition,
|
||||
role='contestant'
|
||||
)
|
||||
|
||||
@@ -398,14 +400,37 @@ def project_detail_api(request, project_id):
|
||||
if peer_count > 0:
|
||||
peer_score_avg = round(peer_total / peer_count, 2)
|
||||
|
||||
# AI评分:来自AIEvaluation的平均分
|
||||
ai_evaluations = AIEvaluation.objects.filter(
|
||||
task__project=project,
|
||||
task__status='COMPLETED'
|
||||
# AI评分:is_public=False 且 is_peer_review=False 的维度(两个都为false就是AI维度)
|
||||
ai_dimensions = ScoreDimension.objects.filter(
|
||||
competition=competition,
|
||||
is_public=False,
|
||||
is_peer_review=False
|
||||
)
|
||||
ai_scores = [e.score for e in ai_evaluations if e.score is not None]
|
||||
if ai_scores:
|
||||
ai_score_avg = round(sum(ai_scores) / len(ai_scores), 2)
|
||||
|
||||
if ai_dimensions.exists():
|
||||
ai_enrollments = CompetitionEnrollment.objects.filter(
|
||||
competition=competition,
|
||||
role='judge'
|
||||
)
|
||||
|
||||
if ai_enrollments.exists():
|
||||
ai_total = 0
|
||||
ai_count = 0
|
||||
for ai_enrollment in ai_enrollments:
|
||||
ai_project_scores = Score.objects.filter(
|
||||
project=project,
|
||||
judge=ai_enrollment,
|
||||
dimension__in=ai_dimensions
|
||||
)
|
||||
if ai_project_scores.exists():
|
||||
ai_score = sum(
|
||||
float(s.score) * float(s.dimension.weight)
|
||||
for s in ai_project_scores
|
||||
)
|
||||
ai_total += ai_score
|
||||
ai_count += 1
|
||||
if ai_count > 0:
|
||||
ai_score_avg = round(ai_total / ai_count, 2)
|
||||
|
||||
data = {
|
||||
'id': project.id,
|
||||
|
||||
Reference in New Issue
Block a user