Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
39 changes: 25 additions & 14 deletions src/app/api/models/task-definition.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
import { HttpClient } from '@angular/common/http';
import { Entity, EntityMapping } from 'ngx-entity-service';
import { Observable, tap } from 'rxjs';
import { AppInjector } from 'src/app/app-injector';
import { DoubtfireConstants } from 'src/app/config/constants/doubtfire-constants';
import { Grade, GroupSet, TutorialStream, Unit } from './doubtfire-model';
import { TaskDefinitionService } from '../services/task-definition.service';

export type UploadRequirement = { key: string; name: string; type: string; tiiCheck?: boolean; tiiPct?: number };
import {HttpClient} from '@angular/common/http';
import {Entity, EntityMapping} from 'ngx-entity-service';
import {Observable, tap} from 'rxjs';
import {AppInjector} from 'src/app/app-injector';
import {DoubtfireConstants} from 'src/app/config/constants/doubtfire-constants';
import {Grade, GroupSet, TutorialStream, Unit} from './doubtfire-model';
import {TaskDefinitionService} from '../services/task-definition.service';

export type UploadRequirement = {
key: string;
name: string;
type: string;
tiiCheck?: boolean;
tiiPct?: number;
};

export type SimilarityCheck = { key: string; type: string; pattern: string };
export type SimilarityCheck = {key: string; type: string; pattern: string};

export class TaskDefinition extends Entity {
id: number;
Expand Down Expand Up @@ -75,15 +81,15 @@ export class TaskDefinition extends Entity {
entity: this,
cache: this.unit.taskDefinitionCache,
constructorParams: this.unit,
}
},
);
} else {
return svc.update(
{
unitId: this.unit.id,
id: this.id,
},
{ entity: this }
{entity: this},
);
}
}
Expand Down Expand Up @@ -130,7 +136,10 @@ export class TaskDefinition extends Entity {
}

public matches(text: string): boolean {
return this.abbreviation.toLowerCase().indexOf(text) !== -1 || this.name.toLowerCase().indexOf(text) !== -1;
return (
this.abbreviation.toLowerCase().indexOf(text) !== -1 ||
this.name.toLowerCase().indexOf(text) !== -1
);
}

/**
Expand Down Expand Up @@ -223,7 +232,9 @@ export class TaskDefinition extends Entity {

public deleteTaskResources(): Observable<any> {
const httpClient = AppInjector.get(HttpClient);
return httpClient.delete(this.taskResourcesUploadUrl).pipe(tap(() => (this.hasTaskResources = false)));
return httpClient
.delete(this.taskResourcesUploadUrl)
.pipe(tap(() => (this.hasTaskResources = false)));
}

public deleteScormData(): Observable<any> {
Expand Down
9 changes: 9 additions & 0 deletions src/app/api/services/task-definition.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ export class TaskDefinitionService extends CachedEntityService<TaskDefinition> {
return taskDef.tutorialStream?.abbreviation;
},
},
{
keys: ['tutorialSelfEnrolmentStream', 'tutorial_self_enrolment_stream_abbr'],
toEntityFn: (data: object, key: string, taskDef: TaskDefinition, params?: any) => {
return taskDef.unit.tutorialStreamsCache.get(data[key]);
},
toJsonFn: (taskDef: TaskDefinition, key: string) => {
return taskDef.tutorialSelfEnrolmentStream?.abbreviation;
},
},
'plagiarismWarnPct',
'restrictStatusUpdates',
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<mat-label
>Tutorial Streams - Which stream students can enrol into a tutorial from?</mat-label
>
<mat-select [formControl]="tutoralStreamControl" multiple>
<mat-select [formControl]="tutoralStreamControl" [selectionchange]="onSelectStream()">
@for (stream of unit.tutorialStreams; track stream) {
<mat-option [value]="stream.key"
<mat-option [value]="stream"
>{{ stream.name }} — ({{
stream.tutorialsIn(taskDefinition.unit).length
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class TaskDefinitionTutorialEnrolmentComponent implements OnInit {

public _selectedTutorialStreams: TutorialStream[] = [];

tutoralStreamControl = new FormControl<TutorialStream | null>(null, Validators.required);
tutoralStreamControl = new FormControl<TutorialStream | null>(null, Validators.required);

public ngOnInit(): void {
const tutorialStreams = this.taskDefinition.unit.tutorialStreamsCache.currentValues;
Expand All @@ -27,6 +27,17 @@ export class TaskDefinitionTutorialEnrolmentComponent implements OnInit {
console.log(stream);

Choose a reason for hiding this comment

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

This log should probably be removed.

this._tutorialStreams.push(stream);
}

console.log(this.taskDefinition.tutorialSelfEnrolmentStream);

Choose a reason for hiding this comment

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

This log should probably be removed.

this.tutoralStreamControl.setValue(this.taskDefinition.tutorialSelfEnrolmentStream);
}

public onSelectStream(): void {
const selectedStream = this.tutoralStreamControl.value;
if (selectedStream) {
console.log(selectedStream);

Choose a reason for hiding this comment

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

This log should probably be removed

this.taskDefinition.tutorialSelfEnrolmentStream = selectedStream;
}
}

constructor(
Expand Down