-
Notifications
You must be signed in to change notification settings - Fork 294
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
Plagiarism checks
: Change separation operator for plagiarism csv file
#9847
base: develop
Are you sure you want to change the base?
Plagiarism checks
: Change separation operator for plagiarism csv file
#9847
Conversation
Plagiarism checks
: fix operator for plagiarism csv file
Plagiarism checks
: fix operator for plagiarism csv filePlagiarism checks
: change separation operator for plagiarism csv file
Plagiarism checks
: change separation operator for plagiarism csv filePlagiarism checks
: Change separation operator for plagiarism csv file
WalkthroughThe changes in this pull request focus on modifying the CSV export functionality within the Changes
Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
Warning Rate limit exceeded@AjayvirS has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 2 minutes and 41 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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: 2
🧹 Outside diff range and nitpick comments (2)
src/main/webapp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.ts (1)
Line range hint
136-149
: Consider architectural improvements for CSV handling.While the current implementation works, consider these improvements:
- Use a CSV library (e.g.,
papaparse
) for more robust CSV handling- Add proper typing for the CSV data structure
- Add error handling for large datasets
- Consider streaming for large exports
Would you like me to provide an example implementation using a CSV library?
src/test/javascript/spec/component/plagiarism/plagiarism-cases-instructor-view.component.spec.ts (1)
193-195
: LGTM! Consider adding more comprehensive test cases.The test correctly verifies the new CSV format with semicolon separators and the matriculation number column. However, consider enhancing the test coverage:
- Add test cases with actual matriculation numbers to verify proper handling:
const plagiarismCase1 = { id: 1, exercise: exercise1, - student: { id: 1, login: 'Student 1' }, + student: { id: 1, login: 'Student 1', matriculationNumber: '12345678' }, verdict: PlagiarismVerdict.PLAGIARISM, // ... } as PlagiarismCase; // In the test: const expectedBlob = [ 'Student Login; Matr. Nr.; Exercise;Verdict; Verdict Date\n', - `Student 1; -; Test Exercise 1; PLAGIARISM; ${date}; Test Instructor 1\n`, + `Student 1; 12345678; Test Exercise 1; PLAGIARISM; ${date}; Test Instructor 1\n`, 'Student 2; -; Test Exercise 2; No verdict yet; -; -\n', ];
- Add test cases to verify proper escaping of semicolons in field values:
const plagiarismCaseWithSemicolon = { student: { login: 'Student; with; semicolons' }, exercise: { title: 'Exercise; with; semicolons' }, // ... } as PlagiarismCase;
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (2)
src/main/webapp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.ts
(1 hunks)src/test/javascript/spec/component/plagiarism/plagiarism-cases-instructor-view.component.spec.ts
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
src/main/webapp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.ts (1)
src/test/javascript/spec/component/plagiarism/plagiarism-cases-instructor-view.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 (1)
src/main/webapp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.ts (1)
Line range hint 136-149
: Verify the CSV export functionality in the UI.
Please ensure that:
- The exported CSV file opens correctly in spreadsheet applications
- The matriculation number is displayed in a separate column
- Special characters are handled correctly
Run the following script to check for potential UI tests:
✅ Verification successful
Let me check the test file content to verify if there are tests covering the CSV export functionality.
CSV export functionality has been verified through unit tests
The test file includes comprehensive verification of the CSV export functionality:
- The test "should export plagiarism cases as CSV" confirms:
- Correct CSV header format with separate columns for Student Login, Matriculation Number, Exercise, Verdict, and Verdict Date
- Proper handling of cases with and without verdicts
- Special characters in exercise titles are handled correctly
- The file is downloaded with correct MIME type ('text/csv')
- The file is named 'plagiarism-cases.csv'
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Look for UI tests related to CSV export functionality
# Search for test files related to this component
fd -e spec.ts plagiarism-cases-instructor-view
# Search for CSV export related tests
rg -l "exportPlagiarismCases" --type ts
Length of output: 388
Script:
#!/bin/bash
# Check the content of the test file
cat src/test/javascript/spec/component/plagiarism/plagiarism-cases-instructor-view.component.spec.ts
Length of output: 9334
...pp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.ts
Outdated
Show resolved
Hide resolved
...pp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.ts
Outdated
Show resolved
Hide resolved
…agiarism-cases-instructor-view.component.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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: 2
🧹 Outside diff range and nitpick comments (1)
src/main/webapp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.ts (1)
137-146
: Consider using a CSV library for robust handlingInstead of manual CSV generation and sanitization, consider using a robust CSV library like
papaparse
or Angular's built-in CSV handling utilities. This would provide:
- Proper escaping and sanitization
- Consistent delimiter handling
- Protection against CSV injection
- Better maintainability
Would you like assistance in implementing this using a CSV library?
🧰 Tools
🪛 eslint (1.23.1)
[error] 137-137: Replace
header·=>·header.replace(/;/g,·''));·
with(header)·=>·header.replace(/;/g,·''));
(prettier/prettier)
🪛 GitHub Check: client-style
[failure] 137-137:
Replaceheader·=>·header.replace(/;/g,·''));·
with(header)·=>·header.replace(/;/g,·''));
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
src/main/webapp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.ts
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/main/webapp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.ts (1)
🪛 eslint (1.23.1)
src/main/webapp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.ts
[error] 137-137: Replace header·=>·header.replace(/;/g,·''));·
with (header)·=>·header.replace(/;/g,·''));
(prettier/prettier)
🪛 GitHub Check: client-style
src/main/webapp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.ts
[failure] 137-137:
Replace header·=>·header.replace(/;/g,·''));·
with (header)·=>·header.replace(/;/g,·''));
🔇 Additional comments (1)
src/main/webapp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.ts (1)
143-143
: Standardize data sanitization and null handling
The current implementation has inconsistent sanitization and spacing:
- Exercise title sanitizes commas but other fields aren't sanitized
- Inconsistent null handling with
!
operator
The previous review comment about creating a helper function for CSV field sanitization is still valid and should be implemented.
...pp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.ts
Outdated
Show resolved
Hide resolved
...pp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.ts
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: 1
🧹 Outside diff range and nitpick comments (2)
src/main/webapp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.ts (2)
40-64
: LGTM! Consider using a more specific type for groupedPlagiarismCases.The grouping logic is well-implemented with proper null checks and type safety. However, the component property
groupedPlagiarismCases
could benefit from a more specific type annotation matching the reducer's accumulator type.- groupedPlagiarismCases: any; // maybe? { [key: number]: PlagiarismCase[] } + groupedPlagiarismCases: { [exerciseId: number]: PlagiarismCase[] };
157-158
: Add localization for CSV headers.The header strings should be localized to support multiple languages.
- const headers = ['Student Login', 'Matr. Nr.', 'Exercise', 'Verdict', 'Verdict Date', 'Verdict By'].map((header) => this.sanitizeCSVField(header)); + const headers = [ + this.translateService.instant('plagiarismCases.csv.studentLogin'), + this.translateService.instant('plagiarismCases.csv.matriculationNumber'), + this.translateService.instant('plagiarismCases.csv.exercise'), + this.translateService.instant('plagiarismCases.csv.verdict'), + this.translateService.instant('plagiarismCases.csv.verdictDate'), + this.translateService.instant('plagiarismCases.csv.verdictBy'), + ].map((header) => this.sanitizeCSVField(header));
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
src/main/webapp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.ts
(2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/main/webapp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.ts (1)
🔇 Additional comments (1)
src/main/webapp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.ts (1)
142-151
: Skipping comment as issues were already raised in past reviews.
The CSV sanitization concerns were thoroughly covered in previous review comments.
...pp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.ts
Outdated
Show resolved
Hide resolved
…agiarism-cases-instructor-view.component.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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: 2
🧹 Outside diff range and nitpick comments (1)
src/main/webapp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.ts (1)
40-64
: Consider using Object.groupBy for more concise grouping logicThe grouping implementation could be simplified using newer JavaScript features while maintaining type safety.
Consider this alternative implementation:
- this.groupedPlagiarismCases = this.plagiarismCases.reduce( - ( - acc: { - [exerciseId: number]: PlagiarismCase[]; - }, - plagiarismCase, - ) => { - const caseExerciseId = plagiarismCase.exercise?.id; - if (caseExerciseId === undefined) { - return acc; - } - - // Group initialization - if (!acc[caseExerciseId]) { - acc[caseExerciseId] = []; - this.exercisesWithPlagiarismCases.push(plagiarismCase.exercise!); - } - - // Grouping - acc[caseExerciseId].push(plagiarismCase); - - return acc; - }, - {}, - ); + const validCases = this.plagiarismCases.filter(case => case.exercise?.id !== undefined); + this.exercisesWithPlagiarismCases = [...new Set(validCases.map(case => case.exercise!))]; + this.groupedPlagiarismCases = Object.groupBy(validCases, case => case.exercise!.id);
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
src/main/webapp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.ts
(2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/main/webapp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.ts (1)
🪛 GitHub Check: client-compilation
src/main/webapp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.ts
[failure] 180-180:
Property 'jhiAlertService' does not exist on type 'PlagiarismCasesInstructorViewComponent'.
🪛 GitHub Check: client-tests-selected
src/main/webapp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.ts
[failure] 180-180:
Property 'jhiAlertService' does not exist on type 'PlagiarismCasesInstructorViewComponent'.
🪛 GitHub Check: client-tests
src/main/webapp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.ts
[failure] 180-180:
Property 'jhiAlertService' does not exist on type 'PlagiarismCasesInstructorViewComponent'.
...pp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.ts
Show resolved
Hide resolved
...pp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
src/main/webapp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.ts
(2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/main/webapp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.ts (1)
🪛 Biome (1.9.4)
src/main/webapp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.ts
[error] 175-176: Illegal use of an import declaration not at the top level
move this declaration to the top level
(parse)
[error] 179-179: Illegal use of reserved keyword private
as an identifier in strict mode
(parse)
[error] 179-179: expected ,
but instead found plagiarismCasesService
Remove plagiarismCasesService
(parse)
[error] 179-179: expected ,
but instead found :
Remove :
(parse)
[error] 180-180: expected ,
but instead found private
Remove private
(parse)
[error] 180-180: expected ,
but instead found route
Remove route
(parse)
[error] 180-180: expected ,
but instead found :
Remove :
(parse)
[error] 181-181: expected ,
but instead found private
Remove private
(parse)
[error] 181-181: expected ,
but instead found jhiAlertService
Remove jhiAlertService
(parse)
[error] 181-181: expected ,
but instead found :
Remove :
(parse)
[error] 182-182: Expected a semicolon or an implicit semicolon after a statement, but found none
An explicit or implicit semicolon is expected here...
...Which is required to end this statement
(parse)
[error] 182-182: This block statement doesn't serve any purpose and can be safely removed.
Standalone block statements without any block-level declarations are redundant in JavaScript and can be removed to simplify the code.
Safe fix: Remove redundant block.
(lint/complexity/noUselessLoneBlockStatements)
🪛 GitHub Check: client-compilation
src/main/webapp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.ts
[failure] 179-179:
',' expected.
[failure] 179-179:
',' expected.
[failure] 180-180:
',' expected.
[failure] 180-180:
',' expected.
[failure] 181-181:
',' expected.
[failure] 181-181:
',' expected.
[failure] 182-182:
';' expected.
🪛 GitHub Check: client-tests-selected
src/main/webapp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.ts
[failure] 179-179:
',' expected.
[failure] 179-179:
',' expected.
[failure] 180-180:
',' expected.
[failure] 180-180:
',' expected.
[failure] 181-181:
',' expected.
[failure] 181-181:
',' expected.
[failure] 182-182:
';' expected.
🪛 GitHub Check: client-tests
src/main/webapp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.ts
[failure] 179-179:
',' expected.
[failure] 179-179:
',' expected.
[failure] 180-180:
',' expected.
[failure] 180-180:
',' expected.
[failure] 181-181:
',' expected.
[failure] 181-181:
',' expected.
[failure] 182-182:
';' expected.
🔇 Additional comments (3)
src/main/webapp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.ts (3)
40-64
: LGTM! Well-structured grouping logic.
The grouping implementation is clear, type-safe, and handles undefined cases properly.
142-151
: Skip comment as the past review is still valid.
157-174
: LGTM! CSV export implementation meets requirements.
The implementation correctly:
- Uses semicolons as separators
- Includes matriculation number
- Handles missing data consistently
...pp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.ts
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: 2
🧹 Outside diff range and nitpick comments (3)
src/main/webapp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.ts (2)
Line range hint
19-19
: Replace 'any' type with a proper interface.The
groupedPlagiarismCases
property uses theany
type, which goes against TypeScript best practices.- groupedPlagiarismCases: any; // maybe? { [key: number]: PlagiarismCase[] } + groupedPlagiarismCases: { [exerciseId: number]: PlagiarismCase[] } = {};
159-176
: Optimize memory usage in CSV generation.While the implementation is correct, we can optimize memory usage by using a generator pattern for large datasets.
exportPlagiarismCases(): void { const headers = ['Student Login', 'Matr. Nr.', 'Exercise', 'Verdict', 'Verdict Date', 'Verdict By'].map((header) => this.sanitizeCSVField(header)); - const blobParts: string[] = [headers.join(';') + '\n']; - this.plagiarismCases.forEach((plagiarismCase) => { + const blobParts = new ReadableStream({ + start(controller) { + controller.enqueue(headers.join(';') + '\n'); + for (const plagiarismCase of this.plagiarismCases) { const fields = [ this.sanitizeCSVField(plagiarismCase.student?.login), this.sanitizeCSVField(plagiarismCase.student?.visibleRegistrationNumber), this.sanitizeCSVField(plagiarismCase.exercise?.title), ]; if (plagiarismCase.verdict) { fields.push( this.sanitizeCSVField(plagiarismCase.verdict), this.sanitizeCSVField(plagiarismCase.verdictDate), this.sanitizeCSVField(plagiarismCase.verdictBy?.name), ); } else { fields.push('No verdict yet', '-', '-'); } - blobParts.push(fields.join(';') + '\n'); + controller.enqueue(fields.join(';') + '\n'); } + controller.close(); + } + });src/main/webapp/i18n/en/plagiarism.json (1)
131-131
: Consider enhancing the export button label.While "Export CSV" is clear, consider making it more specific to help users understand the content being exported.
- "exportCsv": "Export CSV", + "exportCsv": "Export Plagiarism Cases (CSV)",
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (3)
src/main/webapp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.ts
(4 hunks)src/main/webapp/i18n/de/plagiarism.json
(1 hunks)src/main/webapp/i18n/en/plagiarism.json
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
src/main/webapp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.ts (1)
src/main/webapp/i18n/de/plagiarism.json (1)
Pattern src/main/webapp/i18n/de/**/*.json
: German language translations should be informal (dutzen) and should never be formal (sietzen). So the user should always be addressed with "du/dein" and never with "sie/ihr".
🔇 Additional comments (3)
src/main/webapp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.ts (2)
9-9
: LGTM! Proper error handling service integration.
The AlertService integration follows Angular's dependency injection best practices.
Also applies to: 28-28
42-66
: LGTM! Well-structured grouping logic.
The refactored reducer implementation is clear, well-typed, and properly organized with distinct initialization and grouping sections.
src/main/webapp/i18n/en/plagiarism.json (1)
134-136
: LGTM: Clear error message for CSV export failures.
The error message is concise and follows the existing translation structure.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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.
Tested on TS1, works just fine.
Checklist
General
Client
Motivation and Context
Fixes #5599
CSV can eiter be comma separated or semi colon separated. The extension .xlsx mentioned in the issue is a Microsoft Excel extension whose regional default operator value for csv is semi colon separation. Additionally the occurences of CSV checked in the project use semi colon.
Description
Replaced comma with semi colon before creation of CSV Blob, adapted tests.
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.
Review Progress
Performance Review
Code Review
Manual Tests
Test Coverage
Screenshots
Summary by CodeRabbit
New Features
Bug Fixes
Tests