Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Communication: Accept messaging code of conduct #7154

Merged
merged 102 commits into from
Oct 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
61b03c2
Add courseInformationSharingMessagingCodeOfConduct
nityanandaz Aug 30, 2023
c454445
Merge branch 'develop' into 7085/v2/agree-to-messages-code-of-conduct
nityanandaz Aug 30, 2023
05ad6cf
Merge branch 'develop' into 7085/v2/configure-messaging-code-of-conduct
nityanandaz Aug 30, 2023
6580464
Add top bar button
nityanandaz Aug 31, 2023
8e45899
Show code of conduct in dialog
nityanandaz Aug 31, 2023
b92a7f8
Add accept dialog
nityanandaz Sep 5, 2023
bc5fe9c
Merge branch 'develop' into 7085/v2/configure-messaging-code-of-conduct
nityanandaz Sep 5, 2023
93642b3
Make text area a markdown editor
nityanandaz Sep 5, 2023
1181441
Build back dialogs and review change requests
nityanandaz Sep 6, 2023
427566b
Supplement 11814414c99da6e51496b2a865e1782207b77ff1
nityanandaz Sep 6, 2023
c12f787
On review
nityanandaz Sep 7, 2023
8ed563f
Fix tests
nityanandaz Sep 7, 2023
be7c8e4
Add change at end
nityanandaz Sep 7, 2023
db38d8b
Add code of conduct to conversation resource
nityanandaz Sep 7, 2023
0fd1948
On review
nityanandaz Sep 7, 2023
d97f655
Persist code of conduct agreement
nityanandaz Sep 8, 2023
c021ede
Add UI
nityanandaz Sep 8, 2023
45ab4d3
Merge branch 'develop' into 7085/v2/accept-messaging-code-of-conduct
nityanandaz Sep 9, 2023
f679bb7
Localization
nityanandaz Sep 11, 2023
655cc75
Create CourseCodeOfConductService
nityanandaz Sep 11, 2023
9823ef7
Merge branch 'develop' into 7085/v2/accept-messaging-code-of-conduct
nityanandaz Sep 11, 2023
c44e965
Merge branch 'develop' into 7085/v2/configure-messaging-code-of-conduct
nityanandaz Sep 11, 2023
92fe251
Add change log at end
nityanandaz Sep 11, 2023
d3fd1c2
Create CourseCodeOfConductServiceTest
nityanandaz Sep 11, 2023
62b4a99
Merge branch '7085/v2/configure-messaging-code-of-conduct' into 7085/…
nityanandaz Sep 11, 2023
c9c46cd
On review
nityanandaz Sep 11, 2023
fadaaae
Add code of conduct template
nityanandaz Sep 12, 2023
b167d05
Add pipes
nityanandaz Sep 12, 2023
cf79d14
Fix localization
nityanandaz Sep 12, 2023
1bea86c
Prototype load template
nityanandaz Sep 12, 2023
94d59ca
Move getTemplateCodeOfCondcut
nityanandaz Sep 12, 2023
a3de4bc
Fix localization
nityanandaz Sep 13, 2023
b832bb4
List responsible contacts
nityanandaz Sep 13, 2023
8271a4b
On review
nityanandaz Sep 13, 2023
0abdef7
Update test
nityanandaz Sep 13, 2023
fd702fa
Fix test CourseConversationComponent by mockign component and observable
nityanandaz Sep 13, 2023
fdb08c3
Supplement and add id acceptCodeOfConductButton
nityanandaz Sep 13, 2023
d1578bc
Merge branch 'develop' into 7085/v2/accept-messaging-code-of-conduct
nityanandaz Sep 13, 2023
14cf321
Try fixing E2E by accepting code of conduct
nityanandaz Sep 13, 2023
e225a7f
Try fixing E2E by accepting code of conduct
nityanandaz Sep 13, 2023
bac6670
On Messages, check if code of conduct is accepted
nityanandaz Sep 13, 2023
75064e9
Merge branch 'develop' into 7085/v2/configure-messaging-code-of-conduct
nityanandaz Sep 13, 2023
22e69d8
Merge branch '7085/v2/configure-messaging-code-of-conduct' into 7085/…
nityanandaz Sep 13, 2023
2d60af2
Course Conversations Code Of Conduct Component
nityanandaz Sep 14, 2023
d620134
Merge branch 'develop' into 7085/v2/configure-messaging-code-of-conduct
nityanandaz Sep 14, 2023
d03bfc5
Merge branch '7085/v2/configure-messaging-code-of-conduct' into 7085/…
nityanandaz Sep 14, 2023
7c8712e
Fix TypeError:
nityanandaz Sep 14, 2023
77d8a5d
Should update course information sharing code of conduct
nityanandaz Sep 14, 2023
3944ee8
Fix TypeError:
nityanandaz Sep 14, 2023
fd4a97d
Test should display responsible contacts
nityanandaz Sep 14, 2023
01f78d0
Integration test code of conduct
nityanandaz Sep 14, 2023
d4931e8
Try fixing E2E by accepting code of conduct
nityanandaz Sep 15, 2023
fa91935
Increase coverage
nityanandaz Sep 15, 2023
b8cc36b
Rename checkIfCodeOfConductIsAccepted
nityanandaz Sep 15, 2023
b311631
Merge branch 'develop' into 7085/v2/accept-messaging-code-of-conduct
nityanandaz Sep 19, 2023
bf6f1c6
Revert "Try fixing E2E by accepting code of conduct"
nityanandaz Sep 19, 2023
583aca2
E2E: Accept code of conduct
nityanandaz Sep 19, 2023
c1da199
Confirm accept agreement
nityanandaz Sep 19, 2023
59b450f
Rebuild CourseCodeOfConductAgreement table
nityanandaz Sep 19, 2023
1a7e708
Migration and fix CourseCodeOfConductAgreementId member cannot be final
nityanandaz Sep 21, 2023
45fbbc7
Address comments:
nityanandaz Sep 21, 2023
4d662bf
Address comment:
nityanandaz Sep 21, 2023
d64851c
Introduced new responsible users endpoint. Refactor urls.
TimOrtel Sep 21, 2023
41d116e
Merge remote-tracking branch 'upstream/7085/v2/accept-messaging-code-…
TimOrtel Sep 21, 2023
93c03ba
Reset agreements on change and document DTO
nityanandaz Sep 21, 2023
a14964b
Address comment:
nityanandaz Sep 21, 2023
17828d7
Merge branch 'develop' into 7085/v2/accept-messaging-code-of-conduct
nityanandaz Sep 21, 2023
baeeaf3
Address comment:
nityanandaz Sep 21, 2023
dd6b50b
On review
nityanandaz Sep 21, 2023
643a02b
Merge branch 'develop' into 7085/v2/accept-messaging-code-of-conduct
nityanandaz Sep 22, 2023
66ea87f
Merge branch 'develop' into 7085/v2/accept-messaging-code-of-conduct
nityanandaz Sep 25, 2023
39053f6
Merge branch 'develop' into 7085/v2/accept-messaging-code-of-conduct
nityanandaz Sep 25, 2023
b84c4b1
Merge branch 'develop' into 7085/v2/accept-messaging-code-of-conduct
nityanandaz Sep 26, 2023
35bf2d4
Fix error; address comments:
nityanandaz Sep 27, 2023
0f80c15
Address comments:
nityanandaz Sep 27, 2023
61db092
Fix server tests
nityanandaz Sep 28, 2023
26f13ff
Fix client tests
nityanandaz Sep 28, 2023
550b25c
Add comment about responsible users
nityanandaz Oct 2, 2023
8d3f113
Merge branch 'develop' into 7085/v2/accept-messaging-code-of-conduct
nityanandaz Oct 2, 2023
7f2d9a1
Merge branch 'develop' into 7085/v2/accept-messaging-code-of-conduct
nityanandaz Oct 6, 2023
620a530
Shorten
nityanandaz Oct 6, 2023
034310c
Add curly braces
nityanandaz Oct 6, 2023
97e873e
Only accept in first test
nityanandaz Oct 6, 2023
4d9a0d6
add debug texts.
TimOrtel Oct 6, 2023
881c4ad
Fix deleting course
nityanandaz Oct 6, 2023
d69665d
Revert "add debug texts."
nityanandaz Oct 7, 2023
66cc395
Merge branch 'develop' into 7085/v2/accept-messaging-code-of-conduct
nityanandaz Oct 7, 2023
ccf73fd
An empty code of conduct is accepted
nityanandaz Oct 10, 2023
aa9be95
Show openCodeOfConduct if truthy
nityanandaz Oct 10, 2023
0eeadcc
Update tests
nityanandaz Oct 10, 2023
7bd1683
Merge branch 'develop' into 7085/v2/accept-messaging-code-of-conduct
nityanandaz Oct 10, 2023
a0647b9
Add code of conduct
nityanandaz Oct 10, 2023
baf2307
Update test
nityanandaz Oct 10, 2023
9db1e71
Merge branch 'develop' into 7085/v2/accept-messaging-code-of-conduct
nityanandaz Oct 10, 2023
52756cc
Test
nityanandaz Oct 10, 2023
1a507f9
Increase code coverage
nityanandaz Oct 11, 2023
5676e0d
Merge branch 'develop' into 7085/v2/accept-messaging-code-of-conduct
nityanandaz Oct 11, 2023
7a577f0
Fix private/protected access
nityanandaz Oct 11, 2023
897d783
Add time zone
nityanandaz Oct 11, 2023
5bf4860
Increase test coverage
nityanandaz Oct 11, 2023
bddf9b2
On review
nityanandaz Oct 11, 2023
705d9ea
Merge branch 'develop' into 7085/v2/accept-messaging-code-of-conduct
nityanandaz Oct 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package de.tum.in.www1.artemis.domain;

import java.util.Objects;

import javax.persistence.*;

Check warning on line 5 in src/main/java/de/tum/in/www1/artemis/domain/ConductAgreement.java

View check run for this annotation

Teamscale / teamscale-findings

src/main/java/de/tum/in/www1/artemis/domain/ConductAgreement.java#L5

Star import of `javax.persistence.*` should not be used https://teamscale.io/findings.html#details/GitHub-ls1intum-Artemis?t=7085%2Fv2%2Faccept-messaging-code-of-conduct%3AHEAD&id=73CBF151DD61434070A871688F7E4E3A

import com.fasterxml.jackson.annotation.JsonInclude;

/**
* A user's agreement of a course's code of conduct.
*/
@Entity
@Table(name = "conduct_agreement")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@IdClass(ConductAgreementId.class)
public class ConductAgreement {

@Id
@ManyToOne
@JoinColumn(name = "course_id")
private Course course;

@Id
@ManyToOne
@JoinColumn(name = "user_id")
private User user;

public Course getCourse() {
return course;
}

public void setCourse(Course course) {
this.course = course;
}

public User getUser() {
return user;
}

public void setUser(User user) {
this.user = user;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}

Check warning on line 51 in src/main/java/de/tum/in/www1/artemis/domain/ConductAgreement.java

View check run for this annotation

Teamscale / teamscale-findings

src/main/java/de/tum/in/www1/artemis/domain/ConductAgreement.java#L28-L51

Clone with 2 instances of length 13 https://teamscale.io/findings.html#details/GitHub-ls1intum-Artemis?t=7085%2Fv2%2Faccept-messaging-code-of-conduct%3AHEAD&id=DB384D0BEA5385E7067C11DBAAE05618
ConductAgreement that = (ConductAgreement) o;
return course.equals(that.course) && user.equals(that.user);
}

@Override
public int hashCode() {
return Objects.hash(course, user);
}

@Override
public String toString() {
return "ConductAgreement{" + "course=" + course + ", user=" + user + '}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package de.tum.in.www1.artemis.domain;

import java.io.Serializable;
import java.util.Objects;

/**
* The primary key for ConductAgreement
*/
public class ConductAgreementId implements Serializable {

private Long course;

private Long user;

ConductAgreementId(Long course, Long user) {
this.course = course;
this.user = user;
}

ConductAgreementId() {
// Needed for JPA
}

public Long getCourse() {
return course;
}

public void setCourse(Long course) {
this.course = course;
}

public Long getUser() {
return user;
}

public void setUser(Long user) {
this.user = user;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}

Check warning on line 47 in src/main/java/de/tum/in/www1/artemis/domain/ConductAgreementId.java

View check run for this annotation

Teamscale / teamscale-findings

src/main/java/de/tum/in/www1/artemis/domain/ConductAgreementId.java#L24-L47

Clone with 2 instances of length 13 https://teamscale.io/findings.html#details/GitHub-ls1intum-Artemis?t=7085%2Fv2%2Faccept-messaging-code-of-conduct%3AHEAD&id=BBE2B719848B9BE214787456E237AF76
ConductAgreementId that = (ConductAgreementId) o;
return course.equals(that.course) && user.equals(that.user);
}

@Override
public int hashCode() {
return Objects.hash(course, user);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package de.tum.in.www1.artemis.repository;

import java.util.Optional;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import de.tum.in.www1.artemis.domain.ConductAgreement;
import de.tum.in.www1.artemis.domain.ConductAgreementId;

/**
* Spring Data repository for the Code of Conduct Agreement entity.
*/
@Repository
public interface ConductAgreementRepository extends JpaRepository<ConductAgreement, ConductAgreementId> {

/**
* Find the user's agreement to a course's code of conduct.
*
* @param courseId the ID of the code of conduct's course
* @param userId the user's ID
* @return the user's agreement to the course's code of conduct
*/
Optional<ConductAgreement> findByCourseIdAndUserId(Long courseId, Long userId);

/**
* Delete all users' agreements to a course's code of conduct.
*
* @param courseId the ID of the code of conduct's course
*/
@Transactional // ok because of delete
@Modifying
void deleteByCourseId(Long courseId);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package de.tum.in.www1.artemis.service;

import org.springframework.stereotype.Service;

import de.tum.in.www1.artemis.domain.ConductAgreement;
import de.tum.in.www1.artemis.domain.Course;
import de.tum.in.www1.artemis.domain.User;
import de.tum.in.www1.artemis.repository.ConductAgreementRepository;

/**
* Service Implementation for managing a user's agreement to a course's code of conduct.
*/
@Service
public class ConductAgreementService {

private final ConductAgreementRepository conductAgreementRepository;

ConductAgreementService(ConductAgreementRepository conductAgreementRepository) {
this.conductAgreementRepository = conductAgreementRepository;
}

/**
* Fetches if a user agreed to a course's code of conduct.
*
* @param user the user in the course
* @param course the code of conduct's course
* @return if the user agreed to the course's code of conduct
*/
public boolean fetchUserAgreesToCodeOfConductInCourse(User user, Course course) {
var codeOfConduct = course.getCourseInformationSharingMessagingCodeOfConduct();
if (codeOfConduct == null || codeOfConduct.isEmpty()) {
return true;
}
return conductAgreementRepository.findByCourseIdAndUserId(course.getId(), user.getId()).isPresent();
}

/**
* A user agrees to a course's code of conduct.
*
* @param user the user in the course
* @param course the code of conduct's course
*/
public void setUserAgreesToCodeOfConductInCourse(User user, Course course) {
ConductAgreement conductAgreement = new ConductAgreement();
conductAgreement.setCourse(course);
conductAgreement.setUser(user);
conductAgreementRepository.save(conductAgreement);
}

/**
* Reset all agreements to a course's code of conduct.
*
* @param course the code of conduct's course
*/
public void resetUsersAgreeToCodeOfConductInCourse(Course course) {
conductAgreementRepository.deleteByCourseId(course.getId());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package de.tum.in.www1.artemis.service.dto;

/**
* A DTO representing a course's responsible user, i.e., a person to report misconduct to.
*/
public record ResponsibleUserDTO(String name, String email) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ public class CourseResource {

private final GradingScaleRepository gradingScaleRepository;

private final ConductAgreementService conductAgreementService;

@Value("${artemis.course-archives-path}")
private String courseArchivesDirPath;

Expand All @@ -115,7 +117,8 @@ public CourseResource(UserRepository userRepository, CourseService courseService
TutorParticipationRepository tutorParticipationRepository, SubmissionService submissionService, Optional<VcsUserManagementService> optionalVcsUserManagementService,
AssessmentDashboardService assessmentDashboardService, ExerciseRepository exerciseRepository, Optional<CIUserManagementService> optionalCiUserManagementService,
FileService fileService, TutorialGroupsConfigurationService tutorialGroupsConfigurationService, GradingScaleService gradingScaleService,
CourseScoreCalculationService courseScoreCalculationService, GradingScaleRepository gradingScaleRepository, LearningPathService learningPathService) {
CourseScoreCalculationService courseScoreCalculationService, GradingScaleRepository gradingScaleRepository, LearningPathService learningPathService,
ConductAgreementService conductAgreementService) {
this.courseService = courseService;
this.courseRepository = courseRepository;
this.exerciseService = exerciseService;
Expand All @@ -135,6 +138,7 @@ public CourseResource(UserRepository userRepository, CourseService courseService
this.courseScoreCalculationService = courseScoreCalculationService;
this.gradingScaleRepository = gradingScaleRepository;
this.learningPathService = learningPathService;
this.conductAgreementService = conductAgreementService;
}

/**
Expand Down Expand Up @@ -233,6 +237,10 @@ public ResponseEntity<Course> updateCourse(@PathVariable Long courseId, @Request
}
}

if (!Objects.equals(courseUpdate.getCourseInformationSharingMessagingCodeOfConduct(), existingCourse.getCourseInformationSharingMessagingCodeOfConduct())) {
conductAgreementService.resetUsersAgreeToCodeOfConductInCourse(existingCourse);
}

courseUpdate.setId(courseId); // Don't persist a wrong ID
Course result = courseRepository.save(courseUpdate);

Expand Down
14 changes: 14 additions & 0 deletions src/main/java/de/tum/in/www1/artemis/web/rest/FileResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,20 @@ public ResponseEntity<byte[]> getCourseIcon(@PathVariable Long courseId) {
return responseEntityForFilePath(filePathService.actualPathForPublicPath(URI.create(course.getCourseIcon())));
}

/**
* GET /files/templates/code-of-conduct : Get the Code of Conduct template
*
* @return The requested file, 403 if the logged-in user is not allowed to access it, or 404 if the file doesn't exist
*/
@GetMapping("files/templates/code-of-conduct")
@EnforceAtLeastInstructor
public ResponseEntity<byte[]> getCourseCodeOfConduct() throws IOException {
var templatePath = Path.of("templates", "codeofconduct", "README.md");
log.debug("REST request to get template : {}", templatePath);
var resource = resourceLoaderService.getResource(templatePath);
return ResponseEntity.ok(resource.getInputStream().readAllBytes());
}

/**
* GET /files/exam-user/signatures/:examUserId/:filename : Get the exam user signature
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package de.tum.in.www1.artemis.web.rest.metis.conversation;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.*;

Check warning on line 3 in src/main/java/de/tum/in/www1/artemis/web/rest/metis/conversation/ConversationResource.java

View check run for this annotation

Teamscale / teamscale-findings

src/main/java/de/tum/in/www1/artemis/web/rest/metis/conversation/ConversationResource.java#L3

Star import of `java.util.*` should not be used https://teamscale.io/findings.html#details/GitHub-ls1intum-Artemis?t=7085%2Fv2%2Faccept-messaging-code-of-conduct%3AHEAD&id=7AB748D3663E46FE52A1E7C9E5BB6F30

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -22,6 +20,8 @@
import de.tum.in.www1.artemis.security.Role;
import de.tum.in.www1.artemis.security.annotations.EnforceAtLeastStudent;
import de.tum.in.www1.artemis.service.AuthorizationCheckService;
import de.tum.in.www1.artemis.service.ConductAgreementService;
import de.tum.in.www1.artemis.service.dto.ResponsibleUserDTO;
import de.tum.in.www1.artemis.service.dto.UserPublicInfoDTO;
import de.tum.in.www1.artemis.service.metis.conversation.ConversationService;
import de.tum.in.www1.artemis.service.metis.conversation.ConversationService.ConversationMemberSearchFilters;
Expand All @@ -46,13 +46,17 @@

private final UserRepository userRepository;

private final ConductAgreementService conductAgreementService;

public ConversationResource(ConversationService conversationService, ChannelAuthorizationService channelAuthorizationService,
AuthorizationCheckService authorizationCheckService, UserRepository userRepository, CourseRepository courseRepository) {
AuthorizationCheckService authorizationCheckService, UserRepository userRepository, CourseRepository courseRepository,
ConductAgreementService conductAgreementService) {
super(courseRepository);
this.conversationService = conversationService;
this.channelAuthorizationService = channelAuthorizationService;
this.authorizationCheckService = authorizationCheckService;
this.userRepository = userRepository;
this.conductAgreementService = conductAgreementService;
}

/**
Expand Down Expand Up @@ -124,6 +128,61 @@
return ResponseEntity.ok(conversationService.userHasUnreadMessages(courseId, requestingUser));
}

/**
* GET /api/courses/:courseId/code-of-conduct/agreement : Checks if the user agrees to the code of conduct
*
* @param courseId the course's ID
* @return ResponseEntity with status 200 (Ok) and body is true if the user agreed to the course's code of conduct
*/
@GetMapping("/{courseId}/code-of-conduct/agreement")
@EnforceAtLeastStudent
public ResponseEntity<Boolean> isCodeOfConductAccepted(@PathVariable Long courseId) {
checkMessagingEnabledElseThrow(courseId);
var course = courseRepository.findByIdElseThrow(courseId);
var requestingUser = userRepository.getUserWithGroupsAndAuthorities();
authorizationCheckService.checkHasAtLeastRoleInCourseElseThrow(Role.STUDENT, course, requestingUser);
return ResponseEntity.ok(conductAgreementService.fetchUserAgreesToCodeOfConductInCourse(requestingUser, course));
}

/**
* PATCH /api/courses/:courseId/code-of-conduct/agreement : Accept the course's code of conduct
*
* @param courseId the course's ID
* @return ResponseEntity with status 200 (Ok)
*/
@PatchMapping("/{courseId}/code-of-conduct/agreement")
@EnforceAtLeastStudent
public ResponseEntity<Void> acceptCodeOfConduct(@PathVariable Long courseId) {
checkMessagingEnabledElseThrow(courseId);
var course = courseRepository.findByIdElseThrow(courseId);
var requestingUser = userRepository.getUserWithGroupsAndAuthorities();
authorizationCheckService.checkHasAtLeastRoleInCourseElseThrow(Role.STUDENT, course, requestingUser);
conductAgreementService.setUserAgreesToCodeOfConductInCourse(requestingUser, course);
return ResponseEntity.ok().build();
}

/**
* GET /api/courses/:courseId/code-of-conduct/responsible-users : Users responsible for the course
*
* @param courseId the course's ID
* @return ResponseEntity with the status 200 (Ok) and a list of users responsible for the course
*/
@GetMapping("/{courseId}/code-of-conduct/responsible-users")
@EnforceAtLeastStudent
public ResponseEntity<List<ResponsibleUserDTO>> getResponsibleUsersForCodeOfConduct(@PathVariable Long courseId) {
checkMessagingEnabledElseThrow(courseId);

var requestingUser = userRepository.getUserWithGroupsAndAuthorities();

var course = courseRepository.findByIdElseThrow(courseId);
authorizationCheckService.checkHasAtLeastRoleInCourseElseThrow(Role.STUDENT, course, requestingUser);

var responsibleUsers = userRepository.searchAllByLoginOrNameInGroups(Pageable.unpaged(), "", Set.of(course.getInstructorGroupName()))
.map((user) -> new ResponsibleUserDTO(user.getName(), user.getEmail())).toList();

return ResponseEntity.ok(responsibleUsers);
}

/**
* GET /api/courses/:courseId/conversations/:conversationId/members/search: Searches for members of a conversation
*
Expand Down
Loading
Loading