use of org.collectiveone.modules.assignations.EvaluationGrade in project CollectiveOneWebapp by CollectiveOne.
the class PeerReviewedAssignation method addReceiversEvaluations.
private void addReceiversEvaluations() {
/* Update percentages */
for (Receiver receiver : assignation.getReceivers()) {
ReceiverData receiverData = new ReceiverData();
receiverData.receiverId = receiver.getId().toString();
receiverData.isDonor = false;
if (receiver.getType() == ReceiverType.DONOR) {
receiverData.isDonor = true;
}
List<EvaluationGrade> gradesSet = getReceiverGradesSet(receiver.getId());
double mean = 0.0;
boolean evaluated;
if (gradesSet.size() == 0) {
/* no body evaluated this receiver? mean is zero then */
mean = 0.0;
evaluated = false;
} else {
evaluated = true;
/* compute the mean of evaluations set */
double totalWeight = 0.0;
for (EvaluationGrade grade : gradesSet) {
double thisWeight = grade.getEvaluator().getWeight();
totalWeight += thisWeight;
mean += grade.getPercent() * thisWeight;
}
mean = mean / totalWeight;
}
/* update the receiver evaluations */
List<EvaluationGrade> grades = getReceiverGrades(receiver.getId());
for (EvaluationGrade grade : grades) {
EvaluationData evaluation = new EvaluationData();
evaluation.setEvaluatorId(grade.getEvaluator().getId().toString());
evaluation.setWeight(grade.getEvaluator().getWeight());
if (evaluated) {
if (grade.getType() == EvaluationGradeType.SET) {
evaluation.setValue(grade.getPercent());
} else {
evaluation.setValue(mean);
}
} else {
evaluation.setValue(mean);
}
receiverData.evaluations.add(evaluation);
}
receiversData.add(receiverData);
}
}
Aggregations