Implementing Auto Submit Assessment on Timer Expiry in Oracle APEX

Introduction / Issue

In an online assessment, candidates are given a fixed duration to complete the exam. If the timer expires before the candidate clicks the Submit button, the assessment may remain incomplete and the entered responses may not be saved. To overcome this issue, an automatic submission mechanism can be implemented.

Why We Need to Do / Cause of the Issue

During an online examination, candidates may forget to submit the assessment, close the browser, or lose track of the remaining time. This can result in incomplete submissions and loss of responses. Implementing an auto-submit feature ensures that all attempted answers are saved and evaluated when the allotted time expires.

How Do We Solve

Step 1: Create a Timer Region

Create a Static Content region to display the countdown timer on the assessment page. The timer becomes visible as soon as the candidate starts the exam.

<div class="exam-timer">

    ⏳ Time Left :

    <span id="timer">02:00</span>

</div>

Step 2: Start the Countdown Timer

On Page Load, use JavaScript to start the timer. Store the remaining time in sessionStorage so that the timer continues correctly even if the page refreshes.

var timeLeft = sessionStorage.getItem("examTimer");

if(timeLeft === null){

    timeLeft = 120;

}else{

    timeLeft = parseInt(timeLeft);

}

Step 3: Save Candidate Answers

In the Dynamic Content region, save each selected option using sessionStorage.

sessionStorage.setItem(

    "Q" + apex.item("P5_CURRENT_QN").getValue(),

    optionId );

Step 4: Restore Selected Answers

When navigating between questions, retrieve the saved answer from sessionStorage and automatically check the previously selected option.

var selectedOption =

sessionStorage.getItem("Q" + currentQn);

Step 5: Auto Submit on Timer Expiry

When the timer reaches 0, call the SAVE_EXAM Ajax Process to save all selected answers.

apex.server.process(

    "SAVE_EXAM",

    {   x01: sessionStorage.getItem("Q1"),

        x02: sessionStorage.getItem("Q2"),

        x03: sessionStorage.getItem("Q3"),

        x04: sessionStorage.getItem("Q4"),

        x05: sessionStorage.getItem("Q5")  }  );

Step 6: Redirect to Result Page

After successfully saving the responses, automatically submit the page.

apex.submit("AUTO_SUBMIT");

The assessment is completed automatically, and the candidate is redirected to the Result page.

Real-Time Scenario

Assume a candidate is given 2 minutes to complete 5 questions.

  • The candidate answers the first 4 questions.
  • Before answering the fifth question, the timer expires.
  • Instead of losing all responses, the application automatically submits the assessment.
  • The four answered questions are evaluated, while the unanswered question is considered unanswered.
  • Finally, the candidate is redirected to the Result page without requiring any manual action.

Conclusion

The Auto Submit on Timer Expiry feature improves the reliability of online assessments by preventing data loss and ensuring that candidate responses are saved even when the allotted time expires. This solution provides a smooth and fair examination experience in Oracle APEX

Recent Posts