HOME ➔ SUPPORT ➔ Community ➔ General CourseLab issues ... random question test
random question test
  View type:
Is it possible to make a test with 25 question randomly taken from base of 100 question?
Just not sure which version you are using, i do not know 2.4 but in 2.7 no need for coding :)

1) Just insert "Test" from the "Object Library"

2) Double click the Test object (the one with a question mark in the middle)

3)In the "Questions" tab Input the 100 questions ofcourse with identifying the correct answer

4) In the "Questions" tab, just below, there is an option for select questions randomly. Check the box.

5) Then, type the number of questions you want to appear randomly. Like for this situation, 25

6) Click apply and OK [:p]. Clicking OK only has just the same effect. It's just that I am this to make sure girl ^^,

Hope this helps you. :)
This may be a useful workaround:

One solution is to add the following code to an assessment button on an assessment introduction
screen as a On Click event, Javascript:

var qb = new Array(4)
var randNum = Math.floor(Math.random() * 4)
switch (randNum)
case 0:
qb[0] = OpenSlideById ("SLIDE_45")//slide that has first question bank of 25 question on separate frames
case 1:
qb[1] = OpenSlideById ("SLIDE_50")slide that has second question bank of 25 question on separate frames
qb[2] = OpenSlideById ("SLIDE_52")slide that has third question bank of 25 question on separate frames
qb[3] = OpenSlideById ("SLIDE_54")slide that has third question bank of 25 question on separate frames
The above code will randomly pick one of the 4 slides (each with 25 questions - each question
has a score of 4 (x25 = 100 max score).

Now create 4 (or whatever number you need) slides with 25 questions per
frame. Each of this slides is thus a question bank (assessment / test). Do not use the Test
resource, use individual questions on each frame.

Next, instead of default nav between slides and frames, just add an "On Question Answered" event
to go to next frame, for example:

GOTO(Frame='FRAME_48',Option='Next Frame')

The Last frame in each (of the 4 in this example) slide needs, however, to go to the Assessment
Score page, for example:

GOTO(Frame='FRAME_58',Option='Specified Frame')

Now,for the Score Screen, which has 2 frames (one has score that's passed and the other that
has failed). Make sure that the nav between this frame is set to "wait for action".
The passing score frame has just the CourseLabs default Current Results object, whereas the failing score
frame has this Current Results object and directions to retake course or exit. In this example,
the passing score frame auto moves to a declarion or cert screen following short delay.

For the score screen above, put the following On Afer Display action anywhere on both of the frames:

IF SCORE(Objective='total', Source='', Condition='<',Score='80')//we have set the pass rate as 80%
GOTO(Frame='Frame_60,Option='Specified Frame')//Goes to a declartion or Cert screen
GOTO(Frame='Frame_43,Option='Specified Frame')//where you want learner to go to if fail test,
in this case, the Opening course screen.

Dont forget to set the total objective max score to 100 in the course Runtime settings and to add score of 4 to each of the questions, with "total" objective, on each frame.

Thats it!
OK, this was a bit tricky to figure out, but I did get this to work.

On the first slide I add the following JavaScript to the slide itself (on the afterdisplay):

function sortNumeric(a,b){return a-b};

function pickUniqueArray(numPick,pool){
var size = pool.length;
var unique = new Array(numPick);
var choose, temp;
for(var i = 0; i < unique.length; i++){
choose = Math.floor(Math.random() * size);
unique[i] = pool[choose];
var k=i+1;
g_arVars["Question"+k] = "SLIDE_"+unique[i];
temp = pool[choose];
pool[choose] = pool[size];
pool[size] = temp;
return unique.sort(sortNumeric);

I got this from kansel at http://www.codingforums.com/archive/index.php/t-4614.html

I of course tweaked the code a bit for my purposes. the last line that has the pickUniqueArray will have the numbers from the Identifier of the each slide.

I of course have to create a variable on the same slide for each question that I have on there.

I then create a "Question List" slide that has buttons on it. Under the action of the button that has the name of "Question 1" I put the following JavaScript:

var question = g_arVars["Question1"]

This code was put together with the help of barend who helped me with the g_arVars variable. I found the OpenSlideById from looking into some of the files suggested by barend as well.

This took a bit of tweaking, and sometimes I do things incorrectly, but luckily my students help me out to find my errors.

You have to go through and make a list of all of the Identifier numbers so that you can put them in the array in the JavaScript.

This might sound like gibberish, so if you need I can send you a file to see what I did.

Has anyone got this to work?

I have had a try with it, but got lost with the Question List part. Does anyone have any further info?

Thanks in advance.

ozrebel [:)]
OK, I kind of figured my explanation would be confusing. I have posted a file that I created with about 30 questions in it and the test only uses 25, but it randomly picks the questions each time you start the test. The zip file is at: http://moodle.oremjr.alpine.k12.ut.us/ic3/RandomQuestion.zip .

The web pages that I created from this file are at: http://moodle.oremjr.alpine.k12.ut.us . The first couple of pages are not created with CourseLab, but if you go into the Pre- or Post-Test or Trainings and click on "Word Processing Functions" under Level 1 that is what was created with the zip file above (this way you can see what my students see). I don't have all of the tests done, so if you get a blank page, just close it out (ALT+F4) and try another one. As of today I only have a few of the "Word Processing Functions" and "Communicating with Presentation Software" done. It takes awhile to create each question, so I haven't done it in awhile.

Nick, you may change the zip file in anyway that you want to create an example.
OK, so I had a question for people that are going to look at my file. I want to be able to add two things to it, but I can't wrap my brain around how to do it. Instead of the "Question List" that you will see, I want to create buttons for "Previous Question" and "Next Question." I want to keep the question list, just at the end. My second item that I want to add is to indicate if a student completed (possibly even marking if they got it right or not) the question on the question list (i.e. green checkmark if it is completed or done correctly, red X if it is not complete or done incorrectly). If someone can figure that out and help me out, I would LOVE any help that I can get. If not, don't worry about it. Thanks!
For your first question, I don't have the time to try it myself but I would search the answer in:

- make a (global )array
var questions = new Array();
// Note: I don't know if you can do this in CL javascript action.

- make a counter
var questionCounter = 0;
// Note: I don't know if you can do this in CL javascript action.

- fill the array in your function pickUniqueArray
Instead of
g_arVars["Question"+k] = "SLIDE_"+unique[i];

Now you have an array with the hashed (is that the right word?) numbers.

- On a page are two buttons.
Javascript on button one:
Of course fist check questionCounter is >= 1

Similar script on the forward button.

Hope its helps, good luck. [:D]
The second one seems not too difficult ... if I understand you.
On the page with alle the question buttons, make a sign (or two) for every question, initially hidden.
Then on the page make actions such as
IF COMPLETION STATUS(Objective='Task2',Status='Complete')

You can even hide the button, so the question cannot be opened a second time and you won't see this alert.
If you do this, you just put the marker under the button; you won't have to hide it initially.

Nice work indeed. Glad Nick will put it on his site [:cool:]
So this is picking 10 items from the array list of xx items at random.
Send me a sample that's annotated so people can follow it and I'll stick it on the Friendsofcourselab site, or I should be able to make something up from this myself.
Nice work people :)
Hi, JI,

not in current version. Next version will have random question selection.
Message options
No additional options