Skip to content

Commit

Permalink
fix(Embedded): Auto comment does not show up immediately (#1060)
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffreykwan authored Feb 24, 2023
1 parent 17fb33a commit 62bcd7e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 13 deletions.
8 changes: 0 additions & 8 deletions src/assets/wise5/components/component-student.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -727,14 +727,6 @@ export abstract class ComponentStudent {
);
}

updateLatestScoreAnnotation(annotation: any): void {
this.latestAnnotations.score = annotation;
}

updateLatestCommentAnnotation(annotation: any): void {
this.latestAnnotations.comment = annotation;
}

registerNotebookItemChosenListener(): void {
this.subscriptions.add(
this.NotebookService.notebookItemChosen$.subscribe(({ requester, notebookItem }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as html2canvas from 'html2canvas';
import { Component } from '@angular/core';
import { ChangeDetectorRef, Component } from '@angular/core';
import { AnnotationService } from '../../../services/annotationService';
import { ConfigService } from '../../../services/configService';
import { NodeService } from '../../../services/nodeService';
Expand Down Expand Up @@ -70,6 +70,7 @@ export class EmbeddedStudent extends ComponentStudent {

constructor(
protected AnnotationService: AnnotationService,
private changeDetectorRef: ChangeDetectorRef,
protected ComponentService: ComponentService,
protected ConfigService: ConfigService,
protected dialog: MatDialog,
Expand Down Expand Up @@ -622,4 +623,20 @@ export class EmbeddedStudent extends ComponentStudent {
this.sendMessageToApplication(message);
}
}

updateLatestScoreAnnotation(annotation: any): void {
this.latestAnnotations = {
comment: this.latestAnnotations.comment,
score: annotation
};
this.changeDetectorRef.detectChanges();
}

updateLatestCommentAnnotation(annotation: any): void {
this.latestAnnotations = {
comment: annotation,
score: this.latestAnnotations.score
};
this.changeDetectorRef.detectChanges();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ export class ComponentAnnotationsComponent {
getLatestAnnotation() {
let latest = null;
if (this.annotations.comment || this.annotations.score) {
let commentSaveTime = this.annotations.comment ? this.annotations.comment.serverSaveTime : 0;
let scoreSaveTime = this.annotations.score ? this.annotations.score.serverSaveTime : 0;
const commentSaveTime = this.getSaveTime(this.annotations.comment);
const scoreSaveTime = this.getSaveTime(this.annotations.score);
if (commentSaveTime >= scoreSaveTime) {
latest = this.annotations.comment;
} else if (scoreSaveTime > commentSaveTime) {
Expand All @@ -134,10 +134,23 @@ export class ComponentAnnotationsComponent {
return latest;
}

getSaveTime(annotation: any): number {
let saveTime = null;
if (annotation != null) {
if (annotation.serverSaveTime != null) {
saveTime = annotation.serverSaveTime;
}
if (annotation.clientSaveTime != null) {
saveTime = annotation.clientSaveTime;
}
}
return saveTime;
}

getLatestAnnotationTime() {
const latest = this.getLatestAnnotation();
if (latest) {
return this.configService.convertToClientTimestamp(latest.serverSaveTime);
return this.configService.convertToClientTimestamp(this.getSaveTime(latest));
}
return null;
}
Expand All @@ -163,7 +176,7 @@ export class ComponentAnnotationsComponent {
);
let saveTime = null;
if (latestState) {
saveTime = this.configService.convertToClientTimestamp(latestState.serverSaveTime);
saveTime = this.configService.convertToClientTimestamp(this.getSaveTime(latestState));
}
return saveTime;
}
Expand Down

0 comments on commit 62bcd7e

Please sign in to comment.