use of de.tum.in.www1.artemis.domain.enumeration.AssessmentType in project ArTEMiS by ls1intum.
the class AssessmentService method cancelAssessmentOfSubmission.
/**
* Cancel an assessment of a given submission for the current user, i.e. delete the corresponding result / release the lock. Then the submission is available for assessment
* again.
*
* @param submission the submission for which the current assessment should be canceled
*/
// NOTE: As we use delete methods with underscores, we need a transactional context here!
@Transactional
public void cancelAssessmentOfSubmission(Submission submission) {
StudentParticipation participation = studentParticipationRepository.findWithEagerResultsById(submission.getParticipation().getId()).orElseThrow(() -> new BadRequestAlertException("Participation could not be found", "participation", "notfound"));
// cancel is only possible for the latest result.
Result result = submission.getLatestResult();
// We only want to be able to cancel a result if it is not of the AUTOMATIC AssessmentType
if (result != null && result.getAssessmentType() != null && result.getAssessmentType() != AssessmentType.AUTOMATIC) {
participation.removeResult(result);
feedbackRepository.deleteByResult_Id(result.getId());
resultRepository.deleteById(result.getId());
}
}
use of de.tum.in.www1.artemis.domain.enumeration.AssessmentType in project ArTEMiS by ls1intum.
the class ResultServiceTest method testGetFeedbacksForResultAsStudentShouldOnlyFilterAutomaticResultBeforeLastDueDate.
@ParameterizedTest(name = "{displayName} [{index}] {argumentsWithNames}")
@EnumSource(AssessmentType.class)
@WithMockUser(username = "student1", roles = "STUDENT")
public void testGetFeedbacksForResultAsStudentShouldOnlyFilterAutomaticResultBeforeLastDueDate(AssessmentType assessmentType) {
programmingExercise.setDueDate(ZonedDateTime.now().minusHours(2));
programmingExercise.setAssessmentDueDate(null);
programmingExercise = programmingExerciseRepository.save(programmingExercise);
final var participation2 = database.addStudentParticipationForProgrammingExercise(programmingExercise, "student2");
participation2.setIndividualDueDate(ZonedDateTime.now().plusDays(2));
participationRepository.save(participation2);
Result result = database.addResultToParticipation(assessmentType, null, programmingExerciseStudentParticipation);
result = database.addVariousVisibilityFeedbackToResults(result);
result = database.addFeedbackToResult(ModelFactory.createPositiveFeedback(FeedbackType.MANUAL), result);
List<Feedback> expectedFeedbacks;
if (AssessmentType.AUTOMATIC == assessmentType) {
expectedFeedbacks = result.getFeedbacks().stream().filter(feedback -> !feedback.isInvisible() && !feedback.isAfterDueDate()).collect(Collectors.toList());
assertThat(expectedFeedbacks).hasSize(2);
} else {
expectedFeedbacks = result.getFeedbacks().stream().filter(feedback -> !feedback.isInvisible()).collect(Collectors.toList());
assertThat(expectedFeedbacks).hasSize(3);
}
assertThat(resultService.getFeedbacksForResult(result)).isEqualTo(expectedFeedbacks);
}
use of de.tum.in.www1.artemis.domain.enumeration.AssessmentType in project ArTEMiS by ls1intum.
the class ResultServiceTest method testGetFeedbacksForResultAsStudentShouldNotFilterAfterLatestDueDate.
@ParameterizedTest(name = "{displayName} [{index}] {argumentsWithNames}")
@EnumSource(AssessmentType.class)
@WithMockUser(username = "student1", roles = "STUDENT")
public void testGetFeedbacksForResultAsStudentShouldNotFilterAfterLatestDueDate(AssessmentType assessmentType) {
programmingExercise.setDueDate(ZonedDateTime.now().minusHours(2));
programmingExercise.setAssessmentDueDate(null);
programmingExercise = programmingExerciseRepository.save(programmingExercise);
final var participation2 = database.addStudentParticipationForProgrammingExercise(programmingExercise, "student2");
participation2.setIndividualDueDate(ZonedDateTime.now().minusHours(1));
participationRepository.save(participation2);
Result result = database.addResultToParticipation(assessmentType, null, programmingExerciseStudentParticipation);
result = database.addVariousVisibilityFeedbackToResults(result);
result = database.addFeedbackToResult(ModelFactory.createPositiveFeedback(FeedbackType.MANUAL), result);
List<Feedback> expectedFeedbacks;
expectedFeedbacks = result.getFeedbacks().stream().filter(feedback -> !feedback.isInvisible()).collect(Collectors.toList());
assertThat(expectedFeedbacks).hasSize(3);
assertThat(resultService.getFeedbacksForResult(result)).isEqualTo(expectedFeedbacks);
}
use of de.tum.in.www1.artemis.domain.enumeration.AssessmentType in project ArTEMiS by ls1intum.
the class ProgrammingExerciseTest method updateExerciseTestCasesZeroWeight.
@ParameterizedTest(name = "{displayName} [{index}] {argumentsWithNames}")
@EnumSource(AssessmentType.class)
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
void updateExerciseTestCasesZeroWeight(AssessmentType assessmentType) throws Exception {
ProgrammingExercise programmingExercise = programmingExerciseRepository.findWithTemplateAndSolutionParticipationTeamAssignmentConfigCategoriesById(programmingExerciseId).get();
database.addTestCasesToProgrammingExercise(programmingExercise);
Set<ProgrammingExerciseTestCase> testCases = programmingExerciseTestCaseRepository.findByExerciseId(programmingExercise.getId());
testCases.forEach(testCase -> testCase.setWeight(0D));
programmingExerciseTestCaseRepository.saveAll(testCases);
programmingExercise.setAssessmentType(assessmentType);
if (assessmentType == AssessmentType.AUTOMATIC) {
bambooRequestMockProvider.enableMockingOfRequests();
bitbucketRequestMockProvider.enableMockingOfRequests();
bambooRequestMockProvider.mockBuildPlanExists(programmingExercise.getTemplateBuildPlanId(), true, false);
bambooRequestMockProvider.mockBuildPlanExists(programmingExercise.getSolutionBuildPlanId(), true, false);
bitbucketRequestMockProvider.mockRepositoryUrlIsValid(programmingExercise.getVcsTemplateRepositoryUrl(), programmingExercise.getProjectKey(), true);
bitbucketRequestMockProvider.mockRepositoryUrlIsValid(programmingExercise.getVcsSolutionRepositoryUrl(), programmingExercise.getProjectKey(), true);
// test cases with weights = 0, changing to automatic feedback: update should NOT work
request.putAndExpectError("/api/programming-exercises", programmingExercise, HttpStatus.BAD_REQUEST, ProgrammingExerciseResourceErrorKeys.INVALID_TEST_CASE_WEIGHTS);
} else {
// for exercises with manual feedback the update should work
updateProgrammingExercise(programmingExercise, "new problem 1", "new title 1");
}
}
use of de.tum.in.www1.artemis.domain.enumeration.AssessmentType in project ArTEMiS by ls1intum.
the class SubmissionIntegrationTest method addMultipleResultsToOneSubmissionSavedSequentially.
@Test
public void addMultipleResultsToOneSubmissionSavedSequentially() {
AssessmentType assessmentType = AssessmentType.MANUAL;
Submission submission = new TextSubmission();
submission = submissionRepository.save(submission);
Result result1 = new Result().assessmentType(assessmentType).resultString("x points of y").score(100D).rated(true);
result1 = resultRepository.save(result1);
result1.setSubmission(submission);
submission.addResult(result1);
submission = submissionRepository.save(submission);
Result result2 = new Result().assessmentType(assessmentType).resultString("x points of y 2").score(200D).rated(true);
result2 = resultRepository.save(result2);
result2.setSubmission(submission);
submission.addResult(result2);
submission = submissionRepository.save(submission);
submission = submissionRepository.findWithEagerResultsAndAssessorById(submission.getId()).orElseThrow();
assert submission.getResults() != null;
assertThat(submission.getResults()).hasSize(2);
assertThat(submission.getFirstResult()).isNotEqualTo(submission.getLatestResult());
assertThat(submission.getFirstResult()).isEqualTo(result1);
assertThat(submission.getLatestResult()).isEqualTo(result2);
}
Aggregations