LMS & eLearning

How to Add a Time Limit to a LearnDash Quiz

Put a countdown on a LearnDash quiz: the time limit in seconds, what happens when it runs out, how the timer survives a page reload, the cookie and resume options, and the usual failure modes.

How to Add a Time Limit to a LearnDash Quiz

A timed quiz in LearnDash counts down from the moment the learner clicks Start and submits whatever has been answered when the clock reaches zero. The setting is a single number of seconds, which is simple, but the timer runs in the browser, so what happens on a page reload, a dropped connection or a closed laptop depends on two other settings that most people have never looked at.

This guide sets a LearnDash quiz time limit, explains how the countdown is kept and what the learner sees at the end, and shows which companion settings to enable so that a timed exam behaves predictably.

Enable the time limit

On the quiz edit screen, the Settings tab has a Progression and Restriction Settings section. Switch on Time Limit and enter the number of seconds in the field labelled Automatically Submit After. Save the quiz with Update, because like every quiz setting the value is copied into the compiled quiz when the post is saved.

The two keys written are quiz_time_limit_enabled (on) and timeLimit, an integer in seconds. Enter 1800 for thirty minutes, 3600 for an hour. There is no minutes field, so write the conversion in your course notes to save the next admin a calculation. A value of 0 with the switch on is treated as no limit.

What the learner sees

The quiz start screen shows the time limit before the learner begins. Once they click Start, a countdown appears at the top of the quiz and runs while they answer. When it reaches zero the quiz is submitted automatically with the answers given so far; unanswered questions score nothing. The result page then appears as it would after a manual submit, and the attempt is recorded with its timespent value, which reports and the statistics view display.

With the display mode set to one question per page, the countdown continues across questions. With Quiz Completion (forcingQuestionSolve) on, learners must answer every question before they can move on or submit, which under a time limit means a learner who gets stuck can run out of time on one question; combine the two only for exams where that is the intended pressure.

How the timer survives a reload

The countdown is JavaScript in the quiz front-end script. On its own, a page reload would restart it, which would let a learner reset the clock. The plugin prevents that with Browser Cookie Answer Protection, found under Administrative and Data Handling Settings and stored as timeLimitCookie with its switch timeLimitCookie_enabled. When it is on, the start time and the answers given so far are written to a cookie named ld_{quiz_id}_quiz_responses, and a reload within the cookie's lifetime resumes the same countdown with the answers restored. The Cookie time limit field sets how long that cookie lives, in seconds; make it at least as long as the quiz itself.

Turn this on for every timed quiz. The help text warns that cookies have limited capacity, which matters only for very long quizzes with many free-text answers, and a short exam fits comfortably.

Quiz Resume is a different feature

Quiz Resume (quiz_resume, under Progression and Restriction Settings) saves answers to the server at an interval set by quiz_resume_cookie_send_timer so a learner can leave and come back to the same attempt, even on another device. It uses its own cookie, ld_save_{quiz_id}_quiz_responses, and a server-side record. It is designed for untimed quizzes that take a long time. On a timed quiz it will restore answers, but the time already spent is part of the saved state, so a learner who leaves and returns a day later finds the quiz submitted or nearly out of time depending on how the limit elapsed. If you need both, test the exact behaviour on a staging copy before promising it to learners.

Common problems and their causes

  • The timer resets on reload. Browser Cookie Answer Protection is off, or the cookie time limit is shorter than the quiz. Enable it and set a generous lifetime.
  • The timer runs but the quiz never auto-submits. Usually a JavaScript error from another plugin or theme on the page, or the quiz script being deferred by an optimisation plugin. Check the browser console on the quiz page and exclude the quiz script from deferral.
  • The learner reports less time than you set. The value is in seconds. A limit of 60 entered as "one hour" gives one minute.
  • Admins never see the countdown. Administrators bypass quiz restrictions by default. Test with a subscriber account.
  • The result shows a wrong time spent. The stored timespent is measured in the browser, so a learner whose device clock changes mid-quiz can produce an odd value. It does not affect the score.

Choosing a limit

Time a colleague who knows the material and multiply by two to three for a fair limit; tighter limits measure reading speed rather than knowledge, and learners on phones type slowly. If the quiz gates a lesson or certificate, pair the limit with a retake rule so a single dropped connection is not the end of someone's course. Our guide on limiting quiz attempts explains the retry settings, and our article on improving course completion rates looks at how assessment pressure affects drop-off.

When to get help

A time limit is a setting you can manage yourself. Custom timing rules, such as extra time for learners with accommodations, a per-section limit inside one quiz, or a server-enforced timer that cannot be defeated by editing a cookie, are development work against the quiz front-end script and the completion hooks. Those sit with our LearnDash services, and a LearnDash developer can scope an accommodation rule from a short description of who needs it and how much extra time.

Frequently asked questions

Can I set different time limits for different learners?

Not with the built-in setting, which is per quiz. The usual approach for accommodations is a second copy of the quiz with a longer limit, placed in a separate course or group for those learners, or a small snippet that adjusts the limit based on the user.

What happens to answers if the browser closes during a timed quiz?

With Browser Cookie Answer Protection on, the answers and the countdown are restored when the learner reopens the quiz in the same browser before the cookie expires. Without it, the attempt is lost and the learner starts again, which may use a retake.

Does the time limit apply per question or to the whole quiz?

To the whole quiz. LearnDash has no per-question timer. Splitting a long exam into several short quizzes, each with its own limit, is the closest equivalent.

Is the time limit enforced on the server?

No. The countdown and the auto-submit run in the browser, and the submission records the time spent. A technically capable learner could interfere with it, so treat the timer as a fairness tool rather than a security control, and use proctoring software if the exam is high-stakes.

Add WorldWin Coder to your preferred sources

Add worldwincoder.com as a preferred source on Google, or open this article in your AI assistant to use it as a source.

· Developers and project managers

Articles written and reviewed by the developers and project managers at WorldWin Coder, who build and maintain websites, web applications and mobile apps on WordPress, Moodle, PHP, Laravel, CodeIgniter and Flutter.

Keep reading

Have something to build, fix or move?

Tell us where you are. A developer reads every inquiry, and you get next steps and a free quote within one business day.