use of de.tum.in.www1.artemis.domain.metis.CourseWideContext in project ArTEMiS by ls1intum.
the class PostService method getAllPostsByCourseWideContext.
/**
* Checks course, user and post validity,
* retrieves all posts with a certain course-wide context by course id
* and ensures that sensitive information is filtered out
*
* @param courseId id of the course the post belongs to
* @param courseWideContext specific course-wide context to filter course get posts for
* @return list of posts for a certain course-wide context
*/
public List<Post> getAllPostsByCourseWideContext(Long courseId, CourseWideContext courseWideContext) {
final User user = userRepository.getUserWithGroupsAndAuthorities();
// checks
final Course course = preCheckUserAndCourse(user, courseId);
authorizationCheckService.checkHasAtLeastRoleInCourseElseThrow(Role.STUDENT, course, null);
// retrieve posts
List<Post> coursePosts = postRepository.findPostsForCourseWideContext(courseId, courseWideContext);
// protect sample solution, grading instructions, etc.
coursePosts.stream().map(Post::getExercise).filter(Objects::nonNull).forEach(Exercise::filterSensitiveInformation);
return coursePosts;
}
use of de.tum.in.www1.artemis.domain.metis.CourseWideContext in project ArTEMiS by ls1intum.
the class DatabaseUtilService method createBasicPosts.
private List<Post> createBasicPosts(Course courseContext, CourseWideContext[] courseWideContexts) {
List<Post> posts = new ArrayList<>();
for (int i = 0; i < 3; i++) {
Post postToAdd = createBasicPost(i);
postToAdd.setCourse(courseContext);
postToAdd.setCourseWideContext(courseWideContexts[i]);
postRepository.save(postToAdd);
posts.add(postToAdd);
}
return posts;
}
use of de.tum.in.www1.artemis.domain.metis.CourseWideContext in project Artemis by ls1intum.
the class DatabaseUtilService method createBasicPosts.
private List<Post> createBasicPosts(Course courseContext, CourseWideContext[] courseWideContexts) {
List<Post> posts = new ArrayList<>();
for (int i = 0; i < 3; i++) {
Post postToAdd = createBasicPost(i);
postToAdd.setCourse(courseContext);
postToAdd.setCourseWideContext(courseWideContexts[i]);
postRepository.save(postToAdd);
posts.add(postToAdd);
}
return posts;
}
Aggregations