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

Adaptive learning: Redesign edit competency relation section #9447

Merged
merged 23 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
2287371
introduce new relations modal
JohannesWt Oct 9, 2024
d3b78ac
add update competency relation endpoint
JohannesWt Oct 9, 2024
ca328b6
remove relations from competency-management-table tests
JohannesWt Oct 9, 2024
8a060c8
fix relation node test and keep updated relation set (not resetting t…
JohannesWt Oct 9, 2024
86e8de3
move logic to service
JohannesWt Oct 9, 2024
1561ea9
fix server test
JohannesWt Oct 10, 2024
4579fb8
remove id from node
JohannesWt Oct 10, 2024
5ef411d
remove legacy code
JohannesWt Oct 10, 2024
f7647ed
fix client tests
JohannesWt Oct 10, 2024
e1dadc3
fix cycle check
JohannesWt Oct 10, 2024
a8ae560
introduce union search for cycle detection
JohannesWt Oct 14, 2024
96240ac
Merge branch 'develop' into feature/competencies/redesign-relations-c…
JohannesWt Oct 14, 2024
c20a679
show error when circular dependency would occur on update
JohannesWt Oct 14, 2024
2e334fc
deselect current relation on change
JohannesWt Oct 14, 2024
f3226d3
adjust tests and add translation
JohannesWt Oct 14, 2024
b773e2e
add more client tests
JohannesWt Oct 15, 2024
bd3756a
add more client tests for branch coverage
JohannesWt Oct 15, 2024
52f21ec
remove unnecessary number conversion
JohannesWt Oct 15, 2024
f1136c2
fix typos
JohannesWt Oct 15, 2024
b3f14d7
Merge branch 'develop' into feature/competencies/redesign-relations-c…
JohannesWt Oct 16, 2024
462c38a
Merge branch 'develop' into feature/competencies/redesign-relations-c…
JohannesWt Oct 22, 2024
d2d0a0d
fix translations
JohannesWt Oct 22, 2024
d564946
fix icon
JohannesWt Oct 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package de.tum.cit.aet.artemis.atlas.dto;

import com.fasterxml.jackson.annotation.JsonInclude;

import de.tum.cit.aet.artemis.atlas.domain.competency.RelationType;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
public record UpdateCourseCompetencyRelationDTO(RelationType newRelationType) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import de.tum.cit.aet.artemis.atlas.service.LearningObjectImportService;
import de.tum.cit.aet.artemis.atlas.service.learningpath.LearningPathService;
import de.tum.cit.aet.artemis.core.domain.Course;
import de.tum.cit.aet.artemis.core.repository.CourseRepository;
import de.tum.cit.aet.artemis.core.service.AuthorizationCheckService;
import de.tum.cit.aet.artemis.exercise.service.ExerciseService;
import de.tum.cit.aet.artemis.lecture.repository.LectureUnitCompletionRepository;
Expand All @@ -41,9 +42,9 @@ public CompetencyService(CompetencyRepository competencyRepository, Authorizatio
LearningPathService learningPathService, CompetencyProgressService competencyProgressService, LectureUnitService lectureUnitService,
CompetencyProgressRepository competencyProgressRepository, LectureUnitCompletionRepository lectureUnitCompletionRepository,
StandardizedCompetencyRepository standardizedCompetencyRepository, CourseCompetencyRepository courseCompetencyRepository, ExerciseService exerciseService,
LearningObjectImportService learningObjectImportService) {
LearningObjectImportService learningObjectImportService, CourseRepository courseRepository) {
super(competencyProgressRepository, courseCompetencyRepository, competencyRelationRepository, competencyProgressService, exerciseService, lectureUnitService,
learningPathService, authCheckService, standardizedCompetencyRepository, lectureUnitCompletionRepository, learningObjectImportService);
learningPathService, authCheckService, standardizedCompetencyRepository, lectureUnitCompletionRepository, learningObjectImportService, courseRepository);
this.competencyRepository = competencyRepository;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import de.tum.cit.aet.artemis.atlas.dto.CompetencyImportOptionsDTO;
import de.tum.cit.aet.artemis.atlas.dto.CompetencyRelationDTO;
import de.tum.cit.aet.artemis.atlas.dto.CompetencyWithTailRelationDTO;
import de.tum.cit.aet.artemis.atlas.dto.UpdateCourseCompetencyRelationDTO;
import de.tum.cit.aet.artemis.atlas.repository.CompetencyProgressRepository;
import de.tum.cit.aet.artemis.atlas.repository.CompetencyRelationRepository;
import de.tum.cit.aet.artemis.atlas.repository.CourseCompetencyRepository;
Expand All @@ -39,6 +40,7 @@
import de.tum.cit.aet.artemis.core.dto.pageablesearch.CompetencyPageableSearchDTO;
import de.tum.cit.aet.artemis.core.exception.BadRequestAlertException;
import de.tum.cit.aet.artemis.core.exception.EntityNotFoundException;
import de.tum.cit.aet.artemis.core.repository.CourseRepository;
import de.tum.cit.aet.artemis.core.service.AuthorizationCheckService;
import de.tum.cit.aet.artemis.core.util.PageUtil;
import de.tum.cit.aet.artemis.exercise.domain.Exercise;
Expand Down Expand Up @@ -77,11 +79,13 @@ public class CourseCompetencyService {

private final LearningObjectImportService learningObjectImportService;

private final CourseRepository courseRepository;

public CourseCompetencyService(CompetencyProgressRepository competencyProgressRepository, CourseCompetencyRepository courseCompetencyRepository,
CompetencyRelationRepository competencyRelationRepository, CompetencyProgressService competencyProgressService, ExerciseService exerciseService,
LectureUnitService lectureUnitService, LearningPathService learningPathService, AuthorizationCheckService authCheckService,
StandardizedCompetencyRepository standardizedCompetencyRepository, LectureUnitCompletionRepository lectureUnitCompletionRepository,
LearningObjectImportService learningObjectImportService) {
LearningObjectImportService learningObjectImportService, CourseRepository courseRepository) {
this.competencyProgressRepository = competencyProgressRepository;
this.courseCompetencyRepository = courseCompetencyRepository;
this.competencyRelationRepository = competencyRelationRepository;
Expand All @@ -93,6 +97,7 @@ public CourseCompetencyService(CompetencyProgressRepository competencyProgressRe
this.standardizedCompetencyRepository = standardizedCompetencyRepository;
this.lectureUnitCompletionRepository = lectureUnitCompletionRepository;
this.learningObjectImportService = learningObjectImportService;
this.courseRepository = courseRepository;
}

/**
Expand Down Expand Up @@ -123,6 +128,28 @@ public List<CourseCompetency> findCourseCompetenciesWithProgressForUserByCourseI
return findProgressForCompetenciesAndUser(competencies, userId);
}

/**
* Updates the type of a course competency relation.
*
* @param courseId The id of the course for which to fetch the competencies
* @param courseCompetencyRelationId The id of the course competency relation to update
* @param updateCourseCompetencyRelationDTO The DTO containing the new relation type
*
*/
public void updateCourseCompetencyRelation(long courseId, long courseCompetencyRelationId, UpdateCourseCompetencyRelationDTO updateCourseCompetencyRelationDTO) {
var relation = competencyRelationRepository.findByIdElseThrow(courseCompetencyRelationId);
var course = courseRepository.findByIdElseThrow(courseId);
var headCompetency = relation.getHeadCompetency();
var tailCompetency = relation.getTailCompetency();

if (!course.getId().equals(headCompetency.getCourse().getId()) || !course.getId().equals(tailCompetency.getCourse().getId())) {
throw new BadRequestAlertException("The relation does not belong to the course", ENTITY_NAME, "relationWrongCourse");
}

relation.setType(updateCourseCompetencyRelationDTO.newRelationType());
competencyRelationRepository.save(relation);
}

/**
* Search for all course competencies fitting a {@link CompetencyPageableSearchDTO search query}. The result is paged.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import de.tum.cit.aet.artemis.atlas.service.LearningObjectImportService;
import de.tum.cit.aet.artemis.atlas.service.learningpath.LearningPathService;
import de.tum.cit.aet.artemis.core.domain.Course;
import de.tum.cit.aet.artemis.core.repository.CourseRepository;
import de.tum.cit.aet.artemis.core.service.AuthorizationCheckService;
import de.tum.cit.aet.artemis.exercise.service.ExerciseService;
import de.tum.cit.aet.artemis.lecture.repository.LectureUnitCompletionRepository;
Expand All @@ -41,9 +42,9 @@ public PrerequisiteService(PrerequisiteRepository prerequisiteRepository, Author
LearningPathService learningPathService, CompetencyProgressService competencyProgressService, LectureUnitService lectureUnitService,
CompetencyProgressRepository competencyProgressRepository, LectureUnitCompletionRepository lectureUnitCompletionRepository,
StandardizedCompetencyRepository standardizedCompetencyRepository, CourseCompetencyRepository courseCompetencyRepository, ExerciseService exerciseService,
LearningObjectImportService learningObjectImportService) {
LearningObjectImportService learningObjectImportService, CourseRepository courseRepository) {
super(competencyProgressRepository, courseCompetencyRepository, competencyRelationRepository, competencyProgressService, exerciseService, lectureUnitService,
learningPathService, authCheckService, standardizedCompetencyRepository, lectureUnitCompletionRepository, learningObjectImportService);
learningPathService, authCheckService, standardizedCompetencyRepository, lectureUnitCompletionRepository, learningObjectImportService, courseRepository);
this.prerequisiteRepository = prerequisiteRepository;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.Set;
import java.util.stream.Collectors;

import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;

import org.slf4j.Logger;
Expand All @@ -18,6 +19,7 @@
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
Expand All @@ -32,6 +34,7 @@
import de.tum.cit.aet.artemis.atlas.dto.CompetencyJolPairDTO;
import de.tum.cit.aet.artemis.atlas.dto.CompetencyRelationDTO;
import de.tum.cit.aet.artemis.atlas.dto.CompetencyWithTailRelationDTO;
import de.tum.cit.aet.artemis.atlas.dto.UpdateCourseCompetencyRelationDTO;
import de.tum.cit.aet.artemis.atlas.repository.CompetencyProgressRepository;
import de.tum.cit.aet.artemis.atlas.repository.CompetencyRelationRepository;
import de.tum.cit.aet.artemis.atlas.repository.CourseCompetencyRepository;
Expand Down Expand Up @@ -350,6 +353,23 @@ public ResponseEntity<Void> generateCompetenciesFromCourseDescription(@PathVaria
return ResponseEntity.accepted().build();
}

/**
* PATCH courses/:courseId/course-competencies/relations/:competencyRelationId update a relation type of an existing relation
*
* @param courseId the id of the course to which the competencies belong
* @param competencyRelationId the id of the competency relation to update
* @param updateCourseCompetencyRelationDTO the new relation type
* @return the ResponseEntity with status 200 (OK)
*/
@PatchMapping("courses/{courseId}/course-competencies/relations/{competencyRelationId}")
@EnforceAtLeastInstructorInCourse
public ResponseEntity<Void> updateCompetencyRelation(@PathVariable long courseId, @PathVariable long competencyRelationId,
@RequestBody @Valid UpdateCourseCompetencyRelationDTO updateCourseCompetencyRelationDTO) {
log.info("REST request to update a competency relation: {}", competencyRelationId);
courseCompetencyService.updateCourseCompetencyRelation(courseId, competencyRelationId, updateCourseCompetencyRelationDTO);
return ResponseEntity.noContent().build();
}

/**
* PUT courses/:courseId/course-competencies/:competencyId/jol/:jolValue : Sets the judgement of learning for a competency
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
import { Component, EventEmitter, Input, OnDestroy, OnInit, Output, inject } from '@angular/core';
import { CompetencyService } from 'app/course/competencies/competency.service';
import { AlertService } from 'app/core/util/alert.service';
import {
CompetencyRelation,
CompetencyRelationDTO,
CompetencyWithTailRelationDTO,
CourseCompetency,
CourseCompetencyType,
dtoToCompetencyRelation,
getIcon,
} from 'app/entities/competency.model';
import { CompetencyWithTailRelationDTO, CourseCompetency, CourseCompetencyType, getIcon } from 'app/entities/competency.model';
import { HttpErrorResponse, HttpResponse } from '@angular/common/http';
import { filter, map } from 'rxjs/operators';
import { onError } from 'app/shared/util/global.utils';
Expand All @@ -30,7 +22,6 @@ import { ArtemisMarkdownModule } from 'app/shared/markdown.module';
export class CompetencyManagementTableComponent implements OnInit, OnDestroy {
@Input() courseId: number;
@Input() courseCompetencies: CourseCompetency[];
@Input() relations: CompetencyRelation[];
@Input() competencyType: CourseCompetencyType;
@Input() standardizedCompetenciesEnabled: boolean;

Expand Down Expand Up @@ -103,14 +94,7 @@ export class CompetencyManagementTableComponent implements OnInit, OnDestroy {
*/
updateDataAfterImportAll(res: Array<CompetencyWithTailRelationDTO>) {
const importedCompetencies = res.map((dto) => dto.competency).filter((element): element is CourseCompetency => !!element);

const importedRelations = res
.map((dto) => dto.tailRelations)
.flat()
.filter((element): element is CompetencyRelationDTO => !!element)
.map((dto) => dtoToCompetencyRelation(dto));
this.courseCompetencies.push(...importedCompetencies);
this.relations.push(...importedRelations);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ <h2 class="m-0" jhiTranslate="artemisApp.competency.manage.title"></h2>
<span jhiTranslate="artemisApp.competency.manage.generateButton"></span>
</a>
}
<button class="btn btn-primary" id="openCourseCompetencyRelationsButton" (click)="openCourseCompetenciesRelationModal()">
<fa-icon [icon]="faEdit" />
<span jhiTranslate="artemisApp.courseCompetency.manage.editRelationsButton"></span>
</button>
<button class="btn btn-primary" id="courseCompetencyImportAllButton" (click)="openImportAllModal()">
<fa-icon [icon]="faFileImport" />
<span jhiTranslate="artemisApp.courseCompetency.manage.importAllButton"></span>
Expand All @@ -27,24 +31,16 @@ <h2 class="m-0" jhiTranslate="artemisApp.competency.manage.title"></h2>
</div>
</div>
}
<jhi-competency-relation-graph
[competencies]="courseCompetencies"
[relations]="relations"
(onCreateRelation)="createRelation($event)"
(onRemoveRelation)="onRemoveRelation($event)"
/>
<jhi-competency-management-table
[courseId]="courseId"
[courseCompetencies]="competencies"
[relations]="relations"
[competencyType]="CourseCompetencyType.COMPETENCY"
[standardizedCompetenciesEnabled]="standardizedCompetenciesEnabled"
(competencyDeleted)="onRemoveCompetency($event)"
/>
<jhi-competency-management-table
[courseId]="courseId"
[courseCompetencies]="prerequisites"
[relations]="relations"
[competencyType]="CourseCompetencyType.PREREQUISITE"
[standardizedCompetenciesEnabled]="standardizedCompetenciesEnabled"
(competencyDeleted)="onRemoveCompetency($event)"
Expand Down
Loading
Loading