-
Notifications
You must be signed in to change notification settings - Fork 297
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
: Only show accepted categories of accepted FAQs
#9591
Communication
: Only show accepted categories of accepted FAQs
#9591
Conversation
WalkthroughThe pull request introduces enhancements to the FAQ functionality by adding new query methods in the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 11
🧹 Outside diff range and nitpick comments (10)
src/main/java/de/tum/cit/aet/artemis/communication/repository/FaqRepository.java (1)
34-39
: Consider adding database indexes and documentation.For optimal query performance:
- Consider adding database indexes on frequently queried columns (
course.id
,faqState
).- Add Javadoc to document the query's purpose and expected behavior, especially for complex queries like this one.
src/main/webapp/app/faq/faq.service.ts (2)
157-161
: Add return type annotation and documentation.Consider adding TypeScript return type annotation and JSDoc documentation for consistency with other methods:
+ /** + * Retrieves FAQ categories for a specific course filtered by FAQ state + * @param courseId - The ID of the course + * @param faqState - The state to filter categories by + * @returns Observable of FAQ categories response + */ - findAllCategoriesByCourseIdAndCategory(courseId: number, faqState: FaqState) { + findAllCategoriesByCourseIdAndCategory(courseId: number, faqState: FaqState): Observable<HttpResponse<string[]>> {
157-161
: Consider subscription management.When consuming this Observable in components, ensure proper subscription management to prevent memory leaks. Consider using either:
- The async pipe in templates
- Implementing ngOnDestroy to unsubscribe
- Using takeUntil or other cleanup operators
src/test/javascript/spec/service/faq.service.spec.ts (2)
178-183
: Enhance test coverage with more comprehensive test data.The test only validates a single category scenario. Consider adding test cases for:
- Multiple categories
- Empty categories array
- Categories with different states
it('should find all categories by courseId and faqState', () => { - const category = { - color: '#6ae8ac', - category: 'category1', - } as FaqCategory; - const returnedFromService = { categories: [JSON.stringify(category)] }; + const categories = [ + { color: '#6ae8ac', category: 'category1' } as FaqCategory, + { color: '#ff0000', category: 'category2' } as FaqCategory + ]; + const returnedFromService = { + categories: categories.map(cat => JSON.stringify(cat)) + };
194-195
: Use more specific assertions.The current assertion only checks for equality. Consider adding more specific assertions following the coding guidelines.
req.flush(returnedFromService); - expect(expectedResult.body).toEqual(expected); + expect(expectedResult.body).toContainEntries(expected); + expect(req.request.method).toBe('GET'); + expect(req.request.url).toBe(`api/courses/${courseId}/faq-categories/${faqState}`);src/test/java/de/tum/cit/aet/artemis/communication/FaqIntegrationTest.java (2)
183-187
: Enhance assertion coverage and remove redundant test.The test verifies only the size of returned FAQs. Consider:
- Adding assertions for content equality
- Removing the redundant test method
getFaq_ShouldGetFaqByCourseId
(lines 199-202) as it tests the same functionality@Test @WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR") void getFaq_InstructorsShouldGetAllFaqByCourseId() throws Exception { Set<Faq> faqs = faqRepository.findAllByCourseId(this.course1.getId()); Set<FaqDTO> returnedFaqs = request.get("/api/courses/" + course1.getId() + "/faqs", HttpStatus.OK, Set.class); assertThat(returnedFaqs).hasSize(faqs.size()); + assertThat(returnedFaqs).containsExactlyInAnyOrderElementsOf(faqs); }
Line range hint
183-228
: Enhance test coverage with additional scenarios.Consider adding the following test cases to improve coverage:
- Test behavior when no FAQs exist
- Test with empty categories
- Test with special characters in FAQ titles/answers
- Test pagination if supported
- Test error cases (e.g., invalid course ID)
Also, consider organizing related tests using nested test classes (JUnit 5
@Nested
) to group:
- Student access tests
- Instructor access tests
- State-specific tests
src/main/java/de/tum/cit/aet/artemis/communication/web/FaqResource.java (3)
208-208
: Rename variablefaqs
tocategories
for clarityThe variable
faqs
holds a set of FAQ categories (Set<String>
). Renaming it tocategories
improves readability and accurately reflects its content.Apply this change:
- Set<String> faqs = faqRepository.findAllCategoriesByCourseId(courseId); + Set<String> categories = faqRepository.findAllCategoriesByCourseId(courseId);Also, update the variable usage in the return statement:
- return ResponseEntity.ok().body(faqs); + return ResponseEntity.ok().body(categories);
216-216
: Rename variablefaqs
tocategories
for claritySimilar to the previous method, the variable
faqs
here represents a set of category names. Renaming it tocategories
enhances clarity.Apply this change:
- Set<String> faqs = faqRepository.findAllCategoriesByCourseIdAndState(courseId, faqState); + Set<String> categories = faqRepository.findAllCategoriesByCourseIdAndState(courseId, faqState);Also, update the variable usage in the return statement:
- return ResponseEntity.ok().body(faqs); + return ResponseEntity.ok().body(categories);
224-224
: Fix typo in JavaDoc commentIn the JavaDoc comment for
checkRoleForCourse
, correct the typo "atleast" to "at least".Apply this change:
- * @throws AccessForbiddenException if the user is not atleast role + * @throws AccessForbiddenException if the user is not at least role
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (7)
- src/main/java/de/tum/cit/aet/artemis/communication/repository/FaqRepository.java (1 hunks)
- src/main/java/de/tum/cit/aet/artemis/communication/web/FaqResource.java (6 hunks)
- src/main/webapp/app/faq/faq.service.ts (1 hunks)
- src/main/webapp/app/faq/faq.utils.ts (1 hunks)
- src/main/webapp/app/overview/course-faq/course-faq.component.ts (2 hunks)
- src/test/java/de/tum/cit/aet/artemis/communication/FaqIntegrationTest.java (2 hunks)
- src/test/javascript/spec/service/faq.service.spec.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
src/main/java/de/tum/cit/aet/artemis/communication/repository/FaqRepository.java (1)
Pattern
src/main/java/**/*.java
: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_importssrc/main/java/de/tum/cit/aet/artemis/communication/web/FaqResource.java (1)
Pattern
src/main/java/**/*.java
: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_importssrc/main/webapp/app/faq/faq.service.ts (1)
src/main/webapp/app/faq/faq.utils.ts (1)
src/main/webapp/app/overview/course-faq/course-faq.component.ts (1)
src/test/java/de/tum/cit/aet/artemis/communication/FaqIntegrationTest.java (1)
Pattern
src/test/java/**/*.java
: test_naming: descriptive; test_size: small_specific; fixed_data: true; junit5_features: true; assert_use: assertThat; assert_specificity: true; archunit_use: enforce_package_rules; db_query_count_tests: track_performance; util_service_factory_pattern: true; avoid_db_access: true; mock_strategy: static_mocks; context_restart_minimize: truesrc/test/javascript/spec/service/faq.service.spec.ts (1)
Pattern
src/test/javascript/spec/**/*.ts
: jest: true; mock: NgMocks; bad_practices: avoid_full_module_import; perf_improvements: mock_irrelevant_deps; service_testing: mock_http_for_logic; no_schema: avoid_NO_ERRORS_SCHEMA; expectation_specificity: true; solutions: {boolean: toBeTrue/False, reference: toBe, existence: toBeNull/NotNull, undefined: toBeUndefined, class_obj: toContainEntries/toEqual, spy_calls: {not_called: not.toHaveBeenCalled, once: toHaveBeenCalledOnce, with_value: toHaveBeenCalledWith|toHaveBeenCalledExactlyOnceWith}}
🪛 Biome
src/test/javascript/spec/service/faq.service.spec.ts
[error] 189-189: The assignment should not be in an expression.
The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.(lint/suspicious/noAssignInExpressions)
🔇 Additional comments (13)
src/main/webapp/app/faq/faq.utils.ts (3)
7-7
: LGTM!The import of
FaqState
is correctly placed and necessary for the new functionality.
9-9
: LGTM!The function signature change correctly introduces the optional
faqState
parameter while maintaining backward compatibility.
9-25
: Verify the usage of FaqState parameter.The implementation looks correct, but let's verify that it's being used with the correct state to show only accepted categories.
✅ Verification successful
Usage of FaqState.ACCEPTED is correctly implemented
The verification confirms that:
- In
course-faq.component.ts
, the component correctly setsfaqState = FaqState.ACCEPTED
and passes it toloadCourseFaqCategories
- The
faq.component.ts
usesFaqState.ACCEPTED
appropriately when accepting FAQs- The
faq-update.component.ts
sets the state toACCEPTED
for instructors- Test files verify the behavior with
FaqState.ACCEPTED
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that the function is called with ACCEPTED state # where appropriate in the codebase # Check for imports and usage of loadCourseFaqCategories rg -A 5 "loadCourseFaqCategories" --type ts # Check for FaqState.ACCEPTED usage rg "FaqState\.ACCEPTED" --type tsLength of output: 7597
src/main/java/de/tum/cit/aet/artemis/communication/repository/FaqRepository.java (1)
34-39
: LGTM! Well-structured JPQL query implementation.The query is correctly implemented with proper parameter annotations and follows SQL naming conventions. The use of
Set<String>
for distinct categories is appropriate for preventing duplicates.src/main/webapp/app/overview/course-faq/course-faq.component.ts (3)
35-35
: LGTM! Property addition aligns with PR objective.The
faqState
property is correctly initialized withFaqState.ACCEPTED
, ensuring that only accepted FAQs are displayed by default.
Line range hint
76-84
: LGTM! Robust implementation with proper error handling.The modification correctly uses
faqState
to filter FAQs while maintaining proper error handling and following Angular best practices.
35-35
: Verify consistent FAQ state handling across the application.Let's verify that the
FaqState.ACCEPTED
is consistently used across the application and that there are no hardcoded state values elsewhere.Also applies to: 76-76
✅ Verification successful
FAQ state handling is consistently implemented across the application
The verification shows that
FaqState
enum is used consistently throughout the codebase:
- Frontend components (
course-faq.component.ts
,faq.component.ts
,faq-update.component.ts
) properly use the enum- Backend (
FaqResource.java
) correctly handles state transitions and permissions- No hardcoded state values were found
- Test files demonstrate proper usage of the enum for different states (ACCEPTED, PROPOSED, REJECTED)
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for FaqState usage to ensure consistency echo "Checking for FaqState usage patterns:" rg "FaqState\." -A 2 # Search for potential hardcoded state values echo "\nChecking for potential hardcoded state values:" rg -i "state.*=.*['\"]accepted['\"]"Length of output: 12068
src/main/webapp/app/faq/faq.service.ts (1)
157-161
: Verify the new endpoint integration.The method implements the PR objective to filter FAQ categories by state. Let's verify the endpoint integration:
✅ Verification successful
Let me gather more information to verify the endpoint integration completely.
Let me try one more verification with modified commands:
Endpoint integration is properly implemented and tested
The verification shows:
- The endpoint is correctly implemented in the service with proper typing (
FaqState
enum)- The service is covered by unit tests in
faq.service.spec.ts
- The endpoint is utilized in
faq.utils.ts
with proper response handling- The
FaqState
enum is properly defined in the backend with matching values (ACCEPTED, REJECTED, PROPOSED)- The integration follows the same pattern as other endpoints in the codebase
The implementation aligns with the PR objective to filter FAQ categories by state.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the endpoint implementation and usage # Test 1: Check if the endpoint is properly defined in the backend rg -t java "faq-categories/.*FaqState" # Test 2: Check for proper error handling of the endpoint in components rg -t typescript "findAllCategoriesByCourseIdAndCategory.*catch" # Test 3: Verify consistent usage of FaqState enum ast-grep --pattern 'FaqState.$$$'Length of output: 2058
Script:
#!/bin/bash # Check the backend endpoint implementation rg -t java "courses/.*faq-categories.*FaqState" -A 5 # Check the service test coverage rg -t typescript "findAllCategoriesByCourseIdAndCategory" src/test/javascript/spec/service/faq.service.spec.ts -A 5 # Check the component usage rg -t typescript "findAllCategoriesByCourseIdAndCategory" src/main/webapp/app/ -A 2Length of output: 324
Script:
#!/bin/bash # Check the backend endpoint implementation rg "courses/.*faq-categories.*FaqState" -A 5 # Check for the service test coverage and component usage rg "findAllCategoriesByCourseIdAndCategory" -A 3 # Check the FaqState enum definition fd -e ts -e java FaqState --exec cat {}Length of output: 1530
src/main/java/de/tum/cit/aet/artemis/communication/web/FaqResource.java (5)
139-139
: Role check for accessing non-accepted FAQs is appropriateThe call to
checkShouldAccessNotAccepted(faq.getFaqState(), courseId);
ensures that users have the required role when accessing FAQs that are not in theACCEPTED
state. This enforces proper access control based on FAQ state.
172-172
: Method name updated to reflect pluralityRenaming the method to
getFaqsForCourse
improves clarity by indicating that it returns a collection of FAQs rather than a single FAQ. This enhances readability and aligns with naming conventions.
174-175
: Properly restrict FAQs based on user roleThe logic correctly ensures that users who are at least teaching assistants receive all FAQs, while other users receive only FAQs with the state
ACCEPTED
. This implementation aligns with the access control requirements.
191-191
: Role validation when accessing FAQs by stateThe call to
checkShouldAccessNotAccepted(faqState, courseId);
ingetAllFaqsForCourseByStatus
enforces role checks when users attempt to access FAQs that are notACCEPTED
. This ensures proper access control based on user roles.
232-236
: MethodcheckShouldAccessNotAccepted
implements correct access controlThe
checkShouldAccessNotAccepted
method correctly enforces that users must have at least theTEACHING_ASSISTANT
role to access FAQs that are not in theACCEPTED
state.
src/main/java/de/tum/cit/aet/artemis/communication/repository/FaqRepository.java
Outdated
Show resolved
Hide resolved
src/test/java/de/tum/cit/aet/artemis/communication/FaqIntegrationTest.java
Outdated
Show resolved
Hide resolved
src/test/java/de/tum/cit/aet/artemis/communication/FaqIntegrationTest.java
Show resolved
Hide resolved
src/main/java/de/tum/cit/aet/artemis/communication/web/FaqResource.java
Outdated
Show resolved
Hide resolved
src/main/java/de/tum/cit/aet/artemis/communication/web/FaqResource.java
Outdated
Show resolved
Hide resolved
src/main/java/de/tum/cit/aet/artemis/communication/web/FaqResource.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
🧹 Outside diff range and nitpick comments (2)
src/main/java/de/tum/cit/aet/artemis/communication/web/FaqResource.java (2)
212-219
: Add Javadoc for the new endpointThe implementation looks good, but please add Javadoc documentation similar to other endpoints in the class.
+/** + * GET /courses/:courseId/faq-categories/:faqState : get all faq categories of a course for the specified state + * + * @param courseId the courseId of the course for which faq categories should be returned + * @param faqState the state of FAQs whose categories should be returned + * @return the ResponseEntity with status 200 (OK) and the list of categories in body + */ @GetMapping("courses/{courseId}/faq-categories/{faqState}")
232-236
: Add Javadoc for the helper methodPlease add Javadoc documentation to maintain consistency with other methods in the class.
+/** + * Checks if the user should be allowed to access FAQs with non-accepted state + * + * @param faqState the state of the FAQ being accessed + * @param courseId the id of the course the FAQ belongs to + * @throws AccessForbiddenException if the user does not have required role for accessing non-accepted FAQs + */ private void checkShouldAccessNotAccepted(FaqState faqState, Long courseId) {
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (3)
- src/main/java/de/tum/cit/aet/artemis/communication/web/FaqResource.java (6 hunks)
- src/test/java/de/tum/cit/aet/artemis/communication/FaqIntegrationTest.java (2 hunks)
- src/test/javascript/spec/component/overview/course-faq/course-faq.component.spec.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
src/main/java/de/tum/cit/aet/artemis/communication/web/FaqResource.java (1)
Pattern
src/main/java/**/*.java
: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_importssrc/test/java/de/tum/cit/aet/artemis/communication/FaqIntegrationTest.java (1)
Pattern
src/test/java/**/*.java
: test_naming: descriptive; test_size: small_specific; fixed_data: true; junit5_features: true; assert_use: assertThat; assert_specificity: true; archunit_use: enforce_package_rules; db_query_count_tests: track_performance; util_service_factory_pattern: true; avoid_db_access: true; mock_strategy: static_mocks; context_restart_minimize: truesrc/test/javascript/spec/component/overview/course-faq/course-faq.component.spec.ts (1)
Pattern
src/test/javascript/spec/**/*.ts
: jest: true; mock: NgMocks; bad_practices: avoid_full_module_import; perf_improvements: mock_irrelevant_deps; service_testing: mock_http_for_logic; no_schema: avoid_NO_ERRORS_SCHEMA; expectation_specificity: true; solutions: {boolean: toBeTrue/False, reference: toBe, existence: toBeNull/NotNull, undefined: toBeUndefined, class_obj: toContainEntries/toEqual, spy_calls: {not_called: not.toHaveBeenCalled, once: toHaveBeenCalledOnce, with_value: toHaveBeenCalledWith|toHaveBeenCalledExactlyOnceWith}}
🔇 Additional comments (6)
src/test/javascript/spec/component/overview/course-faq/course-faq.component.spec.ts (1)
155-155
: LGTM: Method name updated correctly.The update to use
findAllCategoriesByCourseIdAndCategory
aligns with the PR's objective to filter FAQ categories based on their acceptance status.src/test/java/de/tum/cit/aet/artemis/communication/FaqIntegrationTest.java (2)
189-197
: LGTM! Well-structured test with comprehensive state verification.The test properly verifies that students can only access accepted FAQs and explicitly checks that proposed and rejected FAQs are not included.
215-222
: Refer to previous review comment.src/main/java/de/tum/cit/aet/artemis/communication/web/FaqResource.java (3)
140-140
: LGTM! Access control properly implementedThe access check ensures that only users with appropriate roles can access non-accepted FAQs.
173-176
: LGTM! Improved method naming and role-based filteringThe changes enhance clarity through:
- More accurate method name (plural form for collection return type)
- Clear role-based filtering logic using the ternary operator
221-230
: LGTM! Well-documented helper methodThe helper method is properly implemented with clear documentation and good reuse of existing functionality.
src/test/javascript/spec/component/overview/course-faq/course-faq.component.spec.ts
Show resolved
Hide resolved
src/test/java/de/tum/cit/aet/artemis/communication/FaqIntegrationTest.java
Show resolved
Hide resolved
src/test/java/de/tum/cit/aet/artemis/communication/FaqIntegrationTest.java
Show resolved
Hide resolved
src/main/java/de/tum/cit/aet/artemis/communication/web/FaqResource.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small nitpick:
src/main/java/de/tum/cit/aet/artemis/communication/web/FaqResource.java
Outdated
Show resolved
Hide resolved
b15d8d3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (1)
src/main/java/de/tum/cit/aet/artemis/communication/web/FaqResource.java (1)
206-213
: Add Javadoc for the new endpoint.
The new getFaqCategoriesForCourseByState
endpoint should have proper Javadoc documentation like other endpoints in the class.
Add this documentation:
+ /**
+ * GET /courses/:courseId/faq-categories/:faqState : get all the faq categories of a course with the specified state
+ *
+ * @param courseId the courseId of the course for which all faq categories should be returned
+ * @param faqState the state of FAQs whose categories should be returned
+ * @return the ResponseEntity with status 200 (OK) and the list of faq categories in body
+ */
@GetMapping("courses/{courseId}/faq-categories/{faqState}")
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
- src/main/java/de/tum/cit/aet/artemis/communication/web/FaqResource.java (6 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/main/java/de/tum/cit/aet/artemis/communication/web/FaqResource.java (1)
Pattern src/main/java/**/*.java
: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_imports
🔇 Additional comments (2)
src/main/java/de/tum/cit/aet/artemis/communication/web/FaqResource.java (2)
221-236
: LGTM! Well-structured role check methods.
The implementation follows good practices:
- Clear separation of concerns
- Descriptive method names
- Proper error handling through exceptions
169-170
: 🛠️ Refactor suggestion
Improve readability by avoiding ternary operator.
The current implementation using a ternary operator makes the access control logic less readable.
Consider using a more explicit if-else structure:
- Set<Faq> faqs = authCheckService.isAtLeastTeachingAssistantInCourse(courseId) ? faqRepository.findAllByCourseId(courseId)
- : faqRepository.findAllByCourseIdAndFaqState(courseId, FaqState.ACCEPTED);
+ Set<Faq> faqs;
+ if (authCheckService.isAtLeastTeachingAssistantInCourse(courseId)) {
+ faqs = faqRepository.findAllByCourseId(courseId);
+ } else {
+ faqs = faqRepository.findAllByCourseIdAndFaqState(courseId, FaqState.ACCEPTED);
+ }
Likely invalid or redundant comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-Approve, failing tests seem unrelated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested on TS6. Everything works as expected. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checklist
General
Server
Client
authorities
to all new routes and checked the course groups for displaying navigation elements (links, buttons).Motivation and Context
Currently, all categories are shown in the course overview. This is bad, cause a tutor can propose a new category for FAQs and students could filter for it without having an accepted FAQ --> they see nothing
Description
I added a endpoint for retrieving the FAQ categories per state and adapted the client side to retrieve accepted FAQs
Steps for Testing
Prerequisites:
Testserver States
Note
These badges show the state of the test servers.
Green = Currently available, Red = Currently locked
Click on the badges to get to the test servers.
Performance Review
Code Review
Manual Tests
Exam Mode Test
Performance Tests
Test Coverage
Screenshots
Summary by CodeRabbit
Release Notes
New Features
faqState
property in the Course FAQ component to improve FAQ management flexibility.Bug Fixes
Documentation