Skip to content

Commit

Permalink
Merge branch 'develop' into chore/general/5974-link-plagiarism-detect…
Browse files Browse the repository at this point in the history
…ion-case-view
  • Loading branch information
AjayvirS committed Nov 14, 2024
2 parents aeae957 + d266ee6 commit f8695ef
Show file tree
Hide file tree
Showing 65 changed files with 744 additions and 429 deletions.
12 changes: 6 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ dependencies {

implementation "tech.jhipster:jhipster-framework:${jhipster_dependencies_version}"
implementation "org.springframework.boot:spring-boot-starter-cache:${spring_boot_version}"
implementation "io.micrometer:micrometer-registry-prometheus:1.13.6"
implementation "io.micrometer:micrometer-registry-prometheus:1.14.0"
implementation "net.logstash.logback:logstash-logback-encoder:8.0"

// Defines low-level streaming API, and includes JSON-specific implementations
Expand Down Expand Up @@ -414,8 +414,8 @@ dependencies {
implementation "org.springframework.cloud:spring-cloud-starter-config:4.1.3"
implementation "org.springframework.cloud:spring-cloud-commons:4.1.4"

implementation "io.netty:netty-all:4.1.114.Final"
implementation "io.projectreactor.netty:reactor-netty:1.1.23"
implementation "io.netty:netty-all:4.1.115.Final"
implementation "io.projectreactor.netty:reactor-netty:1.2.0"
implementation "org.springframework:spring-messaging:6.1.14"
implementation "org.springframework.retry:spring-retry:2.0.10"

Expand Down Expand Up @@ -536,10 +536,10 @@ dependencies {
testImplementation "org.mockito:mockito-core:${mockito_version}"
testImplementation "org.mockito:mockito-junit-jupiter:${mockito_version}"

testImplementation "io.github.classgraph:classgraph:4.8.177"
testImplementation "io.github.classgraph:classgraph:4.8.179"
testImplementation "org.awaitility:awaitility:4.2.2"
testImplementation "org.apache.maven.shared:maven-invoker:3.3.0"
testImplementation "org.gradle:gradle-tooling-api:8.10.2"
testImplementation "org.gradle:gradle-tooling-api:8.11"
testImplementation "org.apache.maven.surefire:surefire-report-parser:3.5.2"
testImplementation "com.opencsv:opencsv:5.9"
testImplementation("io.zonky.test:embedded-database-spring-test:2.5.1") {
Expand Down Expand Up @@ -621,7 +621,7 @@ tasks.withType(Test).configureEach {
}

wrapper {
gradleVersion = "8.10.2"
gradleVersion = "8.11"
}

tasks.register("stage") {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jplag_version=5.1.0
# NOTE: we do not need to use the latest version 9.x here as long as Stanford CoreNLP does not reference it
lucene_version=8.11.4
slf4j_version=2.0.16
sentry_version=7.16.0
sentry_version=7.17.0
liquibase_version=4.30.0
docker_java_version=3.4.0
logback_version=1.5.12
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ public interface ParticipantScoreRepository extends ArtemisJpaRepository<Partici
""")
List<ParticipantScore> findAllOutdated();

@Override
@EntityGraph(type = LOAD, attributePaths = { "exercise", "lastResult", "lastRatedResult" })
List<ParticipantScore> findAll();

@EntityGraph(type = LOAD, attributePaths = { "exercise", "lastResult", "lastRatedResult" })
List<ParticipantScore> findAllByExercise(Exercise exercise);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE;

import java.util.List;

import org.springframework.context.annotation.Profile;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import de.tum.cit.aet.artemis.atlas.domain.competency.CompetencyExerciseLink;
Expand All @@ -12,4 +16,10 @@
@Repository
public interface CompetencyExerciseLinkRepository extends ArtemisJpaRepository<CompetencyExerciseLink, Long> {

@Query("""
SELECT cel FROM CompetencyExerciseLink cel
LEFT JOIN FETCH cel.competency
WHERE cel.exercise.id = :exerciseId
""")
List<CompetencyExerciseLink> findByExerciseIdWithCompetency(@Param("exerciseId") long exerciseId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ CASE WHEN TYPE(e) = ProgrammingExercise THEN TRUE ELSE FALSE END,
LEFT JOIN TeamScore tS ON tS.exercise = e AND :user MEMBER OF tS.team.students
WHERE c.id = :competencyId
AND e IS NOT NULL
GROUP BY e.id, e.maxPoints, e.difficulty, TYPE(e), sS.lastScore, tS.lastScore, sS.lastPoints, tS.lastPoints, sS.lastModifiedDate, tS.lastModifiedDate
GROUP BY e.id, e.maxPoints, e.difficulty, TYPE(e), el.weight, sS.lastScore, tS.lastScore, sS.lastPoints, tS.lastPoints, sS.lastModifiedDate, tS.lastModifiedDate
""")
Set<CompetencyExerciseMasteryCalculationDTO> findAllExerciseInfoByCompetencyIdAndUser(@Param("competencyId") long competencyId, @Param("user") User user);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Service;

import de.tum.cit.aet.artemis.atlas.domain.competency.Competency;
import de.tum.cit.aet.artemis.atlas.domain.competency.CompetencyLectureUnitLink;
import de.tum.cit.aet.artemis.atlas.domain.competency.CourseCompetency;
import de.tum.cit.aet.artemis.atlas.dto.CompetencyImportOptionsDTO;
import de.tum.cit.aet.artemis.atlas.dto.CompetencyWithTailRelationDTO;
import de.tum.cit.aet.artemis.atlas.repository.CompetencyExerciseLinkRepository;
import de.tum.cit.aet.artemis.atlas.repository.CompetencyLectureUnitLinkRepository;
import de.tum.cit.aet.artemis.atlas.repository.CompetencyProgressRepository;
import de.tum.cit.aet.artemis.atlas.repository.CompetencyRelationRepository;
Expand All @@ -27,6 +30,8 @@
import de.tum.cit.aet.artemis.core.repository.CourseRepository;
import de.tum.cit.aet.artemis.core.service.AuthorizationCheckService;
import de.tum.cit.aet.artemis.exercise.service.ExerciseService;
import de.tum.cit.aet.artemis.lecture.domain.ExerciseUnit;
import de.tum.cit.aet.artemis.lecture.domain.Lecture;
import de.tum.cit.aet.artemis.lecture.repository.LectureUnitCompletionRepository;
import de.tum.cit.aet.artemis.lecture.service.LectureUnitService;

Expand All @@ -39,15 +44,19 @@ public class CompetencyService extends CourseCompetencyService {

private final CompetencyRepository competencyRepository;

private final CompetencyExerciseLinkRepository competencyExerciseLinkRepository;

public CompetencyService(CompetencyRepository competencyRepository, AuthorizationCheckService authCheckService, CompetencyRelationRepository competencyRelationRepository,
LearningPathService learningPathService, CompetencyProgressService competencyProgressService, LectureUnitService lectureUnitService,
CompetencyProgressRepository competencyProgressRepository, LectureUnitCompletionRepository lectureUnitCompletionRepository,
StandardizedCompetencyRepository standardizedCompetencyRepository, CourseCompetencyRepository courseCompetencyRepository, ExerciseService exerciseService,
LearningObjectImportService learningObjectImportService, CompetencyLectureUnitLinkRepository competencyLectureUnitLinkRepository, CourseRepository courseRepository) {
LearningObjectImportService learningObjectImportService, CompetencyLectureUnitLinkRepository competencyLectureUnitLinkRepository, CourseRepository courseRepository,
CompetencyExerciseLinkRepository competencyExerciseLinkRepository) {
super(competencyProgressRepository, courseCompetencyRepository, competencyRelationRepository, competencyProgressService, exerciseService, lectureUnitService,
learningPathService, authCheckService, standardizedCompetencyRepository, lectureUnitCompletionRepository, learningObjectImportService,
competencyLectureUnitLinkRepository, courseRepository);
this.competencyRepository = competencyRepository;
this.competencyExerciseLinkRepository = competencyExerciseLinkRepository;
}

/**
Expand Down Expand Up @@ -121,4 +130,26 @@ public List<Competency> findCompetenciesWithProgressForUserByCourseId(Long cours
List<Competency> competencies = competencyRepository.findByCourseIdOrderById(courseId);
return findProgressForCompetenciesAndUser(competencies, userId);
}

/**
* Creates competency links for exercise units of the lecture.
* <p>
* As exercise units can not be linked to competencies but only via the exercise itself, we add temporary links to the exercise units.
* Although they can not be persisted, this makes it easier to display the linked competencies in the client consistently across all lecture unit type.
*
* @param lecture the lecture to augment the exercise unit links for
*/
public void addCompetencyLinksToExerciseUnits(Lecture lecture) {
var exerciseUnits = lecture.getLectureUnits().stream().filter(unit -> unit instanceof ExerciseUnit);
exerciseUnits.forEach(unit -> {
var exerciseUnit = (ExerciseUnit) unit;
var exercise = exerciseUnit.getExercise();
if (exercise != null) {
var competencyExerciseLinks = competencyExerciseLinkRepository.findByExerciseIdWithCompetency(exercise.getId());
var competencyLectureUnitLinks = competencyExerciseLinks.stream().map(link -> new CompetencyLectureUnitLink(link.getCompetency(), exerciseUnit, link.getWeight()))
.collect(Collectors.toSet());
exerciseUnit.setCompetencyLinks(competencyLectureUnitLinks);
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ public void importStandardizedCompetencyCatalog(StandardizedCompetencyCatalogDTO
*/
public String exportStandardizedCompetencyCatalog() {
List<KnowledgeArea> knowledgeAreas = getAllForTreeView();
// TODO: we should avoid using findAll() here, as it might return a huge amount of data
List<Source> sources = sourceRepository.findAll();
var catalog = StandardizedCompetencyCatalogDTO.of(knowledgeAreas, sources);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package de.tum.cit.aet.artemis.core.dto;

import com.fasterxml.jackson.annotation.JsonInclude;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
public record CourseGroupsDTO(String instructorGroupName, String editorGroupName, String teachingAssistantGroupName, String studentGroupName) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import de.tum.cit.aet.artemis.core.domain.Organization;
import de.tum.cit.aet.artemis.core.domain.User;
import de.tum.cit.aet.artemis.core.dto.CourseForArchiveDTO;
import de.tum.cit.aet.artemis.core.dto.CourseGroupsDTO;
import de.tum.cit.aet.artemis.core.dto.StatisticsEntry;
import de.tum.cit.aet.artemis.core.exception.EntityNotFoundException;
import de.tum.cit.aet.artemis.core.repository.base.ArtemisJpaRepository;
Expand Down Expand Up @@ -323,14 +324,6 @@ GROUP BY SUBSTRING(CAST(s.submissionDate AS string), 1, 10), p.student.login
""")
List<Course> findAllNotEndedCoursesByManagementGroupNames(@Param("now") ZonedDateTime now, @Param("userGroups") List<String> userGroups);

@Query("""
SELECT COUNT(DISTINCT ug.userId)
FROM Course c
JOIN UserGroup ug ON c.studentGroupName = ug.group
WHERE c.id = :courseId
""")
int countCourseStudents(@Param("courseId") long courseId);

/**
* Counts the number of members of a course, i.e. users that are a member of the course's student, tutor, editor or instructor group.
* Users that are part of multiple groups are NOT counted multiple times.
Expand Down Expand Up @@ -569,4 +562,23 @@ SELECT COUNT(c) > 0
Set<CourseForArchiveDTO> findInactiveCoursesForUserRolesWithNonNullSemester(@Param("isAdmin") boolean isAdmin, @Param("groups") Set<String> groups,
@Param("now") ZonedDateTime now);

@Query("""
SELECT new de.tum.cit.aet.artemis.core.dto.CourseGroupsDTO(
c.instructorGroupName,
c.editorGroupName,
c.teachingAssistantGroupName,
c.studentGroupName
) FROM Course c
""")
Set<CourseGroupsDTO> findAllCourseGroups();

@Query("""
SELECT c
FROM Course c
WHERE c.teachingAssistantGroupName IN :userGroups
OR c.editorGroupName IN :userGroups
OR c.instructorGroupName IN :userGroups
OR :isAdmin = TRUE
""")
List<Course> findCoursesForAtLeastTutorWithGroups(@Param("userGroups") Set<String> userGroups, @Param("isAdmin") boolean isAdmin);
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ OR EXISTS (SELECT c FROM Course c WHERE submission.participation.exercise.course
*
* @param startDate the minimum submission date
* @param endDate the maximum submission date
* @return a list of active users
* @return a count of active users
*/
@Query("""
SELECT COUNT(DISTINCT p.student.id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,7 @@ public List<Course> getAllCoursesForManagementOverview(boolean onlyActive) {
var user = userRepository.getUserWithGroupsAndAuthorities();
boolean isAdmin = authCheckService.isAdmin(user);
if (isAdmin && !onlyActive) {
// TODO: we should avoid using findAll() here, as it might return a huge amount of data
return courseRepository.findAll();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ public List<StudentDTO> importUsers(List<StudentDTO> userDtos) {
* @return the users participation vcs access token, or throws an exception if it does not exist
*/
public ParticipationVCSAccessToken getParticipationVcsAccessTokenForUserAndParticipationIdOrElseThrow(User user, Long participationId) {
return participationVCSAccessTokenService.findByUserIdAndParticipationIdOrElseThrow(user.getId(), participationId);
return participationVCSAccessTokenService.findByUserAndParticipationIdOrElseThrow(user, participationId);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.apache.sshd.common.config.keys.AuthorizedKeyEntry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Profile;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
Expand Down Expand Up @@ -58,9 +57,6 @@ public class AccountResource {

public static final String ENTITY_NAME = "user";

@Value("${jhipster.clientApp.name}")
private String applicationName;

private static final Logger log = LoggerFactory.getLogger(AccountResource.class);

private final UserRepository userRepository;
Expand Down Expand Up @@ -233,7 +229,7 @@ public ResponseEntity<String> getVcsAccessToken(@RequestParam("participationId")
}

/**
* PUT account/participation-vcs-access-token : get the vcsToken for of a user for a participation
* PUT account/participation-vcs-access-token : add a vcsToken for of a user for a participation
*
* @param participationId the participation for which the access token should be fetched
*
Expand Down
Loading

0 comments on commit f8695ef

Please sign in to comment.