This commit is contained in:
@@ -149,10 +149,8 @@ class Project(models.Model):
|
||||
计算项目得分
|
||||
计算公式:
|
||||
1. 获取所有评委对该项目的打分
|
||||
2. 按维度加权平均
|
||||
这里简化处理:
|
||||
总分 = (所有评委的总加权分之和) / 评委人数
|
||||
其中每个评委对项目的打分 = sum(维度分 * 维度权重)
|
||||
2. 每个评委的得分 = sum(维度分数 × 维度权重)
|
||||
3. 项目最终得分 = 所有评委得分的平均值
|
||||
"""
|
||||
# 获取所有评分
|
||||
scores = self.scores.all()
|
||||
@@ -171,19 +169,12 @@ class Project(models.Model):
|
||||
# 获取该评委对该项目的所有维度打分
|
||||
judge_scores = scores.filter(judge=judge)
|
||||
|
||||
current_judge_total_score = 0
|
||||
current_judge_total_weight = 0
|
||||
|
||||
for score in judge_scores:
|
||||
current_judge_total_score += score.score * score.dimension.weight
|
||||
current_judge_total_weight += score.dimension.weight
|
||||
|
||||
if current_judge_total_weight > 0:
|
||||
judge_score = current_judge_total_score / current_judge_total_weight
|
||||
# 如果是百分制,这里算出来就是0-100
|
||||
# 直接用原始分数乘以权重相加
|
||||
judge_score += score.score * score.dimension.weight
|
||||
|
||||
total_weighted_score += judge_score
|
||||
|
||||
|
||||
# 平均分
|
||||
avg_score = total_weighted_score / len(judges)
|
||||
self.final_score = avg_score
|
||||
|
||||
Reference in New Issue
Block a user