use of de.tum.in.www1.artemis.domain.scores.ParticipantScore in project ArTEMiS by ls1intum.
the class ResultListenerIntegrationTest method saveRatedResult_then_changeScoreOfResult_ShouldUpdateOriginalStudentScore.
@ParameterizedTest(name = "{displayName} [{index}] {argumentsWithNames}")
@ValueSource(booleans = { true, false })
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void saveRatedResult_then_changeScoreOfResult_ShouldUpdateOriginalStudentScore(boolean isTeamTest) {
ParticipantScore originalParticipantScore = setupTestScenarioWithOneResultSaved(true, isTeamTest);
Result originalResult = originalParticipantScore.getLastResult();
// update the associated student score should trigger the entity listener and update the student score
originalResult.setScore(0D);
Result updatedResult = resultRepository.saveAndFlush(originalResult);
verifyStructureOfParticipantScoreInDatabase(isTeamTest, updatedResult.getId(), updatedResult.getScore(), updatedResult.getId(), updatedResult.getScore());
}
use of de.tum.in.www1.artemis.domain.scores.ParticipantScore in project ArTEMiS by ls1intum.
the class ResultListenerIntegrationTest method saveUnratedResult_then_changeScoreOfResult_ShouldUpdateOriginalStudentScore.
@ParameterizedTest(name = "{displayName} [{index}] {argumentsWithNames}")
@ValueSource(booleans = { true, false })
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void saveUnratedResult_then_changeScoreOfResult_ShouldUpdateOriginalStudentScore(boolean isTeamTest) {
ParticipantScore originalParticipantScore = setupTestScenarioWithOneResultSaved(false, isTeamTest);
Result originalResult = originalParticipantScore.getLastResult();
// update the associated student score should trigger the entity listener and update the student score
originalResult.setScore(0D);
Result updatedResult = resultRepository.saveAndFlush(originalResult);
verifyStructureOfParticipantScoreInDatabase(isTeamTest, updatedResult.getId(), updatedResult.getScore(), null, null);
}
use of de.tum.in.www1.artemis.domain.scores.ParticipantScore in project ArTEMiS by ls1intum.
the class ResultListenerIntegrationTest method saveRatedResult_then_makeResultUnrated_ShouldUpdateOriginalStudentScore.
@ParameterizedTest(name = "{displayName} [{index}] {argumentsWithNames}")
@ValueSource(booleans = { true, false })
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void saveRatedResult_then_makeResultUnrated_ShouldUpdateOriginalStudentScore(boolean isTeamTest) {
ParticipantScore originalParticipantScore = setupTestScenarioWithOneResultSaved(true, isTeamTest);
Result originalResult = originalParticipantScore.getLastResult();
// update the associated student score should trigger the entity listener and update the student score
originalResult.setRated(null);
Result updatedResult = resultRepository.saveAndFlush(originalResult);
verifyStructureOfParticipantScoreInDatabase(isTeamTest, updatedResult.getId(), updatedResult.getScore(), null, null);
}
use of de.tum.in.www1.artemis.domain.scores.ParticipantScore in project ArTEMiS by ls1intum.
the class ResultListenerIntegrationTest method saveRatedResult_then_saveAnotherUnratedResult_thenRemoveSecondResult_ShouldUpdateStudentScore.
@ParameterizedTest(name = "{displayName} [{index}] {argumentsWithNames}")
@ValueSource(booleans = { true, false })
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void saveRatedResult_then_saveAnotherUnratedResult_thenRemoveSecondResult_ShouldUpdateStudentScore(boolean isTeamTest) {
ParticipantScore originalParticipantScore = setupTestScenarioWithOneResultSaved(true, isTeamTest);
Result originalResult = originalParticipantScore.getLastResult();
// creating a new rated result should trigger the entity listener and update the student score BUT only the not rated part
Result newResult = createNewResult(isTeamTest, false);
verifyStructureOfParticipantScoreInDatabase(isTeamTest, newResult.getId(), newResult.getScore(), originalResult.getId(), originalResult.getScore());
resultRepository.deleteById(newResult.getId());
List<Result> savedResults = resultRepository.findAll();
assertThat(savedResults).hasSize(1);
verifyStructureOfParticipantScoreInDatabase(isTeamTest, originalResult.getId(), originalResult.getScore(), originalResult.getId(), originalResult.getScore());
}
use of de.tum.in.www1.artemis.domain.scores.ParticipantScore in project ArTEMiS by ls1intum.
the class ResultListenerIntegrationTest method updateExercisePoints_ShouldUpdatePointsInParticipantScores.
@ParameterizedTest(name = "{displayName} [{index}] {argumentsWithNames}")
@ValueSource(booleans = { true, false })
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void updateExercisePoints_ShouldUpdatePointsInParticipantScores(boolean isTeamTest) throws Exception {
setupTestScenarioWithOneResultSaved(true, isTeamTest);
Exercise exercise;
if (isTeamTest) {
exercise = exerciseRepository.findById(idOfTeamTextExercise).get();
} else {
exercise = exerciseRepository.findById(idOfIndividualTextExercise).get();
}
exercise.setMaxPoints(100.0);
exercise.setBonusPoints(100.0);
database.changeUser("instructor1");
request.put("/api/text-exercises", exercise, HttpStatus.OK);
List<ParticipantScore> savedParticipantScores = participantScoreRepository.findAllEagerly();
assertThat(savedParticipantScores).isNotEmpty().hasSize(1);
ParticipantScore savedParticipantScore = savedParticipantScores.get(0);
assertThat(savedParticipantScore.getLastPoints()).isEqualTo(200.0);
assertThat(savedParticipantScore.getLastRatedPoints()).isEqualTo(200.0);
}
Aggregations