Search in sources :

Example 1 with TextAssessmentDTO

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);
}
Also used : TextAssessmentDTO(de.tum.in.www1.artemis.web.rest.dto.TextAssessmentDTO) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test)

Example 2 with TextAssessmentDTO

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());
}
Also used : Participation(de.tum.in.www1.artemis.domain.participation.Participation) StudentParticipation(de.tum.in.www1.artemis.domain.participation.StudentParticipation) TextAssessmentDTO(de.tum.in.www1.artemis.web.rest.dto.TextAssessmentDTO) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test)

Example 3 with TextAssessmentDTO

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);
}
Also used : TextAssessmentDTO(de.tum.in.www1.artemis.web.rest.dto.TextAssessmentDTO) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test)

Example 4 with TextAssessmentDTO

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);
}
Also used : TextAssessmentDTO(de.tum.in.www1.artemis.web.rest.dto.TextAssessmentDTO) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test)

Example 5 with TextAssessmentDTO

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();
    });
}
Also used : TextAssessmentDTO(de.tum.in.www1.artemis.web.rest.dto.TextAssessmentDTO) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test)

Aggregations

TextAssessmentDTO (de.tum.in.www1.artemis.web.rest.dto.TextAssessmentDTO)28 Test (org.junit.jupiter.api.Test)28 WithMockUser (org.springframework.security.test.context.support.WithMockUser)28 LinkedMultiValueMap (org.springframework.util.LinkedMultiValueMap)20 Participation (de.tum.in.www1.artemis.domain.participation.Participation)8 StudentParticipation (de.tum.in.www1.artemis.domain.participation.StudentParticipation)8 Constants (de.tum.in.www1.artemis.config.Constants)6 de.tum.in.www1.artemis.domain (de.tum.in.www1.artemis.domain)6 de.tum.in.www1.artemis.domain.enumeration (de.tum.in.www1.artemis.domain.enumeration)6 Exam (de.tum.in.www1.artemis.domain.exam.Exam)6 ExerciseGroup (de.tum.in.www1.artemis.domain.exam.ExerciseGroup)6 de.tum.in.www1.artemis.repository (de.tum.in.www1.artemis.repository)6 AutomaticTextFeedbackService (de.tum.in.www1.artemis.service.AutomaticTextFeedbackService)6 TextAssessmentService (de.tum.in.www1.artemis.service.TextAssessmentService)6 ModelFactory (de.tum.in.www1.artemis.util.ModelFactory)6 TextExerciseUtilService (de.tum.in.www1.artemis.util.TextExerciseUtilService)6 TextAssessmentUpdateDTO (de.tum.in.www1.artemis.web.rest.dto.TextAssessmentUpdateDTO)6 ZonedDateTime (java.time.ZonedDateTime)6 ZonedDateTime.now (java.time.ZonedDateTime.now)6 java.util (java.util)6