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

Plagiarism checks: Change separation operator for plagiarism csv file #9847

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from

Conversation

AjayvirS
Copy link
Contributor

@AjayvirS AjayvirS commented Nov 21, 2024

Checklist

General

  • I tested all changes and their related features with all corresponding user types on a test server.
  • This is a small issue that I tested locally and was confirmed by another developer on a test server.

Client

  • Important: I implemented the changes with a very good performance, prevented too many (unnecessary) REST calls and made sure the UI is responsive, even with large data (e.g. using paging).
  • I strictly followed the client coding and design guidelines.

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:

  • 1 Instructor
  • 2 Students
  • 1 Exercise of any type
  • 2 exercise submissions with identical content
  1. Log in to Artemis as instructor
  2. Navigate to Course Management
  3. Navigate to exercise containing the submissions
  4. Click on "Plagiarism" and select a plagiarism run
  5. Confirm the plagiarism case
  6. Navigate to "Assessment" dashboard of the course and click on "Plagiarism Cases"
  7. Export the CSV and observe semi colon separated values with matriculation number field.

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

  • I (as a reviewer) confirm that the client changes (in particular related to REST calls and UI responsiveness) are implemented with a very good performance even for very large courses with more than 2000 students.
  • I (as a reviewer) confirm that the server changes (in particular related to database calls) are implemented with a very good performance even for very large courses with more than 2000 students.

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Test Coverage

Screenshots

image

Summary by CodeRabbit

  • New Features

    • Updated CSV export format for plagiarism cases to use semicolons as delimiters, improving data structure.
    • Added a new field for the student's visible registration number in the export.
    • Introduced specific error messages for CSV export failures in both English and German.
  • Bug Fixes

    • Enhanced handling of undefined values and verdicts to ensure consistent CSV output format, including error handling during export.
  • Tests

    • Updated test cases to reflect the new CSV export format with semicolons.

@AjayvirS AjayvirS self-assigned this Nov 21, 2024
@github-actions github-actions bot added tests client Pull requests that update TypeScript code. (Added Automatically!) labels Nov 21, 2024
@AjayvirS AjayvirS changed the title Bugfix/plagiarism checks/5599 fix csv spreadsheet format Plagiarism checks: fix operator for plagiarism csv file Nov 21, 2024
@AjayvirS AjayvirS changed the title Plagiarism checks: fix operator for plagiarism csv file Plagiarism checks: change separation operator for plagiarism csv file Nov 21, 2024
@AjayvirS AjayvirS changed the title Plagiarism checks: change separation operator for plagiarism csv file Plagiarism checks: Change separation operator for plagiarism csv file Nov 21, 2024
@AjayvirS AjayvirS added component:Plagiarism Detection small bugfix plagiarism Pull requests that affect the corresponding module labels Nov 21, 2024
@AjayvirS AjayvirS marked this pull request as ready for review November 21, 2024 19:19
@AjayvirS AjayvirS requested a review from a team as a code owner November 21, 2024 19:20
Copy link

coderabbitai bot commented Nov 21, 2024

Walkthrough

The changes in this pull request focus on modifying the CSV export functionality within the PlagiarismCasesInstructorViewComponent. The delimiter for the CSV output has been changed from commas to semicolons, and the header row has been updated to include a new field for the student's visible registration number. Corresponding adjustments have been made to the data rows to ensure consistency with the new format. Additionally, error handling has been introduced in the export method, and the test suite for this component has been updated to reflect these changes in the expected output.

Changes

Files Change Summary
src/main/webapp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.ts Enhanced exportPlagiarismCases method to change CSV delimiter from commas to semicolons, added sanitizeCSVField method, and included visible registration number in the header.
src/test/javascript/spec/component/plagiarism/plagiarism-cases-instructor-view.component.spec.ts Modified test cases to reflect the new CSV format with semicolons and updated expected output accordingly.
src/main/webapp/i18n/de/plagiarism.json Added error message for CSV export failures in the German localization file.
src/main/webapp/i18n/en/plagiarism.json Added error message for CSV export failures and a new key for exporting CSV in the English localization file.

Assessment against linked issues

Objective Addressed Explanation
Specify the Matriculation number and split each parameter into different cells. (#5599)

Possibly related PRs

Suggested labels

ready to merge, maintainer-approved

Suggested reviewers

  • BaumiCoder
  • JohannesStoehr
  • BBesrour
  • SimonEntholzer

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

📥 Commits

Reviewing files that changed from the base of the PR and between b12a166 and 0ea7842.


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between b12a166 and 0ea7842.

📒 Files selected for processing (1)
  • src/main/webapp/i18n/de/plagiarism.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/webapp/i18n/de/plagiarism.json

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a 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:

  1. Use a CSV library (e.g., papaparse) for more robust CSV handling
  2. Add proper typing for the CSV data structure
  3. Add error handling for large datasets
  4. 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:

  1. 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',
 ];
  1. 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

📥 Commits

Reviewing files that changed from the base of the PR and between 31bd52c and 00e76a8.

📒 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)

Pattern src/main/webapp/**/*.ts: angular_style:https://angular.io/guide/styleguide;methods_in_html:false;lazy_loading:true;code_reuse:true;tests:meaningful;types:PascalCase;enums:PascalCase;funcs:camelCase;props:camelCase;no_priv_prefix:true;strings:single_quotes;localize:true;btns:functionality;links:navigation;icons_text:newline;labels:associate;code_style:arrow_funcs,curly_braces,open_braces_same_line,indent_4;memory_leak_prevention:true;routes:naming_schema;chart_framework:ngx-charts;responsive_layout:true

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:

  1. The exported CSV file opens correctly in spreadsheet applications
  2. The matriculation number is displayed in a separate column
  3. 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

…agiarism-cases-instructor-view.component.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@github-actions github-actions bot removed the plagiarism Pull requests that affect the corresponding module label Nov 21, 2024
Copy link

@coderabbitai coderabbitai bot left a 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 handling

Instead 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:

  1. Proper escaping and sanitization
  2. Consistent delimiter handling
  3. Protection against CSV injection
  4. 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:
Replace header·=>·header.replace(/;/g,·''));· with (header)·=>·header.replace(/;/g,·''));

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 00e76a8 and f0fefd4.

📒 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)

Pattern src/main/webapp/**/*.ts: angular_style:https://angular.io/guide/styleguide;methods_in_html:false;lazy_loading:true;code_reuse:true;tests:meaningful;types:PascalCase;enums:PascalCase;funcs:camelCase;props:camelCase;no_priv_prefix:true;strings:single_quotes;localize:true;btns:functionality;links:navigation;icons_text:newline;labels:associate;code_style:arrow_funcs,curly_braces,open_braces_same_line,indent_4;memory_leak_prevention:true;routes:naming_schema;chart_framework:ngx-charts;responsive_layout:true

🪛 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:

  1. Exercise title sanitizes commas but other fields aren't sanitized
  2. 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.

Copy link

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between f0fefd4 and 273dcea.

📒 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)

Pattern src/main/webapp/**/*.ts: angular_style:https://angular.io/guide/styleguide;methods_in_html:false;lazy_loading:true;code_reuse:true;tests:meaningful;types:PascalCase;enums:PascalCase;funcs:camelCase;props:camelCase;no_priv_prefix:true;strings:single_quotes;localize:true;btns:functionality;links:navigation;icons_text:newline;labels:associate;code_style:arrow_funcs,curly_braces,open_braces_same_line,indent_4;memory_leak_prevention:true;routes:naming_schema;chart_framework:ngx-charts;responsive_layout:true

🔇 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.

…agiarism-cases-instructor-view.component.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link

@coderabbitai coderabbitai bot left a 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 logic

The 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

📥 Commits

Reviewing files that changed from the base of the PR and between 273dcea and c8f5301.

📒 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)

Pattern src/main/webapp/**/*.ts: angular_style:https://angular.io/guide/styleguide;methods_in_html:false;lazy_loading:true;code_reuse:true;tests:meaningful;types:PascalCase;enums:PascalCase;funcs:camelCase;props:camelCase;no_priv_prefix:true;strings:single_quotes;localize:true;btns:functionality;links:navigation;icons_text:newline;labels:associate;code_style:arrow_funcs,curly_braces,open_braces_same_line,indent_4;memory_leak_prevention:true;routes:naming_schema;chart_framework:ngx-charts;responsive_layout:true

🪛 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'.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between c8f5301 and eb2f004.

📒 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)

Pattern src/main/webapp/**/*.ts: angular_style:https://angular.io/guide/styleguide;methods_in_html:false;lazy_loading:true;code_reuse:true;tests:meaningful;types:PascalCase;enums:PascalCase;funcs:camelCase;props:camelCase;no_priv_prefix:true;strings:single_quotes;localize:true;btns:functionality;links:navigation;icons_text:newline;labels:associate;code_style:arrow_funcs,curly_braces,open_braces_same_line,indent_4;memory_leak_prevention:true;routes:naming_schema;chart_framework:ngx-charts;responsive_layout:true

🪛 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

Copy link

@coderabbitai coderabbitai bot left a 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 the any 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

📥 Commits

Reviewing files that changed from the base of the PR and between eb2f004 and b12a166.

📒 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)

Pattern src/main/webapp/**/*.ts: angular_style:https://angular.io/guide/styleguide;methods_in_html:false;lazy_loading:true;code_reuse:true;tests:meaningful;types:PascalCase;enums:PascalCase;funcs:camelCase;props:camelCase;no_priv_prefix:true;strings:single_quotes;localize:true;btns:functionality;links:navigation;icons_text:newline;labels:associate;code_style:arrow_funcs,curly_braces,open_braces_same_line,indent_4;memory_leak_prevention:true;routes:naming_schema;chart_framework:ngx-charts;responsive_layout:true

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.

src/main/webapp/i18n/en/plagiarism.json Show resolved Hide resolved
src/main/webapp/i18n/de/plagiarism.json Outdated Show resolved Hide resolved
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link

@HawKhiem HawKhiem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on TS1. Semicolons are used as separation operator as mentioned

image

Copy link

@sachmii sachmii left a 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix client Pull requests that update TypeScript code. (Added Automatically!) component:Plagiarism Detection ready for review small tests
Projects
Status: Ready For Review
3 participants