Skip to content

Commit

Permalink
refactor(TeacherDataService): add type annotations for improved type …
Browse files Browse the repository at this point in the history
…safety and clarity
  • Loading branch information
hirokiterashima committed Dec 20, 2024
1 parent 62281ed commit a6958df
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions src/assets/wise5/services/teacherDataService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,25 +349,25 @@ export class TeacherDataService extends DataService {
return getIntersectOfArrays(componentStatesByWorkgroupId, componentStatesByNodeId);
}

getComponentStatesByWorkgroupIdAndComponentId(workgroupId, componentId) {
getComponentStatesByWorkgroupIdAndComponentId(workgroupId: number, componentId: string): any[] {
const componentStatesByWorkgroupId = this.getComponentStatesByWorkgroupId(workgroupId);
const componentStatesByComponentId = this.getComponentStatesByComponentId(componentId);
return getIntersectOfArrays(componentStatesByWorkgroupId, componentStatesByComponentId);
}

getEventsByWorkgroupId(workgroupId) {
getEventsByWorkgroupId(workgroupId: number): any[] {
return this.studentData.eventsByWorkgroupId[workgroupId] || [];
}

getEventsByNodeId(nodeId) {
getEventsByNodeId(nodeId: string): any[] {
return this.studentData.eventsByNodeId[nodeId] || [];
}

getAnnotationsToWorkgroupId(workgroupId: number) {
getAnnotationsToWorkgroupId(workgroupId: number): any[] {
return this.studentData.annotationsToWorkgroupId[workgroupId] || [];
}

getAnnotationsByNodeId(nodeId: string) {
getAnnotationsByNodeId(nodeId: string): any[] {
return this.studentData.annotationsByNodeId[nodeId] || [];
}

Expand Down Expand Up @@ -396,11 +396,11 @@ export class TeacherDataService extends DataService {
this.currentPeriod = null;
}

getCurrentPeriod() {
getCurrentPeriod(): any {
return this.currentPeriod;
}

getCurrentPeriodId() {
getCurrentPeriodId(): number {
return this.currentPeriod.periodId;
}

Expand All @@ -412,16 +412,12 @@ export class TeacherDataService extends DataService {
this.periods = periods;
}

setCurrentWorkgroup(workgroup) {
setCurrentWorkgroup(workgroup: any): void {
this.currentWorkgroup = workgroup;
this.broadcastCurrentWorkgroupChanged({ currentWorkgroup: this.currentWorkgroup });
this.currentWorkgroupChangedSource.next({ currentWorkgroup: this.currentWorkgroup });
}

broadcastCurrentWorkgroupChanged(args: any) {
this.currentWorkgroupChangedSource.next(args);
}

getCurrentWorkgroup() {
getCurrentWorkgroup(): any {
return this.currentWorkgroup;
}

Expand Down

0 comments on commit a6958df

Please sign in to comment.