Search in sources :

Example 11 with TextAssessmentEvent

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

the class TutorEffortService method buildTutorEffortList.

/**
 * Takes in list of events and submissions per tutor and builds the resulting tutor effort list by relying on the rest
 * of the business logic. First assessments are grouped by user id, then the new tutor effort list is built
 * from the resulting grouping
 * @param courseId id of the course to calculate for
 * @param exerciseId id of the exercise to calculate for
 * @return a list of built tutor efforts
 */
public List<TutorEffort> buildTutorEffortList(Long courseId, Long exerciseId) {
    Map<Long, Integer> submissionsPerTutor = textAssessmentEventRepository.getAssessedSubmissionCountPerTutor(courseId, exerciseId);
    List<TextAssessmentEvent> listOfEvents = textAssessmentEventRepository.findAllNonEmptyEvents(courseId, exerciseId);
    List<TutorEffort> tutorEffortList = new ArrayList<>();
    Map<Long, List<TextAssessmentEvent>> newMap = listOfEvents.stream().collect(groupingBy(TextAssessmentEvent::getUserId));
    if (newMap.isEmpty()) {
        return tutorEffortList;
    }
    newMap.forEach((currentUserId, currentUserEvents) -> {
        TutorEffort effort = createTutorEffortWithInformation(currentUserId, currentUserEvents, submissionsPerTutor.get(currentUserId));
        tutorEffortList.add(effort);
    });
    return tutorEffortList;
}
Also used : TutorEffort(de.tum.in.www1.artemis.domain.statistics.tutor.effort.TutorEffort) TextAssessmentEvent(de.tum.in.www1.artemis.domain.analytics.TextAssessmentEvent)

Example 12 with TextAssessmentEvent

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

the class TextAssessmentEventResource method isEventSubmissionValid.

/**
 * Checks if the data corresponding to the submission in the given TextAssessmentEvent corresponds to an actual
 * submission that exists in the database. In case such a submission doesn't exist in the database it should be ignored.
 * @param event the event to be checked against the database
 * @return whether the event is valid or not
 */
private boolean isEventSubmissionValid(TextAssessmentEvent event) {
    // Fetch the text submission by the received event submission id
    Optional<TextSubmission> textSubmission = textSubmissionRepository.findById(event.getSubmissionId());
    if (textSubmission.isEmpty()) {
        return false;
    }
    // fetch all the relevant id's to be checked
    Long fetchedParticipationId = textSubmission.get().getParticipation().getId();
    Exercise fetchedExercise = textSubmission.get().getParticipation().getExercise();
    Long fetchedExerciseId = fetchedExercise.getId();
    Long fetchedCourseId = fetchedExercise.getCourseViaExerciseGroupOrCourseMember().getId();
    // check if ids of the event ids match with the actual datas id in the repository.
    return fetchedCourseId.equals(event.getCourseId()) && fetchedExerciseId.equals(event.getTextExerciseId()) && fetchedParticipationId.equals(event.getParticipationId());
}
Also used : Exercise(de.tum.in.www1.artemis.domain.Exercise) TextSubmission(de.tum.in.www1.artemis.domain.TextSubmission)

Example 13 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 14 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 15 with TextAssessmentEvent

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

the class TutorEffortIntegrationTest method createTextAssessmentEventsInIntervals.

List<TextAssessmentEvent> createTextAssessmentEventsInIntervals(int timestamps, int distance) {
    List<TextAssessmentEvent> events = new ArrayList<>();
    Instant instant = Instant.now();
    for (int i = 0; i < timestamps; i++) {
        TextAssessmentEvent event = database.createSingleTextAssessmentEvent(course.getId(), 1L, exercise.getId(), studentParticipation.getId(), textSubmission.getId());
        event.setTimestamp(instant);
        instant = instant.plusSeconds(distance * 60L);
        events.add(event);
    }
    return events;
}
Also used : TextAssessmentEvent(de.tum.in.www1.artemis.domain.analytics.TextAssessmentEvent) Instant(java.time.Instant)

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