Skip to content

Commit

Permalink
Adaptive learning: Add option to import exercises and lecture units w…
Browse files Browse the repository at this point in the history
…hen importing competencies (#9205)
  • Loading branch information
JohannesStoehr authored Oct 4, 2024
1 parent aee8c00 commit 9c16f13
Show file tree
Hide file tree
Showing 73 changed files with 3,258 additions and 965 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package de.tum.cit.aet.artemis.atlas.dto;

import java.time.ZonedDateTime;
import java.util.Optional;
import java.util.Set;

import com.fasterxml.jackson.annotation.JsonInclude;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
public record CompetencyImportOptionsDTO(Set<Long> competencyIds, Optional<Long> sourceCourseId, boolean importRelations, boolean importExercises, boolean importLectures,
Optional<ZonedDateTime> referenceDate, boolean isReleaseDate) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@ public interface CompetencyRepository extends ArtemisJpaRepository<Competency, L
@Query("""
SELECT c
FROM Competency c
LEFT JOIN FETCH c.exercises
LEFT JOIN FETCH c.lectureUnits lu
LEFT JOIN FETCH lu.lecture l
LEFT JOIN FETCH l.attachments
WHERE c.course.id = :courseId
""")
Set<Competency> findAllForCourse(@Param("courseId") long courseId);
Set<Competency> findAllForCourseWithExercisesAndLectureUnitsAndLecturesAndAttachments(@Param("courseId") long courseId);

@Query("""
SELECT c
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,44 @@ public interface CourseCompetencyRepository extends ArtemisJpaRepository<CourseC
""")
Set<CourseCompetency> findAllForCourse(@Param("courseId") long courseId);

@Query("""
SELECT c
FROM CourseCompetency c
LEFT JOIN FETCH c.exercises ex
LEFT JOIN FETCH c.lectureUnits lu
LEFT JOIN FETCH lu.lecture l
LEFT JOIN FETCH l.attachments
WHERE c.course.id = :courseId
""")
Set<CourseCompetency> findAllForCourseWithExercisesAndLectureUnitsAndLecturesAndAttachments(@Param("courseId") long courseId);

@Query("""
SELECT c
FROM CourseCompetency c
LEFT JOIN FETCH c.exercises ex
LEFT JOIN FETCH c.lectureUnits lu
LEFT JOIN FETCH lu.lecture l
LEFT JOIN FETCH l.lectureUnits
LEFT JOIN FETCH l.attachments
WHERE c.id = :id
""")
Optional<CourseCompetency> findByIdWithExercisesAndLectureUnitsAndLectures(@Param("id") long id);

default CourseCompetency findByIdWithExercisesAndLectureUnitsAndLecturesElseThrow(long id) {
return getValueElseThrow(findByIdWithExercisesAndLectureUnitsAndLectures(id), id);
}

@Query("""
SELECT c
FROM CourseCompetency c
LEFT JOIN FETCH c.exercises ex
LEFT JOIN FETCH c.lectureUnits lu
LEFT JOIN FETCH lu.lecture l
LEFT JOIN FETCH l.attachments
WHERE c.id IN :ids
""")
Set<CourseCompetency> findAllByIdWithExercisesAndLectureUnitsAndLecturesAndAttachments(@Param("ids") Set<Long> ids);

/**
* Fetches all information related to the calculation of the mastery for exercises in a competency.
* The complex grouping by is necessary for postgres
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,30 @@ public interface PrerequisiteRepository extends ArtemisJpaRepository<Prerequisit
List<Prerequisite> findAllByCourseIdOrderById(long courseId);

@Query("""
SELECT c
FROM Prerequisite c
WHERE c.course.id = :courseId
SELECT p
FROM Prerequisite p
LEFT JOIN FETCH p.exercises
LEFT JOIN FETCH p.lectureUnits lu
LEFT JOIN FETCH lu.lecture l
LEFT JOIN FETCH l.attachments
WHERE p.course.id = :courseId
""")
Set<Prerequisite> findAllForCourse(@Param("courseId") long courseId);
Set<Prerequisite> findAllForCourseWithExercisesAndLectureUnitsAndLecturesAndAttachments(@Param("courseId") long courseId);

@Query("""
SELECT c
FROM Prerequisite c
LEFT JOIN FETCH c.lectureUnits lu
LEFT JOIN FETCH c.exercises
WHERE c.id = :competencyId
SELECT p
FROM Prerequisite p
LEFT JOIN FETCH p.lectureUnits lu
LEFT JOIN FETCH p.exercises
WHERE p.id = :competencyId
""")
Optional<Prerequisite> findByIdWithLectureUnitsAndExercises(@Param("competencyId") long competencyId);

@Query("""
SELECT c
FROM Prerequisite c
LEFT JOIN FETCH c.lectureUnits lu
WHERE c.id = :competencyId
SELECT p
FROM Prerequisite p
LEFT JOIN FETCH p.lectureUnits lu
WHERE p.id = :competencyId
""")
Optional<Prerequisite> findByIdWithLectureUnits(@Param("competencyId") long competencyId);

Expand Down
Loading

0 comments on commit 9c16f13

Please sign in to comment.