-
Notifications
You must be signed in to change notification settings - Fork 358
Adaptive learning: Learner profile - interface to set feedback preference
#10687
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
Closed
ahmetsenturk
wants to merge
13
commits into
develop
from
feature/adaptive-learning/feedback-preference-interface
Closed
Changes from 10 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
784c78e
add feedback preference attributes to learner profile
ahmetsenturk 585fd69
remove constraints from migration script
ahmetsenturk 6aa8686
add translations for learner profile settings
ahmetsenturk ed23fdb
add learner profile dto and service to webapp
ahmetsenturk 6703ca5
WIP - add learner profile to user settings
ahmetsenturk 7cd9cf7
add server-client communication for learner profile
ahmetsenturk 4465067
hide the slider thumb tooltip
ahmetsenturk 1128bc9
update the learner profile directives
ahmetsenturk 204b9a7
add constraints for the learner profile attributes
ahmetsenturk 0c4649f
Merge branch 'develop' into feature/adaptive-learning/feedback-prefer…
ahmetsenturk cd40135
update german translations, add error msg
ahmetsenturk 9d64234
add error handling and ensure consistency
ahmetsenturk b7e4a94
Merge branch 'develop' into feature/adaptive-learning/feedback-prefer…
ahmetsenturk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/main/java/de/tum/cit/aet/artemis/atlas/dto/LearnerProfileDTO.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| package de.tum.cit.aet.artemis.atlas.dto; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonInclude; | ||
|
|
||
| import de.tum.cit.aet.artemis.atlas.domain.profile.LearnerProfile; | ||
|
|
||
| @JsonInclude(JsonInclude.Include.NON_EMPTY) | ||
| public record LearnerProfileDTO(long id, int feedbackPracticalTheoretical, int feedbackCreativeGuidance, int feedbackFollowupSummary, int feedbackBriefDetailed) { | ||
|
|
||
| /** | ||
| * Creates LearnerProfileDTO from given LearnerProfile. | ||
| * | ||
| * @param learnerProfile The given LearnerProfile | ||
| * @return LearnerProfile DTO for transfer | ||
| */ | ||
| public static LearnerProfileDTO of(LearnerProfile learnerProfile) { | ||
| return new LearnerProfileDTO(learnerProfile.getId(), learnerProfile.getFeedbackPracticalTheoretical(), learnerProfile.getFeedbackCreativeGuidance(), | ||
| learnerProfile.getFeedbackFollowupSummary(), learnerProfile.getFeedbackBriefDetailed()); | ||
| } | ||
ahmetsenturk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
97 changes: 97 additions & 0 deletions
97
src/main/java/de/tum/cit/aet/artemis/atlas/web/LearnerProfileResource.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| package de.tum.cit.aet.artemis.atlas.web; | ||
|
|
||
| import java.util.Optional; | ||
|
|
||
| import org.springframework.context.annotation.Conditional; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
| import org.springframework.web.bind.annotation.PathVariable; | ||
| import org.springframework.web.bind.annotation.PutMapping; | ||
| import org.springframework.web.bind.annotation.RequestBody; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| import de.tum.cit.aet.artemis.atlas.config.AtlasEnabled; | ||
| import de.tum.cit.aet.artemis.atlas.domain.profile.LearnerProfile; | ||
| import de.tum.cit.aet.artemis.atlas.dto.LearnerProfileDTO; | ||
| import de.tum.cit.aet.artemis.atlas.repository.LearnerProfileRepository; | ||
| import de.tum.cit.aet.artemis.core.domain.User; | ||
| import de.tum.cit.aet.artemis.core.exception.BadRequestAlertException; | ||
| import de.tum.cit.aet.artemis.core.repository.UserRepository; | ||
| import de.tum.cit.aet.artemis.core.security.annotations.EnforceAtLeastStudent; | ||
|
|
||
| @Conditional(AtlasEnabled.class) | ||
| @RestController | ||
| @RequestMapping("api/atlas/") | ||
| public class LearnerProfileResource { | ||
|
|
||
| private static final int MIN_PROFILE_VALUE = 1; | ||
|
|
||
| private static final int MAX_PROFILE_VALUE = 5; | ||
|
|
||
| private final UserRepository userRepository; | ||
|
|
||
| private final LearnerProfileRepository learnerProfileRepository; | ||
|
|
||
| public LearnerProfileResource(UserRepository userRepository, LearnerProfileRepository learnerProfileRepository) { | ||
| this.userRepository = userRepository; | ||
| this.learnerProfileRepository = learnerProfileRepository; | ||
| } | ||
|
|
||
| /** | ||
| * Validates that fields are within {@link #MIN_PROFILE_VALUE} and {@link #MAX_PROFILE_VALUE}. | ||
| * | ||
| * @param value Value of the field | ||
| * @param fieldName Field name | ||
| */ | ||
| private void validateProfileField(int value, String fieldName) { | ||
| if (value < MIN_PROFILE_VALUE || value > MAX_PROFILE_VALUE) { | ||
| throw new BadRequestAlertException(fieldName + " field is outside valid bounds", LearnerProfile.ENTITY_NAME, fieldName.toLowerCase() + "OutOfBounds", true); | ||
| } | ||
| } | ||
|
|
||
| @GetMapping("learner-profiles") | ||
| @EnforceAtLeastStudent | ||
| public ResponseEntity<LearnerProfileDTO> getLearnerProfile() { | ||
| User user = userRepository.getUser(); | ||
| LearnerProfile profile = learnerProfileRepository.findByUserElseThrow(user); | ||
| return ResponseEntity.ok(LearnerProfileDTO.of(profile)); | ||
| } | ||
|
|
||
| /** | ||
| * PUT /learner-profiles/{learnerProfileId} : update fields in a {@link LearnerProfile}. | ||
| * | ||
| * @param learnerProfileId ID of the LearnerProfile | ||
| * @param learnerProfileDTO {@link LearnerProfileDTO} object from the request body. | ||
| * @return A ResponseEntity with a status matching the validity of the request containing the updated profile. | ||
| */ | ||
| @PutMapping(value = "learner-profiles/{learnerProfileId}") | ||
| @EnforceAtLeastStudent | ||
| public ResponseEntity<LearnerProfileDTO> updateLearnerProfile(@PathVariable long learnerProfileId, @RequestBody LearnerProfileDTO learnerProfileDTO) { | ||
| User user = userRepository.getUser(); | ||
|
|
||
| if (learnerProfileDTO.id() != learnerProfileId) { | ||
| throw new BadRequestAlertException("Provided learnerProfileId does not match learnerProfile.", LearnerProfile.ENTITY_NAME, "objectDoesNotMatchId", true); | ||
| } | ||
|
|
||
| Optional<LearnerProfile> optionalLearnerProfile = learnerProfileRepository.findByUser(user); | ||
|
|
||
| if (optionalLearnerProfile.isEmpty()) { | ||
| throw new BadRequestAlertException("LearnerProfile not found.", LearnerProfile.ENTITY_NAME, "LearnerProfileNotFound", true); | ||
| } | ||
|
|
||
ahmetsenturk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| validateProfileField(learnerProfileDTO.feedbackPracticalTheoretical(), "FeedbackPracticalTheoretical"); | ||
| validateProfileField(learnerProfileDTO.feedbackCreativeGuidance(), "FeedbackCreativeGuidance"); | ||
| validateProfileField(learnerProfileDTO.feedbackFollowupSummary(), "FeedbackFollowupSummary"); | ||
| validateProfileField(learnerProfileDTO.feedbackBriefDetailed(), "FeedbackBriefDetailed"); | ||
|
|
||
| LearnerProfile updateProfile = optionalLearnerProfile.get(); | ||
| updateProfile.setFeedbackPracticalTheoretical(learnerProfileDTO.feedbackPracticalTheoretical()); | ||
| updateProfile.setFeedbackCreativeGuidance(learnerProfileDTO.feedbackCreativeGuidance()); | ||
| updateProfile.setFeedbackFollowupSummary(learnerProfileDTO.feedbackFollowupSummary()); | ||
| updateProfile.setFeedbackBriefDetailed(learnerProfileDTO.feedbackBriefDetailed()); | ||
|
|
||
| LearnerProfile result = learnerProfileRepository.save(updateProfile); | ||
| return ResponseEntity.ok(LearnerProfileDTO.of(result)); | ||
| } | ||
| } | ||
22 changes: 22 additions & 0 deletions
22
src/main/resources/config/liquibase/changelog/20250409191359_changelog.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd"> | ||
|
|
||
| <changeSet id="20250409191359" author="ahmetsenturk"> | ||
| <addColumn tableName="learner_profile"> | ||
| <column name="feedback_practical_theoretical" type="int" defaultValueNumeric="3"> | ||
| <constraints nullable="false"/> | ||
| </column> | ||
| <column name="feedback_creative_guidance" type="int" defaultValueNumeric="3"> | ||
| <constraints nullable="false"/> | ||
| </column> | ||
| <column name="feedback_followup_summary" type="int" defaultValueNumeric="3"> | ||
| <constraints nullable="false"/> | ||
| </column> | ||
| <column name="feedback_brief_detailed" type="int" defaultValueNumeric="3"> | ||
| <constraints nullable="false"/> | ||
| </column> | ||
| </addColumn> | ||
| </changeSet> | ||
|
|
||
| </databaseChangeLog> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
src/main/webapp/app/core/user/settings/learner-profile/learner-profile.component.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| <div class="d-flex justify-content-between"> | ||
| <div> | ||
| <h1 jhiTranslate="artemisApp.learnerProfile.title"></h1> | ||
| <div class="d-flex userSettings-info"> | ||
| <fa-icon class="ng-fa-icon" [icon]="faInfoCircle" /> | ||
| <span class="ps-1" jhiTranslate="artemisApp.learnerProfile.description"></span> | ||
| </div> | ||
| </div> | ||
| @if (settingsChanged) { | ||
| <div class="d-flex align-items-center"> | ||
| <button type="button" class="btn btn-primary" (click)="save()"> | ||
| <fa-icon class="ng-fa-icon" [icon]="faSave" /> | ||
| <span jhiTranslate="entity.action.save"></span> | ||
| </button> | ||
| </div> | ||
| } | ||
| </div> | ||
|
|
||
| <div class="list-group d-block"> | ||
| <div class="list-group-item"> | ||
| <h3 jhiTranslate="artemisApp.learnerProfile.feedback.title"></h3> | ||
| <div class="preference-section"> | ||
| <dt jhiTranslate="artemisApp.learnerProfile.feedback.feedbackPracticalTheoretical.title"></dt> | ||
| <p class="text-muted" jhiTranslate="artemisApp.learnerProfile.feedback.feedbackPracticalTheoretical.description"></p> | ||
| <mat-slider min="1" max="5" step="1" [discrete]="true" showTickMarks [displayWith]="hideTooltip"> | ||
| <input | ||
| matSliderThumb | ||
| [value]="learnerProfile.feedbackPracticalTheoretical" | ||
| (valueChange)="learnerProfile.feedbackPracticalTheoretical = $event" | ||
| (change)="onSliderChange()" | ||
| /> | ||
| </mat-slider> | ||
ahmetsenturk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| <div class="labels"> | ||
| <span jhiTranslate="artemisApp.learnerProfile.feedback.feedbackPracticalTheoretical.practical"></span> | ||
| <span jhiTranslate="artemisApp.learnerProfile.feedback.feedbackPracticalTheoretical.theoretical"></span> | ||
| </div> | ||
| </div> | ||
| <div class="preference-section"> | ||
| <dt jhiTranslate="artemisApp.learnerProfile.feedback.feedbackCreativeGuidance.title"></dt> | ||
| <p class="text-muted" jhiTranslate="artemisApp.learnerProfile.feedback.feedbackCreativeGuidance.description"></p> | ||
| <mat-slider min="1" max="5" step="1" [discrete]="true" showTickMarks [displayWith]="hideTooltip"> | ||
| <input matSliderThumb [(ngModel)]="learnerProfile.feedbackCreativeGuidance" (change)="onSliderChange()" /> | ||
| </mat-slider> | ||
| <div class="labels"> | ||
| <span jhiTranslate="artemisApp.learnerProfile.feedback.feedbackCreativeGuidance.creative"></span> | ||
| <span jhiTranslate="artemisApp.learnerProfile.feedback.feedbackCreativeGuidance.focused"></span> | ||
| </div> | ||
| </div> | ||
| <div class="preference-section"> | ||
| <dt jhiTranslate="artemisApp.learnerProfile.feedback.feedbackFollowupSummary.title"></dt> | ||
| <p class="text-muted" jhiTranslate="artemisApp.learnerProfile.feedback.feedbackFollowupSummary.description"></p> | ||
| <mat-slider min="1" max="5" step="1" [discrete]="true" showTickMarks [displayWith]="hideTooltip"> | ||
| <input matSliderThumb [(ngModel)]="learnerProfile.feedbackFollowupSummary" (change)="onSliderChange()" /> | ||
| </mat-slider> | ||
| <div class="labels"> | ||
| <span jhiTranslate="artemisApp.learnerProfile.feedback.feedbackFollowupSummary.followUp"></span> | ||
| <span jhiTranslate="artemisApp.learnerProfile.feedback.feedbackFollowupSummary.summary"></span> | ||
| </div> | ||
| </div> | ||
| <div class="preference-section"> | ||
| <dt jhiTranslate="artemisApp.learnerProfile.feedback.feedbackBriefDetailed.title"></dt> | ||
| <p class="text-muted" jhiTranslate="artemisApp.learnerProfile.feedback.feedbackBriefDetailed.description"></p> | ||
| <mat-slider min="1" max="5" step="1" [discrete]="true" showTickMarks [displayWith]="hideTooltip"> | ||
| <input matSliderThumb [(ngModel)]="learnerProfile.feedbackBriefDetailed" (change)="onSliderChange()" /> | ||
| </mat-slider> | ||
| <div class="labels"> | ||
| <span jhiTranslate="artemisApp.learnerProfile.feedback.feedbackBriefDetailed.brief"></span> | ||
| <span jhiTranslate="artemisApp.learnerProfile.feedback.feedbackBriefDetailed.detailed"></span> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
ahmetsenturk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
64 changes: 64 additions & 0 deletions
64
src/main/webapp/app/core/user/settings/learner-profile/learner-profile.component.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| .preference-section { | ||
| margin-bottom: 32px; | ||
|
|
||
| .text-muted { | ||
| font-size: 0.9rem; | ||
| margin-bottom: 16px; | ||
| line-height: 1.4; | ||
| } | ||
|
|
||
| mat-slider { | ||
| width: 98%; | ||
| margin-bottom: 8px; | ||
|
|
||
| ::ng-deep { | ||
|
Check warning on line 14 in src/main/webapp/app/core/user/settings/learner-profile/learner-profile.component.scss
|
||
| .mdc-slider__thumb { | ||
| border-radius: 50% !important; | ||
| width: 24px !important; | ||
| height: 24px !important; | ||
| background-color: var(--bs-primary) !important; | ||
| top: 8px !important; | ||
| } | ||
|
|
||
| .mdc-slider__track { | ||
| height: 8px !important; | ||
| border-radius: 5px !important; | ||
| margin: 0 -12px !important; | ||
| } | ||
|
|
||
| .mdc-slider__track--inactive { | ||
| background-color: #e0e0e0 !important; | ||
| border-radius: 5px !important; | ||
| } | ||
|
|
||
| .mdc-slider__track--active { | ||
| background-color: var(--bs-primary) !important; | ||
| border-radius: 5px !important; | ||
| } | ||
|
|
||
| .mdc-slider__thumb-knob { | ||
| border-radius: 100% !important; | ||
| width: 24px !important; | ||
| height: 24px !important; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| .labels { | ||
| display: flex; | ||
| justify-content: space-between; | ||
| color: #666; | ||
| font-size: 0.9rem; | ||
| } | ||
| } | ||
|
|
||
| .btn-primary { | ||
| padding: 8px 24px; | ||
| border-radius: 4px; | ||
| font-weight: 500; | ||
| transition: background-color 0.2s; | ||
|
|
||
| &:hover { | ||
| background-color: darken(#007bff, 5%); | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.