diff --git a/src/main/java/de/unistuttgart/iste/meitrex/common/dapr/DaprTopic.java b/src/main/java/de/unistuttgart/iste/meitrex/common/dapr/DaprTopic.java index 3a7f3ef..30d0867 100644 --- a/src/main/java/de/unistuttgart/iste/meitrex/common/dapr/DaprTopic.java +++ b/src/main/java/de/unistuttgart/iste/meitrex/common/dapr/DaprTopic.java @@ -3,6 +3,7 @@ public enum DaprTopic { COURSE_CHANGED("course-changed"), + CHAPTER_CHANGED("chapter-changed"), CONTENT_PROGRESSED("content-progressed"), @@ -45,7 +46,15 @@ public enum DaprTopic { ASKED_TUTOR_A_QUESTION("asked-tutor-a-question"), - SUBMISSION_COMPLETED("submission-completed"),; + SUBMISSION_COMPLETED("submission-completed"), + + USER_HEXAD_PLAYER_TYPE_SET("user-hexad-player-type-set"), + + REQUEST_HEXAD_PLAYER_TYPE("request-hexad-player-type"), + + REQUEST_USER_SKILL_LEVEL("request-user-skill-level"), + + STUDENT_CODE_SUBMITTED("student-code-submitted"),; private final String topic; diff --git a/src/main/java/de/unistuttgart/iste/meitrex/common/dapr/TopicPublisher.java b/src/main/java/de/unistuttgart/iste/meitrex/common/dapr/TopicPublisher.java index 9ecf441..5b26874 100644 --- a/src/main/java/de/unistuttgart/iste/meitrex/common/dapr/TopicPublisher.java +++ b/src/main/java/de/unistuttgart/iste/meitrex/common/dapr/TopicPublisher.java @@ -197,6 +197,40 @@ public void notifySubmissionCompleted(final SubmissionCompletedEvent event) { publishEvent(event, DaprTopic.SUBMISSION_COMPLETED); } + /** + * Method to notify when a user's Hexad player type is set, updated or requested for the first time + * @param event of the user's Hexad player type that was set + */ + public void notifyUserHexadPlayerTypeSet(final UserHexadPlayerTypeSetEvent event) { + publishEvent(event, DaprTopic.USER_HEXAD_PLAYER_TYPE_SET); + } + + /** + * Method to request a UserHexadPlayerTypeSetEvent for a specific user + * @param event containing the user ID for which the player type is requested + */ + public void notifyRequestHexadPlayerType(final RequestHexadPlayerTypeEvent event) { + publishEvent(event, DaprTopic.REQUEST_HEXAD_PLAYER_TYPE); + } + + /** + * Method to request the skill levels for a specific user + * @param event containing the user ID for which the skill levels are requested + */ + public void notifyRequestUserSkillLevel(final RequestUserSkillLevelEvent event) { + publishEvent(event, DaprTopic.REQUEST_USER_SKILL_LEVEL); + } + + /** + * Method to notify when a student submits code for an assignment. + * This is triggered when the assignment service loads a student's code from their repository. + * + * @param event containing the submission details including student, assignment, repository info, and files + */ + public void notifyStudentCodeSubmitted(final StudentCodeSubmittedEvent event) { + publishEvent(event, DaprTopic.STUDENT_CODE_SUBMITTED); + } + /** * Method to notify when a notification is build and should be sent to Notification Service * @param courseId of changed course diff --git a/src/main/java/de/unistuttgart/iste/meitrex/common/event/HexadPlayerType.java b/src/main/java/de/unistuttgart/iste/meitrex/common/event/HexadPlayerType.java new file mode 100644 index 0000000..8968108 --- /dev/null +++ b/src/main/java/de/unistuttgart/iste/meitrex/common/event/HexadPlayerType.java @@ -0,0 +1,13 @@ +package de.unistuttgart.iste.meitrex.common.event; + +/** + * Enum representing the Hexad player types used in gamification. + */ +public enum HexadPlayerType { + ACHIEVER, + PLAYER, + SOCIALISER, + FREE_SPIRIT, + PHILANTHROPIST, + DISRUPTOR +} diff --git a/src/main/java/de/unistuttgart/iste/meitrex/common/event/RequestHexadPlayerTypeEvent.java b/src/main/java/de/unistuttgart/iste/meitrex/common/event/RequestHexadPlayerTypeEvent.java new file mode 100644 index 0000000..4a7955a --- /dev/null +++ b/src/main/java/de/unistuttgart/iste/meitrex/common/event/RequestHexadPlayerTypeEvent.java @@ -0,0 +1,25 @@ +package de.unistuttgart.iste.meitrex.common.event; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.UUID; + +import jakarta.validation.constraints.NotNull; + +/** + * Event to request the Hexad player type for a specific user. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class RequestHexadPlayerTypeEvent { + /** + * The ID of the user whose Hexad player type is being requested. + */ + @NotNull + private UUID userId; +} diff --git a/src/main/java/de/unistuttgart/iste/meitrex/common/event/RequestUserSkillLevelEvent.java b/src/main/java/de/unistuttgart/iste/meitrex/common/event/RequestUserSkillLevelEvent.java new file mode 100644 index 0000000..c02ff1b --- /dev/null +++ b/src/main/java/de/unistuttgart/iste/meitrex/common/event/RequestUserSkillLevelEvent.java @@ -0,0 +1,25 @@ +package de.unistuttgart.iste.meitrex.common.event; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.UUID; + +import jakarta.validation.constraints.NotNull; + +/** + * Event to request the skill levels for a specific user. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class RequestUserSkillLevelEvent { + /** + * The ID of the user whose skill levels are being requested. + */ + @NotNull + private UUID userId; +} diff --git a/src/main/java/de/unistuttgart/iste/meitrex/common/event/StudentCodeSubmittedEvent.java b/src/main/java/de/unistuttgart/iste/meitrex/common/event/StudentCodeSubmittedEvent.java new file mode 100644 index 0000000..7ce34af --- /dev/null +++ b/src/main/java/de/unistuttgart/iste/meitrex/common/event/StudentCodeSubmittedEvent.java @@ -0,0 +1,67 @@ +package de.unistuttgart.iste.meitrex.common.event; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.OffsetDateTime; +import java.util.Map; +import java.util.UUID; + +/** + * Event published when a student submits code for an assignment. + * + * This event is triggered by the assignment service when it loads and processes + * a student's code submission from their repository. The event contains information + * about the submission including the repository details, commit information, and + * the submitted files. + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class StudentCodeSubmittedEvent { + + /** + * ID of the student who submitted the code. + */ + private UUID studentId; + + /** + * ID of the assignment for which the code was submitted. + */ + private UUID assignmentId; + + /** + * ID of the course the assignment belongs to. + */ + private UUID courseId; + + /** + * URL of the student's repository containing the submitted code. + */ + private String repositoryUrl; + + /** + * SHA hash of the commit that was submitted. + */ + private String commitSha; + + /** + * Timestamp when the commit was created. + */ + private OffsetDateTime commitTimestamp; + + /** + * Map of file paths to their contents from the submission. + * The key is the file path relative to the repository root, + * and the value is the file content. + */ + private Map files; + + /** + * Name of the branch from which the code was submitted. + */ + private String branch; +} diff --git a/src/main/java/de/unistuttgart/iste/meitrex/common/event/TutorCategory.java b/src/main/java/de/unistuttgart/iste/meitrex/common/event/TutorCategory.java index 40e08a0..38e783c 100644 --- a/src/main/java/de/unistuttgart/iste/meitrex/common/event/TutorCategory.java +++ b/src/main/java/de/unistuttgart/iste/meitrex/common/event/TutorCategory.java @@ -5,5 +5,6 @@ public enum TutorCategory { LECTURE, UNRECOGNIZABLE, OTHER, - ERROR + ERROR, + CODE_FEEDBACK } diff --git a/src/main/java/de/unistuttgart/iste/meitrex/common/event/UserHexadPlayerTypeSetEvent.java b/src/main/java/de/unistuttgart/iste/meitrex/common/event/UserHexadPlayerTypeSetEvent.java new file mode 100644 index 0000000..08effbf --- /dev/null +++ b/src/main/java/de/unistuttgart/iste/meitrex/common/event/UserHexadPlayerTypeSetEvent.java @@ -0,0 +1,39 @@ +package de.unistuttgart.iste.meitrex.common.event; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Map; +import java.util.UUID; + +import jakarta.validation.constraints.NotNull; + +/** + * Event sent by the gamification service when a user's Hexad player type is set or updated. + * Additionally send if the user's player type is requested for the first time + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class UserHexadPlayerTypeSetEvent { + /** + * The ID of the user whose Hexad player type was set. + */ + @NotNull + private UUID userId; + + /** + * The primary Hexad player type that was set for the user. + */ + @NotNull + private HexadPlayerType primaryPlayerType; + + /** + * Maps each HexadPlayerType to its score. + */ + @NotNull + private Map playerTypePercentages; +}