use of de.tum.in.www1.artemis.web.rest.dto.TextAssessmentDTO in project ArTEMiS by ls1intum.
the class TextAssessmentIntegrationTest method testSubmitAssessment_IncludedCompletelyWithBonusPointsExercise.
@Test
@WithMockUser(username = "tutor1", roles = "TA")
public void testSubmitAssessment_IncludedCompletelyWithBonusPointsExercise() throws Exception {
// setting up exercise
textExercise.setIncludedInOverallScore(IncludedInOverallScore.INCLUDED_COMPLETELY);
textExercise.setMaxPoints(10.0);
textExercise.setBonusPoints(10.0);
exerciseRepo.save(textExercise);
// setting up student submission
TextSubmission textSubmission = ModelFactory.generateTextSubmission("Some text", Language.ENGLISH, true);
database.saveTextSubmission(textExercise, textSubmission, "student1");
// ending exercise
exerciseDueDatePassed();
// getting submission from db
LinkedMultiValueMap<String, String> params = new LinkedMultiValueMap<>();
params.add("lock", "true");
TextSubmission submissionWithoutAssessment = request.get("/api/exercises/" + textExercise.getId() + "/text-submission-without-assessment", HttpStatus.OK, TextSubmission.class, params);
final TextAssessmentDTO textAssessmentDTO = new TextAssessmentDTO();
List<Feedback> feedbacks = new ArrayList<>();
addAssessmentFeedbackAndCheckScore(submissionWithoutAssessment, textAssessmentDTO, feedbacks, 0.0, 0L);
addAssessmentFeedbackAndCheckScore(submissionWithoutAssessment, textAssessmentDTO, feedbacks, -1.0, 0L);
addAssessmentFeedbackAndCheckScore(submissionWithoutAssessment, textAssessmentDTO, feedbacks, 1.0, 0L);
addAssessmentFeedbackAndCheckScore(submissionWithoutAssessment, textAssessmentDTO, feedbacks, 5.0, 50L);
addAssessmentFeedbackAndCheckScore(submissionWithoutAssessment, textAssessmentDTO, feedbacks, 5.0, 100L);
addAssessmentFeedbackAndCheckScore(submissionWithoutAssessment, textAssessmentDTO, feedbacks, 5.0, 150L);
addAssessmentFeedbackAndCheckScore(submissionWithoutAssessment, textAssessmentDTO, feedbacks, 5.0, 200L);
addAssessmentFeedbackAndCheckScore(submissionWithoutAssessment, textAssessmentDTO, feedbacks, 5.0, 200L);
Course course = request.get("/api/courses/" + textExercise.getCourseViaExerciseGroupOrCourseMember().getId() + "/for-assessment-dashboard", HttpStatus.OK, Course.class);
Exercise exercise = (Exercise) course.getExercises().toArray()[0];
assertThat(exercise.getNumberOfAssessmentsOfCorrectionRounds()).hasSize(1);
assertThat(exercise.getNumberOfAssessmentsOfCorrectionRounds()[0].inTime()).isEqualTo(1L);
}
use of de.tum.in.www1.artemis.web.rest.dto.TextAssessmentDTO in project ArTEMiS by ls1intum.
the class TextAssessmentIntegrationTest method testTextBlocksAreConsistentWhenOpeningSameAssessmentTwiceWithAtheneEnabled.
@Test
@WithMockUser(username = "tutor1", roles = "TA")
public void testTextBlocksAreConsistentWhenOpeningSameAssessmentTwiceWithAtheneEnabled() throws Exception {
TextSubmission textSubmission = ModelFactory.generateTextSubmission("This is Part 1, and this is Part 2. There is also Part 3.", Language.ENGLISH, true);
database.saveTextSubmission(textExercise, textSubmission, "student1");
exerciseDueDatePassed();
var blocks = Set.of(new TextBlock().startIndex(0).endIndex(15).automatic(), new TextBlock().startIndex(16).endIndex(35).automatic(), new TextBlock().startIndex(36).endIndex(57).automatic());
database.addAndSaveTextBlocksToTextSubmission(blocks, textSubmission);
LinkedMultiValueMap<String, String> params = new LinkedMultiValueMap<>();
params.add("lock", "true");
TextSubmission submission1stRequest = request.get("/api/exercises/" + textExercise.getId() + "/text-submission-without-assessment", HttpStatus.OK, TextSubmission.class, params);
var blocksFrom1stRequest = submission1stRequest.getBlocks();
assertThat(blocksFrom1stRequest.toArray()).containsExactlyInAnyOrder(blocks.toArray());
final TextAssessmentDTO textAssessmentDTO = new TextAssessmentDTO();
textAssessmentDTO.setFeedbacks(Collections.singletonList(new Feedback().detailText("Test").credits(1d).reference(blocksFrom1stRequest.iterator().next().getId()).type(FeedbackType.MANUAL)));
textAssessmentDTO.setTextBlocks(blocksFrom1stRequest);
request.postWithResponseBody("/api/participations/" + submission1stRequest.getParticipation().getId() + "/results/" + submission1stRequest.getLatestResult().getId() + "/submit-text-assessment", textAssessmentDTO, Result.class, HttpStatus.OK);
Participation participation2ndRequest = request.get("/api/participations/" + textSubmission.getParticipation().getId() + "/submissions/" + textSubmission.getId() + "/for-text-assessment", HttpStatus.OK, Participation.class, params);
TextSubmission submission2ndRequest = (TextSubmission) (participation2ndRequest).getSubmissions().iterator().next();
var blocksFrom2ndRequest = submission2ndRequest.getBlocks();
assertThat(blocksFrom2ndRequest.toArray()).containsExactlyInAnyOrder(blocks.toArray());
}
use of de.tum.in.www1.artemis.web.rest.dto.TextAssessmentDTO in project ArTEMiS by ls1intum.
the class TextAssessmentIntegrationTest method testSubmitAssessment_IncludedCompletelyWithoutBonusPointsExercise.
@Test
@WithMockUser(username = "tutor1", roles = "TA")
public void testSubmitAssessment_IncludedCompletelyWithoutBonusPointsExercise() throws Exception {
// setting up exercise
textExercise.setIncludedInOverallScore(IncludedInOverallScore.INCLUDED_COMPLETELY);
textExercise.setMaxPoints(10.0);
textExercise.setBonusPoints(0.0);
exerciseRepo.save(textExercise);
// setting up student submission
TextSubmission textSubmission = ModelFactory.generateTextSubmission("Some text", Language.ENGLISH, true);
database.saveTextSubmission(textExercise, textSubmission, "student1");
// ending exercise
exerciseDueDatePassed();
// getting submission from db
LinkedMultiValueMap<String, String> params = new LinkedMultiValueMap<>();
params.add("lock", "true");
TextSubmission submissionWithoutAssessment = request.get("/api/exercises/" + textExercise.getId() + "/text-submission-without-assessment", HttpStatus.OK, TextSubmission.class, params);
final TextAssessmentDTO textAssessmentDTO = new TextAssessmentDTO();
List<Feedback> feedbacks = new ArrayList<>();
addAssessmentFeedbackAndCheckScore(submissionWithoutAssessment, textAssessmentDTO, feedbacks, 0.0, 0L);
addAssessmentFeedbackAndCheckScore(submissionWithoutAssessment, textAssessmentDTO, feedbacks, -1.0, 0L);
addAssessmentFeedbackAndCheckScore(submissionWithoutAssessment, textAssessmentDTO, feedbacks, 1.0, 0L);
addAssessmentFeedbackAndCheckScore(submissionWithoutAssessment, textAssessmentDTO, feedbacks, 5.0, 50L);
addAssessmentFeedbackAndCheckScore(submissionWithoutAssessment, textAssessmentDTO, feedbacks, 5.0, 100L);
addAssessmentFeedbackAndCheckScore(submissionWithoutAssessment, textAssessmentDTO, feedbacks, 5.0, 100L);
}
use of de.tum.in.www1.artemis.web.rest.dto.TextAssessmentDTO in project ArTEMiS by ls1intum.
the class TextAssessmentIntegrationTest method testSubmitAssessment_NotIncludedExercise.
@Test
@WithMockUser(username = "tutor1", roles = "TA")
public void testSubmitAssessment_NotIncludedExercise() throws Exception {
// setting up exercise
textExercise.setIncludedInOverallScore(IncludedInOverallScore.NOT_INCLUDED);
textExercise.setMaxPoints(10.0);
textExercise.setBonusPoints(0.0);
exerciseRepo.save(textExercise);
// setting up student submission
TextSubmission textSubmission = ModelFactory.generateTextSubmission("Some text", Language.ENGLISH, true);
database.saveTextSubmission(textExercise, textSubmission, "student1");
// ending exercise
exerciseDueDatePassed();
// getting submission from db
LinkedMultiValueMap<String, String> params = new LinkedMultiValueMap<>();
params.add("lock", "true");
TextSubmission submissionWithoutAssessment = request.get("/api/exercises/" + textExercise.getId() + "/text-submission-without-assessment", HttpStatus.OK, TextSubmission.class, params);
final TextAssessmentDTO textAssessmentDTO = new TextAssessmentDTO();
List<Feedback> feedbacks = new ArrayList<>();
addAssessmentFeedbackAndCheckScore(submissionWithoutAssessment, textAssessmentDTO, feedbacks, 0.0, 0L);
addAssessmentFeedbackAndCheckScore(submissionWithoutAssessment, textAssessmentDTO, feedbacks, -1.0, 0L);
addAssessmentFeedbackAndCheckScore(submissionWithoutAssessment, textAssessmentDTO, feedbacks, 1.0, 0L);
addAssessmentFeedbackAndCheckScore(submissionWithoutAssessment, textAssessmentDTO, feedbacks, 5.0, 50L);
addAssessmentFeedbackAndCheckScore(submissionWithoutAssessment, textAssessmentDTO, feedbacks, 5.0, 100L);
addAssessmentFeedbackAndCheckScore(submissionWithoutAssessment, textAssessmentDTO, feedbacks, 5.0, 100L);
}
use of de.tum.in.www1.artemis.web.rest.dto.TextAssessmentDTO in project ArTEMiS by ls1intum.
the class TextAssessmentIntegrationTest method testFeedbackIdIsSetCorrectly.
@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void testFeedbackIdIsSetCorrectly() throws Exception {
TextSubmission textSubmission = ModelFactory.generateTextSubmission("This is Part 1, and this is Part 2. There is also Part 3.", Language.ENGLISH, true);
database.saveTextSubmission(textExercise, textSubmission, "student1");
exerciseDueDatePassed();
LinkedMultiValueMap<String, String> params = new LinkedMultiValueMap<>();
params.add("lock", "true");
TextSubmission submissionWithoutAssessment = request.get("/api/exercises/" + textExercise.getId() + "/text-submission-without-assessment", HttpStatus.OK, TextSubmission.class, params);
final TextAssessmentDTO textAssessmentDTO = new TextAssessmentDTO();
textAssessmentDTO.setTextBlocks(Set.of(ModelFactory.generateTextBlock(0, 15, "This is Part 1,"), ModelFactory.generateTextBlock(16, 35, " and this is Part 2."), ModelFactory.generateTextBlock(36, 57, " There is also Part 3.")));
List<Feedback> feedbacks = new ArrayList<>();
textAssessmentDTO.getTextBlocks().forEach(textBlock -> feedbacks.add(new Feedback().type(FeedbackType.MANUAL_UNREFERENCED).detailText("nice submission 1").reference(textBlock.getId())));
textAssessmentDTO.setFeedbacks(feedbacks);
Result result = request.postWithResponseBody("/api/participations/" + submissionWithoutAssessment.getParticipation().getId() + "/results/" + submissionWithoutAssessment.getLatestResult().getId() + "/submit-text-assessment", textAssessmentDTO, Result.class, HttpStatus.OK);
textBlockRepository.findAll().forEach(textBlock -> {
assertThat(textBlock.getFeedback().getId()).isNotNull();
});
}
Aggregations