diff --git a/src/app/classroom-monitor/component-new-work-badge/component-new-work-badge.component.ts b/src/app/classroom-monitor/component-new-work-badge/component-new-work-badge.component.ts index fc54a01a67f..11d95c6176a 100644 --- a/src/app/classroom-monitor/component-new-work-badge/component-new-work-badge.component.ts +++ b/src/app/classroom-monitor/component-new-work-badge/component-new-work-badge.component.ts @@ -3,79 +3,78 @@ import { Subscription } from 'rxjs'; import { AnnotationService } from '../../../assets/wise5/services/annotationService'; import { TeacherDataService } from '../../../assets/wise5/services/teacherDataService'; import { Annotation } from '../../../assets/wise5/common/Annotation'; +import { CommonModule } from '@angular/common'; @Component({ + imports: [CommonModule], selector: 'component-new-work-badge', - template: `New` + standalone: true, + template: `@if (hasNewWork) { + New + }` }) export class ComponentNewWorkBadgeComponent { - annotationSavedToServerSubscription: Subscription; - - @Input() - componentId: string; - - hasNewWork: boolean = false; - - @Input() - nodeId: string; - - @Input() - workgroupId: number; + @Input() componentId: string; + protected hasNewWork: boolean; + @Input() nodeId: string; + private subscriptions: Subscription = new Subscription(); + @Input() workgroupId: number; constructor( - private AnnotationService: AnnotationService, - private TeacherDataService: TeacherDataService + private annotationService: AnnotationService, + private dataService: TeacherDataService ) {} - ngOnInit() { + ngOnInit(): void { this.checkHasNewWork(); - this.annotationSavedToServerSubscription = this.AnnotationService.annotationSavedToServer$.subscribe( - (annotation: Annotation) => { + this.subscriptions.add( + this.annotationService.annotationSavedToServer$.subscribe((annotation: Annotation) => { if (annotation.nodeId === this.nodeId && annotation.componentId === this.componentId) { this.checkHasNewWork(); } - } + }) ); } - ngOnDestroy() { - this.annotationSavedToServerSubscription.unsubscribe(); + ngOnDestroy(): void { + this.subscriptions.unsubscribe(); } - checkHasNewWork() { - const latestComponentState = this.TeacherDataService.getLatestComponentStateByWorkgroupIdNodeIdAndComponentId( + private checkHasNewWork(): void { + this.hasNewWork = false; + const componentState = this.dataService.getLatestComponentStateByWorkgroupIdNodeIdAndComponentId( this.workgroupId, this.nodeId, this.componentId ); - const latestAnnotations = this.AnnotationService.getLatestComponentAnnotations( + const annotations = this.annotationService.getLatestComponentAnnotations( this.nodeId, this.componentId, this.workgroupId, - null, + 'any', 'comment' ); - if (latestComponentState) { - let latestTeacherComment = null; - if (latestAnnotations && latestAnnotations.comment) { - latestTeacherComment = latestAnnotations.comment; + if (componentState) { + let teacherComment = null; + if (annotations && annotations.comment) { + teacherComment = annotations.comment; } - let latestTeacherScore = null; - if (latestAnnotations && latestAnnotations.score) { - if (latestAnnotations.score.type !== 'autoScore') { - latestTeacherScore = latestAnnotations.score; + let teacherScore = null; + if (annotations && annotations.score) { + if (annotations.score.type !== 'autoScore') { + teacherScore = annotations.score; } } - const commentSaveTime = latestTeacherComment ? latestTeacherComment.serverSaveTime : 0; - const scoreSaveTime = latestTeacherScore ? latestTeacherScore.serverSaveTime : 0; - let latestTeacherAnnotationTime = 0; + const commentSaveTime = teacherComment ? teacherComment.serverSaveTime : 0; + const scoreSaveTime = teacherScore ? teacherScore.serverSaveTime : 0; + let teacherAnnotationTime = 0; if (commentSaveTime >= scoreSaveTime) { - latestTeacherAnnotationTime = commentSaveTime; + teacherAnnotationTime = commentSaveTime; } else if (scoreSaveTime > commentSaveTime) { - latestTeacherAnnotationTime = scoreSaveTime; + teacherAnnotationTime = scoreSaveTime; } - let latestComponentStateTime = latestComponentState.serverSaveTime; - if (latestComponentStateTime > latestTeacherAnnotationTime) { + let componentStateTime = componentState.serverSaveTime; + if (componentStateTime > teacherAnnotationTime) { this.hasNewWork = true; } } diff --git a/src/app/teacher/classroom-monitor.module.ts b/src/app/teacher/classroom-monitor.module.ts index b00ac30ec5a..724e741fb5a 100644 --- a/src/app/teacher/classroom-monitor.module.ts +++ b/src/app/teacher/classroom-monitor.module.ts @@ -42,7 +42,6 @@ import { StepToolsComponent } from '../../assets/wise5/common/stepTools/step-too declarations: [ AlertStatusCornerComponent, ClassroomMonitorComponent, - ComponentNewWorkBadgeComponent, ComponentSelectComponent, NavItemComponent, NodeInfoComponent, @@ -63,8 +62,8 @@ import { StepToolsComponent } from '../../assets/wise5/common/stepTools/step-too ViewComponentRevisionsComponent ], imports: [ - StudentTeacherCommonModule, ComponentGradingModule, + ComponentNewWorkBadgeComponent, ComponentStudentModule, DataExportModule, GradingCommonModule, @@ -79,7 +78,8 @@ import { StepToolsComponent } from '../../assets/wise5/common/stepTools/step-too SaveIndicatorComponent, SelectPeriodModule, StepInfoComponent, - StepToolsComponent + StepToolsComponent, + StudentTeacherCommonModule ] }) export class ClassroomMonitorModule {} diff --git a/src/assets/wise5/classroomMonitor/classroomMonitorComponents/milestones/milestone-workgroup-item/milestone-workgroup-item.component.html b/src/assets/wise5/classroomMonitor/classroomMonitorComponents/milestones/milestone-workgroup-item/milestone-workgroup-item.component.html index c8f396a28bc..12010f382bc 100644 --- a/src/assets/wise5/classroomMonitor/classroomMonitorComponents/milestones/milestone-workgroup-item/milestone-workgroup-item.component.html +++ b/src/assets/wise5/classroomMonitor/classroomMonitorComponents/milestones/milestone-workgroup-item/milestone-workgroup-item.component.html @@ -77,7 +77,7 @@

[componentId]="firstComponentId" [workgroupId]="workgroupId" [nodeId]="firstNodeId" - > + />

[componentId]="lastComponentId" [workgroupId]="workgroupId" [nodeId]="lastNodeId" - > + /> [componentId]="component.id" [workgroupId]="workgroupId" [nodeId]="nodeId" - > + /> [componentId]="component.id" [workgroupId]="workgroupId" [nodeId]="nodeId" - > - + /> New src/app/classroom-monitor/component-new-work-badge/component-new-work-badge.component.ts - 9 + 13 src/app/classroom-monitor/step-info/step-info.component.html