Adding Timer(Time-Limit) to Captivate Quiz using JavaScript.

January 12, 2019
in It industry as Instructor, Developer since 25+ years. Work on Java, .Net, Network protocols, Different Networking System like Linux, Windows Server . Prog. in Adv. Excel etc.
Wizard 13 posts
Followers: 1 people
7

Adding Timer(Time-Limit) to Captivate Quiz using JavaScript.

in It industry as Instructor, Developer since 25+ years. Work on Java, .Net, Network protocols, Different Networking System like Linux, Windows Server . Prog. in Adv. Excel etc.
Wizard 13 posts
Followers: 1 people
January 12, 2019
Play

Although Captivate provides Widget to implement timer in Quiz(Test), following simple procedure, using JavaScript, could give you lot more freedom to program and control the Quiz. I regularly use this in the online Test of my Students.
Let me explain with example, steps required for the same.
In a Captivate project, Add following user variables:
Step 1:
User Variables:
cp_min, cp_sec, cp_time_out, time_left:
Create /add questions slides of your choice. I have added simple 5 slides in this Captivate project to explain this procedure.
Step 2:
As shown below, Insert similar Slide, just before 1st Quiz Slide.

Step 3:

“On Exit” Action of this Slide, add JavaScript as scripted below:

Explanation of the above Script: To explain it better, let me divide script in different parts :
Line 1 to 4: setting JavaScript variables and passing it’s value to Captivate. Here you can set time-limit of your choice. For Demo purpose, I have set just 2 minutes as Time-limit.
Line 7 to 23: it is the function which would be called every second by line number 24.
Inside the function: Line number 8 to 13: simple manipulation of seconds , minutes.
Line 15 to 18: checking if the time is Over. And if thime is over Resullt slide is called.

Timer(second_Passed() function) will continually check for Time elapsed. The moment time is up, JavaScript will force program execution to jump from the current question slide to the Result slide.
Note: The candidate who is giving that exam is not necessarily Failed, but marks would be counted for whatsoever correct answers he/she has given in the time-limit, and Result is displayed accordingly.

Step 4:

To inform Student, about this(sudden end of Exam due to time-out), Time-Out message need to be displayed.

In the Result Slide, following Advanced Actions is added to display “Timed-Out” Box, if time was over.

Result:

I hope this will be useful to many who want to add simple time-limit in the Quiz(online exam).

Note: Although everything is shown and working example in also hosted, I have purposely kept one ‘cache’ without explanation. And those who will do it, will come to know about that cache. Try solving that at least for some time… otherwise I will explain that Defiantly. But I strongly believe that first you must try practically.

Request to Expert: Defiantly, You may be knowing the ‘Cache’ and its solution, but please don’t explain and give solution in the immediate post. Let other do by them selves.

Comments (7)
2019-01-14 14:25:52
2019-01-14 14:25:52

I had issues with On Exit actions on many occasions, because it is executed after visiting the last frame of a slide.  If the developer replicating this example adds a Start button to the slide, with the action ‘Go to Next Slide’, will the On Exit script be executed?  Do I miss something like a warning?

I am not the only to recommend never to use the On Exit action, not only for this reason but it is also not always to be  trusted, at least not with advanced/shared actions.

Next question: can this script be entered into a Captivate JS window without  issues? Or are you using an external JS file.

Like
(4)
>
Lieve Weymeis
's comment
2019-01-14 14:37:58
2019-01-14 14:37:58
>
Lieve Weymeis
's comment

That is why if you see carefully my note, I have applied javascript JUST Before exam start. So when Exam has started, the script is in action in the background regardless of student goes for next slide or not…

Like
>
Chandresh Shah
's comment
2019-01-14 14:44:01
2019-01-14 14:44:01
>
Chandresh Shah
's comment

I did read carefully and I see that you use the On Exit action on the slide inserted just before the first quiz slide. I was talking about that slide (with Good Luck). If the developer adds a button Start to that slide, with the simple action ‘Go to Next Slide’ pausing that slide to give control to the learner, will your script be executed? Of course you need to start the timer at least on the first frame of the first question slide, which is not possible if those are random questions. I would prefer to use an On Enter action of a very short slide (0,1secs) before the quiz slide, not on a meaningful slide like the one with Good Luck.  Maybe I explained not well in my previous answer.

Like
>
Lieve Weymeis
's comment
2019-01-14 15:06:58
2019-01-14 15:06:58
>
Lieve Weymeis
's comment

See, the point of Random Question comes when Exam starts. That’s why, I have added script JUST before that. So, when Exam has started, means Script got executed and is in memory of computer… and is working continuously every second. Let me repeat, I use this in my all exams where I, my self, always use random questions from Q pool. It is 100% logical.

Your suggestion of using the script on very short slide was also used by me in my earlier exams. But the practical problem is, sometimes, we delete many duplicate or meaningless slides(that gets generated by simulation). and we may forget that this short slide is having a very important script. and we may delete by-mistake. So I purposely added this Script to ‘Good Luck’ Slide. Because regardless of the subject of any Exam, I will always use Good luck Slide. and thereby it assured that script has come.

Otherwise, your point is also good.

Like
>
Chandresh Shah
's comment
2019-01-14 15:24:40
2019-01-14 15:24:40
>
Chandresh Shah
's comment

At least add a warning that the developer should never use an interactive object on that slide with the On Exit action!  I am very well aware of the necessity of having the timer started with the first question, which is not possible using an On Enter action if it is a random question. I have created a lot of timers for clients with Shared actions, but they required more functionality than what you explain in this tutorial. I needed to use scripts on each pool question as well.

What about that script: is it in the Captivate JS window? No problems with some characters in that case? Whenever using functions in JS I prefer to use an external file for that reason.

Like
2019-01-14 08:53:29
2019-01-14 08:53:29

Thanks for posting this workflow. It would be interesting to compare with my usual workflow without any JS, only with shared actions.   In most cases I need to do this with random slides generated from question pools. Did you try that?

 

Like
(1)
>
Lieve Weymeis
's comment
2019-01-14 14:12:48
2019-01-14 14:12:48
>
Lieve Weymeis
's comment

Yes. I always create my tests(quiz) with random Q. slides and use this for time-limit. Just to make it simple, I kept static questions in this uploaded Demo.

Like
Add your comment