Search in sources :

Example 1 with TextAssessmentEvent

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

the class TutorEffortService method calculateTutorOverallTimeSpent.

/**
 * Traverses over tutorEvents (which contain timestamps). Calculates time spent between timestamps
 * assuming timestamps are not further than THRESHOLD_MINUTES away from each other.
 * @param tutorEvents events to be analysed
 * @return the number of minutes spent
 */
private double calculateTutorOverallTimeSpent(List<TextAssessmentEvent> tutorEvents) {
    double timeSeconds = 0;
    int index = 0;
    // avoid index out of bounds by incrementing index for accessing tutorEvents list elements
    while (index + 1 < tutorEvents.size()) {
        TextAssessmentEvent current = tutorEvents.get(index);
        // access next element
        TextAssessmentEvent next = tutorEvents.get(index + 1);
        int diffInSeconds = getDateDiffInSeconds(Date.from(current.getTimestamp()), Date.from(next.getTimestamp()));
        if (diffInSeconds <= THRESHOLD_MINUTES * 60) {
            timeSeconds += diffInSeconds;
        }
        index++;
    }
    return timeSeconds / 60;
}
Also used : TextAssessmentEvent(de.tum.in.www1.artemis.domain.analytics.TextAssessmentEvent)

Example 2 with TextAssessmentEvent

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

the class TutorEffortService method createTutorEffortWithInformation.

/**
 * Takes in parameters and sets respective properties on a new TutorEffort object
 * @param userId the id of the user to set
 * @param events the events of the respective user
 * @param submissions the number of submissions the tutor assessed
 * @return a TutorEffort object with all the data set
 */
private TutorEffort createTutorEffortWithInformation(Long userId, List<TextAssessmentEvent> events, int submissions) {
    TutorEffort effort = new TutorEffort();
    effort.setUserId(userId);
    effort.setCourseId(events.get(0).getCourseId());
    effort.setExerciseId(events.get(0).getTextExerciseId());
    effort.setTotalTimeSpentMinutes(calculateTutorOverallTimeSpent(events));
    effort.setNumberOfSubmissionsAssessed(submissions);
    return effort;
}
Also used : TutorEffort(de.tum.in.www1.artemis.domain.statistics.tutor.effort.TutorEffort)

Example 3 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 4 with TextAssessmentEvent

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

the class TextExerciseAnalyticsIntegrationTest method testAddMultipleCompleteAssessmentEvents.

/**
 * Tests adding multiple different combinations of events
 */
@Test
@WithMockUser(username = "tutor1", roles = "TA")
public void testAddMultipleCompleteAssessmentEvents() {
    List<TextAssessmentEvent> events = ModelFactory.generateMultipleTextAssessmentEvents(course.getId(), tutor.getId(), exercise.getId(), studentParticipation.getId(), textSubmission.getId());
    for (TextAssessmentEvent event : events) {
        ResponseEntity<Void> responseEntity = textAssessmentEventResource.addAssessmentEvent(event);
        assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
    }
}
Also used : TextAssessmentEvent(de.tum.in.www1.artemis.domain.analytics.TextAssessmentEvent) WithMockUser(org.springframework.security.test.context.support.WithMockUser)

Example 5 with TextAssessmentEvent

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

the class TextExerciseAnalyticsIntegrationTest method expectEventAddedWithResponse.

/**
 * Local helper function that given a userId and an expected status, adds an event and checks if the result is as expected
 * @param expected the status expected from the Http response
 * @param userId the id of the user to be tested in the event
 */
private void expectEventAddedWithResponse(HttpStatus expected, Long userId) {
    TextAssessmentEvent event = database.createSingleTextAssessmentEvent(course.getId(), userId, exercise.getId(), studentParticipation.getId(), textSubmission.getId());
    ResponseEntity<Void> responseEntity = textAssessmentEventResource.addAssessmentEvent(event);
    assertThat(responseEntity.getStatusCode()).isEqualTo(expected);
}
Also used : TextAssessmentEvent(de.tum.in.www1.artemis.domain.analytics.TextAssessmentEvent)

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