> ## Documentation Index
> Fetch the complete documentation index at: https://docs.altoura.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Set Time Limit & Remove Time Limit

> Control countdown timers for timed challenges and assessments

## Overview

Use **Set Time Limit** to start a countdown timer for a training state. When the timer expires, a configurable event fires, allowing you to route the learner to a timeout state or apply consequences. Use **Remove Time Limit** to cancel an active timer.

Timers are useful for creating urgency, simulating real-world constraints, and preventing learners from taking unlimited time on assessments.

## Set Time Limit

### When to Use

* **Timed assessments** — Limit time available to answer questions
* **Timed challenges** — Create pressure-based scenarios (e.g., "respond within 30 seconds")
* **Emergency simulations** — Model real-world time constraints
* **Workflow efficiency** — Measure and reward quick, accurate performance
* **Compliance training** — Enforce time requirements for specific procedures

### Parameters

| Parameter | Type             | Required | Description                                                                      |
| --------- | ---------------- | -------- | -------------------------------------------------------------------------------- |
| Duration  | Number (integer) | Yes      | Timer length in seconds (or milliseconds if specified). Example: 60 for 1 minute |
| Time Unit | String           | No       | Unit of measurement: `"seconds"` (default) or `"milliseconds"`                   |

### Example 1: 60-Second Quiz Question

```
Action: Set Time Limit
Duration: 60
Time Unit: "seconds"
```

The timer starts and counts down from 60 seconds. When it reaches zero, a timeout event fires.

### Example 2: Emergency Response Simulation (30 seconds)

```
Action: Set Time Limit
Duration: 30
Time Unit: "seconds"
```

The learner has 30 seconds to complete the emergency procedure before timeout.

### Example 3: Quick-Response Challenge (5 seconds)

```
Action: Set Time Limit
Duration: 5000
Time Unit: "milliseconds"
```

A very short 5-second timer for a quick-reaction challenge.

## Remove Time Limit

### When to Use

* Cancel a timer after the learner completes the step successfully
* Remove the timer before transitioning to an untimed state
* Allow unlimited time after a timed challenge phase

### Parameters

| Parameter | Type | Required | Description                             |
| --------- | ---- | -------- | --------------------------------------- |
| None      | —    | —        | No parameters. Cancels any active timer |

### Example

```
Action: Remove Time Limit
```

The countdown timer stops immediately, even if time remains.

## Best Practices

<Steps>
  <Step title="Show a timer UI">
    Display the countdown visually using **Show Text** or **Show Panel** so learners know time is running.
  </Step>

  <Step title="Use in onEntry">
    Start the timer in **onEntry** when the learner enters a timed state.
  </Step>

  <Step title="Plan timeout routes">
    Define a target state for the timeout event so timeouts don't break the training flow.
  </Step>

  <Step title="Remove or handle timer completion">
    In **onExit**, either **Remove Time Limit** or let the timer fire its event to transition states.
  </Step>

  <Step title="Test timer durations">
    Verify your time limits are realistic for the task. Too short = frustration; too long = no pressure.
  </Step>
</Steps>

## Common Patterns

### Quiz with Time Limit

```
State: QuizQuestion1
  onEntry:
    → Set Time Limit (Duration: 60, Unit: "seconds")
    → Show Panel
        Title: "Question 1"
        Display Text: "Answer this question: {{question}}"
        Choices: [A, B, C, D]
        Billboard: true
    → Show Text "Time remaining: 60 seconds"

  transitions:
    - event: "choice-a"
      target: "QuizFeedback1"
    - event: "choice-b"
      target: "QuizFeedback1"
    - event: "choice-c"
      target: "QuizFeedback1"
    - event: "choice-d"
      target: "QuizFeedback1"
    - event: "timeout"
      target: "QuizTimeout"

  onExit:
    → Remove Time Limit
    → Hide Panel
    → Hide Text
```

The learner has 60 seconds to choose an answer. If time expires, the timeout event routes to a timeout state.

### Emergency Response Scenario

```
State: AlarmTriggered
  onEntry:
    → Set Time Limit (Duration: 45, Unit: "seconds")
    → Show Panel
        Title: "ALARM! Emergency Response Required"
        Display Text: "You have 45 seconds to shut down the equipment safely."
        Billboard: true
    → Set Interactable Objects (["emergency-button"], true)

  transitions:
    - event: "emergency-button-tapped"
      target: "EmergencyStopped"
    - event: "timeout"
      target: "EmergencyTimeout"

  onExit:
    → Remove Time Limit
    → Hide Panel
```

The learner must hit the emergency button within 45 seconds. A timeout indicates they failed the scenario.

### Timed Practice Exercise

```
State: AssemblyChallenge
  onEntry:
    → Set Time Limit (Duration: 120, Unit: "seconds")
    → Show Panel
        Title: "Quick Assembly Challenge"
        Display Text: "Assemble the components as fast as you can!"
        Billboard: true
    → Set Interactable Objects (["component-1", "component-2", "component-3"], true)

  transitions:
    - event: "assembly-complete"
      action:
        - Remove Time Limit
        - Record achievement "Completed in {{timeElapsed}} seconds"
      target: "AssemblyResults"
    - event: "timeout"
      target: "AssemblyChallengeTimeout"

  onExit:
    → Hide Panel
```

The learner races to complete the assembly. Completing early removes the timer; timeout routes to a "time's up" state.

## Timer Behavior

* **Countdown** — Timer counts down from the specified duration to zero
* **Automatic timeout event** — When the timer reaches zero, a `"timeout"` event automatically fires
* **Non-blocking** — Other interactions can occur while the timer runs
* **Single timer** — Only one active timer per state (creating a new timer replaces the previous one)

## Related Actions

* **Show Text** — Display countdown or time-pressure messaging
* **Show Panel** — Present quiz or challenge instructions
* **Pause Training** — Optional: pause when time expires
