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

Add Token Counter Displayer in Repl #2775

Merged

Conversation

jayjay19630
Copy link
Contributor

@jayjay19630 jayjay19630 commented Feb 12, 2024

Add Token Counter Displayer in Repl

Description:

This pull request creates a new assessment config which enables a token counter. This token counter is a notification which lets the user know how many tokens their program has. This notification can be seen as an output in the Repl once the program is run.

Tasks:

  • Create new Repl output type called notification output.
  • Add new hasTokenCounter and customNotification properties to workspace.
  • Import Acorn dependency to count tokens in user's program.
  • Display token counter in Repl conditionally depending on assessment configurations.
  • Add new BooleanCell in admin panel to toggle token counter feature.
  • Fix testcases.

Notes:

Note that modifying custom Repl notifications hasn't been implemented yet (possible future updates).


Co-authored-by: Lau Xiang Yu

jayjay19630 and others added 20 commits February 3, 2024 14:05
@jayjay19630 jayjay19630 force-pushed the ReplNotificationDisplayer branch from b5944f4 to 32d9e1d Compare February 12, 2024 16:00
@coveralls
Copy link

coveralls commented Feb 12, 2024

Pull Request Test Coverage Report for Build 7889640712

Details

  • -14 of 38 (63.16%) changed or added relevant lines in 7 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.05%) to 37.245%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/commons/repl/Repl.tsx 0 1 0.0%
src/commons/workspace/WorkspaceActions.ts 5 6 83.33%
src/commons/assessmentWorkspace/AssessmentWorkspace.tsx 5 7 71.43%
src/commons/workspace/WorkspaceReducer.ts 7 12 58.33%
src/pages/academy/adminPanel/subcomponents/assessmentConfigPanel/AssessmentConfigPanel.tsx 0 5 0.0%
Totals Coverage Status
Change from base Build 7883369399: 0.05%
Covered Lines: 5745
Relevant Lines: 14498

💛 - Coveralls

@RichDom2185
Copy link
Member

Corresponding backend PR: source-academy/backend#1062

Copy link
Member

@RichDom2185 RichDom2185 left a comment

Choose a reason for hiding this comment

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

Thanks for working on this, looking forward to the new additions 👍 just some comments below:

type: 'notification'
});
}
const customNotification = state[workspaceLocation].customNotification;
Copy link
Member

Choose a reason for hiding this comment

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

Is this for future plans, or already used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is most likely for future plans. Not yet used.

Copy link
Member

Choose a reason for hiding this comment

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

Would it make more sense for customNotification to be customNotifications (a string[]) instead then? Since it's reasonable to assume you can have either 0, 1, or more than 1; there's no reason to only have either 0 or 1 notification present.

Anyway, it's not used now, so I'll just approve the PR, but perhaps you can create an issue: either remove it (cause it's unused), or make it support multiple notifications?

Copy link
Member

@RichDom2185 RichDom2185 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the quick fixes! Please refer to the thread above regarding custom notifications.

Thanks again!

@RichDom2185 RichDom2185 merged commit 4f55b88 into source-academy:master Feb 13, 2024
6 checks passed
@jayjay19630 jayjay19630 deleted the ReplNotificationDisplayer branch February 26, 2024 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants