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

Iris: Add FAQ consistency check for rewritting pipeline #10437

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

Conversation

cremertim
Copy link
Contributor

@cremertim cremertim commented Mar 3, 2025

Note

This PR depends on the counterpart in IRIS. For testing, deploy Pyris#209 via deploy:pyris-test if it is not already deployed (lock:pyris-test). You can only use TS3 for testing because you potentially need turn on the IRIS settings of the server with an admin account.

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 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 multiple screenshots/screencasts of my UI changes.
  • I translated all newly inserted strings into English and German.

Motivation and Context

If a user creates a FAQ, the system should ensure that the newly created FAQ is consistent with all existing FAQs.

Description

I extended the rewrite pipeline of iris to show , wheter the provided information are consistent or not

Steps for Testing

Prerequisites:

  • 1 Instructor or Tutor
  • 1 Course with FAQ enabled
  1. Log in to Artemis
  2. Navigate to the FAQ overview
  3. Create a new FAQ
  4. Insert some FAQ content, which is conflicting with already existing FAQs (otherwise, create some)
  5. Klick on rewrite FAQ
  6. Wait until the response is there.
  7. Check, wheter the inconsistencies are described and shown
  8. Check wheter there is an alternative formulation of your faq

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

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

Screenshots

image

Summary by CodeRabbit

  • New Features

    • Enhanced text rewriting now provides detailed feedback with suggestions, inconsistencies, and improvement recommendations.
    • Introduced a new FAQ consistency check alert that offers actionable guidance and dismissible notifications.
    • Upgraded instructional interfaces to display enriched rewriting results, offering clearer insights.
    • Added improved language support with updated messages in both English and German.
    • New component for managing FAQ consistency checks, enhancing user interaction.
  • Bug Fixes

    • Improved error handling in the rewriting process, ensuring better user feedback during issues.
  • Tests

    • Expanded test coverage for the ArtemisIntelligenceService, including new scenarios for consistency checks and error handling.
    • Introduced integration tests for the IRIS rewriting functionality, validating access control and response handling.

@github-actions github-actions bot added server Pull requests that update Java code. (Added Automatically!) client Pull requests that update TypeScript code. (Added Automatically!) iris Pull requests that affect the corresponding module labels Mar 3, 2025
@cremertim cremertim changed the title IRIS: Add FAQ consistency check for rewritting pipeline Iris: Add FAQ consistency check for rewritting pipeline Mar 3, 2025
@github-actions github-actions bot added tests core Pull requests that affect the corresponding module labels Mar 3, 2025
@cremertim cremertim marked this pull request as ready for review March 6, 2025 12:47
@cremertim cremertim requested a review from a team as a code owner March 6, 2025 12:47
Copy link

coderabbitai bot commented Mar 6, 2025

Walkthrough

The changes extend the rewriting pipeline functionality both on the backend and frontend. On the server side, the DTOs for rewriting pipeline execution and status update are updated to include additional parameters such as course ID, inconsistencies, suggestions, and improvement details, and the logging in the resource is modified. On the client side, new interfaces and Angular components are introduced to handle consistency check results, and the action flow is enhanced with a result signal. Test cases and i18n files are also updated accordingly.

Changes

File(s) Change Summary
src/main/java/de/tum/cit/aet/artemis/iris/service/IrisRewritingService.java Modified executeRewritingPipeline to pass variant.name().toLowerCase() and include course.getId(), and adjusted status update DTO instantiation with additional parameters.
src/main/java/de/tum/cit/aet/artemis/iris/service/pyris/dto/rewriting/PyrisRewritingPipelineExecutionDTO.java Added a new Long courseId field to the DTO.
src/main/java/de/tum/cit/aet/artemis/iris/service/pyris/dto/rewriting/PyrisRewritingStatusUpdateDTO.java Updated the DTO by adding parameters for inconsistencies, suggestions, and improvement.
src/main/java/de/tum/cit/aet/artemis/iris/web/IrisRewritingResource.java Removed a debug logging statement in the rewriteText method.
src/main/webapp/app/exercises/.../programming-exercise-editable-instruction.component.ts Modified the instantiation of RewriteAction to include a signal with a default RewriteResult value.
src/main/webapp/app/faq/faq-consistency.component.{html,ts} and src/main/webapp/app/faq/faq-update.component.{html,ts} Introduced new Angular components and logic to display and manage FAQ consistency check alerts, including new signals, computed properties, and event handling.
src/main/webapp/app/shared/monaco-editor/model/actions/artemis-intelligence/RewriteResult.ts Added a new TypeScript interface RewriteResult specifying properties for result, inconsistencies, suggestions, and improvement.
src/main/webapp/app/shared/monaco-editor/model/actions/artemis-intelligence/artemis-intelligence.service.ts Updated the rewrite method to return an Observable<RewriteResult> and constructed a result object with the new properties.
src/main/webapp/app/shared/monaco-editor/model/actions/artemis-intelligence/rewrite.action.ts Modified RewriteAction to include a resultSignal parameter in its constructor and adjusted the run method accordingly.
src/main/webapp/app/shared/monaco-editor/model/actions/text-editor-action.model.ts Updated rewriteMarkdown to accept a new resultSignal parameter and to update the UI using the rewriteResult.
src/main/webapp/i18n/{de,en}/programmingExercise.json Added new key-value pairs for improvement and inconsistencies in the consistency check alert configuration.
src/test/java/de/tum/cit/aet/artemis/core/connector/IrisRequestMockProvider.java Renamed the method to mockRewritingPipelineResponse and updated the parameter name for clarity.
src/test/java/de/tum/cit/aet/artemis/iris/PyrisRewritingTest.java Introduced a new integration test class for the rewriting pipeline, testing both instructor and student roles.
src/test/javascript/spec/service/artemis-intelligence.service.spec.ts Enhanced tests for ArtemisIntelligenceService including new tests for consistency checking, error handling, and loading state.

Possibly related PRs

Suggested labels

feature

Suggested reviewers

  • EneaGore
  • HawKhiem
  • Malekos74
  • SimonEntholzer
  • krusche
  • florian-glombik

📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ae0d07d and b8914c9.

📒 Files selected for processing (2)
  • src/main/webapp/i18n/de/programmingExercise.json (1 hunks)
  • src/main/webapp/i18n/en/programmingExercise.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/main/webapp/i18n/en/programmingExercise.json
  • src/main/webapp/i18n/de/programmingExercise.json
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: Call Build Workflow / Build and Push Docker Image
  • GitHub Check: Call Build Workflow / Build .war artifact
  • GitHub Check: client-style
  • GitHub Check: client-tests-selected
  • GitHub Check: server-style
  • GitHub Check: client-tests
  • GitHub Check: server-tests
  • GitHub Check: Analyse

🪧 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.
  • @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

🧹 Nitpick comments (6)
src/main/webapp/app/faq/faq-consistency.component.html (2)

8-11: Consider semantic HTML structure improvements.

The current HTML structure uses a div inside a list item which breaks standard list semantics.

-                <div>
-                    <li>{{ element.suggestion }}</li>
-                    <p>{{ element.inconsistentFaq }}</p>
-                </div>
+                <li>
+                    <div>{{ element.suggestion }}</div>
+                    <p>{{ element.inconsistentFaq }}</p>
+                </li>

16-16: Remove unnecessary 'this' reference.

In Angular templates, the 'this' keyword is optional and typically omitted for cleaner code.

-    <div [innerHtml]="this.improvement()"></div>
+    <div [innerHtml]="improvement()"></div>
src/main/webapp/app/faq/faq-update.component.ts (1)

194-201: Added method to dismiss consistency check results

The dismissConsistencyCheck method properly resets all fields in the consistency check result signal. However, consider extracting the default empty result object to a constant to avoid duplication between initialization and reset.

+  private readonly EMPTY_CONSISTENCY_CHECK_RESULT: RewriteResult = {
+    result: '',
+    inconsistencies: [],
+    suggestions: [],
+    improvement: '',
+  };

-  renderedConsistencyCheckResultMarkdown = signal<RewriteResult>({
-    result: '',
-    inconsistencies: [],
-    suggestions: [],
-    improvement: '',
-  });
+  renderedConsistencyCheckResultMarkdown = signal<RewriteResult>(this.EMPTY_CONSISTENCY_CHECK_RESULT);

  dismissConsistencyCheck() {
-    this.renderedConsistencyCheckResultMarkdown.set({
-      result: '',
-      inconsistencies: [],
-      suggestions: [],
-      improvement: '',
-    });
+    this.renderedConsistencyCheckResultMarkdown.set(this.EMPTY_CONSISTENCY_CHECK_RESULT);
  }
src/test/java/de/tum/cit/aet/artemis/iris/PyrisRewritingTest.java (1)

53-61: Test for instructor rewriting pipeline access.

This test verifies that instructors can access the rewriting pipeline. However, it only checks the HTTP status code without verifying the actual response content or structure.

Consider enhancing this test to verify the actual response structure and content to ensure the rewriting pipeline returns the expected results with inconsistencies and suggestions. You could modify the test to:

@Test
@WithMockUser(username = TEST_PREFIX + "instructor1", roles = "INSTRUCTOR")
void callRewritingPipeline() throws Exception {
    activateIrisFor(course1);
    irisRequestMockProvider.mockRewritingPipelineResponse(dto -> {
+        // Setup mock to return specific inconsistencies/suggestions
    });
    PyrisRewriteTextRequestDTO requestDTO = new PyrisRewriteTextRequestDTO("test", RewritingVariant.FAQ);
-    request.postWithoutResponseBody("/api/iris/courses/" + course1.getId() + "/rewrite-text", requestDTO, HttpStatus.OK);
+    var response = request.post("/api/iris/courses/" + course1.getId() + "/rewrite-text", requestDTO, HttpStatus.OK, String.class);
+    // Assert response contains expected structure with inconsistencies/suggestions
}
src/test/javascript/spec/service/artemis-intelligence.service.spec.ts (2)

63-71: Consider using more specific spy expectations.

While the test is correct, using toHaveBeenCalledExactlyOnceWith instead of toHaveBeenCalledWith would be more aligned with the coding guidelines.

-expect(alertService.success).toHaveBeenCalledWith('artemisApp.markdownEditor.artemisIntelligence.alerts.rewrite.success');
+expect(alertService.success).toHaveBeenCalledExactlyOnceWith('artemisApp.markdownEditor.artemisIntelligence.alerts.rewrite.success');

124-135: Missing HTTP error test for consistencyCheck.

While WebSocket errors are tested, there's no test for HTTP errors during consistency check.

Add a test for HTTP errors similar to the one for the rewrite method:

it('should handle HTTP error during consistency check', () => {
  const exerciseId = 42;

  service.consistencyCheck(exerciseId).subscribe({
    next: () => fail('Expected an error'),
    error: (err) => expect(err.status).toBe(400),
  });

  const req = httpMock.expectOne(`api/iris/consistency-check/exercises/${exerciseId}`);
  req.flush({ message: 'Error' }, { status: 400, statusText: 'Bad Request' });
});
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 93eba08 and 7f05512.

📒 Files selected for processing (18)
  • src/main/java/de/tum/cit/aet/artemis/iris/service/IrisRewritingService.java (1 hunks)
  • src/main/java/de/tum/cit/aet/artemis/iris/service/pyris/dto/rewriting/PyrisRewritingPipelineExecutionDTO.java (1 hunks)
  • src/main/java/de/tum/cit/aet/artemis/iris/service/pyris/dto/rewriting/PyrisRewritingStatusUpdateDTO.java (1 hunks)
  • src/main/java/de/tum/cit/aet/artemis/iris/web/IrisRewritingResource.java (0 hunks)
  • src/main/webapp/app/exercises/programming/manage/instructions-editor/programming-exercise-editable-instruction.component.ts (2 hunks)
  • src/main/webapp/app/faq/faq-consistency.component.html (1 hunks)
  • src/main/webapp/app/faq/faq-consistency.component.ts (1 hunks)
  • src/main/webapp/app/faq/faq-update.component.html (1 hunks)
  • src/main/webapp/app/faq/faq-update.component.ts (4 hunks)
  • src/main/webapp/app/shared/monaco-editor/model/actions/artemis-intelligence/RewriteResult.ts (1 hunks)
  • src/main/webapp/app/shared/monaco-editor/model/actions/artemis-intelligence/artemis-intelligence.service.ts (3 hunks)
  • src/main/webapp/app/shared/monaco-editor/model/actions/artemis-intelligence/rewrite.action.ts (3 hunks)
  • src/main/webapp/app/shared/monaco-editor/model/actions/text-editor-action.model.ts (2 hunks)
  • src/main/webapp/i18n/de/programmingExercise.json (1 hunks)
  • src/main/webapp/i18n/en/programmingExercise.json (1 hunks)
  • src/test/java/de/tum/cit/aet/artemis/core/connector/IrisRequestMockProvider.java (3 hunks)
  • src/test/java/de/tum/cit/aet/artemis/iris/PyrisRewritingTest.java (1 hunks)
  • src/test/javascript/spec/service/artemis-intelligence.service.spec.ts (2 hunks)
💤 Files with no reviewable changes (1)
  • src/main/java/de/tum/cit/aet/artemis/iris/web/IrisRewritingResource.java
🧰 Additional context used
📓 Path-based instructions (6)
`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/shared/monaco-editor/model/actions/artemis-intelligence/RewriteResult.ts
  • src/main/webapp/app/faq/faq-consistency.component.ts
  • src/main/webapp/app/shared/monaco-editor/model/actions/artemis-intelligence/rewrite.action.ts
  • src/main/webapp/app/exercises/programming/manage/instructions-editor/programming-exercise-editable-instruction.component.ts
  • src/main/webapp/app/shared/monaco-editor/model/actions/text-editor-action.model.ts
  • src/main/webapp/app/shared/monaco-editor/model/actions/artemis-intelligence/artemis-intelligence.service.ts
  • src/main/webapp/app/faq/faq-update.component.ts
`src/main/webapp/i18n/de/**/*.json`: German language transla...

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/i18n/de/programmingExercise.json
`src/main/java/**/*.java`: naming:CamelCase; principles:{sin...

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/java/de/tum/cit/aet/artemis/iris/service/IrisRewritingService.java
  • src/main/java/de/tum/cit/aet/artemis/iris/service/pyris/dto/rewriting/PyrisRewritingPipelineExecutionDTO.java
  • src/main/java/de/tum/cit/aet/artemis/iris/service/pyris/dto/rewriting/PyrisRewritingStatusUpdateDTO.java
`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/faq/faq-consistency.component.html
  • src/main/webapp/app/faq/faq-update.component.html
`src/test/java/**/*.java`: test_naming: descriptive; test_si...

src/test/java/**/*.java: test_naming: descriptive; test_size: small_specific; fixed_data: true; junit5_features: true; assert_use: assertThat; assert_specificity: true; archunit_use: enforce_package_rules; db_query_count_tests: track_performance; util_service_factory_pattern: true; avoid_db_access: true; mock_strategy: static_mocks; context_restart_minimize: true

  • src/test/java/de/tum/cit/aet/artemis/core/connector/IrisRequestMockProvider.java
  • src/test/java/de/tum/cit/aet/artemis/iris/PyrisRewritingTest.java
`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/service/artemis-intelligence.service.spec.ts
🧠 Learnings (1)
src/test/java/de/tum/cit/aet/artemis/iris/PyrisRewritingTest.java (1)
Learnt from: alexjoham
PR: ls1intum/Artemis#9455
File: src/test/java/de/tum/cit/aet/artemis/iris/IrisTextExerciseChatMessageIntegrationTest.java:401-401
Timestamp: 2024-11-12T12:51:58.050Z
Learning: In the Artemis project, when new fields are added to classes like `PyrisChatStatusUpdateDTO`, corresponding tests may be implemented in separate integration test classes such as `IrisChatTokenTrackingIntegrationTest`.
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: Call Build Workflow / Build .war artifact
  • GitHub Check: Call Build Workflow / Build and Push Docker Image
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: client-tests-selected
  • GitHub Check: client-tests
  • GitHub Check: server-tests
  • GitHub Check: Analyse
🔇 Additional comments (37)
src/main/webapp/app/shared/monaco-editor/model/actions/artemis-intelligence/RewriteResult.ts (1)

1-6: Well-structured interface design.

The RewriteResult interface provides a clear data structure for handling rewrite operations with consistency checking. The properties are well-named and follow the appropriate casing conventions.

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

750-751: Translation keys correctly implemented.

The new translation keys for the consistency check feature are properly structured and have clear, descriptive values.

src/main/webapp/app/faq/faq-update.component.html (1)

29-36: Clean integration of the consistency check component.

The faq-consistency-check component is properly integrated with appropriate properties and event binding. The usage of modern Angular @if syntax aligns with the coding guidelines.

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

750-753: LGTM: New translations added correctly

The new German translations for the consistency check alert are concise and appropriate nouns. They correctly follow the guidelines for German translations, using "Verbesserungsempfehlung" and "Inkonsistenzen" as substantive terms.

src/main/java/de/tum/cit/aet/artemis/iris/service/pyris/dto/rewriting/PyrisRewritingPipelineExecutionDTO.java (1)

14-14: LGTM: Added courseId parameter to the record

The addition of the courseId parameter to the DTO record follows Java best practices:

  • Uses camelCase for the parameter name
  • Maintains the record's single responsibility of encapsulating rewriting pipeline execution data
  • Provides the necessary context for course-specific FAQ consistency checks
src/main/java/de/tum/cit/aet/artemis/iris/service/IrisRewritingService.java (2)

65-65: Improved enum handling

Changed from variant.toString() to variant.name().toLowerCase(), which provides more explicit control over the string representation of the enum value.


68-69: Updated constructor calls for enhanced functionality

The changes properly expand the DTO and status update objects to support the new FAQ consistency check feature:

  1. Added course.getId() to the PyrisRewritingPipelineExecutionDTO to provide course context
  2. Updated PyrisRewritingStatusUpdateDTO with additional parameters for inconsistencies, suggestions, and improvement details

These changes align with the requirements for implementing the FAQ consistency check functionality.

src/main/webapp/app/faq/faq-consistency.component.ts (1)

1-39: Well-structured new component for FAQ consistency checks

The new FaqConsistencyComponent follows Angular best practices:

  • Uses standalone component architecture
  • Follows proper naming conventions with PascalCase for component class and camelCase for properties/methods
  • Leverages Angular's input/output API for component communication
  • Uses reactive signals and effects for state management
  • Implements clean template/component separation

The component correctly formats and displays inconsistencies and suggestions, with a clear dismissal mechanism.

src/main/java/de/tum/cit/aet/artemis/iris/service/pyris/dto/rewriting/PyrisRewritingStatusUpdateDTO.java (1)

15-22: Updates to DTO record with consistency check parameters

The DTO has been appropriately extended with the new parameters needed for the FAQ consistency check feature. The record uses proper Java patterns and includes all required fields with clear parameter documentation.

src/test/java/de/tum/cit/aet/artemis/core/connector/IrisRequestMockProvider.java (2)

183-183: Method renamed for clarity

The method rename from mockRunRewritingResponseAnd to mockRewritingPipelineResponse improves naming clarity and better reflects its purpose.


191-191: Updated parameter name for consistency

Parameter name change from executionDTOConsumer to responseConsumer provides better semantic clarity while maintaining the same functionality.

src/main/webapp/app/exercises/programming/manage/instructions-editor/programming-exercise-editable-instruction.component.ts (2)

52-52: Added import for new RewriteResult interface

The import statement is correctly added to support the new consistency check functionality.


94-99: Updated RewriteAction instantiation with result signal

The RewriteAction constructor now properly includes the new signal parameter for handling consistency check results. This aligns with the updated rewrite pipeline that checks FAQ consistency.

src/main/webapp/app/faq/faq-update.component.ts (5)

26-27: Added imports for consistency check components

The imports for RewriteResult and FaqConsistencyComponent are correctly added to support the new consistency check functionality.


33-33: Updated component imports with FaqConsistencyComponent

The FaqConsistencyComponent is properly added to the component imports array.


54-59: Added signal for consistency check results

The RewriteResult signal is properly initialized with default empty values for all fields. This will store the consistency check results from the rewriting pipeline.


61-61: Added computed property for conditionally showing consistency checks

The computed property correctly determines whether to show consistency check results based on the presence of result content.


64-66: Updated artemisIntelligenceActions to use consistency check result signal

The RewriteAction is now correctly wired with the consistency check result signal, allowing it to store and update consistency check results.

src/main/webapp/app/shared/monaco-editor/model/actions/artemis-intelligence/rewrite.action.ts (3)

5-6: New imports added for the FAQ consistency check feature.

The added imports for WritableSignal and RewriteResult suggest implementation of a reactive approach to handle the consistency check results. This aligns well with Angular's recommended practices for state management.


20-20: Constructor parameter added to handle rewrite results.

The added resultSignal parameter introduces a reactive way to communicate inconsistencies and suggestions back to the UI, which is essential for the FAQ consistency check feature.


30-30: Updated method call with new result signal parameter.

The implementation correctly passes the resultSignal to the rewriteMarkdown method, ensuring that any inconsistencies discovered during the FAQ rewriting process are properly communicated.

src/main/webapp/app/shared/monaco-editor/model/actions/text-editor-action.model.ts (3)

14-14: New import for handling structured rewrite results.

The addition of the RewriteResult import supports the structured response handling needed for the FAQ consistency check feature.


308-316: Method signature update with improved JSDoc.

The rewriteMarkdown method now accepts a resultSignal parameter with clear documentation about its purpose. This change properly supports the consistency check functionality by providing a channel to communicate inconsistencies back to the UI.


320-322: Enhanced rewrite result handling.

The implementation now correctly:

  1. Uses the structured result's result property for the editor content
  2. Updates the signal with the complete result object containing inconsistencies and suggestions

This implementation properly supports the new FAQ consistency check feature.

src/test/java/de/tum/cit/aet/artemis/iris/PyrisRewritingTest.java (2)

1-52: Well-structured test class setup.

The test class follows JUnit 5 best practices with proper annotations, dependency injection, and test data setup. The @BeforeEach method correctly initializes test users and courses needed for the tests.


63-72: Test for student access restriction.

This test correctly verifies that students cannot access the rewriting pipeline, following good security testing practices. The empty string in the request DTO also tests boundary conditions.

src/main/webapp/app/shared/monaco-editor/model/actions/artemis-intelligence/artemis-intelligence.service.ts (3)

7-7: Import for structured rewrite result handling.

The import of RewriteResult supports the enhanced functionality to handle inconsistencies and suggestions in the rewriting pipeline.


32-32: Updated return type for structured response.

The method signature now correctly reflects that it returns a complex object containing not just the rewritten text but also inconsistencies and suggestions for the FAQ consistency check.


34-35: Observable creation for structured response.

The Observable now properly defines the structure of the response object.

src/test/javascript/spec/service/artemis-intelligence.service.spec.ts (8)

5-5: Good import additions for enhanced testing.

The addition of of, throwError from rxjs, and AlertService properly supports the new test cases.

Also applies to: 10-10


18-29: Great mock implementation with comprehensive test data.

The mock now returns additional properties (inconsistencies, suggestions, improvement) which aligns with the PR objective of implementing FAQ consistency checks.


31-33: Properly mocked AlertService for testing success notifications.

The mock service correctly implements the required method for testing.


54-54: Good test hygiene with jest.clearAllMocks().

Clearing mocks after each test ensures test isolation and prevents side effects.


83-86: Good use of subscribed error handling.

The error handling follows best practices with a proper failure check and specific status code expectation.


92-104: Well-structured WebSocket error test.

This test appropriately handles the WebSocket error case and verifies the subscription was called.


107-122: Good implementation of consistency check test.

The test properly verifies WebSocket topic subscription/unsubscription and result handling.


137-149: Excellent loading state testing.

The test correctly verifies the loading state transitions and properly cleans up the subscription, preventing memory leaks.

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 iris Pull requests that affect the corresponding module ready for review server Pull requests that update Java code. (Added Automatically!) tests
Projects
Status: Ready For Review
Development

Successfully merging this pull request may close these issues.

1 participant