Search in sources :

Example 1 with TextAssessmentUpdateDTO

use of de.tum.in.www1.artemis.web.rest.dto.TextAssessmentUpdateDTO in project ArTEMiS by ls1intum.

the class TextAssessmentIntegrationTest method updateTextAssessmentAfterComplaint_withTextBlocks.

@Test
@WithMockUser(username = "tutor2", roles = "TA")
public void updateTextAssessmentAfterComplaint_withTextBlocks() throws Exception {
    // Setup
    TextSubmission textSubmission = ModelFactory.generateTextSubmission("This is Part 1, and this is Part 2. There is also Part 3.", Language.ENGLISH, true);
    textSubmission = database.saveTextSubmissionWithResultAndAssessor(textExercise, textSubmission, "student1", "tutor1");
    database.addAndSaveTextBlocksToTextSubmission(Set.of(new TextBlock().startIndex(0).endIndex(15).automatic(), new TextBlock().startIndex(16).endIndex(35).automatic(), new TextBlock().startIndex(36).endIndex(57).automatic()), textSubmission);
    Result textAssessment = textSubmission.getLatestResult();
    complaintRepo.save(new Complaint().result(textAssessment).complaintText("This is not fair"));
    // Get Text Submission and Complaint
    StudentParticipation participation = request.get("/api/participations/" + textSubmission.getParticipation().getId() + "/submissions/" + textSubmission.getId() + "/for-text-assessment", HttpStatus.OK, StudentParticipation.class);
    final Complaint complaint = request.get("/api/complaints/submissions/" + textSubmission.getId(), HttpStatus.OK, Complaint.class);
    // Accept Complaint and update Assessment
    ComplaintResponse complaintResponse = database.createInitialEmptyResponse("tutor2", complaint);
    complaintResponse.getComplaint().setAccepted(false);
    complaintResponse.setResponseText("rejected");
    TextAssessmentUpdateDTO assessmentUpdate = new TextAssessmentUpdateDTO();
    assessmentUpdate.feedbacks(new ArrayList<>()).complaintResponse(complaintResponse);
    assessmentUpdate.setTextBlocks(new HashSet<>());
    Result updatedResult = request.putWithResponseBody("/api/participations/" + textSubmission.getParticipation().getId() + "/submissions/" + textSubmission.getId() + "/text-assessment-after-complaint", assessmentUpdate, Result.class, HttpStatus.OK);
    assertThat(updatedResult).as("updated result found").isNotNull();
}
Also used : StudentParticipation(de.tum.in.www1.artemis.domain.participation.StudentParticipation) TextAssessmentUpdateDTO(de.tum.in.www1.artemis.web.rest.dto.TextAssessmentUpdateDTO) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test)

Example 2 with TextAssessmentUpdateDTO

use of de.tum.in.www1.artemis.web.rest.dto.TextAssessmentUpdateDTO in project Artemis by ls1intum.

the class TextAssessmentIntegrationTest method updateTextAssessmentAfterComplaint_withTextBlocks.

@Test
@WithMockUser(username = "tutor2", roles = "TA")
public void updateTextAssessmentAfterComplaint_withTextBlocks() throws Exception {
    // Setup
    TextSubmission textSubmission = ModelFactory.generateTextSubmission("This is Part 1, and this is Part 2. There is also Part 3.", Language.ENGLISH, true);
    textSubmission = database.saveTextSubmissionWithResultAndAssessor(textExercise, textSubmission, "student1", "tutor1");
    database.addAndSaveTextBlocksToTextSubmission(Set.of(new TextBlock().startIndex(0).endIndex(15).automatic(), new TextBlock().startIndex(16).endIndex(35).automatic(), new TextBlock().startIndex(36).endIndex(57).automatic()), textSubmission);
    Result textAssessment = textSubmission.getLatestResult();
    complaintRepo.save(new Complaint().result(textAssessment).complaintText("This is not fair"));
    // Get Text Submission and Complaint
    StudentParticipation participation = request.get("/api/participations/" + textSubmission.getParticipation().getId() + "/submissions/" + textSubmission.getId() + "/for-text-assessment", HttpStatus.OK, StudentParticipation.class);
    final Complaint complaint = request.get("/api/complaints/submissions/" + textSubmission.getId(), HttpStatus.OK, Complaint.class);
    // Accept Complaint and update Assessment
    ComplaintResponse complaintResponse = database.createInitialEmptyResponse("tutor2", complaint);
    complaintResponse.getComplaint().setAccepted(false);
    complaintResponse.setResponseText("rejected");
    TextAssessmentUpdateDTO assessmentUpdate = new TextAssessmentUpdateDTO();
    assessmentUpdate.feedbacks(new ArrayList<>()).complaintResponse(complaintResponse);
    assessmentUpdate.setTextBlocks(new HashSet<>());
    Result updatedResult = request.putWithResponseBody("/api/participations/" + textSubmission.getParticipation().getId() + "/submissions/" + textSubmission.getId() + "/text-assessment-after-complaint", assessmentUpdate, Result.class, HttpStatus.OK);
    assertThat(updatedResult).as("updated result found").isNotNull();
}
Also used : StudentParticipation(de.tum.in.www1.artemis.domain.participation.StudentParticipation) TextAssessmentUpdateDTO(de.tum.in.www1.artemis.web.rest.dto.TextAssessmentUpdateDTO) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test)

Aggregations

StudentParticipation (de.tum.in.www1.artemis.domain.participation.StudentParticipation)2 TextAssessmentUpdateDTO (de.tum.in.www1.artemis.web.rest.dto.TextAssessmentUpdateDTO)2 Test (org.junit.jupiter.api.Test)2 WithMockUser (org.springframework.security.test.context.support.WithMockUser)2