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: Enhance navigation to plagiarism cases from detection page #10078

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

Conversation

AjayvirS
Copy link
Contributor

@AjayvirS AjayvirS commented Dec 23, 2024

Checklist

General

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.
  • Following the theming guidelines, I specified colors only in the theming variable files and checked that the changes look consistent in both the light and the dark theme.
  • I added multiple integration tests (Jest) related to the features (with a high test coverage), while following the test guidelines.
  • I added multiple screenshots/screencasts of my UI changes.
  • I translated all newly inserted strings into English and German.

Motivation and Context

The ‘Confirm’ button does not directly send a notification to the students. That has to be done manually from the ‘Plagiarism Cases‘ page. However this is not very clear from the UI

Navigating to that one has to be done via

- Going back to the course management page /course-management/:courseId
- Button Assessment Dashboard
- Button Plagiarism Cases

The change replaces the Confirm button with "View Cases" which leads you to the cases of the exercise and scrolls to it if need be.

Description

Added a routerlink to plagiarism detection page. Also added a scrollIntoView to scroll to the exercise table if it is necessary.

Steps for Testing

Prerequisites:

  • 1 Instructor
  • 2 Students
  • 1 Exercise (for example a text exercise)
  1. Log in to Artemis as an Instructor and create an text exercise with the deadline soon in the future (not sure if last part is necessary)
  2. Log in to Artemis as Student1 and submit one lengthy text
  3. Log in to Artemis as Student2 and submit a really similar text
  4. Check plagiarism
  5. Notice the button "View Case(s)" replacing the Confirm button
  6. Click on the button
  7. Confirm that the button takes you to the Plagiarism Cases page for the exercise and scrolls into view if necessary.

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

  • 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

Exam Mode Test

  • Test 1
  • Test 2

Performance Tests

  • Test 1
  • Test 2

Test Coverage

Class/File Line Coverage Confirmation (assert/expect)
[plagiarism-header.component.ts] 93%

Screenshots

After pressing on Confirm:

image

Summary by CodeRabbit

  • New Features

    • Enhanced exercise identification in the plagiarism cases view with dynamic IDs.
    • Introduced smooth scrolling to specific exercises based on user selection.
    • Added conditional buttons in the plagiarism header for better user interaction.
  • Localization

    • Added new entries for "View cases" in both German and English localization files.
  • Bug Fixes

    • Improved button rendering logic based on plagiarism comparison status.
  • Tests

    • Added tests for the new scrolling functionality in the plagiarism cases instructor view component.

@AjayvirS AjayvirS requested a review from a team as a code owner December 23, 2024 18:39
@AjayvirS AjayvirS requested a review from asliayk December 23, 2024 18:40
@github-actions github-actions bot added tests client Pull requests that update TypeScript code. (Added Automatically!) labels Dec 23, 2024
Copy link

coderabbitai bot commented Dec 23, 2024

Walkthrough

This pull request introduces enhancements to the plagiarism cases management interface in the Artemis application. The changes focus on improving the user experience by adding dynamic scrolling to specific exercise elements with plagiarism cases and modifying the plagiarism header component's button rendering. The modifications include updating the HTML structure, adding a scrolling method in the TypeScript component, updating localization files, and adding corresponding test cases to verify the new functionality.

Changes

File Change Summary
src/main/webapp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.html Added template reference variable #plagExerciseElement and dynamic id attribute to exercise div
src/main/webapp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.ts Added exerciseId property, exerciseWithPlagCasesElements view children, and scrollToExercise() method
src/main/webapp/app/exercises/shared/plagiarism/plagiarism-header/plagiarism-header.component.html Modified button rendering logic using @if for conditional display of "confirm plagiarism" and "view cases" buttons
src/main/webapp/i18n/de/plagiarism.json Added new localization entry "viewCases": "Fälle ansehen"
src/main/webapp/i18n/en/plagiarism.json Added new localization entry "viewCases": "View Case(s)"
src/test/javascript/spec/component/plagiarism/plagiarism-cases-instructor-view.component.spec.ts Added test case for scrollToExercise() method

Sequence Diagram

sequenceDiagram
    participant User
    participant Component as PlagiarismCasesInstructorView
    participant Router
    
    User->>Component: Navigate to page
    Component->>Router: Get exercise ID from query params
    Router-->>Component: Return exercise ID
    Component->>Component: Set exerciseId
    Component->>Component: Scroll to specific exercise element
Loading

Possibly related PRs

Suggested Labels

tests, client, small, component:Plagiarism Detection, bugfix

Suggested Reviewers

  • krusche
  • BBesrour
  • SimonEntholzer
  • az108
  • JohannesWt

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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: 1

🧹 Nitpick comments (3)
src/main/webapp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.ts (3)

18-18: Use inline documentation to clarify purpose of exerciseId.
It's helpful to describe why we store exerciseId, especially since it’s only optionally defined.


23-24: Ensure consistency in variable naming.
“exerciseWithPlagCasesElements” is descriptive but quite long. If used in multiple places, consider consolidating or making the name more concise.


43-43: Initialize exerciseId conditionally if query parameter is absent.
Consider checking if the query parameter is defined before assigning.

- this.exerciseId = Number(this.route.snapshot.queryParamMap?.get('exerciseId'));
+ const exerciseQueryParam = this.route.snapshot.queryParamMap?.get('exerciseId');
+ if (exerciseQueryParam) {
+     this.exerciseId = Number(exerciseQueryParam);
+ }
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 97c0636 and ced4c92.

📒 Files selected for processing (6)
  • src/main/webapp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.html (1 hunks)
  • src/main/webapp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.ts (3 hunks)
  • src/main/webapp/app/exercises/shared/plagiarism/plagiarism-header/plagiarism-header.component.html (1 hunks)
  • src/main/webapp/i18n/de/plagiarism.json (1 hunks)
  • src/main/webapp/i18n/en/plagiarism.json (1 hunks)
  • src/test/javascript/spec/component/plagiarism/plagiarism-cases-instructor-view.component.spec.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
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".

src/main/webapp/app/exercises/shared/plagiarism/plagiarism-header/plagiarism-header.component.html (1)

Pattern src/main/webapp/**/*.html: @if and @for are new and valid Angular syntax replacing *ngIf and *ngFor. They should always be used over the old style.

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}}

src/main/webapp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.html (1)

Pattern src/main/webapp/**/*.html: @if and @for are new and valid Angular syntax replacing *ngIf and *ngFor. They should always be used over the old style.

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 (9)
src/main/webapp/app/exercises/shared/plagiarism/plagiarism-header/plagiarism-header.component.html (2)

10-12: LGTM! Modern Angular syntax used correctly.

The conditional rendering uses the new @if syntax as per coding guidelines, replacing the older *ngIf directive.


13-20: Verify the router navigation parameters.

The implementation looks good, but let's ensure the navigation parameters are properly handled when exercise.course?.id is undefined.

Run this script to check for proper error handling of undefined course IDs:

✅ Verification successful

Based on the search results, I can now generate the final response:

The router navigation with optional course ID is consistently handled across the codebase

The search results show that the pattern exercise.course?.id is used consistently throughout the application in router navigation. In cases where the course ID might be undefined:

  • The optional chaining operator (?.) is properly used
  • Some components even have fallback paths (e.g., in example-modeling-submission.component.ts: exercise.course?.id || exercise.exerciseGroup?.exam?.course?.id)
  • The Angular router handles undefined segments gracefully by design
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for similar router navigation patterns to verify consistent handling
ast-grep --pattern '[routerLink]="[_, $course, _]"'

# Check for any error handling patterns around course navigation
rg -A 3 'exercise\.course\?\.id'

Length of output: 6971

src/main/webapp/i18n/en/plagiarism.json (1)

6-6: LGTM! Clear and consistent translation.

The English translation "View Case(s)" is clear, properly handles pluralization, and maintains consistent capitalization with other UI elements.

src/main/webapp/i18n/de/plagiarism.json (1)

6-6: LGTM! Translation follows German language guidelines.

The German translation "Fälle ansehen" is appropriate and follows the informal language requirement (dutzen) as per coding guidelines.

src/main/webapp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.ts (2)

2-2: Consider verifying the compatibility of 'effect' and 'viewChildren' usage across Angular versions.
These are relatively new features in Angular signals. Ensure the application’s Angular version supports them and there are no browser compatibility issues.

✅ Verification successful

Let me gather information about the Angular version and usage of these features in the codebase.


The usage of 'effect' and 'viewChildren' is compatible with the current Angular version

The codebase is using Angular v18.2.13, which fully supports both the effect and viewChildren signals features. The search results show these features are widely used across multiple components in the application:

  • effect is used in 45 different files
  • viewChildren is used in 3 different files

This consistent usage pattern and the modern Angular version indicate there are no compatibility concerns.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Check package.json for Angular version
cat package.json | jq '.dependencies["@angular/core"]'

# Search for other usages of effect and viewChildren
rg "import.*effect.*from '@angular/core'" -g '*.ts'
rg "import.*viewChildren.*from '@angular/core'" -g '*.ts'

# Check if there are any browser compatibility configurations
fd "browserslist" --type f
cat browserslist 2>/dev/null || true

Length of output: 11094


32-38: Validate that the reactive effect is unsubscribed or cleaned up if needed.
Using an effect in a constructor can lead to potential memory leaks if the component is destroyed frequently. Make sure Angular’s built-in signals or the environment handle this automatically.

✅ Verification successful

Let me gather more information about how the effect is being used and if there are any cleanup mechanisms in place.


Let me search for more specific information about the effect usage and Angular's signal implementation.


Effects in Angular 18+ are automatically cleaned up

The code is using Angular 18.2.13, which includes the new signals and effects system. Angular's effect() automatically handles cleanup when the component is destroyed. The effect is being used correctly in the constructor to handle scrolling when exerciseId changes, and there's no need for manual cleanup.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for the component class implementation to understand the context
ast-grep --pattern 'export class PlagiarismCasesInstructorViewComponent {
  $$$
}'

# Search for any cleanup methods or ngOnDestroy implementation
ast-grep --pattern 'ngOnDestroy() {
  $$$
}'

# Look for any signal or effect related imports
rg "import.*effect" src/main/webapp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.ts

Length of output: 468


Script:

#!/bin/bash
# Search for the entire file content to understand the component implementation
cat src/main/webapp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.ts

# Search for any Angular documentation or configuration files that might indicate the version
rg "\"@angular/core\":" package.json

Length of output: 9083

src/test/javascript/spec/component/plagiarism/plagiarism-cases-instructor-view.component.spec.ts (2)

203-222: Great test coverage for scrollToExercise.
Verifies that the correct element is scrolled into view. This ensures robust coverage of the new logic.


19-19: Check if signal usage requires additional test bed configuration.
Signals in Angular might need certain compiler settings. Confirm your test environment is configured properly for the new Angular APIs.

src/main/webapp/app/course/plagiarism-cases/instructor-view/plagiarism-cases-instructor-view.component.html (1)

14-14: Excellent approach to dynamic element referencing.
The addition of the ID and template reference variable ensures that scrollToExercise can target the correct element. This aligns with Angular’s recommended patterns for interactive UIs.

Comment on lines +81 to +90
scrollToExercise() {
const element = this.exerciseWithPlagCasesElements().find((elem) => elem.nativeElement.id === 'exercise-with-plagiarism-case-' + this.exerciseId);
if (element) {
element.nativeElement.scrollIntoView({
behavior: 'smooth',
block: 'start',
inline: 'nearest',
});
}
}
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Based on the search results, I can now provide a final response as we've found evidence of fixed headers in the application:

Consider adding offset for fixed navbar when scrolling
The application has a fixed navbar with a height of 68px ($header-height: 68px) and uses sticky positioning. To ensure the target element is not hidden behind the navbar, add an offset:

  • Add a scroll margin to the target element:
element.nativeElement.style.scrollMarginTop = '70px';  // slightly more than header height
element.nativeElement.scrollIntoView({
    behavior: 'smooth',
    block: 'start',
    inline: 'nearest',
});
🔗 Analysis chain

Validate offset handling for scrollIntoView if headers or sticky toolbars exist.
If there is a top navbar or sticky element, consider adjusting the scroll position to ensure the target element is fully visible.

 element.nativeElement.scrollIntoView({
   behavior: 'smooth',
   block: 'start',
+  // potential offset logic if a fixed header obstructs the view
 });

Let me search for any fixed headers or navigation bars in the codebase that might affect the scrolling behavior.


Let me search specifically for the navbar component and its styling to verify if there are fixed headers that might affect scrolling.


Let me search for any global styles that might affect the navbar or header positioning.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for navigation components and fixed/sticky positioning
rg -l "position:\s*(fixed|sticky)" --type html
rg "navbar" --type html -l
rg "header" --type html -l

# Search for any CSS classes that might define fixed positioning
rg "\.fixed|\.sticky" --type css --type scss -l

# Look for navigation component definitions
ast-grep --pattern 'class $_ implements OnInit {
  $$$
  // Look for navbar/header related component
  $$$
}'

Length of output: 23385


Script:

#!/bin/bash
# Check navbar component implementation and its styling
cat src/main/webapp/app/shared/layouts/navbar/navbar.component.html
rg "position:\s*(fixed|sticky)" src/main/webapp/app/shared/layouts/navbar/navbar.component.html
rg "position:\s*(fixed|sticky)" src/main/webapp/content/scss/global.scss

Length of output: 20889


Script:

#!/bin/bash
# Search for navbar and header related styles in all scss files
fd -e scss -x rg "navbar|header" {} \;
fd -e scss -x rg "position:\s*(fixed|sticky)" {} \;

# Also check for any global styles that might affect scrolling
fd -e scss -x rg "scroll|overflow" {} \;

Length of output: 22543

@AjayvirS AjayvirS changed the title Plagiarism checks: Enhance nvaigation to plagiarism cases from detection page Plagiarism checks: Enhance navigation to plagiarism cases from detection page Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client Pull requests that update TypeScript code. (Added Automatically!) tests
Projects
Status: Ready For Review
Development

Successfully merging this pull request may close these issues.

1 participant