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: Unlink edited competencies from standardised competencies #9396

Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
Expand Up @@ -359,6 +359,7 @@ public <C extends CourseCompetency> C updateCourseCompetency(C competencyToUpdat
competencyToUpdate.setMasteryThreshold(competency.getMasteryThreshold());
competencyToUpdate.setTaxonomy(competency.getTaxonomy());
competencyToUpdate.setOptional(competency.isOptional());
competencyToUpdate.setLinkedStandardizedCompetency(null);
JohannesStoehr marked this conversation as resolved.
Show resolved Hide resolved
final var persistedCompetency = courseCompetencyRepository.save(competencyToUpdate);

// update competency progress if necessary
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<h3 jhiTranslate="artemisApp.competency.edit.title"></h3>
<jhi-competency-form
[isEditMode]="true"
[hasLinkedStandardizedCompetency]="!!competency.linkedStandardizedCompetency"
JohannesStoehr marked this conversation as resolved.
Show resolved Hide resolved
[formData]="formData"
(formSubmitted)="updateCompetency($event)"
[courseId]="courseId"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,23 @@
<form [formGroup]="form" (ngSubmit)="submitForm()">
<jhi-common-course-competency-form
[formData]="formData"
[isEditMode]="isEditMode"
[isInConnectMode]="isInConnectMode"
[isInSingleLectureMode]="isInSingleLectureMode"
[lecturesOfCourseWithLectureUnits]="lecturesOfCourseWithLectureUnits"
[averageStudentScore]="averageStudentScore"
[isEditMode]="isEditMode()"
[isInConnectMode]="isInConnectMode()"
[isInSingleLectureMode]="isInSingleLectureMode()"
[lecturesOfCourseWithLectureUnits]="lecturesOfCourseWithLectureUnits()"
[averageStudentScore]="averageStudentScore()"
JohannesStoehr marked this conversation as resolved.
Show resolved Hide resolved
[form]="form"
[competencyType]="CourseCompetencyType.COMPETENCY"
(onLectureUnitSelectionChange)="onLectureUnitSelectionChange($event)"
/>
<div>
@if (hasLinkedStandardizedCompetency()) {
<div class="alert alert-warning" role="alert" jhiTranslate="artemisApp.courseCompetency.edit.unlinkStandardizedCompetenciesWarning"></div>
}
<button id="submitButton" class="btn btn-primary me-2" type="submit" [disabled]="!isSubmitPossible">
<span jhiTranslate="entity.action.submit"></span>
</button>
@if (hasCancelButton) {
@if (hasCancelButton()) {
<button type="button" (click)="cancelForm()" class="btn btn-default">
<fa-icon [icon]="faTimes" />&nbsp;<span jhiTranslate="entity.action.cancel"></span>
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class CompetencyFormComponent extends CourseCompetencyFormComponent imple

ngOnChanges(): void {
this.initializeForm();
if (this.isEditMode && this.formData) {
if (this.isEditMode() && this.formData) {
JohannesStoehr marked this conversation as resolved.
Show resolved Hide resolved
this.setFormValues(this.formData);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { Component, EventEmitter, Output, input } from '@angular/core';
import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Incorrect import of 'input' from '@angular/core'

The input function is being imported from @angular/core, but it is not a standard export from that module. This could lead to import errors. Please ensure that input is imported from the correct module.

Apply this diff to correct the import statement:

-import { Component, EventEmitter, Output, input } from '@angular/core';
+import { Component, EventEmitter, Output } from '@angular/core';
+import { input } from 'path/to/your/utility/module'; // Replace with the correct import path

Committable suggestion was skipped due to low confidence.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason for changing the order here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, input is now no longer capitalised (signal vs. @Input()) and our linter wants all capitalised words before the others

import { of } from 'rxjs';
import { catchError, delay, map, switchMap } from 'rxjs/operators';
Expand Down Expand Up @@ -55,20 +55,14 @@ export interface CourseCompetencyFormData {
export abstract class CourseCompetencyFormComponent {
abstract formData: CourseCompetencyFormData;

@Input()
isEditMode = false;
@Input()
isInConnectMode = false;
@Input()
isInSingleLectureMode = false;
@Input()
courseId: number;
@Input()
lecturesOfCourseWithLectureUnits: Lecture[] = [];
@Input()
averageStudentScore?: number;
@Input()
hasCancelButton: boolean;
isEditMode = input<boolean>(false);
isInConnectMode = input<boolean>(false);
isInSingleLectureMode = input<boolean>(false);
hasLinkedStandardizedCompetency = input<boolean>(false);
courseId = input<number>();
lecturesOfCourseWithLectureUnits = input<Lecture[]>([]);
JohannesStoehr marked this conversation as resolved.
Show resolved Hide resolved
averageStudentScore = input<number | undefined>();
hasCancelButton = input<boolean>();

JohannesStoehr marked this conversation as resolved.
Show resolved Hide resolved
@Output()
onCancel: EventEmitter<any> = new EventEmitter<any>();
Expand Down Expand Up @@ -122,14 +116,14 @@ export abstract class CourseCompetencyFormComponent {
return;
}
let initialTitle: string | undefined = undefined;
if (this.isEditMode && this.formData && this.formData.title) {
if (this.isEditMode() && this.formData && this.formData.title) {
initialTitle = this.formData.title;
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Accessing input properties as functions may be confusing

In the condition if (this.isEditMode() && this.formData && this.formData.title), isEditMode is accessed as a function (this.isEditMode()). This may cause confusion, as input properties in Angular are typically accessed as variables, not functions.

Consider refactoring to access isEditMode as a property:

- if (this.isEditMode() && this.formData && this.formData.title) {
+ if (this.isEditMode && this.formData && this.formData.title) {

If input returns a function intentionally, consider renaming it to clarify its usage, or document this behavior to aid other developers.

Committable suggestion was skipped due to low confidence.

}
this.form = this.fb.nonNullable.group({
title: [
undefined as string | undefined,
[Validators.required, Validators.maxLength(255)],
[titleUniqueValidator(this.courseCompetencyService, this.courseId, initialTitle)],
[titleUniqueValidator(this.courseCompetencyService, this.courseId()!, initialTitle)],
],
JohannesStoehr marked this conversation as resolved.
Show resolved Hide resolved
description: [undefined as string | undefined, [Validators.maxLength(10000)]],
softDueDate: [undefined],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,23 @@
<form [formGroup]="form" (ngSubmit)="submitForm()">
<jhi-common-course-competency-form
[formData]="formData"
[isEditMode]="isEditMode"
[isInConnectMode]="isInConnectMode"
[isInSingleLectureMode]="isInSingleLectureMode"
[lecturesOfCourseWithLectureUnits]="lecturesOfCourseWithLectureUnits"
[averageStudentScore]="averageStudentScore"
[isEditMode]="isEditMode()"
[isInConnectMode]="isInConnectMode()"
[isInSingleLectureMode]="isInSingleLectureMode()"
[lecturesOfCourseWithLectureUnits]="lecturesOfCourseWithLectureUnits()"
[averageStudentScore]="averageStudentScore()"
[form]="form"
[competencyType]="CourseCompetencyType.PREREQUISITE"
(onLectureUnitSelectionChange)="onLectureUnitSelectionChange($event)"
/>
<div>
@if (hasLinkedStandardizedCompetency()) {
<div class="alert alert-warning" role="alert" jhiTranslate="artemisApp.courseCompetency.edit.unlinkStandardizedCompetenciesWarning"></div>
}
<button id="submitButton" class="btn btn-primary me-2" type="submit" [disabled]="!isSubmitPossible">
<span jhiTranslate="entity.action.submit"></span>
</button>
@if (hasCancelButton) {
@if (hasCancelButton()) {
<button type="button" (click)="cancelForm()" class="btn btn-default">
<fa-icon [icon]="faTimes" />&nbsp;<span jhiTranslate="entity.action.cancel"></span>
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class PrerequisiteFormComponent extends CourseCompetencyFormComponent imp

ngOnChanges(): void {
this.initializeForm();
if (this.isEditMode && this.formData) {
if (this.isEditMode() && this.formData) {
JohannesStoehr marked this conversation as resolved.
Show resolved Hide resolved
this.setFormValues(this.formData);
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/webapp/i18n/de/competency.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@
"noOfParticipants": "Anzahl der Teilnehmenden",
"participationRate": "Teilnahmerate"
}
},
"edit": {
"unlinkStandardizedCompetenciesWarning": "Das Editieren wird dazu führen, dass die Verbindung zu standardisierten Kompetenzen gelöst wird!"
JohannesStoehr marked this conversation as resolved.
Show resolved Hide resolved
}
},
"prerequisite": {
Expand Down
3 changes: 3 additions & 0 deletions src/main/webapp/i18n/en/competency.json
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@
"participationRate": "Participation Rate"
}
},
"edit": {
"unlinkStandardizedCompetenciesWarning": "Editing will unlink the standardized competency!"
},
JohannesStoehr marked this conversation as resolved.
Show resolved Hide resolved
"taxonomies": {
"REMEMBER": "Remember",
"UNDERSTAND": "Understand",
Expand Down
Loading