use of de.tum.in.www1.artemis.domain.scores.TeamScore in project ArTEMiS by ls1intum.
the class ScoreService method getNewLastRatedResultForParticipantScore.
/**
* Get the result that can replace the currently set last rated result for a participant score
*
* @param participantScore participant score
* @return optional of new result
*/
private Optional<Result> getNewLastRatedResultForParticipantScore(ParticipantScore participantScore) {
List<Result> ratedResultsOrdered;
if (participantScore.getClass().equals(StudentScore.class)) {
StudentScore studentScore = (StudentScore) participantScore;
ratedResultsOrdered = resultRepository.getRatedResultsOrderedByParticipationIdLegalSubmissionIdResultIdDescForStudent(participantScore.getExercise().getId(), studentScore.getUser().getId()).stream().filter(r -> !participantScore.getLastRatedResult().equals(r)).collect(Collectors.toList());
} else {
TeamScore teamScore = (TeamScore) participantScore;
ratedResultsOrdered = resultRepository.getRatedResultsOrderedByParticipationIdLegalSubmissionIdResultIdDescForTeam(participantScore.getExercise().getId(), teamScore.getTeam().getId()).stream().filter(r -> !participantScore.getLastRatedResult().equals(r)).collect(Collectors.toList());
}
// the new last rated result (rated result with the highest id of submission with the highest id) will be at the beginning of the list
return ratedResultsOrdered.isEmpty() ? Optional.empty() : Optional.of(ratedResultsOrdered.get(0));
}
use of de.tum.in.www1.artemis.domain.scores.TeamScore in project ArTEMiS by ls1intum.
the class ScoreService method createNewTeamScore.
private void createNewTeamScore(Result newResult, StudentParticipation studentParticipation, Exercise exercise) {
TeamScore newTeamScore = new TeamScore();
newTeamScore.setExercise(exercise);
newTeamScore.setTeam(studentParticipation.getTeam().get());
setLastAttributes(newTeamScore, newResult, exercise);
if (newResult.isRated() != null && newResult.isRated()) {
setLastRatedAttributes(newTeamScore, newResult, exercise);
}
TeamScore teamScore = teamScoreRepository.saveAndFlush(newTeamScore);
logger.info("Saved a new team score: " + teamScore);
}
use of de.tum.in.www1.artemis.domain.scores.TeamScore in project ArTEMiS by ls1intum.
the class ScoreService method getNewLastResultForParticipantScore.
/**
* Get the result that can replace the currently set last result for a participant score
*
* @param participantScore participant score
* @return optional of new result
*/
private Optional<Result> getNewLastResultForParticipantScore(ParticipantScore participantScore) {
List<Result> resultOrdered;
if (participantScore.getClass().equals(StudentScore.class)) {
StudentScore studentScore = (StudentScore) participantScore;
resultOrdered = resultRepository.getResultsOrderedByParticipationIdLegalSubmissionIdResultIdDescForStudent(participantScore.getExercise().getId(), studentScore.getUser().getId()).stream().filter(r -> !participantScore.getLastResult().equals(r)).collect(Collectors.toList());
} else {
TeamScore teamScore = (TeamScore) participantScore;
resultOrdered = resultRepository.getResultsOrderedByParticipationIdLegalSubmissionIdResultIdDescForTeam(participantScore.getExercise().getId(), teamScore.getTeam().getId()).stream().filter(r -> !participantScore.getLastResult().equals(r)).collect(Collectors.toList());
}
// the new last result (result with the highest id of submission with the highest id) will be at the beginning of the list
return resultOrdered.isEmpty() ? Optional.empty() : Optional.of(resultOrdered.get(0));
}
use of de.tum.in.www1.artemis.domain.scores.TeamScore in project ArTEMiS by ls1intum.
the class ParticipantScoreDTO method generateFromParticipantScore.
/**
* Generates a {@link ParticipantScoreDTO} from a {@link ParticipantScore}
*
* @param participantScore ParticipantScore input
* @return {@link ParticipantScoreDTO}
*/
public static ParticipantScoreDTO generateFromParticipantScore(ParticipantScore participantScore) {
String userName = null;
Long userId = null;
String teamName = null;
Long teamId = null;
if (participantScore.getClass().equals(StudentScore.class)) {
StudentScore studentScore = (StudentScore) participantScore;
if (studentScore.getUser() != null) {
userName = studentScore.getUser().getLogin();
userId = studentScore.getUser().getId();
}
} else {
TeamScore teamScore = (TeamScore) participantScore;
if (teamScore.getTeam() != null) {
teamName = teamScore.getTeam().getName();
teamId = teamScore.getTeam().getId();
}
}
Long id = participantScore.getId();
String exerciseTitle = participantScore.getExercise() != null && participantScore.getExercise().getTitle() != null ? participantScore.getExercise().getTitle() : null;
Long exerciseId = participantScore.getExercise() != null ? participantScore.getExercise().getId() : null;
Long lastResultId = participantScore.getLastResult() != null ? participantScore.getLastResult().getId() : null;
Double lastResultScore = participantScore.getLastScore();
Long lastRatedResultId = participantScore.getLastRatedResult() != null ? participantScore.getLastRatedResult().getId() : null;
Double lastRatedResultScore = participantScore.getLastRatedScore();
Double lastPoints = participantScore.getLastPoints();
Double lastRatedPoints = participantScore.getLastRatedPoints();
return new ParticipantScoreDTO(id, userId, userName, teamId, teamName, exerciseId, exerciseTitle, lastResultId, lastResultScore, lastRatedResultId, lastRatedResultScore, lastPoints, lastRatedPoints);
}
use of de.tum.in.www1.artemis.domain.scores.TeamScore in project Artemis by ls1intum.
the class ScoreService method getNewLastResultForParticipantScore.
/**
* Get the result that can replace the currently set last result for a participant score
*
* @param participantScore participant score
* @return optional of new result
*/
private Optional<Result> getNewLastResultForParticipantScore(ParticipantScore participantScore) {
List<Result> resultOrdered;
if (participantScore.getClass().equals(StudentScore.class)) {
StudentScore studentScore = (StudentScore) participantScore;
resultOrdered = resultRepository.getResultsOrderedByParticipationIdLegalSubmissionIdResultIdDescForStudent(participantScore.getExercise().getId(), studentScore.getUser().getId()).stream().filter(r -> !participantScore.getLastResult().equals(r)).collect(Collectors.toList());
} else {
TeamScore teamScore = (TeamScore) participantScore;
resultOrdered = resultRepository.getResultsOrderedByParticipationIdLegalSubmissionIdResultIdDescForTeam(participantScore.getExercise().getId(), teamScore.getTeam().getId()).stream().filter(r -> !participantScore.getLastResult().equals(r)).collect(Collectors.toList());
}
// the new last result (result with the highest id of submission with the highest id) will be at the beginning of the list
return resultOrdered.isEmpty() ? Optional.empty() : Optional.of(resultOrdered.get(0));
}
Aggregations