Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/programming-exercises/ad…
Browse files Browse the repository at this point in the history
…d-grouping-feature-to-analysis-table' into feature/programming-exercises/add-grouping-feature-to-analysis-table
  • Loading branch information
az108 committed Dec 10, 2024
2 parents ccf1d27 + 85fad28 commit 9d0afee
Show file tree
Hide file tree
Showing 36 changed files with 559 additions and 157 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ spotless {
}
}
importOrderFile "artemis-spotless.importorder"
eclipse("4.28").configFile "artemis-spotless-style.xml"
eclipse("4.33").configFile "artemis-spotless-style.xml"

removeUnusedImports()
trimTrailingWhitespace()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package de.tum.cit.aet.artemis.iris.domain.settings;

import jakarta.annotation.Nullable;
import jakarta.persistence.Column;
import jakarta.persistence.DiscriminatorValue;
import jakarta.persistence.Entity;

import com.fasterxml.jackson.annotation.JsonInclude;

/**
* An {@link IrisSubSettings} implementation for course chat settings.
* Chat settings notably provide settings for the rate limit.
*/
@Entity
@DiscriminatorValue("COURSE_CHAT")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class IrisCourseChatSubSettings extends IrisSubSettings {

@Nullable
@Column(name = "rate_limit")
private Integer rateLimit;

@Nullable
@Column(name = "rate_limit_timeframe_hours")
private Integer rateLimitTimeframeHours;

@Nullable
public Integer getRateLimit() {
return rateLimit;
}

public void setRateLimit(@Nullable Integer rateLimit) {
this.rateLimit = rateLimit;
}

@Nullable
public Integer getRateLimitTimeframeHours() {
return rateLimitTimeframeHours;
}

public void setRateLimitTimeframeHours(@Nullable Integer rateLimitTimeframeHours) {
this.rateLimitTimeframeHours = rateLimitTimeframeHours;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ public class IrisCourseSettings extends IrisSettings {
@JoinColumn(name = "iris_text_exercise_chat_settings_id")
private IrisTextExerciseChatSubSettings irisTextExerciseChatSettings;

@OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER, optional = false)
@JoinColumn(name = "iris_course_chat_settings_id")
private IrisCourseChatSubSettings irisCourseChatSettings;

@OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
@JoinColumn(name = "iris_lecture_ingestion_settings_id")
private IrisLectureIngestionSubSettings irisLectureIngestionSettings;
Expand Down Expand Up @@ -78,6 +82,16 @@ public void setIrisTextExerciseChatSettings(IrisTextExerciseChatSubSettings iris
this.irisTextExerciseChatSettings = irisTextExerciseChatSettings;
}

@Override
public IrisCourseChatSubSettings getIrisCourseChatSettings() {
return irisCourseChatSettings;
}

@Override
public void setIrisCourseChatSettings(IrisCourseChatSubSettings irisCourseChatSettings) {
this.irisCourseChatSettings = irisCourseChatSettings;
}

@Override
public IrisCompetencyGenerationSubSettings getIrisCompetencyGenerationSettings() {
return irisCompetencyGenerationSettings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ public void setIrisTextExerciseChatSettings(IrisTextExerciseChatSubSettings iris
this.irisTextExerciseChatSettings = irisTextExerciseChatSettings;
}

@Override
public IrisCourseChatSubSettings getIrisCourseChatSettings() {
// Empty because exercises don't have course chat settings
return null;
}

@Override
public void setIrisCourseChatSettings(IrisCourseChatSubSettings irisCourseChatSettings) {
// Empty because exercises don't have course chat settings
}

@Override
public IrisCompetencyGenerationSubSettings getIrisCompetencyGenerationSettings() {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ public class IrisGlobalSettings extends IrisSettings {
@JoinColumn(name = "iris_text_exercise_chat_settings_id")
private IrisTextExerciseChatSubSettings irisTextExerciseChatSettings;

@OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER, optional = false)
@JoinColumn(name = "iris_course_chat_settings_id")
private IrisCourseChatSubSettings irisCourseChatSettings;

@OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER, optional = false)
@JoinColumn(name = "iris_lecture_ingestion_settings_id")
private IrisLectureIngestionSubSettings irisLectureIngestionSettings;
Expand Down Expand Up @@ -65,6 +69,16 @@ public void setIrisTextExerciseChatSettings(IrisTextExerciseChatSubSettings iris
this.irisTextExerciseChatSettings = irisTextExerciseChatSettings;
}

@Override
public IrisCourseChatSubSettings getIrisCourseChatSettings() {
return irisCourseChatSettings;
}

@Override
public void setIrisCourseChatSettings(IrisCourseChatSubSettings irisCourseChatSettings) {
this.irisCourseChatSettings = irisCourseChatSettings;
}

@Override
public IrisCompetencyGenerationSubSettings getIrisCompetencyGenerationSettings() {
return irisCompetencyGenerationSettings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ public abstract class IrisSettings extends DomainObject {

public abstract void setIrisTextExerciseChatSettings(IrisTextExerciseChatSubSettings irisTextExerciseChatSettings);

public abstract IrisCourseChatSubSettings getIrisCourseChatSettings();

public abstract void setIrisCourseChatSettings(IrisCourseChatSubSettings irisCourseChatSettings);

public abstract IrisLectureIngestionSubSettings getIrisLectureIngestionSettings();

public abstract void setIrisLectureIngestionSettings(IrisLectureIngestionSubSettings irisLectureIngestionSettings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
@JsonSubTypes({
@JsonSubTypes.Type(value = IrisChatSubSettings.class, name = "chat"),
@JsonSubTypes.Type(value = IrisTextExerciseChatSubSettings.class, name = "text-exercise-chat"),
@JsonSubTypes.Type(value = IrisCourseChatSubSettings.class, name = "course-chat"),
@JsonSubTypes.Type(value = IrisLectureIngestionSubSettings.class, name = "lecture-ingestion"),
@JsonSubTypes.Type(value = IrisCompetencyGenerationSubSettings.class, name = "competency-generation")
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package de.tum.cit.aet.artemis.iris.domain.settings;

public enum IrisSubSettingsType {
CHAT, // TODO: Split into PROGRAMMING_EXERCISE_CHAT and COURSE_CHAT
TEXT_EXERCISE_CHAT, COMPETENCY_GENERATION, LECTURE_INGESTION
CHAT, // TODO: Rename to PROGRAMMING_EXERCISE_CHAT
TEXT_EXERCISE_CHAT, COURSE_CHAT, COMPETENCY_GENERATION, LECTURE_INGESTION
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package de.tum.cit.aet.artemis.iris.dto;

import java.util.SortedSet;

import jakarta.annotation.Nullable;

import com.fasterxml.jackson.annotation.JsonInclude;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
public record IrisCombinedCourseChatSubSettingsDTO(boolean enabled, Integer rateLimit, Integer rateLimitTimeframeHours, @Nullable SortedSet<String> allowedVariants,
@Nullable String selectedVariant) {

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
public record IrisCombinedSettingsDTO(
IrisCombinedChatSubSettingsDTO irisChatSettings,
IrisCombinedTextExerciseChatSubSettingsDTO irisTextExerciseChatSettings,
IrisCombinedCourseChatSubSettingsDTO irisCourseChatSettings,
IrisCombinedLectureIngestionSubSettingsDTO irisLectureIngestionSettings,
IrisCombinedCompetencyGenerationSubSettingsDTO irisCompetencyGenerationSettings
) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void checkHasAccessTo(User user, IrisCourseChatSession session) {
*/
@Override
public void checkIsFeatureActivatedFor(IrisCourseChatSession session) {
irisSettingsService.isEnabledForElseThrow(IrisSubSettingsType.CHAT, session.getCourse());
irisSettingsService.isEnabledForElseThrow(IrisSubSettingsType.COURSE_CHAT, session.getCourse());
}

@Override
Expand Down Expand Up @@ -134,7 +134,7 @@ protected void setLLMTokenUsageParameters(LLMTokenUsageService.LLMTokenUsageBuil
*/
public void onJudgementOfLearningSet(CompetencyJol competencyJol) {
var course = competencyJol.getCompetency().getCourse();
if (!irisSettingsService.isEnabledFor(IrisSubSettingsType.CHAT, course)) {
if (!irisSettingsService.isEnabledFor(IrisSubSettingsType.COURSE_CHAT, course)) {
return;
}
var user = competencyJol.getUser();
Expand All @@ -154,7 +154,7 @@ public void onJudgementOfLearningSet(CompetencyJol competencyJol) {
*/
public IrisCourseChatSession getCurrentSessionOrCreateIfNotExists(Course course, User user, boolean sendInitialMessageIfCreated) {
user.hasAcceptedIrisElseThrow();
irisSettingsService.isEnabledForElseThrow(IrisSubSettingsType.CHAT, course);
irisSettingsService.isEnabledForElseThrow(IrisSubSettingsType.COURSE_CHAT, course);
return getCurrentSessionOrCreateIfNotExistsInternal(course, user, sendInitialMessageIfCreated);
}

Expand Down Expand Up @@ -184,7 +184,7 @@ private IrisCourseChatSession getCurrentSessionOrCreateIfNotExistsInternal(Cours
*/
public IrisCourseChatSession createSession(Course course, User user, boolean sendInitialMessage) {
user.hasAcceptedIrisElseThrow();
irisSettingsService.isEnabledForElseThrow(IrisSubSettingsType.CHAT, course);
irisSettingsService.isEnabledForElseThrow(IrisSubSettingsType.COURSE_CHAT, course);
return createSessionInternal(course, user, sendInitialMessage);
}

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

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

import java.util.List;
import java.util.Objects;
import java.util.Optional;

Expand All @@ -27,6 +28,7 @@
import de.tum.cit.aet.artemis.iris.service.settings.IrisSettingsService;
import de.tum.cit.aet.artemis.iris.service.websocket.IrisChatWebsocketService;
import de.tum.cit.aet.artemis.programming.domain.ProgrammingExercise;
import de.tum.cit.aet.artemis.programming.domain.ProgrammingExerciseStudentParticipation;
import de.tum.cit.aet.artemis.programming.domain.ProgrammingSubmission;
import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseRepository;
import de.tum.cit.aet.artemis.programming.repository.ProgrammingExerciseStudentParticipationRepository;
Expand Down Expand Up @@ -144,7 +146,14 @@ public void requestAndHandleResponse(IrisExerciseChatSession session) {
}

private Optional<ProgrammingSubmission> getLatestSubmissionIfExists(ProgrammingExercise exercise, User user) {
var participations = programmingExerciseStudentParticipationRepository.findAllWithSubmissionsByExerciseIdAndStudentLogin(exercise.getId(), user.getLogin());
List<ProgrammingExerciseStudentParticipation> participations;
if (exercise.isTeamMode()) {
participations = programmingExerciseStudentParticipationRepository.findAllWithSubmissionByExerciseIdAndStudentLoginInTeam(exercise.getId(), user.getLogin());
}
else {
participations = programmingExerciseStudentParticipationRepository.findAllWithSubmissionsByExerciseIdAndStudentLogin(exercise.getId(), user.getLogin());
}

if (participations.isEmpty()) {
return Optional.empty();
}
Expand Down
Loading

0 comments on commit 9d0afee

Please sign in to comment.