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: Allow users to search for answer post in course wide channels #9616

Closed
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
cb29b7b
Enable references for FAQ's
cremertim Oct 22, 2024
0660599
sort faqs by id
cremertim Oct 22, 2024
f91168d
Scroll to FAQ on reference
cremertim Oct 23, 2024
61ea920
Fixed tests
cremertim Oct 23, 2024
dc8c74d
Fixed tests
cremertim Oct 23, 2024
6518cf5
Added FAQ's to initial CourseOverviewComponents
cremertim Oct 23, 2024
a3f8ba3
Add test for postingContent
cremertim Oct 23, 2024
22706e3
Merge branch 'develop' into feature/communication/reference-faq-in-me…
cremertim Oct 23, 2024
c617c83
Add tests
cremertim Oct 23, 2024
f7683a0
Adressed coderabit
cremertim Oct 23, 2024
54fc115
Added testcases
cremertim Oct 24, 2024
86c9383
Merge branch 'develop' into feature/communication/reference-faq-in-me…
cremertim Oct 24, 2024
f1f99f9
You should only be able to reference accepted FAQs
cremertim Oct 24, 2024
5860f85
Removed uneccessary attribute
cremertim Oct 24, 2024
fe73a9a
Resolved failing test
cremertim Oct 24, 2024
b999232
Margin to make ui cleaner
cremertim Oct 24, 2024
81857de
Remove console error
cremertim Oct 24, 2024
436aa5a
fixed test
cremertim Oct 24, 2024
2c00600
Changes from patrik
cremertim Oct 24, 2024
0f42275
render selected faq
cremertim Oct 24, 2024
6885814
fixed query issues with ?
cremertim Oct 24, 2024
ea0d825
Merge branch 'develop' into feature/communication/reference-faq-in-me…
cremertim Oct 25, 2024
7566bc6
Merge branch 'develop' into feature/communication/reference-faq-in-me…
cremertim Oct 25, 2024
509eb8b
Merge branch 'develop' into feature/communication/reference-faq-in-me…
cremertim Oct 26, 2024
23d9633
resolved merge conflict
cremertim Oct 26, 2024
6f53284
fixed style
cremertim Oct 26, 2024
89fe6a2
fixed failing tests
cremertim Oct 27, 2024
7b0876d
fixed error with ( the title
cremertim Oct 28, 2024
47c6d5d
Changed search to apply on answers and on private chats
cremertim Oct 28, 2024
45befc9
Merge branch 'develop' into feature/communication/reference-faq-in-me…
cremertim Oct 28, 2024
c9f2dbd
Merge branch 'develop' into feature/communication/add-answers-to-post…
cremertim Oct 28, 2024
f1562b2
Fixed seach to have no errors
cremertim Oct 28, 2024
dbe5e5f
Added references to non-channel posts
cremertim Oct 28, 2024
c45068b
Fixed tests, fixed string insertion
cremertim Oct 28, 2024
ffbac97
remove logging
cremertim Oct 28, 2024
676d211
Fixed search to only display course wide posts. Also did fix own filter
cremertim Oct 29, 2024
6234eab
Changes from johannes
cremertim Oct 29, 2024
86594a3
Merge branch 'develop' into feature/communication/reference-faq-in-me…
cremertim Oct 29, 2024
17755b8
Merge remote-tracking branch 'origin/feature/communication/reference-…
cremertim Oct 29, 2024
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
Expand Up @@ -19,7 +19,6 @@
import de.tum.cit.aet.artemis.communication.domain.PostSortCriterion;
import de.tum.cit.aet.artemis.communication.domain.Post_;
import de.tum.cit.aet.artemis.communication.domain.Reaction_;
import de.tum.cit.aet.artemis.communication.domain.conversation.Channel;
import de.tum.cit.aet.artemis.communication.domain.conversation.Channel_;
import de.tum.cit.aet.artemis.communication.domain.conversation.Conversation_;
import de.tum.cit.aet.artemis.core.domain.Course_;
Expand Down Expand Up @@ -61,7 +60,10 @@ else if (searchText.startsWith("#") && StringUtils.isNumeric(searchText.substrin

Predicate searchInMessageContent = criteriaBuilder.like(criteriaBuilder.lower(root.get(Post_.CONTENT)), searchTextLiteral);

return criteriaBuilder.and(searchInMessageContent);
Join<Post, AnswerPost> answersJoin = root.join(Post_.ANSWERS, JoinType.LEFT);
Predicate searchInAnswerContent = criteriaBuilder.like(criteriaBuilder.lower(answersJoin.get(AnswerPost_.CONTENT)), searchTextLiteral);

return criteriaBuilder.or(searchInMessageContent, searchInAnswerContent);
}
});
}
Expand Down Expand Up @@ -93,11 +95,7 @@ public static Specification<Post> getCourseWideChannelsSpecification(Long course
return (root, query, criteriaBuilder) -> {
final var conversationJoin = root.join(Post_.conversation, JoinType.LEFT);
final var isInCoursePredicate = criteriaBuilder.equal(conversationJoin.get(Channel_.COURSE).get(Course_.ID), courseId);
final var isCourseWidePredicate = criteriaBuilder.isTrue(conversationJoin.get(Channel_.IS_COURSE_WIDE));
// make sure we only fetch channels (which are sub types of conversations)
// this avoids the creation of sub queries
final var isChannelPredicate = criteriaBuilder.equal(conversationJoin.type(), criteriaBuilder.literal(Channel.class));
return criteriaBuilder.and(isInCoursePredicate, isCourseWidePredicate, isChannelPredicate);
return criteriaBuilder.and(isInCoursePredicate);
};
}

Expand Down
19 changes: 16 additions & 3 deletions src/main/webapp/app/shared/metis/metis.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { User } from 'app/core/user/user.model';
import { AccountService } from 'app/core/auth/account.service';
import { Course } from 'app/entities/course.model';
import { Posting } from 'app/entities/metis/posting.model';
import { Injectable, OnDestroy } from '@angular/core';
import { Injectable, OnDestroy, inject } from '@angular/core';
import { AnswerPostService } from 'app/shared/metis/answer-post.service';
import { AnswerPost } from 'app/entities/metis/answer-post.model';
import { Reaction } from 'app/entities/metis/reaction.model';
Expand All @@ -27,10 +27,11 @@ import { JhiWebsocketService } from 'app/core/websocket/websocket.service';
import { MetisPostDTO } from 'app/entities/metis/metis-post-dto.model';
import dayjs from 'dayjs/esm';
import { PlagiarismCase } from 'app/exercises/shared/plagiarism/types/PlagiarismCase';
import { Conversation, ConversationDTO } from 'app/entities/metis/conversation/conversation.model';
import { Conversation, ConversationDTO, ConversationType } from 'app/entities/metis/conversation/conversation.model';
import { ChannelDTO, ChannelSubType, getAsChannelDTO } from 'app/entities/metis/conversation/channel.model';
import { ConversationService } from 'app/shared/metis/conversations/conversation.service';
import { NotificationService } from 'app/shared/notification/notification.service';
import { TranslateService } from '@ngx-translate/core';

@Injectable()
export class MetisService implements OnDestroy {
Expand All @@ -49,6 +50,7 @@ export class MetisService implements OnDestroy {
private subscriptionChannel?: string;

private courseWideTopicSubscription: Subscription;
private translateService = inject(TranslateService);
cremertim marked this conversation as resolved.
Show resolved Hide resolved

constructor(
protected postService: PostService,
Expand Down Expand Up @@ -516,13 +518,24 @@ export class MetisService implements OnDestroy {
let queryParams = undefined;
let displayName = '';
if (post.conversation) {
displayName = getAsChannelDTO(post.conversation)?.name ?? '';
displayName = this.getDisplayName(post)!;
routerLinkComponents = ['/courses', this.courseId, 'communication'];
queryParams = { conversationId: post.conversation.id! };
}
return { routerLinkComponents, displayName, queryParams };
}

getDisplayName(post: Post) {
switch (post.conversation!.type) {
case ConversationType.CHANNEL:
return getAsChannelDTO(post.conversation)?.name ?? '';
case ConversationType.ONE_TO_ONE:
return this.translateService.instant('artemisApp.conversationsLayout.conversationSelectionSideBar.groupChat');
case ConversationType.GROUP_CHAT:
return this.translateService.instant('artemisApp.conversationsLayout.conversationSelectionSideBar.directMessage');
}
}

/**
* Creates (and updates) the websocket channel for receiving messages in dedicated channels;
* On message reception, subsequent actions for updating the dependent components are defined based on the MetisPostAction encapsulated in the MetisPostDTO (message payload);
Expand Down
2 changes: 2 additions & 0 deletions src/main/webapp/i18n/de/conversation.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@
"examChannels": "Klausuren",
"createChannel": "Kanal erstellen",
"browseChannels": "Kanäle durchsuchen",
"groupChat": "Gruppenchat",
"groupChats": "Gruppenchats",
"directMessage": "Direktnachricht",
"directMessages": "Direktnachrichten",
"filterConversationPlaceholder": "Konversationen filtern",
"sideBarSection": {
Expand Down
2 changes: 2 additions & 0 deletions src/main/webapp/i18n/en/conversation.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@
"examChannels": "Exams",
"createChannel": "Create channel",
"browseChannels": "Browse channels",
"groupChat": "Group Chat",
"groupChats": "Group Chats",
"directMessage": "Direct Message",
"directMessages": "Direct Messages",
"filterConversationPlaceholder": "Filter conversations",
"sideBarSection": {
Expand Down
Loading