Skip to content

Fix #5037: Pause hint timer while hints and solution dialog is open - #6425

Draft
Kishan8548 wants to merge 2 commits into
oppia:developfrom
Kishan8548:fix-5037-pause-hint-timer-when-hint-dialog-open
Draft

Fix #5037: Pause hint timer while hints and solution dialog is open#6425
Kishan8548 wants to merge 2 commits into
oppia:developfrom
Kishan8548:fix-5037-pause-hint-timer-when-hint-dialog-open

Conversation

@Kishan8548

Copy link
Copy Markdown
Collaborator

Explanation

Fixes #5037

Pause hint timer while hints and solution dialog is open

Context & Root Cause

Previously, HintHandlerProdImpl scheduled hints and solution availability on an uninterrupted countdown delay. If a learner opened the HintsAndSolutionDialogFragment to read an earlier hint or inspect a solution, the countdown timer for subsequent hints or solutions continued ticking in the background. As a result:

  • Subsequent hints could unlock while the dialog was still visible.
  • Learners could receive hints without spending active problem-solving time on the card itself.

Technical Implementation

  1. Domain Timer State (HintHandlerProdImpl & HintHandlerDebugImpl):

    • Added pause() and resume() to the HintHandler interface.
    • In HintHandlerProdImpl, integrated OppiaClock to track the exact elapsed time prior to pausing. When resumed, the remaining duration (targetDelay - elapsedTime) is scheduled rather than restarting the full delay.
    • Handled edge cases: pausing when no timer is active, multiple sequential pauses, and resuming after the delay has already elapsed.
    • Updated HintHandlerDebugImpl with matching no-op / state-tracking methods.
  2. Controller & Concurrency Layer:

    • Added pauseHintsAndSolutionTimer() and resumeHintsAndSolutionTimer() to both ExplorationProgressController and QuestionAssessmentProgressController.
    • Serialized pause/resume events via the existing actor message channels to guarantee thread safety and proper ordering with answer submissions and state transitions.
  3. Lifecycle & UI Wiring:

    • Extended HintsAndSolutionListener with onHintsAndSolutionDialogShown() and onHintsAndSolutionDialogDismissed().
    • Connected HintsAndSolutionDialogFragment's onStart() and onDismiss() lifecycle methods to notify the listener.
    • Delegated these events from ExplorationActivity and QuestionPlayerActivity through their respective fragments down to ExplorationProgressController and QuestionAssessmentProgressController.
  4. Testing & Verification:

    • Unit Tests: Added targeted tests in HintHandlerProdImplTest, HintHandlerDebugImplTest, ExplorationProgressControllerTest, and QuestionAssessmentProgressControllerTest covering pause before first hint, pause between hints, multiple pause/resume cycles, and solution timers.
    • DI / Modules: Updated HintsAndSolutionProdModuleTest and HintsAndSolutionDebugModuleTest with FakeOppiaClockModule to verify Dagger dependency graph integrity.
    • Local Verification: Ran all related unit tests and interaction tests (StateFragmentTest, ExplorationActivityTest, QuestionPlayerActivityTest) as well as all static checks (ktlint, checkstyle, buildifier), all of which passed.

Essential Checklist

  • The PR title starts with "Fix #bugnum: " (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".)
  • The explanation section above starts with "Fixes #bugnum: " (If this PR fixes part of an issue, use instead: "Fixes part of #bugnum: ...".)
  • Any changes to scripts/assets files have their rationale included in the PR explanation.
  • The PR follows the style guide.
  • The PR does not contain any unnecessary code changes from Android Studio (reference).
  • The PR is made from a branch that's not called "develop" and is up-to-date with "develop".
  • The PR is assigned to the appropriate reviewers (reference).

Disclosure of LLM Usage

  • Did you use AI/LLMs when working on this PR? Type Yes or No.
    Yes
  • If yes, describe the extent AI was used: Brainstorming architecture, implementing pause/resume logic, writing unit tests, and debugging Bazel build dependencies.

- HintHandler: Add pause and resume capabilities to the HintHandler interface and its implementations (HintHandlerProdImpl and HintHandlerDebugImpl). Track elapsed time using OppiaClock to ensure the remaining hint delay is preserved and resumed accurately when the dialog is dismissed.

- ExplorationProgressController & QuestionAssessmentProgressController: Add pause and resume methods that delegate events to HintHandler through actor message channels, connected to HintsAndSolutionDialogFragment lifecycle via ExplorationActivity and QuestionPlayerActivity.

- Tests: Add comprehensive unit test coverage across HintHandlerProdImplTest, HintHandlerDebugImplTest, ExplorationProgressControllerTest, and QuestionAssessmentProgressControllerTest, and update Dagger test modules with FakeOppiaClockModule.
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Coverage Report

Results

Number of files assessed: 22
Overall Coverage: 0.00%
Coverage Analysis: PASS

Exempted coverage

Files exempted from coverage
File Exemption Reason
ExplorationFragment.ktapp/src/main/java/org/oppia/android/app/player/exploration/ExplorationFragment.kt
This file is exempted from having a test file; skipping coverage check.
ExplorationFragmentPresenter.ktapp/src/main/java/org/oppia/android/app/player/exploration/ExplorationFragmentPresenter.kt
This file is exempted from having a test file; skipping coverage check.
ExplorationActivity.ktapp/src/main/java/org/oppia/android/app/player/exploration/ExplorationActivity.kt
This file is incompatible with code coverage tooling; skipping coverage check.
ExplorationActivityPresenter.ktapp/src/main/java/org/oppia/android/app/player/exploration/ExplorationActivityPresenter.kt
This file is exempted from having a test file; skipping coverage check.
StateFragmentPresenter.ktapp/src/main/java/org/oppia/android/app/player/state/StateFragmentPresenter.kt
This file is exempted from having a test file; skipping coverage check.
StateFragmentTestActivityPresenter.ktapp/src/main/java/org/oppia/android/app/player/state/testing/StateFragmentTestActivityPresenter.kt
This file is exempted from having a test file; skipping coverage check.
StateFragmentTestActivity.ktapp/src/main/java/org/oppia/android/app/player/state/testing/StateFragmentTestActivity.kt
This file is exempted from having a test file; skipping coverage check.
StateFragment.ktapp/src/main/java/org/oppia/android/app/player/state/StateFragment.kt
This file is incompatible with code coverage tooling; skipping coverage check.
HintsAndSolutionDialogFragmentPresenter.ktapp/src/main/java/org/oppia/android/app/hintsandsolution/HintsAndSolutionDialogFragmentPresenter.kt
This file is exempted from having a test file; skipping coverage check.
HintsAndSolutionDialogFragment.ktapp/src/main/java/org/oppia/android/app/hintsandsolution/HintsAndSolutionDialogFragment.kt
This file is exempted from having a test file; skipping coverage check.
HintsAndSolutionListener.ktapp/src/main/java/org/oppia/android/app/hintsandsolution/HintsAndSolutionListener.kt
This file is exempted from having a test file; skipping coverage check.
QuestionPlayerFragment.ktapp/src/main/java/org/oppia/android/app/topic/questionplayer/QuestionPlayerFragment.kt
This file is exempted from having a test file; skipping coverage check.
QuestionPlayerActivityPresenter.ktapp/src/main/java/org/oppia/android/app/topic/questionplayer/QuestionPlayerActivityPresenter.kt
This file is exempted from having a test file; skipping coverage check.
QuestionPlayerFragmentPresenter.ktapp/src/main/java/org/oppia/android/app/topic/questionplayer/QuestionPlayerFragmentPresenter.kt
This file is exempted from having a test file; skipping coverage check.
QuestionPlayerActivity.ktapp/src/main/java/org/oppia/android/app/topic/questionplayer/QuestionPlayerActivity.kt
This file is incompatible with code coverage tooling; skipping coverage check.
QuestionAssessmentProgressController.ktdomain/src/main/java/org/oppia/android/domain/question/QuestionAssessmentProgressController.kt
This file is incompatible with code coverage tooling; skipping coverage check.
ExplorationProgressController.ktdomain/src/main/java/org/oppia/android/domain/exploration/ExplorationProgressController.kt
This file is incompatible with code coverage tooling; skipping coverage check.
HintHandlerDebugImpl.ktdomain/src/main/java/org/oppia/android/domain/hintsandsolution/HintHandlerDebugImpl.kt
This file is incompatible with code coverage tooling; skipping coverage check.
HintHandler.ktdomain/src/main/java/org/oppia/android/domain/hintsandsolution/HintHandler.kt
This file is exempted from having a test file; skipping coverage check.
HintsAndSolutionDebugModule.ktdomain/src/main/java/org/oppia/android/domain/hintsandsolution/HintsAndSolutionDebugModule.kt
This file is incompatible with code coverage tooling; skipping coverage check.
HintsAndSolutionProdModule.ktdomain/src/main/java/org/oppia/android/domain/hintsandsolution/HintsAndSolutionProdModule.kt
This file is incompatible with code coverage tooling; skipping coverage check.
HintHandlerProdImpl.ktdomain/src/main/java/org/oppia/android/domain/hintsandsolution/HintHandlerProdImpl.kt
This file is incompatible with code coverage tooling; skipping coverage check.

Refer test_file_exemptions.textproto for the comprehensive list of file exemptions and their required coverage percentages.

To learn more, visit the Oppia Android Code Coverage wiki page

@Kishan8548

Copy link
Copy Markdown
Collaborator Author

@adhiamboperes PTAL

I've opened this draft PR with the implementation for pausing and resuming the hint timer when the hints/solution dialog is open, along with unit tests for HintHandler and controllers. Looking forward to your feedback to ensure we're going in the right direction!

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.

[BUG]: Fix hint timers continuing to count while hints are being viewed

2 participants