Search in sources :

Example 1 with de.tum.in.www1.artemis.repository

use of de.tum.in.www1.artemis.repository in project ArTEMiS by ls1intum.

the class GitServiceIntTest method testListFiles.

@Test
public void testListFiles() throws IOException, GitAPIException {
    Participation participation = new Participation();
    participation.setRepositoryUrl(remoteTestRepo);
    Repository repo = gitService.getOrCheckoutRepository(participation);
    Collection<de.tum.in.www1.artemis.domain.File> files = gitService.listFiles(repo);
    assertThat(files.size()).isGreaterThan(0);
    gitService.deleteLocalRepository(repo);
}
Also used : Participation(de.tum.in.www1.artemis.domain.Participation) Repository(de.tum.in.www1.artemis.domain.Repository) File(java.io.File) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with de.tum.in.www1.artemis.repository

use of de.tum.in.www1.artemis.repository in project ArTEMiS by ls1intum.

the class ParticipantScoreResource method getScoresOfExam.

/**
 * GET /exams/:examId/exam-scores gets the exam scores of the exam
 * <p>
 * This method represents a server based way to calculate a students achieved points / score in an exam.
 * <p>
 * Currently both this server based calculation method and the traditional client side calculation method is used
 * side-by-side in exam-scores.component.ts.
 * <p>
 * The goal is to switch completely to this much faster server based calculation if the {@link de.tum.in.www1.artemis.service.listeners.ResultListener}
 * has been battle tested enough.
 *
 * @param examId the id of the exam for which to calculate the exam scores
 * @return list of scores for every registered user in the xam
 */
@GetMapping("/exams/{examId}/exam-scores")
@PreAuthorize("hasRole('INSTRUCTOR')")
public ResponseEntity<List<ScoreDTO>> getScoresOfExam(@PathVariable Long examId) {
    long start = System.currentTimeMillis();
    log.debug("REST request to get exam scores for exam : {}", examId);
    Exam exam = examRepository.findByIdWithRegisteredUsersExerciseGroupsAndExercisesElseThrow(examId);
    authorizationCheckService.checkHasAtLeastRoleInCourseElseThrow(Role.INSTRUCTOR, exam.getCourse(), null);
    List<ScoreDTO> scoreDTOS = participantScoreService.calculateExamScores(exam);
    log.info("getScoresOfExam took {}ms", System.currentTimeMillis() - start);
    return ResponseEntity.ok().body(scoreDTOS);
}
Also used : ParticipantScoreDTO(de.tum.in.www1.artemis.web.rest.dto.ParticipantScoreDTO) ScoreDTO(de.tum.in.www1.artemis.web.rest.dto.ScoreDTO) Exam(de.tum.in.www1.artemis.domain.exam.Exam) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 3 with de.tum.in.www1.artemis.repository

use of de.tum.in.www1.artemis.repository in project ArTEMiS by ls1intum.

the class ParticipantScoreResource method getAverageScoreOfParticipantInCourse.

/**
 * GET /courses/:courseId/participant-scores/average-participant  gets the average scores of the participants in the course
 * <p>
 * Important: Exercises with {@link de.tum.in.www1.artemis.domain.enumeration.IncludedInOverallScore#NOT_INCLUDED} will be not taken into account!
 *
 * @param courseId the id of the course for which to get the average scores of the participants
 * @return the ResponseEntity with status 200 (OK) and with the average scores in the body
 */
@GetMapping("/courses/{courseId}/participant-scores/average-participant")
@PreAuthorize("hasRole('INSTRUCTOR')")
public ResponseEntity<List<ParticipantScoreAverageDTO>> getAverageScoreOfParticipantInCourse(@PathVariable Long courseId) {
    long start = System.currentTimeMillis();
    log.debug("REST request to get average participant scores of participants for course : {}", courseId);
    Course course = courseRepository.findByIdWithEagerExercisesElseThrow(courseId);
    authorizationCheckService.checkHasAtLeastRoleInCourseElseThrow(Role.INSTRUCTOR, course, null);
    Set<Exercise> exercisesOfCourse = course.getExercises().stream().filter(Exercise::isCourseExercise).filter(exercise -> !exercise.getIncludedInOverallScore().equals(IncludedInOverallScore.NOT_INCLUDED)).collect(toSet());
    List<ParticipantScoreAverageDTO> resultsOfAllExercises = participantScoreService.getParticipantScoreAverageDTOs(exercisesOfCourse);
    log.info("getAverageScoreOfStudentInCourse took {}ms", System.currentTimeMillis() - start);
    return ResponseEntity.ok().body(resultsOfAllExercises);
}
Also used : ParticipantScoreDTO(de.tum.in.www1.artemis.web.rest.dto.ParticipantScoreDTO) Logger(org.slf4j.Logger) CourseRepository(de.tum.in.www1.artemis.repository.CourseRepository) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) LoggerFactory(org.slf4j.LoggerFactory) Course(de.tum.in.www1.artemis.domain.Course) Set(java.util.Set) Role(de.tum.in.www1.artemis.security.Role) ParticipantScoreAverageDTO(de.tum.in.www1.artemis.web.rest.dto.ParticipantScoreAverageDTO) HashSet(java.util.HashSet) List(java.util.List) ScoreDTO(de.tum.in.www1.artemis.web.rest.dto.ScoreDTO) ExerciseGroup(de.tum.in.www1.artemis.domain.exam.ExerciseGroup) Exercise(de.tum.in.www1.artemis.domain.Exercise) org.springframework.web.bind.annotation(org.springframework.web.bind.annotation) ParticipantScoreService(de.tum.in.www1.artemis.service.ParticipantScoreService) AuthorizationCheckService(de.tum.in.www1.artemis.service.AuthorizationCheckService) Pageable(org.springframework.data.domain.Pageable) ResponseEntity(org.springframework.http.ResponseEntity) IncludedInOverallScore(de.tum.in.www1.artemis.domain.enumeration.IncludedInOverallScore) Exam(de.tum.in.www1.artemis.domain.exam.Exam) Collectors.toSet(java.util.stream.Collectors.toSet) ExamRepository(de.tum.in.www1.artemis.repository.ExamRepository) Exercise(de.tum.in.www1.artemis.domain.Exercise) ParticipantScoreAverageDTO(de.tum.in.www1.artemis.web.rest.dto.ParticipantScoreAverageDTO) Course(de.tum.in.www1.artemis.domain.Course) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 4 with de.tum.in.www1.artemis.repository

use of de.tum.in.www1.artemis.repository in project Artemis by ls1intum.

the class ParticipantScoreResource method getScoresOfExam.

/**
 * GET /exams/:examId/exam-scores gets the exam scores of the exam
 * <p>
 * This method represents a server based way to calculate a students achieved points / score in an exam.
 * <p>
 * Currently both this server based calculation method and the traditional client side calculation method is used
 * side-by-side in exam-scores.component.ts.
 * <p>
 * The goal is to switch completely to this much faster server based calculation if the {@link de.tum.in.www1.artemis.service.listeners.ResultListener}
 * has been battle tested enough.
 *
 * @param examId the id of the exam for which to calculate the exam scores
 * @return list of scores for every registered user in the xam
 */
@GetMapping("/exams/{examId}/exam-scores")
@PreAuthorize("hasRole('INSTRUCTOR')")
public ResponseEntity<List<ScoreDTO>> getScoresOfExam(@PathVariable Long examId) {
    long start = System.currentTimeMillis();
    log.debug("REST request to get exam scores for exam : {}", examId);
    Exam exam = examRepository.findByIdWithRegisteredUsersExerciseGroupsAndExercisesElseThrow(examId);
    authorizationCheckService.checkHasAtLeastRoleInCourseElseThrow(Role.INSTRUCTOR, exam.getCourse(), null);
    List<ScoreDTO> scoreDTOS = participantScoreService.calculateExamScores(exam);
    log.info("getScoresOfExam took {}ms", System.currentTimeMillis() - start);
    return ResponseEntity.ok().body(scoreDTOS);
}
Also used : ParticipantScoreDTO(de.tum.in.www1.artemis.web.rest.dto.ParticipantScoreDTO) ScoreDTO(de.tum.in.www1.artemis.web.rest.dto.ScoreDTO) Exam(de.tum.in.www1.artemis.domain.exam.Exam) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 5 with de.tum.in.www1.artemis.repository

use of de.tum.in.www1.artemis.repository in project Artemis by ls1intum.

the class ParticipantScoreResource method getScoresOfCourse.

/**
 * GET /courses/:courseId/course-scores gets the course scores of the course
 * <p>
 * This method represents a server based way to calculate a students achieved points / score in a course.
 * <p>
 * Currently both this server based calculation method and the traditional client side calculation method is used
 * side-by-side in course-scores.component.ts.
 * <p>
 * The goal is to switch completely to this much faster server based calculation if the {@link de.tum.in.www1.artemis.service.listeners.ResultListener}
 * has been battle tested enough.
 *
 * @param courseId the id of the course for which to calculate the course scores
 * @return list of scores for every member of the course
 */
@GetMapping("/courses/{courseId}/course-scores")
@PreAuthorize("hasRole('INSTRUCTOR')")
public ResponseEntity<List<ScoreDTO>> getScoresOfCourse(@PathVariable Long courseId) {
    long start = System.currentTimeMillis();
    log.debug("REST request to get course scores for course : {}", courseId);
    Course course = courseRepository.findByIdWithEagerExercisesElseThrow(courseId);
    authorizationCheckService.checkHasAtLeastRoleInCourseElseThrow(Role.INSTRUCTOR, course, null);
    List<ScoreDTO> scoreDTOS = participantScoreService.calculateCourseScores(course);
    log.info("getScoresOfCourse took {}ms", System.currentTimeMillis() - start);
    return ResponseEntity.ok().body(scoreDTOS);
}
Also used : ParticipantScoreDTO(de.tum.in.www1.artemis.web.rest.dto.ParticipantScoreDTO) ScoreDTO(de.tum.in.www1.artemis.web.rest.dto.ScoreDTO) Course(de.tum.in.www1.artemis.domain.Course) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

ParticipantScoreDTO (de.tum.in.www1.artemis.web.rest.dto.ParticipantScoreDTO)8 ScoreDTO (de.tum.in.www1.artemis.web.rest.dto.ScoreDTO)8 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)8 Course (de.tum.in.www1.artemis.domain.Course)6 Exam (de.tum.in.www1.artemis.domain.exam.Exam)6 Exercise (de.tum.in.www1.artemis.domain.Exercise)4 IncludedInOverallScore (de.tum.in.www1.artemis.domain.enumeration.IncludedInOverallScore)4 ExerciseGroup (de.tum.in.www1.artemis.domain.exam.ExerciseGroup)4 CourseRepository (de.tum.in.www1.artemis.repository.CourseRepository)4 ExamRepository (de.tum.in.www1.artemis.repository.ExamRepository)4 Role (de.tum.in.www1.artemis.security.Role)4 AuthorizationCheckService (de.tum.in.www1.artemis.service.AuthorizationCheckService)4 ParticipantScoreService (de.tum.in.www1.artemis.service.ParticipantScoreService)4 ParticipantScoreAverageDTO (de.tum.in.www1.artemis.web.rest.dto.ParticipantScoreAverageDTO)4 HashSet (java.util.HashSet)4 List (java.util.List)4 Set (java.util.Set)4 Collectors.toSet (java.util.stream.Collectors.toSet)4 Logger (org.slf4j.Logger)4 LoggerFactory (org.slf4j.LoggerFactory)4