Skip to content

immediate bug solved#57

Merged
FOSSCLUB-LBSITW merged 2 commits into
FOSSCLUB-LBSITW:mainfrom
annrose2277-glitch:feature
Mar 3, 2026
Merged

immediate bug solved#57
FOSSCLUB-LBSITW merged 2 commits into
FOSSCLUB-LBSITW:mainfrom
annrose2277-glitch:feature

Conversation

@annrose2277-glitch
Copy link
Copy Markdown
Contributor

@annrose2277-glitch annrose2277-glitch commented Mar 2, 2026

📌 Description

Brief description of what this PR does.

  1. Added self.time_left and self.timer_id: To track the countdown and manage the after() loop.
    2. Added self.timer_label: A new UI element to display the remaining time.
    3. Implemented update_timer: Handles the countdown logic and triggers check_result when time runs out.
    4. Updated start_test: To initialize the timer and reset the countdown.
    5. Fixed check_result: Added a timeout parameter. If the test ends via timeout, elapsed_time is set to the exact TEST_DURATION (60s)
    instead of calculating it from time.time(), ensuring consistent WPM results.

🔗 Related Issue

Closes: #52#53#54

so basically when i solved immediate bug solution it automattically solved the time related problems so it closed the remaing issues too.

How to verify the "Ghost Timer" Fix
To see if your fix actually worked (independent of the Git error), run your script and do this:

Click Start Test.

Wait 5 seconds.

Click Restart Test immediately.

Watch the clock: If it counts down normally (59, 58, 57...), the Ghost Timer is solved.

If it jumps (59, 57, 55...), the after_cancel is not triggering correctly.


🛠 Changes Made

-Initialised Timer State: Added self.time_left (set to 60s) and self.timer_id to track the countdown and manage the after() loop.
Added Timer UI: Created self.timer_label to display the remaining time to the user.
Implemented update_timer: This method handles the 1-second interval countdown. When it hits 0, it automatically triggers
check_result(timeout=True).
Reset Logic in start_test: Ensuring any existing timer is cancelled before starting a new one (also fixing the "Ghost Timer"
issue) and resetting the countdown.
The Math Fix in check_result:
* Added a timeout parameter to the function.
* Logical Fix: If the test ends because the timer reached 0 (timeout=True), the code now uses the exact TEST_DURATION (60) for the
elapsed_time variable. This prevents WPM inaccuracies caused by the slight CPU latency (e.g., 60.01s) that occurs when using
time.time().

 if timeout:
         elapsed_time = TEST_DURATION  # Fix: Use fixed duration if timer expires
    else:
          end_time = time.time()
          elapsed_time = end_time - self.start_time

📷 Screenshots (if applicable)

Screenshot 2026-03-03 023032

✅ Checklist

  • [yes ] I have tested my changes
  • [yes ] My code follows project guidelines
  • [yes ] I have linked the related issue

@github-actions github-actions Bot added bug Something isn't working HackTheStack level-3 labels Mar 2, 2026
@FOSSCLUB-LBSITW FOSSCLUB-LBSITW merged commit dbed0b5 into FOSSCLUB-LBSITW:main Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working HackTheStack level-3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The "Immediate Win" Bug (Logic)

2 participants