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

Assessment: Scroll down to complaint form after clicking on a complain button #10352

Merged
merged 23 commits into from
Feb 18, 2025

Conversation

badkeyy
Copy link
Contributor

@badkeyy badkeyy commented Feb 17, 2025

Checklist

General

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 principle of data economy for all client-server REST calls.
  • 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 authorities to all new routes and checked the course groups for displaying navigation elements (links, buttons).
  • I documented the TypeScript code using JSDoc style.
  • I added multiple screenshots/screencasts of my UI changes.
  • I translated all newly inserted strings into English and German.

Motivation and Context

Fixes #9735

Description

Sometimes students were not able to see that the complaint form opened after pressing the "Complain" button. With this PR the browser windows gets scrolled down to the end of the form (To after the submit button) after pressing the button.

Steps for Testing

Prerequisites:

  • 1 Instructor
  • 2 Students
  • 1 Programming Exercise with Complaints enabled
  1. Go to a course that has a text exercice as a student
  2. Start the exercice (type whatever)
  3. Log in as a tutor or instructor and grade the exercice
  4. Login as the original student and open your assesement
  5. Click on the complain button
  6. Find

Exam Mode Testing

Prerequisites:

  • 1 Instructor
  • 1 Students
  • 1 Graded exam with complaint functionallity
  1. Log in to Artemis
  2. Participate in the exam as a student
  3. Grade the exam (Instructor)
  4. Complain about the grading using the "Complain" button as a student

Testserver States

You can manage test servers using Helios. Check environment statuses in the environment list. To deploy to a test server, go to the CI/CD page, find your PR or branch, and trigger the deployment.

Review Progress

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Test Coverage

Client

Class/File Line Coverage Confirmation (assert/expect)
complaints-student-view.component.ts 97.4%

Screenshots

video
video
video

Summary by CodeRabbit

  • New Features

    • Improved the complaints page by conditionally displaying action options for filing a complaint or requesting more feedback when authorized.
    • Enhanced the user experience with automatic scrolling to the complaint form upon selecting an action.
  • Tests

    • Expanded test coverage to verify that the correct complaint action is selected and the scroll behavior functions as intended.

@badkeyy badkeyy requested a review from a team as a code owner February 17, 2025 17:01
@github-actions github-actions bot added tests client Pull requests that update TypeScript code. (Added Automatically!) labels Feb 17, 2025
Copy link

coderabbitai bot commented Feb 17, 2025

Walkthrough

This pull request updates the complaints student view component by modifying both its HTML template and TypeScript logic. The HTML now conditionally renders buttons for filing a complaint or requesting more feedback based on user authorization and the absence of an existing complaint. The click event handlers have been updated to call a new openComplaintForm method with the appropriate complaint type, and a new DOM element is added for scrolling support. The component class now includes new methods for initiating the complaint form and performing a scroll action, with corresponding test cases added for these behaviors.

Changes

File(s) Change Summary
src/.../complaints-student-view.component.html Updated conditional rendering; event handlers now invoke openComplaintForm(ComplaintType.COMPLAINT) or openComplaintForm(ComplaintType.MORE_FEEDBACK); added <div #complaintScrollpoint></div> for scroll targeting.
src/.../complaints-student-view.component.ts Added new imports (ChangeDetectorRef, ElementRef, ViewChild); introduced the complaintScrollpoint property; added methods openComplaintForm and scrollToComplaint to set complaint types and manage scrolling.
src/test/.../complaint-student-view.component.spec.ts Added new test cases and imports to validate the updated event handling and scrolling behavior.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant V as View (HTML)
    participant C as ComplaintsStudentViewComponent
    participant D as DOM (Scrollpoint)

    U->>V: Click "File Complaint" / "Request More Feedback"
    V->>C: Call openComplaintForm(ComplaintType)
    C->>C: Set complaint type and trigger ChangeDetectorRef update
    C->>C: Invoke scrollToComplaint()
    C->>D: Scroll to complaintScrollpoint element
Loading

Possibly related PRs

Suggested labels

bugfix, ready for review, small

Suggested reviewers

  • JohannesStoehr
  • EneaGore
  • florian-glombik
  • HawKhiem
  • krusche
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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

🧹 Nitpick comments (2)
src/main/webapp/app/complaints/complaints-for-students/complaints-student-view.component.ts (1)

173-175: Consider enhancing scroll behavior robustness.

While the current implementation works, it could be improved for better maintainability and error handling.

Consider this refactor:

-    private scrollToComplaint(): void {
-        this.complaintScrollpoint?.nativeElement.scrollIntoView({ behavior: 'smooth', block: 'end' });
-    }
+    private readonly SCROLL_OPTIONS = { behavior: 'smooth' as const, block: 'end' as const };
+    
+    private scrollToComplaint(): void {
+        try {
+            this.complaintScrollpoint?.nativeElement.scrollIntoView(this.SCROLL_OPTIONS);
+        } catch (error) {
+            console.warn('Failed to scroll to complaint form:', error);
+        }
+    }
src/test/javascript/spec/component/complaints/complaint-student-view.component.spec.ts (1)

242-305: Consider reducing test code duplication.

While the tests are thorough, there's duplicate code for scroll mock setup that could be extracted.

Consider creating a helper function:

+    function setupScrollMock(component: ComplaintsStudentViewComponent): jest.Mock {
+        const scrollIntoViewMock = jest.fn();
+        component.complaintScrollpoint = {
+            nativeElement: {
+                scrollIntoView: scrollIntoViewMock,
+            },
+        } as ElementRef;
+        return scrollIntoViewMock;
+    }

     it('should set complaint type COMPLAINT and scroll to complaint form when pressing complaint', fakeAsync(() => {
         testInitWithResultStub(of());
         // ... other setup ...
-        const scrollIntoViewMock = jest.fn();
-        component.complaintScrollpoint = {
-            nativeElement: {
-                scrollIntoView: scrollIntoViewMock,
-            },
-        } as ElementRef;
+        const scrollIntoViewMock = setupScrollMock(component);
         // ... rest of the test
     }));
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b80e594 and 1a624e8.

📒 Files selected for processing (3)
  • src/main/webapp/app/complaints/complaints-for-students/complaints-student-view.component.html (3 hunks)
  • src/main/webapp/app/complaints/complaints-for-students/complaints-student-view.component.ts (4 hunks)
  • src/test/javascript/spec/component/complaints/complaint-student-view.component.spec.ts (3 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
`src/test/javascript/spec/**/*.ts`: jest: true; mock: NgMock...

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/test/javascript/spec/component/complaints/complaint-student-view.component.spec.ts
`src/main/webapp/**/*.html`: @if and @for are new and valid ...

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/complaints/complaints-for-students/complaints-student-view.component.html
`src/main/webapp/**/*.ts`: angular_style:https://angular.io/...

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/app/complaints/complaints-for-students/complaints-student-view.component.ts
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: client-tests
  • GitHub Check: Call Build Workflow / Build .war artifact
  • GitHub Check: Call Build Workflow / Build and Push Docker Image
  • GitHub Check: server-tests
  • GitHub Check: Analyse
🔇 Additional comments (6)
src/main/webapp/app/complaints/complaints-for-students/complaints-student-view.component.ts (2)

1-44: LGTM! Clean imports and proper component setup.

The imports are well-organized, and the ViewChild decorator is correctly used for the scroll functionality.


164-168: LGTM! Well-structured complaint form handling.

The method properly handles state updates and ensures the view is ready before scrolling.

src/main/webapp/app/complaints/complaints-for-students/complaints-student-view.component.html (2)

27-27: LGTM! Clean event handling implementation.

The click handlers are properly updated to use the new openComplaintForm method with correct ComplaintType values.

Also applies to: 42-42


63-63: LGTM! Well-placed scroll target element.

The scroll point div is correctly positioned after the complaint form for proper scrolling behavior.

src/test/javascript/spec/component/complaints/complaint-student-view.component.spec.ts (2)

28-29: LGTM! Proper test imports.

The necessary imports for ElementRef and ComplaintType are correctly added.


151-182: LGTM! Comprehensive exam mode scroll testing.

The test properly verifies both the complaint type setting and scroll behavior, with good use of fakeAsync and mocking.

@helios-aet helios-aet bot temporarily deployed to artemis-test3.artemis.cit.tum.de February 17, 2025 20:31 Inactive
Copy link
Contributor

@SimonEntholzer SimonEntholzer left a comment

Choose a reason for hiding this comment

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

Code looks good, tests make sense too

Copy link

@HanyangXu0508 HanyangXu0508 left a comment

Choose a reason for hiding this comment

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

Tested the exercise part on server 3 and worked as expected, because of the server 3 is working really really slow
image

@helios-aet helios-aet bot temporarily deployed to artemis-test3.artemis.cit.tum.de February 18, 2025 12:20 Inactive
@helios-aet helios-aet bot temporarily deployed to artemis-test5.artemis.cit.tum.de February 18, 2025 14:28 Inactive
Copy link

@simonbohnen simonbohnen left a comment

Choose a reason for hiding this comment

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

Tested without exam mode on TS5. Works! 👍🏼

@Longppham
Copy link

Tested on TS5. No Problems noticed :)

@krusche krusche changed the title Grading: Scroll down to complaint form after clicking on a complain button Assessment: Scroll down to complaint form after clicking on a complain button Feb 18, 2025
@krusche krusche added this to the 7.10.2 milestone Feb 18, 2025
@krusche krusche merged commit 5ebf213 into develop Feb 18, 2025
25 of 28 checks passed
@krusche krusche deleted the bugfix/grading/scroll-down-after-clicking-complain branch February 18, 2025 19:28
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!) ready to merge tests
Projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

Clicking on the Complain button appears to do Nothing
6 participants