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

Plagiarsim checks: Fix default value of after due date checks #7657

Merged
merged 11 commits into from
Dec 8, 2023
16 changes: 9 additions & 7 deletions src/main/webapp/app/entities/exercise.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="form-group col-auto border border-warning p-3">
<div class="form-group col-auto border border-warning p-3" *ngIf="exercise.plagiarismDetectionConfig">
<div class="row">
Strohgelaender marked this conversation as resolved.
Show resolved Hide resolved
<div>
<label jhiTranslate="artemisApp.plagiarism.continuousPlagiarismControl">Continuous Plagiarism Control</label>
Expand All @@ -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()"
/>
Strohgelaender marked this conversation as resolved.
Show resolved Hide resolved
<div class="plagiarism-option-label" jhiTranslate="artemisApp.plagiarism.continuousPlagiarismControlEnabled">Enable Continuous Plagiarism Control</div>
</div>
Expand All @@ -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"
/>
<div class="plagiarism-option-label" jhiTranslate="artemisApp.plagiarism.continuousPlagiarismControlPostDueDateChecksEnabled">
Run additional checks during the night after exercise's due date.
Expand All @@ -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"
/>
</div>
</div>
Expand All @@ -70,15 +70,15 @@
id="plagiarism-minimum-score"
name="exercise.plagiarismDetectionConfig.minimumScore"
#exercise.plagiarismDetectionConfig.minimumScore="ngModel"
[(ngModel)]="exercise.plagiarismDetectionConfig!.minimumScore"
[(ngModel)]="exercise.plagiarismDetectionConfig.minimumScore"
/>
</div>
</div>
<div class="col">
<div class="form-group">
<div>
<label class="form-control-label" jhiTranslate="artemisApp.plagiarism.minimumSize">Minimum Size</label>
<fa-icon [icon]="faQuestionCircle" placement="bottom auto" [ngbTooltip]="getMinimumSizeTooltip() | artemisTranslate"></fa-icon>
<fa-icon [icon]="faQuestionCircle" placement="bottom auto" [ngbTooltip]="minimumSizeTooltip | artemisTranslate"></fa-icon>
</div>
krusche marked this conversation as resolved.
Show resolved Hide resolved
<input
type="number"
Expand All @@ -89,7 +89,7 @@
id="plagiarism-minimum-size"
name="exercise.plagiarismDetectionConfig.minimumSize"
#exercise.plagiarismDetectionConfig.minimumSize="ngModel"
[(ngModel)]="exercise.plagiarismDetectionConfig!.minimumSize"
[(ngModel)]="exercise.plagiarismDetectionConfig.minimumSize"
/>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,36 @@
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;
minimumSizeTooltip?: string;

faQuestionCircle = faQuestionCircle;
readonly faQuestionCircle = faQuestionCircle;

ngOnInit(): void {
this.minimumSizeTooltip = this.getMinimumSizeTooltip();
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;
}
}

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.
*/
getMinimumSizeTooltip() {
getMinimumSizeTooltip(): string | undefined {
switch (this.exercise.type) {
case ExerciseType.PROGRAMMING: {
return 'artemisApp.plagiarism.minimumSizeTooltipProgrammingExercise';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
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<ExerciseUpdatePlagiarismComponent>;

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');
});
});
Loading