Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(AnnotationService): getLatestScoreAnnotation() #1469

Merged

Conversation

hirokiterashima
Copy link
Member

@hirokiterashima hirokiterashima commented Oct 13, 2023

Changes

  • Simplify function using Array.filter() and Array.at()
  • Function now returns undefined instead of null if there is no latest score or auto-score
  • Add private modifiers, param types and function return types
  • Update references
  • Add basic tests

Test

  • Teacher score and auto-score annotations appear correctly as before in
    • Grading by step
    • Grade by team
    • Milestone report -> Student Work
    • Student VLE component scores from teacher and auto-scores from CRater

@hirokiterashima hirokiterashima added this to the Tech Debt 19 -> 18 milestone Oct 13, 2023
@hirokiterashima hirokiterashima self-assigned this Oct 13, 2023
@hirokiterashima hirokiterashima marked this pull request as ready for review October 13, 2023 16:49
Copy link
Member

@geoffreykwan geoffreykwan left a comment

Choose a reason for hiding this comment

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

Works well.

I'm wondering if getLatestScoreAnnotation() should return null for consistency. There's also a slight difference in behavior between null and undefined.

Calling this
JSON.stringify({a: null, b: undefined})

Returns this
'{"a":null}'

I'm wondering if that will come into play in places like this or similar places.

const latestScoreAnnotation = this.AnnotationService.getLatestScoreAnnotation(
this.nodeId,
this.componentId,
workgroupId,
type
);
const latestCommentAnnotation = this.AnnotationService.getLatestCommentAnnotation(
this.nodeId,
this.componentId,
workgroupId,
type
);
const message = {
messageType: 'latestAnnotations',
latestScoreAnnotation: latestScoreAnnotation,
latestCommentAnnotation: latestCommentAnnotation
};
this.sendMessageToApplication(message);

and

const latestScoreAnnotation = this.AnnotationService.getLatestScoreAnnotation(
this.nodeId,
this.componentId,
workgroupId,
type
);
const latestCommentAnnotation = this.AnnotationService.getLatestCommentAnnotation(
this.nodeId,
this.componentId,
workgroupId,
type
);
const message = {
messageType: 'latestAnnotations',
latestScoreAnnotation: latestScoreAnnotation,
latestCommentAnnotation: latestCommentAnnotation
};
this.sendMessageToApplication(message);

Comment on lines 554 to 557
return (
['autoScore', 'score'].includes(annotation.type) &&
(scoreType === 'any' || annotation.type === scoreType)
);
Copy link
Member

Choose a reason for hiding this comment

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

Should this be something like this to be more concise?

    return (
      (scoreType === 'any' && ['autoScore', 'score'].includes(annotation.type)) ||
      annotation.type === scoreType
    );

Copy link
Member

@geoffreykwan geoffreykwan left a comment

Choose a reason for hiding this comment

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

Looks good.

@hirokiterashima hirokiterashima merged commit 2e9d537 into develop Oct 16, 2023
2 checks passed
@hirokiterashima hirokiterashima deleted the refactor-annotationService-getLatestScoreAnnotation branch October 16, 2023 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants