Skip to content

Fix Duplicate ID, Add Per-Problem Time Limit and Custom Answer Comparison #545

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

Merged
merged 2 commits into from
Mar 26, 2025

Conversation

Acfboy
Copy link
Contributor

@Acfboy Acfboy commented Mar 23, 2025

Hello everyone! In this PR, I have fixed an issue that I encountered multiple times and added two useful features.

  1. ID duplication causing infinite running: The original implementation used a random number in the range [1, 100] added to the timestamp as the ID. However, after calculation, it can be determined that if a problem with 4 examples is added by the companion, the probability of an error occurring will exceed 50% after just 8 problems. This will lead to an unending display of "running," which I have encountered many times.

  2. Adding a per-problem time limit: Some problems have longer time limits, and it is not convenient to change the timeout setting in the preferences. Therefore, I added the option to modify it near "Set ONLINE_JUDGE".

  3. Different comparison methods: Some problems involve floating-point comparison and Yes/No comparison, but this plugin can only perform text comparison, which is not very convenient. Therefore, I added an option to choose different precision floating-point comparisons and case-insensitive Yes/No comparisons.

Im sure I have passed the tests mentioned in dev-guide.md, hoping this work can be a helpful addition to the plugin.

image

@agrawal-d
Copy link
Owner

Thanks for your contribution, @Acfboy!
At this time, I can only consider feature (1). (2) and (3) are not too widely useful so I'm not planning on adding them right now.

Can you please make changes to your PR so that it only contains changes related to (1) ?

Thanks again!

@Acfboy
Copy link
Contributor Author

Acfboy commented Mar 25, 2025

Alright. I've changed my PR to focus only on feature (1).

src/utils.ts Outdated
@@ -162,7 +162,13 @@ export const ocHide = () => {
oc.hide();
};

export const randomId = () => Math.floor(Date.now() + Math.random() * 100);
export const randomId = (index: number | null) => {
if (index) {
Copy link
Owner

@agrawal-d agrawal-d Mar 26, 2025

Choose a reason for hiding this comment

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

If index is 0 it index will be false-like. Do an explicit null check here ( index !== null )

@Acfboy
Copy link
Contributor Author

Acfboy commented Mar 26, 2025

Done. Thanks.

@agrawal-d agrawal-d merged commit 89c7e71 into agrawal-d:main Mar 26, 2025
4 checks passed
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.

2 participants