Skip to content

Commit

Permalink
Merge branch 'develop' into feature/localVC/support-multiple-SSH-keys
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonEntholzer authored Nov 27, 2024
2 parents 8408ab7 + 4eaba4e commit f69a283
Show file tree
Hide file tree
Showing 138 changed files with 4,782 additions and 175 deletions.
20 changes: 20 additions & 0 deletions src/main/java/de/tum/cit/aet/artemis/assessment/domain/Result.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,12 @@ public class Result extends DomainObject implements Comparable<Result> {
@JsonView(QuizView.Before.class)
private List<Feedback> feedbacks = new ArrayList<>();

/**
* @deprecated: Will be removed for 8.0, please use submission.participation instead
*/
@ManyToOne
@JsonView(QuizView.Before.class)
@Deprecated(since = "7.7", forRemoval = true)
private Participation participation;

@ManyToOne(fetch = FetchType.LAZY)
Expand Down Expand Up @@ -385,15 +389,31 @@ private boolean feedbackTextHasChanged(String existingText, String newText) {
return !Objects.equals(existingText, newText);
}

/**
* @deprecated: Will be removed for 8.0, please use submission.participation instead
* @return the participation
*/
@Deprecated(since = "7.7", forRemoval = true)
public Participation getParticipation() {
return participation;
}

/**
* @deprecated: Will be removed for 8.0, please use submission.participation instead
* @param participation the participation to set
* @return the result
*/
@Deprecated(since = "7.7", forRemoval = true)
public Result participation(Participation participation) {
this.participation = participation;
return this;
}

/**
* @deprecated: Will be removed for 8.0, please use submission.participation instead
* @param participation the participation to set
*/
@Deprecated(since = "7.7", forRemoval = true)
public void setParticipation(Participation participation) {
this.participation = participation;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -692,4 +692,15 @@ public void deleteLongFeedback(List<Feedback> feedbackList, Result result) {
List<Feedback> feedbacks = new ArrayList<>(feedbackList);
result.updateAllFeedbackItems(feedbacks, true);
}

/**
* Retrieves the number of students affected by a specific feedback detail text for a given exercise.
*
* @param exerciseId for which the affected student count is requested.
* @param detailText used to filter affected students.
* @return the total number of distinct students affected by the feedback detail text.
*/
public long getAffectedStudentCountByFeedbackDetailText(long exerciseId, String detailText) {
return studentParticipationRepository.countAffectedStudentsByFeedbackDetailText(exerciseId, detailText);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -373,4 +373,18 @@ public ResponseEntity<Page<FeedbackAffectedStudentDTO>> getAffectedStudentsWithF

return ResponseEntity.ok(participation);
}

/**
* GET /exercises/{exerciseId}/feedback-detail/affected-students : Retrieves the count of students affected by a specific feedback detail text.
*
* @param exerciseId The ID of the exercise for which affected students are counted.
* @param detailText The feedback detail text to filter by.
* @return A {@link ResponseEntity} containing the count of affected students.
*/
@GetMapping("exercises/{exerciseId}/feedback-detail/affected-students")
@EnforceAtLeastEditorInExercise
public ResponseEntity<Long> countAffectedStudentsByFeedbackDetailText(@PathVariable long exerciseId, @RequestParam("detailText") String detailText) {
long affectedStudentCount = resultService.getAffectedStudentCountByFeedbackDetailText(exerciseId, detailText);
return ResponseEntity.ok(affectedStudentCount);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,9 @@ private BuildAgentInformation getUpdatedLocalBuildAgentInformation(BuildJobQueue
}

private List<BuildJobQueueItem> getProcessingJobsOfNode(String memberAddress) {
return processingJobs.values().stream().filter(job -> Objects.equals(job.buildAgent().memberAddress(), memberAddress)).toList();
// NOTE: we should not use streams with IMap, because it can be unstable, when many items are added at the same time and there is a slow network condition
List<BuildJobQueueItem> processingJobsList = new ArrayList<>(processingJobs.values());
return processingJobsList.stream().filter(job -> Objects.equals(job.buildAgent().memberAddress(), memberAddress)).toList();
}

private void removeOfflineNodes() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import jakarta.persistence.Transient;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.SQLRestriction;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonIncludeProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

import de.tum.cit.aet.artemis.communication.domain.conversation.Conversation;
import de.tum.cit.aet.artemis.core.domain.Course;

/**
Expand All @@ -35,10 +39,20 @@ public class AnswerPost extends Posting {
@OneToMany(mappedBy = "answerPost", cascade = CascadeType.REMOVE, orphanRemoval = true, fetch = FetchType.EAGER)
private Set<Reaction> reactions = new HashSet<>();

/***
* The value 1 represents an answer post, given by the enum {{@link PostingType}}
*/
@OneToMany(mappedBy = "postId", cascade = CascadeType.REMOVE, orphanRemoval = true, fetch = FetchType.LAZY)
@SQLRestriction("post_type = 1")
private Set<SavedPost> savedPosts = new HashSet<>();

@ManyToOne
@JsonIncludeProperties({ "id", "exercise", "lecture", "course", "courseWideContext", "conversation", "author" })
private Post post;

@Transient
private boolean isSaved = false;

@JsonProperty("resolvesPost")
public Boolean doesResolvePost() {
return resolvesPost;
Expand Down Expand Up @@ -76,6 +90,25 @@ public void setPost(Post post) {
this.post = post;
}

@JsonIgnore
public Set<SavedPost> getSavedPosts() {
return savedPosts;
}

@JsonProperty("isSaved")
public boolean getIsSaved() {
return isSaved;
}

public void setIsSaved(boolean isSaved) {
this.isSaved = isSaved;
}

@JsonIgnore
public Conversation getConversation() {
return getPost().getConversation();
}

/**
* Helper method to extract the course an AnswerPost belongs to, which is found in different locations based on the parent Post's context
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@
import jakarta.persistence.OneToMany;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;
import jakarta.persistence.Transient;
import jakarta.validation.constraints.Size;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.SQLRestriction;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonIncludeProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

import de.tum.cit.aet.artemis.communication.domain.conversation.Conversation;
import de.tum.cit.aet.artemis.core.domain.Course;
Expand Down Expand Up @@ -54,6 +57,13 @@ public class Post extends Posting {
@OneToMany(mappedBy = "post", cascade = CascadeType.REMOVE, orphanRemoval = true, fetch = FetchType.EAGER)
private Set<AnswerPost> answers = new HashSet<>();

/***
* The value 0 represents a post, given by the enum {{@link PostingType}}
*/
@OneToMany(mappedBy = "postId", cascade = CascadeType.REMOVE, orphanRemoval = true, fetch = FetchType.LAZY)
@SQLRestriction("post_type = 0")
private Set<SavedPost> savedPosts = new HashSet<>();

@ElementCollection(fetch = FetchType.EAGER)
@CollectionTable(name = "post_tag", joinColumns = @JoinColumn(name = "post_id"))
@Column(name = "text")
Expand Down Expand Up @@ -96,6 +106,9 @@ public class Post extends Posting {
@Column(name = "vote_count")
private int voteCount;

@Transient
private boolean isSaved = false;

public Post() {
}

Expand Down Expand Up @@ -222,6 +235,20 @@ public void setVoteCount(Integer voteCount) {
this.voteCount = voteCount != null ? voteCount : 0;
}

@JsonIgnore
public Set<SavedPost> getSavedPosts() {
return savedPosts;
}

@JsonProperty("isSaved")
public boolean getIsSaved() {
return isSaved;
}

public void setIsSaved(boolean isSaved) {
this.isSaved = isSaved;
}

/**
* Helper method to extract the course a Post belongs to, which is found in different locations based on the Post's context
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.fasterxml.jackson.annotation.JsonIncludeProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

import de.tum.cit.aet.artemis.communication.domain.conversation.Conversation;
import de.tum.cit.aet.artemis.core.domain.Course;
import de.tum.cit.aet.artemis.core.domain.DomainObject;
import de.tum.cit.aet.artemis.core.domain.User;
Expand Down Expand Up @@ -118,4 +119,6 @@ public void setAuthorRole(UserRole authorRole) {

@Transient
public abstract Course getCoursePostingBelongsTo();

public abstract Conversation getConversation();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package de.tum.cit.aet.artemis.communication.domain;

import java.util.Arrays;

public enum PostingType {

POST((short) 0), ANSWER((short) 1);

private final short databaseKey;

PostingType(short databaseKey) {
this.databaseKey = databaseKey;
}

public short getDatabaseKey() {
return databaseKey;
}

public static PostingType fromDatabaseKey(short databaseKey) {
return Arrays.stream(PostingType.values()).filter(type -> type.getDatabaseKey() == databaseKey).findFirst()
.orElseThrow(() -> new IllegalArgumentException("Unknown database key: " + databaseKey));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package de.tum.cit.aet.artemis.communication.domain;

import java.time.ZonedDateTime;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Enumerated;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;

import de.tum.cit.aet.artemis.core.domain.DomainObject;
import de.tum.cit.aet.artemis.core.domain.User;

@Entity
@Table(name = "saved_post")
public class SavedPost extends DomainObject {

@ManyToOne
@JoinColumn(name = "user_id", nullable = false)
private User user;

@Column(name = "post_id", nullable = false)
private Long postId;

@Enumerated
@Column(name = "post_type", nullable = false)
private PostingType postType;

@Enumerated
@Column(name = "status", nullable = false)
private SavedPostStatus status;

@Column(name = "completed_at")
private ZonedDateTime completedAt;

public SavedPost() {
}

public SavedPost(User user, Long postId, PostingType postType, SavedPostStatus status, ZonedDateTime completedAt) {
this.user = user;
this.postId = postId;
this.postType = postType;
this.status = status;
this.completedAt = completedAt;
}

public Long getPostId() {
return postId;
}

public void setPostId(Long postId) {
this.postId = postId;
}

public void setStatus(SavedPostStatus status) {
this.status = status;
}

public User getUser() {
return user;
}

public SavedPostStatus getStatus() {
return status;
}

public void setCompletedAt(ZonedDateTime completedAt) {
this.completedAt = completedAt;
}

public void setPostType(PostingType postType) {
this.postType = postType;
}

public PostingType getPostType() {
return postType;
}

public ZonedDateTime getCompletedAt() {
return completedAt;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package de.tum.cit.aet.artemis.communication.domain;

import java.util.Arrays;

public enum SavedPostStatus {

IN_PROGRESS((short) 0), COMPLETED((short) 1), ARCHIVED((short) 2);

private final short databaseKey;

SavedPostStatus(short databaseKey) {
this.databaseKey = databaseKey;
}

public short getDatabaseKey() {
return databaseKey;
}

public static SavedPostStatus fromDatabaseKey(short databaseKey) {
return Arrays.stream(SavedPostStatus.values()).filter(type -> type.getDatabaseKey() == databaseKey).findFirst()
.orElseThrow(() -> new IllegalArgumentException("Unknown database key: " + databaseKey));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package de.tum.cit.aet.artemis.communication.dto;

import com.fasterxml.jackson.annotation.JsonInclude;

import de.tum.cit.aet.artemis.core.domain.User;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
public record AuthorDTO(Long id, String name, String imageUrl) {

public AuthorDTO(User user) {
this(user.getId(), user.getName(), user.getImageUrl());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package de.tum.cit.aet.artemis.communication.dto;

import com.fasterxml.jackson.annotation.JsonInclude;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
public record FeedbackChannelRequestDTO(ChannelDTO channel, String feedbackDetailText) {
}
Loading

0 comments on commit f69a283

Please sign in to comment.