Skip to content

Communication: Add first Iris Tutor Suggestion Interface #10666

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

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

Conversation

alexjoham
Copy link
Member

@alexjoham alexjoham commented Apr 12, 2025

⚠️ Do not deploy - contains database migration ⚠️

Checklist

General

Server

  • Important: I implemented the changes with a very good performance and prevented too many (unnecessary) and too complex database calls.
  • I strictly followed the principle of data economy for all database calls.
  • I strictly followed the server coding and design guidelines.
  • I added multiple integration tests (Spring) related to the features (with a high test coverage).
  • I added pre-authorization annotations according to the guidelines and checked the course groups for all new REST Calls (security).
  • I documented the Java code using JavaDoc style.

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

The communication section gets a big upgrade: The tutor suggestion. This adds a new tool for all tutors to use when answering student questions. When opening a thread, Iris creates a suggestion for tutors to use when answering questions from students. This means the communication section needs to add this feature. For that, a first version is needed that already includes: Settings to toggle this feature, Authentification to only allow tutors and higher to see the suggestions, and a database migration that saves sessions and history. This basic version lays the ground for further improvements to be added in follow-up PRs.

Description

!! Important: This is work in progress! With this PR a first version of the tutor suggestion feature is introduced. More changes are added with upcoming PRs !!

This PR introduces the Iris Tutor Suggestion functionality, enabling the generation of Iris-assisted tutor suggestions in response to student posts within conversation threads.
Domain & Session Layer:

  • Introduced IrisTutorSuggestionSession, a new session type that links a tutor’s Iris chat session to a specific Post.
  • Updated IrisMessageSender to include TUT_SUG as a new message source.
  • Extended IrisSessionService to handle the new session type and associated access control.

Settings Infrastructure:

  • Added IrisTutorSuggestionSubSettings with support across global, course, and exercise-level configurations.
  • Incorporated tutor suggestion settings into IrisCombinedSettingsDTO.
  • Updated IrisSettingsService and IrisSubSettingsService to manage these new settings and enable cascading logic.

Pipeline Execution

  • Implemented TutorSuggestionJob and PyrisTutorSuggestionPipelineExecutionDTO to define the tutor suggestion pipeline in Pyris.
  • Integrated execution logic into PyrisPipelineService and status handling in PyrisStatusUpdateService.

REST API:
Added IrisTutorSuggestionSessionResource with endpoints to:

  • Create or fetch the current tutor suggestion session for a post.
  • Extended IrisMessageResource to allow TUT_SUG messages to be saved and processed appropriately.

Frontend:
New Angular component TutorSuggestionComponent:

  • Dynamically loads AI suggestions for a post.
  • Displays formatted LLM messages and pipeline execution status.
  • Hooked into the existing ConversationThreadSidebar to render suggestions in line.
  • Extended settings management UI to include tutor suggestion settings.
  • Fully tested with component and service unit tests.

Persistence:
Liquibase changes to:

  • Add post_id to iris_session.
  • Support foreign key constraints for the new subsettings.

Steps for Testing

Prerequisites:

Activate the feature:

  1. Log in to Artemis as an Instructor
  2. Navigate to Course Administration
  3. Activate the Tutor suggestions in the Artemis Iris settings globally and also for the course

Test for students:

  1. Login as a student and ask any question in a course channel
  2. Check if anything related to Tutor suggestions is displayed if you open a thread. Nothing should happen

Test for tutors:

  1. Login as a Tutor
  2. Navigate to the Communication section and open the previously asked question in a thread
  3. Check if the tutor suggestion div is displayed with its stages and a summary is generated

Check settings:

  1. log in as a instructor and disable the feature
  2. Check if a tutor suggestion is still generated in the thread of a post

To roll back the migration, execute this SQL statement:

-- Drop foreign key constraints
ALTER TABLE iris_session DROP CONSTRAINT FK_IRIS_SESSION_ON_POST;
ALTER TABLE iris_settings DROP CONSTRAINT FK_IRIS_SETTINGS_ON_IRIS_TUTOR_SUGGESTION_SETTINGS;

-- Drop added columns
ALTER TABLE iris_session DROP COLUMN post_id;
ALTER TABLE iris_settings DROP COLUMN iris_tutor_suggestion_settings_id;

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

Client

Class/File Line Coverage Confirmation (assert/expect)
conversation-thread-sidebar.component.spec.ts not found (modified)
conversation-thread-sidebar.component.ts 88.88% ✅ ❌
tutor-suggestion.component.spec.ts not found (added)
tutor-suggestion.component.ts 98.41% ✅ ❌
iris-course-settings-update.component.spec.ts not found (modified)
iris-global-settings-update.component.spec.ts not found (modified)
iris-settings-update.component.ts 90.9% ✅ ❌
iris-chat-http.service.spec.ts not found (modified)
iris-chat-http.service.ts 90% ✅ ❌
iris-chat.service.spec.ts not found (modified)
iris-chat.service.ts 87.34% ✅ ❌
iris-message.model.ts 100%
iris-settings.model.ts 90.9% ✅ ❌
iris-sub-settings.model.ts 100%

Server

Class/File Line Coverage Confirmation (assert/expect)
IrisMessageSender.java 100%
IrisSession.java 100%
IrisTutorSuggestionSession.java 100%
IrisCourseSettings.java 100%
IrisExerciseSettings.java 85% ✅ ❌
IrisGlobalSettings.java 100%
IrisSettings.java 100%
IrisSubSettings.java 100%
IrisSubSettingsType.java 100%
IrisTutorSuggestionSubSettings.java 100%
IrisCombinedSettingsDTO.java 100%
IrisCombinedTutorSuggestionSubSettingsDTO.java 100%
IrisTutorSuggestionSessionRepository.java 89% ✅ ❌
IrisSessionService.java 81% ✅ ❌
PyrisJobService.java 93% ✅ ❌
PyrisPipelineService.java 82% ✅ ❌
PyrisStatusUpdateService.java 61% ✅ ❌
PyrisTutorSuggestionPipelineExecutionDTO.java 100%
PyrisAnswerPostDTO.java 96% ✅ ❌
PyrisPostDTO.java 100%
TutorSuggestionJob.java 46% ✅ ❌
IrisTutorSuggestionSessionService.java 65% ✅ ❌
IrisSettingsService.java 87% ✅ ❌
IrisSubSettingsService.java 89% ✅ ❌
IrisMessageResource.java 95% ✅ ❌
IrisTutorSuggestionSessionResource.java 93% ✅ ❌
PublicPyrisStatusUpdateResource.java 46% ✅ ❌

Screenshots

Running pipeline

Screenshot 2025-04-13 at 08 14 17

Finished pipeline with result

Screenshot 2025-04-13 at 08 14 29

Failed pipeline

Screenshot 2025-04-13 at 08 15 17

Summary by CodeRabbit

  • New Features

    • Introduced tutor suggestion functionality with dedicated session management, messaging, and pipeline execution.
    • Added UI components for tutor suggestions visible to users with tutor roles in conversation threads.
    • Enabled configuration of tutor suggestion settings in global, course, and exercise settings.
    • Enhanced chat service and backend to support tutor suggestion message types and workflows.
    • Added REST endpoints for creating and retrieving tutor suggestion sessions.
    • Implemented rate limiting and access control specific to tutor suggestion sessions.
  • Bug Fixes

    • Improved message creation logic to differentiate between tutor suggestion system messages and user messages, enhancing access control.
  • Tests

    • Added extensive unit and integration tests covering tutor suggestion sessions, message handling, pipeline execution, and access permissions.

@github-project-automation github-project-automation bot moved this to Work In Progress in Artemis Development Apr 12, 2025
@github-actions github-actions bot added tests server Pull requests that update Java code. (Added Automatically!) client Pull requests that update TypeScript code. (Added Automatically!) database Pull requests that update the database. (Added Automatically!). Require a CRITICAL deployment. labels Apr 12, 2025
@ls1intum ls1intum deleted a comment from github-actions bot Apr 19, 2025
@ls1intum ls1intum deleted a comment from github-actions bot Apr 19, 2025
@ls1intum ls1intum deleted a comment from github-actions bot Apr 19, 2025
@ls1intum ls1intum deleted a comment from github-actions bot Apr 19, 2025
@ls1intum ls1intum deleted a comment from github-actions bot Apr 19, 2025
Copy link

End-to-End (E2E) Test Results Summary

TestsPassed ☑️Skipped ⚠️Failed ❌️Time ⏱
End-to-End (E2E) Test Report201 ran196 passed3 skipped2 failed49m 28s 330ms
TestResultTime ⏱
End-to-End (E2E) Test Report
e2e/course/CourseMessages.spec.ts
ts.Course messages › Channel messages › Write/edit/delete message in channel › Student should be able to edit message in channel❌ failure2m 3s 45ms
e2e/exercise/programming/ProgrammingExerciseStaticCodeAnalysis.spec.ts
ts.Static code analysis tests › Configures SCA grading and makes a successful submission with SCA errors❌ failure1m 43s 753ms

Copy link

End-to-End (E2E) Test Results Summary

TestsPassed ☑️Skipped ⚠️Failed ❌️Time ⏱
End-to-End (E2E) Test Report201 ran197 passed3 skipped1 failed45m 31s 967ms
TestResultTime ⏱
End-to-End (E2E) Test Report
e2e/course/CourseMessages.spec.ts
ts.Course messages › Channel messages › Write/edit/delete message in channel › Student should be able to edit message in channel❌ failure2m 3s 670ms

coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 20, 2025
Copy link

End-to-End (E2E) Test Results Summary

TestsPassed ☑️Skipped ⚠️Failed ❌️Time ⏱
End-to-End (E2E) Test Report201 ran196 passed3 skipped2 failed50m 45s 754ms
TestResultTime ⏱
End-to-End (E2E) Test Report
e2e/course/CourseMessages.spec.ts
ts.Course messages › Channel messages › Write/edit/delete message in channel › Student should be able to edit message in channel❌ failure2m 2s 933ms
e2e/exercise/programming/ProgrammingExerciseStaticCodeAnalysis.spec.ts
ts.Static code analysis tests › Configures SCA grading and makes a successful submission with SCA errors❌ failure1m 45s 215ms

Copy link
Contributor

@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/communication/course-conversations/tutor-suggestion/tutor-suggestion.component.spec.ts (2)

63-134: Consider refactoring the nested test cases to reduce code duplication.

Each test under "should set irisEnabled to" performs similar component re-creation steps that could be extracted to a helper method for better maintainability.

+ private recreateComponent(): void {
+     fixture = TestBed.createComponent(TutorSuggestionComponent);
+     component = fixture.componentInstance;
+     componentRef = fixture.componentRef;
+ }

139-142: Use constants for message sender types to improve consistency.

The tests use string literals 'TUT_SUG' and 'LLM' in different places for checking message senders. Consider using constants for these values to improve consistency and maintainability.

+ // At the top of the file with other constants
+ const SENDER_TUTOR_SUGGESTION = 'TUT_SUG';
+ const SENDER_LLM = 'LLM';
+
- const mockMessages = [{ id: 2, sender: 'TUT_SUG' }] as IrisMessage[];
+ const mockMessages = [{ id: 2, sender: SENDER_TUTOR_SUGGESTION }] as IrisMessage[];

// And in other places
- const mockMessages = [{ id: 1, sender: 'USER' } as IrisMessage, { id: 2, sender: 'LLM' } as IrisMessage];
+ const mockMessages = [{ id: 1, sender: 'USER' } as IrisMessage, { id: 2, sender: SENDER_LLM } as IrisMessage];

Also applies to: 179-180

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f9228a8 and 3ef3a76.

⛔ Files ignored due to path filters (1)
  • src/main/resources/config/liquibase/master.xml is excluded by !**/*.xml
📒 Files selected for processing (2)
  • src/main/webapp/app/communication/course-conversations/tutor-suggestion/tutor-suggestion.component.spec.ts (1 hunks)
  • src/main/webapp/app/communication/course-conversations/tutor-suggestion/tutor-suggestion.component.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/webapp/app/communication/course-conversations/tutor-suggestion/tutor-suggestion.component.ts
🧰 Additional context used
📓 Path-based instructions (1)
`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:PascalC...

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/communication/course-conversations/tutor-suggestion/tutor-suggestion.component.spec.ts
🧬 Code Graph Analysis (1)
src/main/webapp/app/communication/course-conversations/tutor-suggestion/tutor-suggestion.component.spec.ts (1)
src/main/webapp/app/iris/shared/entities/iris-message.model.ts (1)
  • IrisMessage (41-41)
⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: Build and Push Docker Image / Build Docker Image for ls1intum/artemis
  • GitHub Check: Build and Push Docker Image / Build Docker Image for ls1intum/artemis
  • GitHub Check: Build .war artifact
  • GitHub Check: client-tests-selected
  • GitHub Check: client-tests
  • GitHub Check: client-style
  • GitHub Check: server-tests
  • GitHub Check: server-style
  • GitHub Check: Analyse
  • GitHub Check: Mend Security Check
🔇 Additional comments (3)
src/main/webapp/app/communication/course-conversations/tutor-suggestion/tutor-suggestion.component.spec.ts (3)

1-241: Well-structured and comprehensive test suite for the new TutorSuggestionComponent.

The test file follows Angular testing best practices with good coverage of component lifecycle, conditional logic, and error handling scenarios. The tests properly verify:

  • Component initialization with service interactions
  • Proper switching to TUTOR_SUGGESTION mode
  • Settings loading and permission checking
  • Subscription management
  • Message handling and suggestion requests

150-176: Good subscription management to prevent memory leaks.

The tests properly verify that all subscriptions are unsubscribed in the ngOnDestroy lifecycle hook, which is essential for preventing memory leaks in Angular applications.


189-240: Thorough testing of requestSuggestion method with various conditions.

The test suite comprehensively covers the requestSuggestion method behavior under different conditions:

  • Error handling with fallback
  • Message emission sequencing
  • Permission checking
  • Message type validation

This thorough testing ensures the component behaves correctly in various scenarios.

coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 21, 2025
Copy link

End-to-End (E2E) Test Results Summary

TestsPassed ☑️Skipped ⚠️Failed ❌️Time ⏱
End-to-End (E2E) Test Report201 ran196 passed3 skipped2 failed50m 19s 275ms
TestResultTime ⏱
End-to-End (E2E) Test Report
e2e/course/CourseMessages.spec.ts
ts.Course messages › Channel messages › Write/edit/delete message in channel › Student should be able to edit message in channel❌ failure2m 3s 297ms
e2e/exercise/programming/ProgrammingExerciseStaticCodeAnalysis.spec.ts
ts.Static code analysis tests › Configures SCA grading and makes a successful submission with SCA errors❌ failure1m 45s 88ms

@Anishyou
Copy link
Contributor

image

Iris suggestion needs to be aligned with the dark mode

image
When clicked on the selection box, it shows nothing

@alexjoham
Copy link
Member Author

I added a darkmode. Regarding the bug with the selected variant. I had it too locally, but also for other Iris settings. I deleted the settings in the database and restarted the Server and not it is working again displaying default as a variant. I am not sure what is destroying the database entries, but I reused exisiting settings to build those settings, so if this problem still exists we should think about creating an issue for that

Copy link

End-to-End (E2E) Test Results Summary

TestsPassed ☑️Skipped ⚠️Failed ❌️Time ⏱
End-to-End (E2E) Test Report201 ran196 passed3 skipped2 failed52m 25s 562ms
TestResultTime ⏱
End-to-End (E2E) Test Report
e2e/course/CourseMessages.spec.ts
ts.Course messages › Channel messages › Write/edit/delete message in channel › Student should be able to edit message in channel❌ failure2m 3s 260ms
e2e/exercise/programming/ProgrammingExerciseStaticCodeAnalysis.spec.ts
ts.Static code analysis tests › Configures SCA grading and makes a successful submission with SCA errors❌ failure1m 44s 915ms

Copy link

End-to-End (E2E) Test Results Summary

TestsPassed ☑️Skipped ⚠️Failed ❌️Time ⏱
End-to-End (E2E) Test Report201 ran196 passed3 skipped2 failed50m 47s 33ms
TestResultTime ⏱
End-to-End (E2E) Test Report
e2e/course/CourseMessages.spec.ts
ts.Course messages › Channel messages › Write/edit/delete message in channel › Student should be able to edit message in channel❌ failure2m 3s 571ms
e2e/exercise/programming/ProgrammingExerciseStaticCodeAnalysis.spec.ts
ts.Static code analysis tests › Configures SCA grading and makes a successful submission with SCA errors❌ failure1m 47s 282ms

@Anishyou
Copy link
Contributor

Tested locally- Works fine. On student perspective tutor suggestion pipeline is not shown.
For tutor perspective and users above tutors like instructor and admin , tutor suggestion pipeline works.
👍

Copy link
Contributor

@Anishyou Anishyou left a comment

Choose a reason for hiding this comment

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

Locally tested. Here are some screenshots 👍
image
image
image

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!) communication Pull requests that affect the corresponding module core Pull requests that affect the corresponding module database Pull requests that update the database. (Added Automatically!). Require a CRITICAL deployment. 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
Status: Todo
Development

Successfully merging this pull request may close these issues.

4 participants