Search in sources :

Example 16 with TextAssessmentEvent

use of de.tum.in.www1.artemis.domain.analytics.TextAssessmentEvent in project Artemis by ls1intum.

the class TutorEffortIntegrationTest method testCalculateTutorEfforts0MinutesOneTimestamp.

/**
 * Tests the TutorEffortResource.calculateTutorEffort method with a scenario involving a distance between
 * timestamps of 1 minute but
 * @throws Exception
 */
@Test
@WithMockUser(username = "instructor", roles = "INSTRUCTOR")
public void testCalculateTutorEfforts0MinutesOneTimestamp() throws Exception {
    List<TextAssessmentEvent> events = createTextAssessmentEventsInIntervals(1, 1);
    textAssessmentEventRepository.saveAll(events);
    List<TutorEffort> tutorEfforts = request.getList("/api/courses/" + course.getId() + "/exercises/" + exercise.getId() + "/tutor-effort", HttpStatus.OK, TutorEffort.class);
    TutorEffort effortExpected = createTutorEffortObject(0);
    assertThat(tutorEfforts).isNotNull().hasSize(1);
    assertThat(tutorEfforts.get(0)).usingRecursiveComparison().isEqualTo(effortExpected);
}
Also used : TutorEffort(de.tum.in.www1.artemis.domain.statistics.tutor.effort.TutorEffort) TextAssessmentEvent(de.tum.in.www1.artemis.domain.analytics.TextAssessmentEvent) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test)

Example 17 with TextAssessmentEvent

use of de.tum.in.www1.artemis.domain.analytics.TextAssessmentEvent in project Artemis by ls1intum.

the class TutorEffortIntegrationTest method testCalculateTutorEffortsDistance10Minutes.

/**
 * Tests the TutorEffortResource.calculateTutorEffort method with a scenario involving 10 minutes
 * of distance between timestamps. In this case time difference between timestamps is not calculated
 * as it is referred as a period of inactivity
 * @throws Exception
 */
@Test
@WithMockUser(username = "instructor", roles = "INSTRUCTOR")
public void testCalculateTutorEffortsDistance10Minutes() throws Exception {
    List<TextAssessmentEvent> events = createTextAssessmentEventsInIntervals(11, 10);
    textAssessmentEventRepository.saveAll(events);
    List<TutorEffort> tutorEfforts = request.getList("/api/courses/" + course.getId() + "/exercises/" + exercise.getId() + "/tutor-effort", HttpStatus.OK, TutorEffort.class);
    TutorEffort effortExpected = createTutorEffortObject(0);
    assertThat(tutorEfforts).isNotNull().hasSize(1);
    assertThat(tutorEfforts.get(0)).usingRecursiveComparison().isEqualTo(effortExpected);
}
Also used : TutorEffort(de.tum.in.www1.artemis.domain.statistics.tutor.effort.TutorEffort) TextAssessmentEvent(de.tum.in.www1.artemis.domain.analytics.TextAssessmentEvent) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test)

Example 18 with TextAssessmentEvent

use of de.tum.in.www1.artemis.domain.analytics.TextAssessmentEvent in project ArTEMiS by ls1intum.

the class TextExerciseAnalyticsIntegrationTest method testGetNumberOfTutorsInvolvedInAssessingByExerciseAndCourseId.

/**
 * Tests the get events endpoint with admin role
 */
@Test
@WithMockUser(username = "instructor", roles = "INSTRUCTOR")
public void testGetNumberOfTutorsInvolvedInAssessingByExerciseAndCourseId() throws Exception {
    User user = new User();
    user.setLogin("instructor");
    user.setGroups(Set.of(course.getInstructorGroupName()));
    userRepository.save(user);
    TextAssessmentEvent event1 = database.createSingleTextAssessmentEvent(course.getId(), 0L, exercise.getId(), studentParticipation.getId(), textSubmission.getId());
    TextAssessmentEvent event2 = database.createSingleTextAssessmentEvent(course.getId(), 1L, exercise.getId(), studentParticipation.getId(), textSubmission.getId());
    // Add two events with two different tutor ids
    textAssessmentEventRepository.saveAll(List.of(event1, event2));
    int numberOfTutorsInvolved = request.get("/api/analytics/text-assessment/courses/" + course.getId() + "/text-exercises/" + exercise.getId() + "/tutors-involved", HttpStatus.OK, Integer.class);
    assertThat(numberOfTutorsInvolved).isNotNull().isEqualTo(2);
}
Also used : WithMockUser(org.springframework.security.test.context.support.WithMockUser) TextAssessmentEvent(de.tum.in.www1.artemis.domain.analytics.TextAssessmentEvent) WithMockUser(org.springframework.security.test.context.support.WithMockUser)

Example 19 with TextAssessmentEvent

use of de.tum.in.www1.artemis.domain.analytics.TextAssessmentEvent in project ArTEMiS by ls1intum.

the class TextExerciseAnalyticsIntegrationTest method testGetAllEventsByCourseId.

/**
 * Tests the get events endpoint with admin role
 */
@Test
@WithMockUser(username = "admin", roles = "ADMIN")
public void testGetAllEventsByCourseId() {
    User user = new User();
    user.setLogin("admin");
    user.setGroups(Set.of(course.getTeachingAssistantGroupName()));
    userRepository.save(user);
    TextAssessmentEvent event = database.createSingleTextAssessmentEvent(course.getId(), user.getId(), exercise.getId(), studentParticipation.getId(), textSubmission.getId());
    ResponseEntity<Void> responseAddEvent = textAssessmentEventResource.addAssessmentEvent(event);
    assertThat(responseAddEvent.getStatusCode()).isEqualTo(HttpStatus.OK);
    ResponseEntity<List<TextAssessmentEvent>> responseFindEvents = textAssessmentEventResource.getEventsByCourseId(course.getId());
    assertThat(responseFindEvents.getStatusCode()).isEqualTo(HttpStatus.OK);
    assertThat(responseFindEvents.getBody()).isEqualTo(List.of(event));
}
Also used : WithMockUser(org.springframework.security.test.context.support.WithMockUser) TextAssessmentEvent(de.tum.in.www1.artemis.domain.analytics.TextAssessmentEvent) List(java.util.List) WithMockUser(org.springframework.security.test.context.support.WithMockUser)

Example 20 with TextAssessmentEvent

use of de.tum.in.www1.artemis.domain.analytics.TextAssessmentEvent in project ArTEMiS by ls1intum.

the class TutorEffortIntegrationTest method testCalculateTutorEfforts0MinutesOneTimestamp.

/**
 * Tests the TutorEffortResource.calculateTutorEffort method with a scenario involving a distance between
 * timestamps of 1 minute but
 * @throws Exception
 */
@Test
@WithMockUser(username = "instructor", roles = "INSTRUCTOR")
public void testCalculateTutorEfforts0MinutesOneTimestamp() throws Exception {
    List<TextAssessmentEvent> events = createTextAssessmentEventsInIntervals(1, 1);
    textAssessmentEventRepository.saveAll(events);
    List<TutorEffort> tutorEfforts = request.getList("/api/courses/" + course.getId() + "/exercises/" + exercise.getId() + "/tutor-effort", HttpStatus.OK, TutorEffort.class);
    TutorEffort effortExpected = createTutorEffortObject(0);
    assertThat(tutorEfforts).isNotNull().hasSize(1);
    assertThat(tutorEfforts.get(0)).usingRecursiveComparison().isEqualTo(effortExpected);
}
Also used : TutorEffort(de.tum.in.www1.artemis.domain.statistics.tutor.effort.TutorEffort) TextAssessmentEvent(de.tum.in.www1.artemis.domain.analytics.TextAssessmentEvent) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test)

Aggregations

TextAssessmentEvent (de.tum.in.www1.artemis.domain.analytics.TextAssessmentEvent)22 WithMockUser (org.springframework.security.test.context.support.WithMockUser)14 TutorEffort (de.tum.in.www1.artemis.domain.statistics.tutor.effort.TutorEffort)10 Test (org.junit.jupiter.api.Test)6 Exercise (de.tum.in.www1.artemis.domain.Exercise)2 TextSubmission (de.tum.in.www1.artemis.domain.TextSubmission)2 Instant (java.time.Instant)2 List (java.util.List)2