Skip to content

Commit

Permalink
fix(frontend): Don't show unedited evaluations from similar solutions…
Browse files Browse the repository at this point in the history
… if disabled
  • Loading branch information
Clashsoft committed Nov 18, 2023
1 parent 6917342 commit 926114b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
13 changes: 13 additions & 0 deletions frontend/src/app/assignment/model/evaluation.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import {Config} from "./config";

export class Snippet {
file: string;
from: { line: number; character: number; };
Expand Down Expand Up @@ -39,6 +41,17 @@ export class Evaluation {
similarity?: SimilarityInfo;
}

// TODO Remove this after the Winter Term 2023/24 study is over
export function isVisible(evaluation: Evaluation, config: Pick<Config, 'codeSearch' | 'similarSolutions'>) {
if (!config.codeSearch && evaluation.author === 'Code Search') {
return false;
}
if (!config.similarSolutions && evaluation.similarity?.origin && evaluation.createdAt !== evaluation.updatedAt) {
return false;
}
return true;
}

export interface CreateEvaluationDto extends Omit<Evaluation, '_id' | 'assignment' | 'solution' | 'createdAt' | 'createdBy' | 'updatedAt' | 'codeSearch'> {
codeSearch?: boolean;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {ActivatedRoute, Router} from '@angular/router';
import {ModalComponent, ToastService} from '@mean-stream/ngbx';
import {EMPTY, Observable, of, Subscription} from 'rxjs';
import {filter, share, switchMap, tap} from 'rxjs/operators';
import {CodeSearchInfo, CreateEvaluationDto, Evaluation} from '../../../model/evaluation';
import {CodeSearchInfo, CreateEvaluationDto, Evaluation, isVisible} from '../../../model/evaluation';
import Solution from '../../../model/solution';
import Task from '../../../model/task';
import {AssignmentService} from '../../../services/assignment.service';
Expand Down Expand Up @@ -68,10 +68,13 @@ export class EvaluationModalComponent implements OnInit, OnDestroy {
this.loadCodeSearchEnabled(assignment$);
this.loadTask(assignment$);

const config = {
codeSearch: this.codeSearchEnabled,
similarSolutions: this.similarSolutionsEnabled,
};
const evaluation$ = this.route.params.pipe(
switchMap(({aid, sid, task}) => this.evaluationService.findByTask(aid, sid, task)),
// TODO Remove this after the Winter Term 2023/24 study is over
filter(evaluation => this.codeSearchEnabled || evaluation?.author !== 'Code Search'),
filter(evaluation => !!evaluation && isVisible(evaluation, config)),
share(),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {ActivatedRoute} from '@angular/router';
import {forkJoin, Subscription} from 'rxjs';
import {map, switchMap, tap} from 'rxjs/operators';
import Assignment, {ReadAssignmentDto} from '../../../model/assignment';
import {Evaluation} from '../../../model/evaluation';
import {Evaluation, isVisible} from '../../../model/evaluation';
import Solution from '../../../model/solution';
import {AssignmentService} from '../../../services/assignment.service';
import {SolutionService} from '../../../services/solution.service';
Expand Down Expand Up @@ -61,8 +61,8 @@ export class SolutionTasksComponent implements OnInit, OnDestroy {
switchMap(({aid, sid}) => forkJoin([
this.assignmentService.get(aid).pipe(tap(assignment => this.assignment = assignment)),
this.evaluationService.findAll(aid, sid).pipe(map(evaluations => {
if (!this.config.codeSearch) { // TODO Remove this after the Winter Term 2023/24 study is over
evaluations = evaluations.filter(evaluation => evaluation.author !== 'Code Search');
if (!this.config.codeSearch || !this.config.similarSolutions) {
evaluations = evaluations.filter(evaluation => isVisible(evaluation, this.config));
}
this.evaluations = {};
for (const evaluation of evaluations) {
Expand All @@ -86,8 +86,7 @@ export class SolutionTasksComponent implements OnInit, OnDestroy {
if (event === 'deleted') {
delete this.evaluations[task];
}
else if (!this.config.codeSearch && evaluation.author === 'Code Search') { // TODO Remove this after the Winter Term 2023/24 study is over
// Code Search evaluations are not shown to the user
else if (!isVisible(evaluation, this.config)) {
return;
} else {
this.evaluations[task] = evaluation;
Expand Down

0 comments on commit 926114b

Please sign in to comment.