-
Notifications
You must be signed in to change notification settings - Fork 301
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
General
: Refactor feedback utility functions to separate manual and automatic
#10120
base: develop
Are you sure you want to change the base?
Conversation
…unreferenced feedback filtering
WalkthroughThis pull request introduces changes to the feedback retrieval mechanism across multiple exercise components. The primary modification involves replacing the generic Changes
Sequence DiagramsequenceDiagram
participant Component as Exercise Component
participant Utils as Result Utils
participant Feedbacks as Feedback Collection
Component->>Utils: Request Unreferenced Feedbacks
alt Manual Unreferenced Feedback
Utils->>Feedbacks: Filter for Manual Type
Utils-->>Component: Return Manual Unreferenced Feedbacks
else Automatic Unreferenced Feedback
Utils->>Feedbacks: Filter for Automatic Type
Utils-->>Component: Return Automatic Unreferenced Feedbacks
end
Possibly related PRs
Suggested Labels
Suggested Reviewers
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (1)src/test/javascript/spec/component/modeling-submission/modeling-submission-team.component.spec.ts (1)Pattern ⏰ Context from checks skipped due to timeout of 90000ms (8)
🔇 Additional comments (1)
Finishing Touches
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: 0
🧹 Nitpick comments (3)
src/test/javascript/spec/component/utils/result.utils.spec.ts (1)
23-24
: Test case needs additional coverage.While the test case correctly verifies manual unreferenced feedback filtering, it should be expanded to cover more scenarios:
- Empty feedback array
- Array with only automatic unreferenced feedback
- Array with mixed manual and automatic unreferenced feedback
- it('should filter out all non unreferenced feedbacks', () => { - const feedbacks = [{ reference: 'foo' }, { reference: 'foo', type: FeedbackType.MANUAL_UNREFERENCED }, { type: FeedbackType.MANUAL_UNREFERENCED }, {}]; - const unreferencedFeedbacks = getManualUnreferencedFeedback(feedbacks); - expect(unreferencedFeedbacks).toEqual([{ type: FeedbackType.MANUAL_UNREFERENCED }]); - }); + describe('getManualUnreferencedFeedback', () => { + it('should return undefined for undefined input', () => { + expect(getManualUnreferencedFeedback(undefined)).toBeUndefined(); + }); + + it('should return empty array for empty input', () => { + expect(getManualUnreferencedFeedback([])).toEqual([]); + }); + + it('should filter out all non-manual unreferenced feedbacks', () => { + const feedbacks = [ + { reference: 'foo' }, + { reference: 'foo', type: FeedbackType.MANUAL_UNREFERENCED }, + { type: FeedbackType.MANUAL_UNREFERENCED }, + { type: FeedbackType.AUTOMATIC }, + {} + ]; + expect(getManualUnreferencedFeedback(feedbacks)).toEqual([ + { type: FeedbackType.MANUAL_UNREFERENCED } + ]); + }); + + it('should handle array with only automatic unreferenced feedback', () => { + const feedbacks = [ + { type: FeedbackType.AUTOMATIC }, + { type: FeedbackType.AUTOMATIC } + ]; + expect(getManualUnreferencedFeedback(feedbacks)).toEqual([]); + }); + });src/main/webapp/app/exercises/shared/result/result.utils.ts (1)
119-133
: Consider enhancing error handling and input validation.While the implementation is correct, consider adding input validation for edge cases:
- Handle malformed feedback objects (missing type property)
- Add type guards for better type safety
+interface ValidFeedback extends Feedback { + type: FeedbackType; +} + +function isValidFeedback(feedback: Feedback): feedback is ValidFeedback { + return 'type' in feedback; +} + export const getManualUnreferencedFeedback = (feedbacks: Feedback[] | undefined): Feedback[] | undefined => { - return feedbacks ? feedbacks.filter((feedbackElement) => !feedbackElement.reference && feedbackElement.type === FeedbackType.MANUAL_UNREFERENCED) : undefined; + return feedbacks?.filter((feedbackElement): feedbackElement is ValidFeedback => + isValidFeedback(feedbackElement) && !feedbackElement.reference && feedbackElement.type === FeedbackType.MANUAL_UNREFERENCED + ); }; export const getAutomaticUnreferencedFeedback = (feedbacks: Feedback[] | undefined): Feedback[] | undefined => { - return feedbacks ? feedbacks.filter((feedbackElement) => !feedbackElement.reference && feedbackElement.type === FeedbackType.AUTOMATIC) : undefined; + return feedbacks?.filter((feedbackElement): feedbackElement is ValidFeedback => + isValidFeedback(feedbackElement) && !feedbackElement.reference && feedbackElement.type === FeedbackType.AUTOMATIC + ); };src/main/webapp/app/exercises/modeling/participate/modeling-submission.component.ts (1)
666-668
: Consider documenting the feedback type selection rationale.The codebase now uses different types of feedback for different exercise types:
- Text exercises: Manual feedback
- Modeling exercises: Automatic feedback
Consider adding documentation to explain this architectural decision, making it easier for future developers to understand why different feedback types are used for different exercise types.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
src/main/webapp/app/exercises/file-upload/participate/file-upload-submission.component.ts
(2 hunks)src/main/webapp/app/exercises/modeling/participate/modeling-submission.component.ts
(2 hunks)src/main/webapp/app/exercises/programming/participate/code-editor-student-container.component.ts
(2 hunks)src/main/webapp/app/exercises/shared/result/result.utils.ts
(1 hunks)src/main/webapp/app/exercises/text/participate/text-editor.component.ts
(2 hunks)src/test/javascript/spec/component/utils/result.utils.spec.ts
(2 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
src/main/webapp/app/exercises/file-upload/participate/file-upload-submission.component.ts (1)
src/main/webapp/app/exercises/programming/participate/code-editor-student-container.component.ts (1)
src/test/javascript/spec/component/utils/result.utils.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}}
src/main/webapp/app/exercises/text/participate/text-editor.component.ts (1)
src/main/webapp/app/exercises/modeling/participate/modeling-submission.component.ts (1)
src/main/webapp/app/exercises/shared/result/result.utils.ts (1)
⏰ Context from checks skipped due to timeout of 90000ms (7)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: client-tests-selected
- GitHub Check: client-tests
- GitHub Check: Build and Push Docker Image
- GitHub Check: server-tests
- GitHub Check: Build .war artifact
- GitHub Check: Analyse
🔇 Additional comments (11)
src/main/webapp/app/exercises/programming/participate/code-editor-student-container.component.ts (2)
17-17
: LGTM! Import statement updated correctly.The import statement has been updated to use the new
getManualUnreferencedFeedback
function, which aligns with the PR objective of separating manual and automatic feedback.
163-163
: LGTM! Getter implementation updated correctly.The
unreferencedFeedback
getter now specifically retrieves manual unreferenced feedback, which is the correct behavior for this component as it should only display manual feedback to students.src/test/javascript/spec/component/utils/result.utils.spec.ts (1)
4-4
: LGTM! Import statement updated correctly.The import statement has been updated to include the new
getManualUnreferencedFeedback
function.src/main/webapp/app/exercises/file-upload/participate/file-upload-submission.component.ts (2)
25-25
: LGTM! Import statement updated correctly.The import statement has been updated to use the new
getManualUnreferencedFeedback
function.
250-250
: LGTM! Getter implementation updated correctly.The
unreferencedFeedback
getter now specifically retrieves manual unreferenced feedback, which is the correct behavior for this component.src/main/webapp/app/exercises/shared/result/result.utils.ts (2)
119-125
: LGTM! Manual feedback utility function implemented correctly.The
getManualUnreferencedFeedback
function is well-implemented with clear documentation and proper type safety.
127-133
: LGTM! Automatic feedback utility function implemented correctly.The
getAutomaticUnreferencedFeedback
function is well-implemented with clear documentation and proper type safety.src/main/webapp/app/exercises/text/participate/text-editor.component.ts (2)
23-23
: LGTM! Import statement updated to use the new feedback utility function.The change aligns with the PR objectives to separate manual and automatic feedback retrieval.
315-315
: LGTM! Updated to use manual feedback retrieval.The getter now correctly returns only manual unreferenced feedback, which is appropriate for text exercises.
src/main/webapp/app/exercises/modeling/participate/modeling-submission.component.ts (2)
18-18
: LGTM! Import statement updated to use the new feedback utility function.The change aligns with the PR objectives to separate manual and automatic feedback retrieval.
667-667
: LGTM! Updated to use automatic feedback retrieval.The getter now correctly returns only automatic unreferenced feedback, which is appropriate for modeling exercises.
General
: Refactor feedback utility functions to separate manual and automaticGeneral
: Refactor feedback utility functions to separate manual and automatic
|
Checklist
General
Server
Client
authorities
to all new routes and checked the course groups for displaying navigation elements (links, buttons).Changes affecting Programming Exercises
Motivation and Context
The previous implementation of
getUnreferencedFeedback()
returned unreferenced feedback of typeMANUAL_UNREFERENCED
and of typeAUTOMATIC
. Since some parts of the application expected to only receive unreferenced feedback of typeMANUAL_UNREFERENCED
,AUTOMATIC
unreferenced feedback was displayed in places where it was not expected.Description
This PR introduces two new functions:
MANUAL_UNREFERENCED
AUTOMATIC
The code was updated accordingly to use the appropriate functions.
Steps for Testing
Prerequisites:
Instructor:
Enable feedback suggestions from Athena
enabledStudent: Programming
Additional Feedback
shown below theBuild Output
, or that ifAdditional Feedback
is shown, the feedback only includes non-automatic feedback (no test case feedback)Student: Modeling
Exam Mode Testing
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.
Review Progress
Performance Review
Code Review
Manual Tests
Exam Mode Test
Performance Tests
Test Coverage
Screenshots
Summary by CodeRabbit
Refactor
getUnreferencedFeedback
with more specificgetManualUnreferencedFeedback
andgetAutomaticUnreferencedFeedback
functions.Tests