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

Development: Fix wrong result subscription for exam exercises #9453

Merged
merged 1 commit into from
Oct 12, 2024

Conversation

Strohgelaender
Copy link
Contributor

@Strohgelaender Strohgelaender commented Oct 11, 2024

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

We noticed some log messages saying:

User with login '' tried to access the protected topic: /topic/exercise/14238/newResults
User with login '' tried to access the protected topic: /topic/exercise/10200/newResults

This PR fixes the cause of these warnings.

Description

When opening the exam summary page, a subscription to result updates is initiated. The client incorrectly used the non-personal topic instead of the personal topic. This is now fixed.

Steps for Testing

You can best test this locally or on a test server with access to the logs.

As a student, view your exams results summary. Then check the server and make sure none of the warnings as above are present.

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

Performance Tests

  • Test 1
  • Test 2

Test Coverage

Summary by CodeRabbit

  • New Features

    • Introduced an instructorView property to enhance the exam result summary display for instructors.
    • Added a personalParticipation property to better manage participation visibility based on the instructor view.
  • Bug Fixes

    • Streamlined authorization checks for user subscriptions to exercise results, improving logic clarity and efficiency.
  • Documentation

    • Updated component signatures to reflect new input properties for better integration and usage.

@github-actions github-actions bot added server Pull requests that update Java code. (Added Automatically!) client Pull requests that update TypeScript code. (Added Automatically!) core Pull requests that affect the corresponding module labels Oct 11, 2024
@Strohgelaender Strohgelaender marked this pull request as ready for review October 11, 2024 11:15
@Strohgelaender Strohgelaender requested a review from a team as a code owner October 11, 2024 11:15
Copy link

coderabbitai bot commented Oct 11, 2024

Walkthrough

The changes in this pull request primarily involve modifications to the WebsocketConfiguration class and related components in the exam summary feature. The allowSubscription method's logic is updated to simplify authorization checks by directly assessing instructor status in exercises. Additionally, new input properties are introduced in various components to manage instructor-specific views, enhancing the overall functionality of the exam result summary interface.

Changes

File Change Summary
src/main/java/de/tum/cit/aet/artemis/core/config/websocket/WebsocketConfiguration.java Modified allowSubscription method to simplify authorization checks by using isAtLeastInstructorInExercise instead of isAtLeastInstructorInCourse. Removed retrieval of Exercise object.
src/main/webapp/app/exam/participate/summary/exam-result-summary.component.html Added new input property [instructorView] to jhi-programming-exam-summary component.
src/main/webapp/app/exam/participate/summary/exercises/programming-exam-summary/programming-exam-summary.component.html Added new input property [personalParticipation] to jhi-programming-exercise-instructions component, set to negation of instructorView.
src/main/webapp/app/exam/participate/summary/exercises/programming-exam-summary/programming-exam-summary.component.ts Introduced new optional input property instructorView with a default value of false in ProgrammingExamSummaryComponent.

Possibly related PRs

Suggested labels

tests, ready for review, bugfix, small, component:Exam Mode

Suggested reviewers

  • krusche
  • SimonEntholzer
  • pzdr7
  • coolchock
  • JohannesStoehr

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

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between 607e8f7 and 4bce811.

📒 Files selected for processing (4)
  • src/main/java/de/tum/cit/aet/artemis/core/config/websocket/WebsocketConfiguration.java (1 hunks)
  • src/main/webapp/app/exam/participate/summary/exam-result-summary.component.html (1 hunks)
  • src/main/webapp/app/exam/participate/summary/exercises/programming-exam-summary/programming-exam-summary.component.html (1 hunks)
  • src/main/webapp/app/exam/participate/summary/exercises/programming-exam-summary/programming-exam-summary.component.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
src/main/java/de/tum/cit/aet/artemis/core/config/websocket/WebsocketConfiguration.java (1)

Pattern src/main/java/**/*.java: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_imports

src/main/webapp/app/exam/participate/summary/exam-result-summary.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/exam/participate/summary/exercises/programming-exam-summary/programming-exam-summary.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/exam/participate/summary/exercises/programming-exam-summary/programming-exam-summary.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 (4)
src/main/webapp/app/exam/participate/summary/exercises/programming-exam-summary/programming-exam-summary.component.html (2)

51-51: LGTM: New input property enhances view differentiation

The addition of [personalParticipation]="!instructorView" to the jhi-programming-exercise-instructions component is a good enhancement. This change allows the component to differentiate between instructor and student views, which aligns with the PR objective of fixing the wrong result subscription for exam exercises.


Line range hint 1-58: Excellent use of new Angular syntax

The template consistently uses the new Angular syntax (@if) throughout the file, adhering to the provided coding guidelines. There are no instances of the deprecated *ngIf or *ngFor syntax, which is commendable.

src/main/webapp/app/exam/participate/summary/exercises/programming-exam-summary/programming-exam-summary.component.ts (1)

42-43: 🧹 Nitpick (assertive)

LGTM! Consider adding a comment for clarity.

The new instructorView input property is well-implemented and aligns with the coding guidelines. It uses camelCase, is properly decorated with @Input(), and has an appropriate default value.

This addition supports the PR objective by allowing differentiation between instructor and student views, which could be crucial for fixing the result subscription issue.

Consider adding a brief comment explaining the purpose and usage of this property, for example:

/** Determines if the component should render in instructor view mode. */
@Input() instructorView?: boolean = false;

To ensure this property is utilized, let's check for its usage:

If no results are found, consider implementing the logic that utilizes this new property.

✅ Verification successful

Verification Successful

The instructorView input property is correctly utilized within the component's template to control the personalParticipation binding. There is no need for additional logic in the TypeScript file.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for usage of instructorView in component logic and template
echo "Searching for instructorView usage in component file:"
rg "this\.instructorView" src/main/webapp/app/exam/participate/summary/exercises/programming-exam-summary/programming-exam-summary.component.ts

echo "\nSearching for instructorView usage in component template:"
rg "instructorView" src/main/webapp/app/exam/participate/summary/exercises/programming-exam-summary/programming-exam-summary.component.html

Length of output: 689

src/main/webapp/app/exam/participate/summary/exam-result-summary.component.html (1)

Line range hint 1-208: Excellent use of new Angular control flow syntax!

The template consistently uses the new Angular control flow syntax (@if and @for) throughout the file, adhering to the provided coding guidelines. This modern approach enhances readability and aligns with best practices.

Copy link
Contributor

@JohannesStoehr JohannesStoehr left a comment

Choose a reason for hiding this comment

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

Code

Copy link
Contributor

@edkaya edkaya left a comment

Choose a reason for hiding this comment

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

changes lgtm

@krusche krusche added this to the 7.6.0 milestone Oct 12, 2024
@krusche krusche merged commit ced37c1 into develop Oct 12, 2024
22 of 25 checks passed
@krusche krusche deleted the bugfix/exam/result-subscription branch October 12, 2024 08:26
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!) core Pull requests that affect the corresponding module ready for review server Pull requests that update Java code. (Added Automatically!)
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants