Skip to content

Commit 0d10dda

Browse files
committed
fix: recalculate CQI from current weights instead of using stale persisted value
reconstructCqiDetails() was returning participation.getCqi() which was computed at analysis time with whatever weights were active then. After changing custom weights the CQI didn't update. Now recalculates the weighted sum from persisted component scores and current weights.
1 parent 057cf04 commit 0d10dda

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/main/java/de/tum/cit/aet/analysis/service/AnalysisQueryService.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,11 @@ public ClientResponseDTO mapParticipationToClientResponse(TeamParticipation part
130130
s.getLinesDeleted(), s.getLinesChanged()))
131131
.toList();
132132

133-
Double cqi = participation.getCqi();
134133
Boolean isSuspicious = participation.getIsSuspicious() != null ? participation.getIsSuspicious() : false;
135134

136135
AnalysisMode mode = analysisStateService.getStatus(participation.getExerciseId()).getAnalysisMode();
137136
CQIResultDTO cqiDetails = reconstructCqiDetails(participation, mode);
137+
Double cqi = cqiDetails != null ? cqiDetails.cqi() : participation.getCqi();
138138

139139
return new ClientResponseDTO(
140140
tutor != null ? tutor.getName() : "Unassigned",
@@ -260,12 +260,12 @@ public CQIResultDTO reconstructCqiDetails(TeamParticipation participation, Analy
260260
: cqiCalculatorService.buildRenormalizedWeightsWithoutEffort(exerciseId);
261261
}
262262

263-
return new CQIResultDTO(
264-
participation.getCqi() != null ? participation.getCqi() : 0.0,
265-
components,
266-
weights,
267-
participation.getCqiBaseScore() != null ? participation.getCqiBaseScore() : 0.0,
268-
null);
263+
double baseScore = components.weightedSum(
264+
weights.effortBalance(), weights.locBalance(),
265+
weights.temporalSpread(), weights.ownershipSpread());
266+
double cqi = Math.max(0, Math.min(100, baseScore));
267+
268+
return new CQIResultDTO(cqi, components, weights, baseScore, null);
269269
}
270270

271271
/**

0 commit comments

Comments
 (0)