From 5f59f5de0ca7207dd152ae042905e7298138d89d Mon Sep 17 00:00:00 2001 From: Lucas Welscher Date: Thu, 23 Nov 2023 14:50:59 +0100 Subject: [PATCH 1/6] `General`: Fix an issue when importing exercises --- src/main/webapp/app/entities/exercise.model.ts | 16 +++++++++------- .../exercise-update-plagiarism.component.html | 2 +- .../exercise-update-plagiarism.component.ts | 17 ++++++++++++----- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/main/webapp/app/entities/exercise.model.ts b/src/main/webapp/app/entities/exercise.model.ts index a47019072b04..1014f09d6269 100644 --- a/src/main/webapp/app/entities/exercise.model.ts +++ b/src/main/webapp/app/entities/exercise.model.ts @@ -63,6 +63,14 @@ export enum IncludedInOverallScore { NOT_INCLUDED = 'NOT_INCLUDED', } +export const DEFAULT_PLAGIARISM_DETECTION_CONFIG: PlagiarismDetectionConfig = { + continuousPlagiarismControlEnabled: false, + continuousPlagiarismControlPostDueDateChecksEnabled: false, + similarityThreshold: 90, + minimumSize: 50, + minimumScore: 0, +}; + export abstract class Exercise implements BaseEntity { public id?: number; public problemStatement?: string; @@ -97,13 +105,7 @@ export abstract class Exercise implements BaseEntity { public exerciseGroup?: ExerciseGroup; public competencies?: Competency[]; - public plagiarismDetectionConfig?: PlagiarismDetectionConfig = { - continuousPlagiarismControlEnabled: false, - continuousPlagiarismControlPostDueDateChecksEnabled: true, - similarityThreshold: 90, - minimumSize: 50, - minimumScore: 0, - }; // default value + public plagiarismDetectionConfig?: PlagiarismDetectionConfig = DEFAULT_PLAGIARISM_DETECTION_CONFIG; // default value // transient objects which might not be set public numberOfSubmissions?: DueDateStat; diff --git a/src/main/webapp/app/exercises/shared/plagiarism/exercise-update-plagiarism/exercise-update-plagiarism.component.html b/src/main/webapp/app/exercises/shared/plagiarism/exercise-update-plagiarism/exercise-update-plagiarism.component.html index e89266cfe6c2..c67a7766089f 100644 --- a/src/main/webapp/app/exercises/shared/plagiarism/exercise-update-plagiarism/exercise-update-plagiarism.component.html +++ b/src/main/webapp/app/exercises/shared/plagiarism/exercise-update-plagiarism/exercise-update-plagiarism.component.html @@ -1,4 +1,4 @@ -
+
diff --git a/src/main/webapp/app/exercises/shared/plagiarism/exercise-update-plagiarism/exercise-update-plagiarism.component.ts b/src/main/webapp/app/exercises/shared/plagiarism/exercise-update-plagiarism/exercise-update-plagiarism.component.ts index 41b6a4576361..04ccb18cf1fd 100644 --- a/src/main/webapp/app/exercises/shared/plagiarism/exercise-update-plagiarism/exercise-update-plagiarism.component.ts +++ b/src/main/webapp/app/exercises/shared/plagiarism/exercise-update-plagiarism/exercise-update-plagiarism.component.ts @@ -1,20 +1,27 @@ -import { Component, Input } from '@angular/core'; -import { Exercise, ExerciseType } from 'app/entities/exercise.model'; +import { Component, Input, OnInit } from '@angular/core'; +import { DEFAULT_PLAGIARISM_DETECTION_CONFIG, Exercise, ExerciseType } from 'app/entities/exercise.model'; import { faQuestionCircle } from '@fortawesome/free-solid-svg-icons'; @Component({ selector: 'jhi-exercise-update-plagiarism', templateUrl: './exercise-update-plagiarism.component.html', }) -export class ExerciseUpdatePlagiarismComponent { +export class ExerciseUpdatePlagiarismComponent implements OnInit { @Input() exercise: Exercise; - faQuestionCircle = faQuestionCircle; + readonly faQuestionCircle = faQuestionCircle; + + ngOnInit(): void { + if (!this.exercise.plagiarismDetectionConfig) { + // Create the default plagiarism configuration if there is none (e.g. importing an old exercise from a file) + this.exercise.plagiarismDetectionConfig = DEFAULT_PLAGIARISM_DETECTION_CONFIG; + } + } /** * Return the translation identifier of the minimum size tooltip for the current exercise type. */ - getMinimumSizeTooltip() { + getMinimumSizeTooltip(): string | undefined { switch (this.exercise.type) { case ExerciseType.PROGRAMMING: { return 'artemisApp.plagiarism.minimumSizeTooltipProgrammingExercise'; From d8f28a245e2b6969bf6838fc0213d710ab3800c1 Mon Sep 17 00:00:00 2001 From: Lucas Welscher Date: Thu, 23 Nov 2023 16:13:50 +0100 Subject: [PATCH 2/6] fix default value for after-due-date checks --- .../exercise-update-plagiarism.component.html | 16 ++++++++-------- .../exercise-update-plagiarism.component.ts | 7 +++++++ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/main/webapp/app/exercises/shared/plagiarism/exercise-update-plagiarism/exercise-update-plagiarism.component.html b/src/main/webapp/app/exercises/shared/plagiarism/exercise-update-plagiarism/exercise-update-plagiarism.component.html index c67a7766089f..d260c53d94b5 100644 --- a/src/main/webapp/app/exercises/shared/plagiarism/exercise-update-plagiarism/exercise-update-plagiarism.component.html +++ b/src/main/webapp/app/exercises/shared/plagiarism/exercise-update-plagiarism/exercise-update-plagiarism.component.html @@ -12,8 +12,8 @@ id="continuous_plagiarism_control_enabled" class="plagiarism-option-checkbox form-check-input" name="exercise.plagiarismDetectionConfig.continuousPlagiarismControlEnabled" - #exercise.plagiarismDetectionConfig.continuousPlagiarismControlEnabled="ngModel" - [(ngModel)]="exercise.plagiarismDetectionConfig!.continuousPlagiarismControlEnabled" + [checked]="exercise.plagiarismDetectionConfig.continuousPlagiarismControlEnabled" + (click)="toggleCPCEnabled()" />
Enable Continuous Plagiarism Control
@@ -25,9 +25,9 @@ id="continuous_plagiarism_control_post_due_date_checks_enabled" class="plagiarism-option-checkbox form-check-input" name="exercise.plagiarismDetectionConfig.continuousPlagiarismControlPostDueDateChecksEnabled" - [disabled]="!exercise.plagiarismDetectionConfig?.continuousPlagiarismControlEnabled" + [disabled]="!exercise.plagiarismDetectionConfig.continuousPlagiarismControlEnabled" #exercise.plagiarismDetectionConfig.continuousPlagiarismControlPostDueDateChecksEnabled="ngModel" - [(ngModel)]="exercise.plagiarismDetectionConfig!.continuousPlagiarismControlPostDueDateChecksEnabled" + [(ngModel)]="exercise.plagiarismDetectionConfig.continuousPlagiarismControlPostDueDateChecksEnabled" />
Run additional checks during the night after exercise's due date. @@ -50,8 +50,8 @@ step="5" id="plagiarism-similarity-threshold" name="plagiarismChecksSimilarityThresholdPercentage" - #exercise.plagiarismDetectionConfig!.similarityThreshol="ngModel" - [(ngModel)]="exercise.plagiarismDetectionConfig!.similarityThreshold" + #exercise.plagiarismDetectionConfig.similarityThreshol="ngModel" + [(ngModel)]="exercise.plagiarismDetectionConfig.similarityThreshold" />
@@ -70,7 +70,7 @@ id="plagiarism-minimum-score" name="exercise.plagiarismDetectionConfig.minimumScore" #exercise.plagiarismDetectionConfig.minimumScore="ngModel" - [(ngModel)]="exercise.plagiarismDetectionConfig!.minimumScore" + [(ngModel)]="exercise.plagiarismDetectionConfig.minimumScore" />
@@ -89,7 +89,7 @@ id="plagiarism-minimum-size" name="exercise.plagiarismDetectionConfig.minimumSize" #exercise.plagiarismDetectionConfig.minimumSize="ngModel" - [(ngModel)]="exercise.plagiarismDetectionConfig!.minimumSize" + [(ngModel)]="exercise.plagiarismDetectionConfig.minimumSize" /> diff --git a/src/main/webapp/app/exercises/shared/plagiarism/exercise-update-plagiarism/exercise-update-plagiarism.component.ts b/src/main/webapp/app/exercises/shared/plagiarism/exercise-update-plagiarism/exercise-update-plagiarism.component.ts index 04ccb18cf1fd..47c2c02673bb 100644 --- a/src/main/webapp/app/exercises/shared/plagiarism/exercise-update-plagiarism/exercise-update-plagiarism.component.ts +++ b/src/main/webapp/app/exercises/shared/plagiarism/exercise-update-plagiarism/exercise-update-plagiarism.component.ts @@ -18,6 +18,13 @@ export class ExerciseUpdatePlagiarismComponent implements OnInit { } } + toggleCPCEnabled() { + const config = this.exercise.plagiarismDetectionConfig!; + const newValue = !config.continuousPlagiarismControlEnabled; + config.continuousPlagiarismControlEnabled = newValue; + config.continuousPlagiarismControlPostDueDateChecksEnabled = newValue; + } + /** * Return the translation identifier of the minimum size tooltip for the current exercise type. */ From 70df93d10b73771a91cb97d0a0184fcd8de8bcce Mon Sep 17 00:00:00 2001 From: Lucas Welscher Date: Thu, 23 Nov 2023 19:45:13 +0100 Subject: [PATCH 3/6] add client tests, optimize tooltip method --- .../exercise-update-plagiarism.component.html | 2 +- .../exercise-update-plagiarism.component.ts | 2 + ...ercise-update-plagiarism.component.spec.ts | 67 +++++++++++++++++++ 3 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 src/test/javascript/spec/component/exercises/shared/plagiarism/exercise-update-plagiarism.component.spec.ts diff --git a/src/main/webapp/app/exercises/shared/plagiarism/exercise-update-plagiarism/exercise-update-plagiarism.component.html b/src/main/webapp/app/exercises/shared/plagiarism/exercise-update-plagiarism/exercise-update-plagiarism.component.html index d260c53d94b5..7db1234459ab 100644 --- a/src/main/webapp/app/exercises/shared/plagiarism/exercise-update-plagiarism/exercise-update-plagiarism.component.html +++ b/src/main/webapp/app/exercises/shared/plagiarism/exercise-update-plagiarism/exercise-update-plagiarism.component.html @@ -78,7 +78,7 @@
- +
{ + let component: ExerciseUpdatePlagiarismComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [ArtemisTestModule, FormsModule, NgbTooltipMocksModule], + declarations: [ExerciseUpdatePlagiarismComponent, MockPipe(ArtemisTranslatePipe)], + }).compileComponents(); + fixture = TestBed.createComponent(ExerciseUpdatePlagiarismComponent); + component = fixture.componentInstance; + }); + + it('should set minimumSizeTooltip on init', () => { + component.exercise = { type: ExerciseType.PROGRAMMING } as Exercise; + fixture.detectChanges(); + expect(component.minimumSizeTooltip).toBe('artemisApp.plagiarism.minimumSizeTooltipProgrammingExercise'); + }); + + it('should set default plagiarism detection config on init if not set', () => { + component.exercise = { type: ExerciseType.PROGRAMMING } as Exercise; + fixture.detectChanges(); + expect(component.exercise.plagiarismDetectionConfig).toEqual(DEFAULT_PLAGIARISM_DETECTION_CONFIG); + }); + + it('should enable cpc', () => { + component.exercise = { + plagiarismDetectionConfig: { continuousPlagiarismControlEnabled: false, continuousPlagiarismControlPostDueDateChecksEnabled: false }, + } as Exercise; + component.toggleCPCEnabled(); + expect(component.exercise.plagiarismDetectionConfig!.continuousPlagiarismControlEnabled).toBeTrue(); + expect(component.exercise.plagiarismDetectionConfig!.continuousPlagiarismControlPostDueDateChecksEnabled).toBeTrue(); + }); + + it('should disable cpc', () => { + component.exercise = { + plagiarismDetectionConfig: { continuousPlagiarismControlEnabled: true, continuousPlagiarismControlPostDueDateChecksEnabled: true }, + } as Exercise; + component.toggleCPCEnabled(); + expect(component.exercise.plagiarismDetectionConfig!.continuousPlagiarismControlEnabled).toBeFalse(); + expect(component.exercise.plagiarismDetectionConfig!.continuousPlagiarismControlPostDueDateChecksEnabled).toBeFalse(); + }); + + it('should get correct minimumSizeTooltip for programming exercises', () => { + component.exercise = { type: ExerciseType.PROGRAMMING } as Exercise; + expect(component.getMinimumSizeTooltip()).toBe('artemisApp.plagiarism.minimumSizeTooltipProgrammingExercise'); + }); + + it('should get correct minimumSizeTooltip for text exercises', () => { + component.exercise = { type: ExerciseType.TEXT } as Exercise; + expect(component.getMinimumSizeTooltip()).toBe('artemisApp.plagiarism.minimumSizeTooltipTextExercise'); + }); + + it('should get correct minimumSizeTooltip for modeling exercises', () => { + component.exercise = { type: ExerciseType.MODELING } as Exercise; + expect(component.getMinimumSizeTooltip()).toBe('artemisApp.plagiarism.minimumSizeTooltipModelingExercise'); + }); +}); From c728c6850d8e6e01b2a09bf964eb0c70a52401f0 Mon Sep 17 00:00:00 2001 From: Lucas Welscher Date: Sun, 26 Nov 2023 18:26:18 +0100 Subject: [PATCH 4/6] remove ngif --- .../exercise-update-plagiarism.component.html | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/webapp/app/exercises/shared/plagiarism/exercise-update-plagiarism/exercise-update-plagiarism.component.html b/src/main/webapp/app/exercises/shared/plagiarism/exercise-update-plagiarism/exercise-update-plagiarism.component.html index 7db1234459ab..71b53471259d 100644 --- a/src/main/webapp/app/exercises/shared/plagiarism/exercise-update-plagiarism/exercise-update-plagiarism.component.html +++ b/src/main/webapp/app/exercises/shared/plagiarism/exercise-update-plagiarism/exercise-update-plagiarism.component.html @@ -1,4 +1,4 @@ -
+
@@ -12,7 +12,7 @@ id="continuous_plagiarism_control_enabled" class="plagiarism-option-checkbox form-check-input" name="exercise.plagiarismDetectionConfig.continuousPlagiarismControlEnabled" - [checked]="exercise.plagiarismDetectionConfig.continuousPlagiarismControlEnabled" + [checked]="exercise.plagiarismDetectionConfig!.continuousPlagiarismControlEnabled" (click)="toggleCPCEnabled()" />
Enable Continuous Plagiarism Control
@@ -25,9 +25,9 @@ id="continuous_plagiarism_control_post_due_date_checks_enabled" class="plagiarism-option-checkbox form-check-input" name="exercise.plagiarismDetectionConfig.continuousPlagiarismControlPostDueDateChecksEnabled" - [disabled]="!exercise.plagiarismDetectionConfig.continuousPlagiarismControlEnabled" - #exercise.plagiarismDetectionConfig.continuousPlagiarismControlPostDueDateChecksEnabled="ngModel" - [(ngModel)]="exercise.plagiarismDetectionConfig.continuousPlagiarismControlPostDueDateChecksEnabled" + [disabled]="!exercise.plagiarismDetectionConfig!.continuousPlagiarismControlEnabled" + #exercise.plagiarismDetectionConfig!.continuousPlagiarismControlPostDueDateChecksEnabled="ngModel" + [(ngModel)]="exercise.plagiarismDetectionConfig!.continuousPlagiarismControlPostDueDateChecksEnabled" />
Run additional checks during the night after exercise's due date. @@ -50,8 +50,8 @@ step="5" id="plagiarism-similarity-threshold" name="plagiarismChecksSimilarityThresholdPercentage" - #exercise.plagiarismDetectionConfig.similarityThreshol="ngModel" - [(ngModel)]="exercise.plagiarismDetectionConfig.similarityThreshold" + #exercise.plagiarismDetectionConfig!.similarityThreshol="ngModel" + [(ngModel)]="exercise.plagiarismDetectionConfig!.similarityThreshold" />
@@ -69,8 +69,8 @@ max="100" id="plagiarism-minimum-score" name="exercise.plagiarismDetectionConfig.minimumScore" - #exercise.plagiarismDetectionConfig.minimumScore="ngModel" - [(ngModel)]="exercise.plagiarismDetectionConfig.minimumScore" + #exercise.plagiarismDetectionConfig!.minimumScore="ngModel" + [(ngModel)]="exercise.plagiarismDetectionConfig!.minimumScore" />
@@ -88,8 +88,8 @@ max="100" id="plagiarism-minimum-size" name="exercise.plagiarismDetectionConfig.minimumSize" - #exercise.plagiarismDetectionConfig.minimumSize="ngModel" - [(ngModel)]="exercise.plagiarismDetectionConfig.minimumSize" + #exercise.plagiarismDetectionConfig!.minimumSize="ngModel" + [(ngModel)]="exercise.plagiarismDetectionConfig!.minimumSize" />
From 668e1fbd9ece451853220134a0b4d0b1e79ce382 Mon Sep 17 00:00:00 2001 From: Lucas Welscher Date: Mon, 27 Nov 2023 10:36:05 +0100 Subject: [PATCH 5/6] merge tests --- .../webapp/app/entities/exercise.model.ts | 16 ++--- .../exercise-update-plagiarism.component.html | 4 +- ...ercise-update-plagiarism.component.spec.ts | 67 ------------------- ...ercise-update-plagiarism.component.spec.ts | 49 +++++++++++++- 4 files changed, 57 insertions(+), 79 deletions(-) delete mode 100644 src/test/javascript/spec/component/exercises/shared/plagiarism/exercise-update-plagiarism.component.spec.ts diff --git a/src/main/webapp/app/entities/exercise.model.ts b/src/main/webapp/app/entities/exercise.model.ts index 4d53627aa880..51cdcaf0a763 100644 --- a/src/main/webapp/app/entities/exercise.model.ts +++ b/src/main/webapp/app/entities/exercise.model.ts @@ -54,6 +54,14 @@ export interface PlagiarismDetectionConfig { minimumSize?: number; } +export const DEFAULT_PLAGIARISM_DETECTION_CONFIG: PlagiarismDetectionConfig = { + continuousPlagiarismControlEnabled: false, + continuousPlagiarismControlPostDueDateChecksEnabled: false, + similarityThreshold: 90, + minimumSize: 50, + minimumScore: 0, +}; + export const exerciseTypes: ExerciseType[] = [ExerciseType.TEXT, ExerciseType.MODELING, ExerciseType.PROGRAMMING, ExerciseType.FILE_UPLOAD, ExerciseType.QUIZ]; // IMPORTANT NOTICE: The following strings have to be consistent with the ones defined in Exercise.java @@ -63,14 +71,6 @@ export enum IncludedInOverallScore { NOT_INCLUDED = 'NOT_INCLUDED', } -export const DEFAULT_PLAGIARISM_DETECTION_CONFIG: PlagiarismDetectionConfig = { - continuousPlagiarismControlEnabled: false, - continuousPlagiarismControlPostDueDateChecksEnabled: false, - similarityThreshold: 90, - minimumSize: 50, - minimumScore: 0, -}; - export abstract class Exercise implements BaseEntity { public id?: number; public problemStatement?: string; diff --git a/src/main/webapp/app/exercises/shared/plagiarism/exercise-update-plagiarism/exercise-update-plagiarism.component.html b/src/main/webapp/app/exercises/shared/plagiarism/exercise-update-plagiarism/exercise-update-plagiarism.component.html index 71b53471259d..50169b95af67 100644 --- a/src/main/webapp/app/exercises/shared/plagiarism/exercise-update-plagiarism/exercise-update-plagiarism.component.html +++ b/src/main/webapp/app/exercises/shared/plagiarism/exercise-update-plagiarism/exercise-update-plagiarism.component.html @@ -69,7 +69,7 @@ max="100" id="plagiarism-minimum-score" name="exercise.plagiarismDetectionConfig.minimumScore" - #exercise.plagiarismDetectionConfig!.minimumScore="ngModel" + #exercise.plagiarismDetectionConfig.minimumScore="ngModel" [(ngModel)]="exercise.plagiarismDetectionConfig!.minimumScore" /> @@ -88,7 +88,7 @@ max="100" id="plagiarism-minimum-size" name="exercise.plagiarismDetectionConfig.minimumSize" - #exercise.plagiarismDetectionConfig!.minimumSize="ngModel" + #exercise.plagiarismDetectionConfig.minimumSize="ngModel" [(ngModel)]="exercise.plagiarismDetectionConfig!.minimumSize" /> diff --git a/src/test/javascript/spec/component/exercises/shared/plagiarism/exercise-update-plagiarism.component.spec.ts b/src/test/javascript/spec/component/exercises/shared/plagiarism/exercise-update-plagiarism.component.spec.ts deleted file mode 100644 index 78c84c5e0184..000000000000 --- a/src/test/javascript/spec/component/exercises/shared/plagiarism/exercise-update-plagiarism.component.spec.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { FormsModule } from '@angular/forms'; -import { DEFAULT_PLAGIARISM_DETECTION_CONFIG, Exercise, ExerciseType } from 'app/entities/exercise.model'; -import { ExerciseUpdatePlagiarismComponent } from 'app/exercises/shared/plagiarism/exercise-update-plagiarism/exercise-update-plagiarism.component'; -import { ArtemisTranslatePipe } from 'app/shared/pipes/artemis-translate.pipe'; -import { MockPipe } from 'ng-mocks'; -import { NgbTooltipMocksModule } from '../../../../helpers/mocks/directive/ngbTooltipMocks.module'; -import { ArtemisTestModule } from '../../../../test.module'; - -describe('ExerciseUpdatePlagiarismComponent', () => { - let component: ExerciseUpdatePlagiarismComponent; - let fixture: ComponentFixture; - - beforeEach(async () => { - await TestBed.configureTestingModule({ - imports: [ArtemisTestModule, FormsModule, NgbTooltipMocksModule], - declarations: [ExerciseUpdatePlagiarismComponent, MockPipe(ArtemisTranslatePipe)], - }).compileComponents(); - fixture = TestBed.createComponent(ExerciseUpdatePlagiarismComponent); - component = fixture.componentInstance; - }); - - it('should set minimumSizeTooltip on init', () => { - component.exercise = { type: ExerciseType.PROGRAMMING } as Exercise; - fixture.detectChanges(); - expect(component.minimumSizeTooltip).toBe('artemisApp.plagiarism.minimumSizeTooltipProgrammingExercise'); - }); - - it('should set default plagiarism detection config on init if not set', () => { - component.exercise = { type: ExerciseType.PROGRAMMING } as Exercise; - fixture.detectChanges(); - expect(component.exercise.plagiarismDetectionConfig).toEqual(DEFAULT_PLAGIARISM_DETECTION_CONFIG); - }); - - it('should enable cpc', () => { - component.exercise = { - plagiarismDetectionConfig: { continuousPlagiarismControlEnabled: false, continuousPlagiarismControlPostDueDateChecksEnabled: false }, - } as Exercise; - component.toggleCPCEnabled(); - expect(component.exercise.plagiarismDetectionConfig!.continuousPlagiarismControlEnabled).toBeTrue(); - expect(component.exercise.plagiarismDetectionConfig!.continuousPlagiarismControlPostDueDateChecksEnabled).toBeTrue(); - }); - - it('should disable cpc', () => { - component.exercise = { - plagiarismDetectionConfig: { continuousPlagiarismControlEnabled: true, continuousPlagiarismControlPostDueDateChecksEnabled: true }, - } as Exercise; - component.toggleCPCEnabled(); - expect(component.exercise.plagiarismDetectionConfig!.continuousPlagiarismControlEnabled).toBeFalse(); - expect(component.exercise.plagiarismDetectionConfig!.continuousPlagiarismControlPostDueDateChecksEnabled).toBeFalse(); - }); - - it('should get correct minimumSizeTooltip for programming exercises', () => { - component.exercise = { type: ExerciseType.PROGRAMMING } as Exercise; - expect(component.getMinimumSizeTooltip()).toBe('artemisApp.plagiarism.minimumSizeTooltipProgrammingExercise'); - }); - - it('should get correct minimumSizeTooltip for text exercises', () => { - component.exercise = { type: ExerciseType.TEXT } as Exercise; - expect(component.getMinimumSizeTooltip()).toBe('artemisApp.plagiarism.minimumSizeTooltipTextExercise'); - }); - - it('should get correct minimumSizeTooltip for modeling exercises', () => { - component.exercise = { type: ExerciseType.MODELING } as Exercise; - expect(component.getMinimumSizeTooltip()).toBe('artemisApp.plagiarism.minimumSizeTooltipModelingExercise'); - }); -}); diff --git a/src/test/javascript/spec/component/plagiarism/exercise-update-plagiarism.component.spec.ts b/src/test/javascript/spec/component/plagiarism/exercise-update-plagiarism.component.spec.ts index fe2990df3ae9..725292aa1fae 100644 --- a/src/test/javascript/spec/component/plagiarism/exercise-update-plagiarism.component.spec.ts +++ b/src/test/javascript/spec/component/plagiarism/exercise-update-plagiarism.component.spec.ts @@ -1,4 +1,4 @@ -import { defaultPlagiarismDetectionConfig } from 'app/entities/exercise.model'; +import { DEFAULT_PLAGIARISM_DETECTION_CONFIG, Exercise, ExerciseType } from 'app/entities/exercise.model'; import { ExerciseUpdatePlagiarismComponent } from 'app/exercises/shared/plagiarism/exercise-update-plagiarism/exercise-update-plagiarism.component'; import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; @@ -31,6 +31,51 @@ describe('Exercise Update Plagiarism Component', () => { comp.ngOnInit(); - expect(comp.exercise.plagiarismDetectionConfig).toEqual(defaultPlagiarismDetectionConfig); + expect(comp.exercise.plagiarismDetectionConfig).toEqual(DEFAULT_PLAGIARISM_DETECTION_CONFIG); + }); + + it('should set minimumSizeTooltip on init', () => { + comp.exercise = { type: ExerciseType.PROGRAMMING } as Exercise; + comp.ngOnInit(); + expect(comp.minimumSizeTooltip).toBe('artemisApp.plagiarism.minimumSizeTooltipProgrammingExercise'); + }); + + it('should set default plagiarism detection config on init if not set', () => { + comp.exercise = { type: ExerciseType.PROGRAMMING } as Exercise; + comp.ngOnInit(); + expect(comp.exercise.plagiarismDetectionConfig).toEqual(DEFAULT_PLAGIARISM_DETECTION_CONFIG); + }); + + it('should enable cpc', () => { + comp.exercise = { + plagiarismDetectionConfig: { continuousPlagiarismControlEnabled: false, continuousPlagiarismControlPostDueDateChecksEnabled: false }, + } as Exercise; + comp.toggleCPCEnabled(); + expect(comp.exercise.plagiarismDetectionConfig!.continuousPlagiarismControlEnabled).toBeTrue(); + expect(comp.exercise.plagiarismDetectionConfig!.continuousPlagiarismControlPostDueDateChecksEnabled).toBeTrue(); + }); + + it('should disable cpc', () => { + comp.exercise = { + plagiarismDetectionConfig: { continuousPlagiarismControlEnabled: true, continuousPlagiarismControlPostDueDateChecksEnabled: true }, + } as Exercise; + comp.toggleCPCEnabled(); + expect(comp.exercise.plagiarismDetectionConfig!.continuousPlagiarismControlEnabled).toBeFalse(); + expect(comp.exercise.plagiarismDetectionConfig!.continuousPlagiarismControlPostDueDateChecksEnabled).toBeFalse(); + }); + + it('should get correct minimumSizeTooltip for programming exercises', () => { + comp.exercise = { type: ExerciseType.PROGRAMMING } as Exercise; + expect(comp.getMinimumSizeTooltip()).toBe('artemisApp.plagiarism.minimumSizeTooltipProgrammingExercise'); + }); + + it('should get correct minimumSizeTooltip for text exercises', () => { + comp.exercise = { type: ExerciseType.TEXT } as Exercise; + expect(comp.getMinimumSizeTooltip()).toBe('artemisApp.plagiarism.minimumSizeTooltipTextExercise'); + }); + + it('should get correct minimumSizeTooltip for modeling exercises', () => { + comp.exercise = { type: ExerciseType.MODELING } as Exercise; + expect(comp.getMinimumSizeTooltip()).toBe('artemisApp.plagiarism.minimumSizeTooltipModelingExercise'); }); }); From e50b1925562077d3456ae899918cad7279026713 Mon Sep 17 00:00:00 2001 From: Lucas Welscher Date: Mon, 27 Nov 2023 10:38:47 +0100 Subject: [PATCH 6/6] reduce changes --- .../exercise-update-plagiarism.component.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/webapp/app/exercises/shared/plagiarism/exercise-update-plagiarism/exercise-update-plagiarism.component.html b/src/main/webapp/app/exercises/shared/plagiarism/exercise-update-plagiarism/exercise-update-plagiarism.component.html index 50169b95af67..850c397ee7ba 100644 --- a/src/main/webapp/app/exercises/shared/plagiarism/exercise-update-plagiarism/exercise-update-plagiarism.component.html +++ b/src/main/webapp/app/exercises/shared/plagiarism/exercise-update-plagiarism/exercise-update-plagiarism.component.html @@ -25,8 +25,8 @@ id="continuous_plagiarism_control_post_due_date_checks_enabled" class="plagiarism-option-checkbox form-check-input" name="exercise.plagiarismDetectionConfig.continuousPlagiarismControlPostDueDateChecksEnabled" - [disabled]="!exercise.plagiarismDetectionConfig!.continuousPlagiarismControlEnabled" - #exercise.plagiarismDetectionConfig!.continuousPlagiarismControlPostDueDateChecksEnabled="ngModel" + [disabled]="!exercise.plagiarismDetectionConfig?.continuousPlagiarismControlEnabled" + #exercise.plagiarismDetectionConfig.continuousPlagiarismControlPostDueDateChecksEnabled="ngModel" [(ngModel)]="exercise.plagiarismDetectionConfig!.continuousPlagiarismControlPostDueDateChecksEnabled" />