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: Allow editors to edit the competency link weight #9564

Merged
merged 50 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
9713857
First refactoring
JohannesStoehr Oct 18, 2024
73f9597
Fix most tests
JohannesStoehr Oct 18, 2024
4c367aa
Merge branch 'develop' into feature/adaptive-learning/competency-link…
JohannesStoehr Oct 19, 2024
a700139
Try around
JohannesStoehr Oct 19, 2024
4d68a02
Revert LoggingAspect
JohannesStoehr Oct 19, 2024
99d0c85
Merge branch 'develop' into feature/adaptive-learning/competency-link…
JohannesStoehr Oct 20, 2024
8c3dc7c
Fix more tests
JohannesStoehr Oct 20, 2024
b029f0f
Merge branch 'refs/heads/develop' into feature/adaptive-learning/comp…
JohannesStoehr Oct 21, 2024
8d63e74
Fix more tests
JohannesStoehr Oct 21, 2024
3145850
Fix more tests
JohannesStoehr Oct 21, 2024
ff64ccc
Fix more tests
JohannesStoehr Oct 21, 2024
fe7318a
Fix exercise creation
JohannesStoehr Oct 21, 2024
4458e47
Fix exercise update server
JohannesStoehr Oct 21, 2024
bfa4f28
Fix exercise import
JohannesStoehr Oct 21, 2024
9f070ac
Done
JohannesStoehr Oct 22, 2024
b52d014
Fix tests
JohannesStoehr Oct 22, 2024
7bead56
Merge branch 'develop' into feature/adaptive-learning/competency-link…
JohannesStoehr Oct 22, 2024
dcd99c3
Fix last things
JohannesStoehr Oct 22, 2024
c87a614
Remove log
JohannesStoehr Oct 22, 2024
c7dbf9d
Allow user editing
JohannesStoehr Oct 22, 2024
f285a0d
Patrik
JohannesStoehr Oct 22, 2024
583ee8a
Merge branch 'feature/adaptive-learning/competency-link-weight' into …
JohannesStoehr Oct 22, 2024
038d66c
Merge branch 'develop' into feature/adaptive-learning/competency-link…
JohannesStoehr Oct 23, 2024
2d3cade
Merge branch 'feature/adaptive-learning/competency-link-weight' into …
JohannesStoehr Oct 23, 2024
1d2d45a
Merge branch 'develop' into feature/adaptive-learning/competency-link…
JohannesStoehr Oct 24, 2024
43b5e39
Use variables
JohannesStoehr Oct 24, 2024
b4f1334
Use SCREAMING_SNAKE_CASE
JohannesStoehr Oct 24, 2024
40d3d87
Merge branch 'feature/adaptive-learning/competency-link-weight' into …
JohannesStoehr Oct 24, 2024
45103b8
Merge remote-tracking branch 'origin/feature/adaptive-learning/compet…
JohannesStoehr Oct 24, 2024
30f9583
Make Flo happy
JohannesStoehr Oct 25, 2024
009c6ec
Merge branch 'develop' into feature/adaptive-learning/competency-link…
JohannesStoehr Oct 25, 2024
ad560fd
Merge branch 'feature/adaptive-learning/competency-link-weight' into …
JohannesStoehr Oct 25, 2024
7c0d345
Make Flo happy transitively
JohannesStoehr Oct 25, 2024
9efb40f
Fix and combine test
JohannesStoehr Oct 25, 2024
597ea81
Merge branch 'feature/adaptive-learning/competency-link-weight' into …
JohannesStoehr Oct 25, 2024
7534972
Merge branch 'develop' into feature/adaptive-learning/competency-link…
JohannesStoehr Oct 25, 2024
c0d5076
Merge branch 'feature/adaptive-learning/competency-link-weight' into …
JohannesStoehr Oct 25, 2024
c4f30cf
Merge branch 'develop' into feature/adaptive-learning/competency-link…
JohannesStoehr Oct 26, 2024
7a0eace
Merge branch 'develop' into feature/adaptive-learning/competency-link…
JohannesStoehr Oct 26, 2024
b1f9e9d
Merge branch 'develop' into feature/adaptive-learning/competency-link…
JohannesStoehr Oct 27, 2024
b2cf54d
Merge branch 'feature/adaptive-learning/competency-link-weight' into …
JohannesStoehr Oct 27, 2024
276989e
Merge branch 'develop' into feature/adaptive-learning/competency-link…
JohannesStoehr Oct 27, 2024
674a52d
Merge branch 'develop' into feature/adaptive-learning/competency-link…
JohannesStoehr Oct 28, 2024
19c6044
Increase test coverage
JohannesStoehr Oct 28, 2024
f543026
Fix constructor order
JohannesStoehr Oct 28, 2024
b83e2cf
Merge branch 'feature/adaptive-learning/competency-link-weight' into …
JohannesStoehr Oct 28, 2024
eca4ef4
Merge branch 'develop' into feature/adaptive-learning/competency-link…
JohannesStoehr Oct 30, 2024
e1bb388
Fix merge conflict
JohannesStoehr Oct 30, 2024
b492936
Merge branch 'feature/adaptive-learning/competency-link-weight' into …
JohannesStoehr Oct 30, 2024
bf92aac
Merge branch 'develop' into feature/adaptive-learning/competency-link…
JohannesStoehr Oct 30, 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
4 changes: 4 additions & 0 deletions src/main/webapp/app/entities/competency.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ export enum CourseCompetencyType {

export const DEFAULT_MASTERY_THRESHOLD = 100;

export const HIGH_COMPETENCY_LINK_WEIGHT = 1;
export const MEDIUM_COMPETENCY_LINK_WEIGHT = 0.5;
export const LOW_COMPETENCY_LINK_WEIGHT = 0.25;
export const LOW_COMPETENCY_LINK_WEIGHT_CUT_OFF = 0.375; // halfway between low and medium
export const MEDIUM_COMPETENCY_LINK_WEIGHT_CUT_OFF = 0.75; // halfway between medium and high

export abstract class BaseCompetency implements BaseEntity {
id?: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,23 @@
<fa-icon [icon]="getIcon(competencyLink.competency.taxonomy)" [fixedWidth]="true" />
{{ competencyLink.competency.title }}
</label>
@if (checkboxStates[competencyLink.competency.id]) {
<select
[ngModel]="
competencyLink.weight < LOW_COMPETENCY_LINK_WEIGHT_CUT_OFF
? LOW_COMPETENCY_LINK_WEIGHT
: competencyLink.weight < MEDIUM_COMPETENCY_LINK_WEIGHT_CUT_OFF
? MEDIUM_COMPETENCY_LINK_WEIGHT
: HIGH_COMPETENCY_LINK_WEIGHT
"
JohannesStoehr marked this conversation as resolved.
Show resolved Hide resolved
(ngModelChange)="updateLinkWeight(competencyLink, $event)"
ngbTooltip="{{ 'artemisApp.competency.link.weightTooltip' | artemisTranslate }}"
>
<option [ngValue]="LOW_COMPETENCY_LINK_WEIGHT" [jhiTranslate]="'artemisApp.competency.link.weightLabels.low'"></option>
<option [ngValue]="MEDIUM_COMPETENCY_LINK_WEIGHT" [jhiTranslate]="'artemisApp.competency.link.weightLabels.medium'"></option>
<option [ngValue]="HIGH_COMPETENCY_LINK_WEIGHT" [jhiTranslate]="'artemisApp.competency.link.weightLabels.high'"></option>
</select>
}
</div>
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
import { ChangeDetectorRef, Component, EventEmitter, Input, OnInit, Output, forwardRef } from '@angular/core';
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
import { faQuestionCircle } from '@fortawesome/free-solid-svg-icons';
import { CompetencyLearningObjectLink, CourseCompetency, MEDIUM_COMPETENCY_LINK_WEIGHT, getIcon } from 'app/entities/competency.model';
import {
CompetencyLearningObjectLink,
CourseCompetency,
HIGH_COMPETENCY_LINK_WEIGHT,
LOW_COMPETENCY_LINK_WEIGHT,
LOW_COMPETENCY_LINK_WEIGHT_CUT_OFF,
MEDIUM_COMPETENCY_LINK_WEIGHT,
MEDIUM_COMPETENCY_LINK_WEIGHT_CUT_OFF,
getIcon,
} from 'app/entities/competency.model';
import { ActivatedRoute } from '@angular/router';
import { CourseStorageService } from 'app/course/manage/course-storage.service';
import { finalize } from 'rxjs';
Expand Down Expand Up @@ -40,6 +49,12 @@ export class CompetencySelectionComponent implements OnInit, ControlValueAccesso
// eslint-disable-next-line @typescript-eslint/no-unused-vars
_onChange = (value: any) => {};

protected readonly HIGH_COMPETENCY_LINK_WEIGHT = HIGH_COMPETENCY_LINK_WEIGHT;
protected readonly MEDIUM_COMPETENCY_LINK_WEIGHT = MEDIUM_COMPETENCY_LINK_WEIGHT;
protected readonly LOW_COMPETENCY_LINK_WEIGHT = LOW_COMPETENCY_LINK_WEIGHT;
protected readonly LOW_COMPETENCY_LINK_WEIGHT_CUT_OFF = LOW_COMPETENCY_LINK_WEIGHT_CUT_OFF; // halfway between low and medium
protected readonly MEDIUM_COMPETENCY_LINK_WEIGHT_CUT_OFF = MEDIUM_COMPETENCY_LINK_WEIGHT_CUT_OFF; // halfway between medium and high

constructor(
private route: ActivatedRoute,
private courseStorageService: CourseStorageService,
Expand Down Expand Up @@ -122,7 +137,19 @@ export class CompetencySelectionComponent implements OnInit, ControlValueAccesso
}
}

updateLinkWeight(link: CompetencyLearningObjectLink, value: number) {
link.weight = value;

this._onChange(this.selectedCompetencyLinks);
this.valueChange.emit(this.selectedCompetencyLinks);
}

writeValue(value?: CompetencyLearningObjectLink[]): void {
this.competencyLinks?.forEach((link) => {
const selectedLink = value?.find((value) => value.competency?.id === link.competency?.id);
link.weight = selectedLink?.weight ?? MEDIUM_COMPETENCY_LINK_WEIGHT;
});

if (value && this.competencyLinks) {
// Compare the ids of the competencies instead of the whole objects
const ids = value.map((el) => el.competency?.id);
Expand Down
8 changes: 7 additions & 1 deletion src/main/webapp/i18n/de/competency.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,13 @@
"link": {
"title": "Verbundene Kompetenzen",
"lectureUnit": "Verbinde diese Vorlesungseinheit wahlweise mit einer oder mehreren Kompetenzen.",
"exercise": "Verbinde diese Übung wahlweise mit einer oder mehreren Kompetenzen."
"exercise": "Verbinde diese Übung wahlweise mit einer oder mehreren Kompetenzen.",
"weightTooltip": "Die Relevanz dieses Lernobjektes für die Kompetenz.",
"weightLabels": {
"low": "Niedrig",
"medium": "Mittel",
"high": "Hoch"
}
},
"competencyCard": {
"connectedLectureUnits": "Verbundene Vorlesungseinheiten",
Expand Down
8 changes: 7 additions & 1 deletion src/main/webapp/i18n/en/competency.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,13 @@
"link": {
"title": "Linked Competencies",
"lectureUnit": "Optionally link this lecture unit to one or more competencies.",
"exercise": "Optionally link this exercise to one or more competencies."
"exercise": "Optionally link this exercise to one or more competencies.",
"weightTooltip": "The relevance of this learning object for the competency.",
"weightLabels": {
"low": "Low",
"medium": "Medium",
"high": "High"
}
},
"competencyCard": {
"connectedLectureUnits": "Linked Lecture Units",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { By } from '@angular/platform-browser';
import { CourseStorageService } from 'app/course/manage/course-storage.service';
import { ChangeDetectorRef } from '@angular/core';
import { CourseCompetencyService } from 'app/course/competencies/course-competency.service';
import { Prerequisite } from 'app/entities/prerequisite.model';

describe('CompetencySelection', () => {
let fixture: ComponentFixture<CompetencySelectionComponent>;
Expand Down Expand Up @@ -122,6 +123,22 @@ describe('CompetencySelection', () => {
expect(component.selectedCompetencyLinks?.first()?.competency?.title).toBe('test');
});

it('should update link weight when value is written', () => {
jest.spyOn(courseStorageService, 'getCourse').mockReturnValue({
competencies: [{ id: 1, title: 'test' } as Competency, { id: 2, title: 'testAgain' } as Prerequisite, { id: 3, title: 'testMore' } as Competency],
});

fixture.detectChanges();

component.writeValue([
new CompetencyLearningObjectLink({ id: 1, title: 'other' } as Competency, 0.5),
new CompetencyLearningObjectLink({ id: 3, title: 'otherMore' } as Competency, 1),
]);
expect(component.selectedCompetencyLinks).toBeArrayOfSize(2);
expect(component.selectedCompetencyLinks?.first()?.weight).toBe(0.5);
expect(component.selectedCompetencyLinks?.last()?.weight).toBe(1);
});

it('should trigger change detection after loading competencies', () => {
jest.spyOn(courseStorageService, 'getCourse').mockReturnValue({ competencies: undefined });
const changeDetector = fixture.debugElement.injector.get(ChangeDetectorRef);
Expand Down
Loading