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

Development: Use default value if exercise has no plagiarism checks config #7665

Merged
Show file tree
Hide file tree
Changes from all 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
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 @@ -54,6 +54,14 @@ export interface PlagiarismDetectionConfig {
minimumSize?: number;
}

export const defaultPlagiarismDetectionConfig: PlagiarismDetectionConfig = {
continuousPlagiarismControlEnabled: false,
continuousPlagiarismControlPostDueDateChecksEnabled: true,
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
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 = defaultPlagiarismDetectionConfig;

// transient objects which might not be set
public numberOfSubmissions?: DueDateStat;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
import { Component, Input } from '@angular/core';
import { Exercise, ExerciseType } from 'app/entities/exercise.model';
import { Component, Input, OnInit } from '@angular/core';
import { Exercise, ExerciseType, defaultPlagiarismDetectionConfig } 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;

ngOnInit(): void {
if (!this.exercise.plagiarismDetectionConfig) {
this.exercise.plagiarismDetectionConfig = defaultPlagiarismDetectionConfig;
}
}

/**
* Return the translation identifier of the minimum size tooltip for the current exercise type.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { defaultPlagiarismDetectionConfig } 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';

describe('Exercise Update Plagiarism Component', () => {
let comp: ExerciseUpdatePlagiarismComponent;

beforeEach(() => {
comp = new ExerciseUpdatePlagiarismComponent();

comp.exercise = new ProgrammingExercise(undefined, undefined);
});

it('should use provided plagiarism checks config', () => {
const plagiarismDetectionConfig = {
continuousPlagiarismControlEnabled: true,
continuousPlagiarismControlPostDueDateChecksEnabled: false,
similarityThreshold: 1,
minimumScore: 2,
minimumSize: 3,
};
comp.exercise.plagiarismDetectionConfig = plagiarismDetectionConfig;

comp.ngOnInit();

expect(comp.exercise.plagiarismDetectionConfig).toEqual(plagiarismDetectionConfig);
});

it('should use default if exercise does not have plagiarism checks config', () => {
comp.exercise.plagiarismDetectionConfig = undefined;

comp.ngOnInit();

expect(comp.exercise.plagiarismDetectionConfig).toEqual(defaultPlagiarismDetectionConfig);
});
});
Loading