Solved

Limiting checkboxes in a quiz

Hi there -

I am attempting to follow the steps outlined in the blog post to limit the number of selections that can be done by a learner.

$(‘input’).click(check_and_limit);

function check_and_limit() {

if ($(‘input:checked’).length == 3) {

$(‘input:not(:checked)’).attr(‘disabled’, true)

} else {

$(‘input’).attr(‘disabled’, false)

}

}

I continually get the error below.

I attempted using other lines of code to double check that it isn't me, but i get the same error message.

I am using IE11 due to our dependency on the Harman Flash Plugin for continued support until all of our learning products are transitioned.

Solution

I've attached an example.

You will need to download the attached zip, then remove the .zip extension. The file is a PKG file but interestingly our forum doesn't support that format (we'll have to fix that!).

The example can be imported and will work in Desktop or Online. For Lectora Online you have to update the JavaScript action named OnShowRunJS there are comments as to what to update.

The example shows how to set "known" names for objects and then use the Lectora Object API to do things like disable / enable buttons and to show or hide text blocks.

You will also see that triv$ is used, if you have a current version of desktop or if you use online then that is how you can access the built in jQuery object.

Additionally you will see the use of getDisplayWindow() and getDisplayDocument() which are necessary to support our seamless play publish option.

Hope this helps show some possibilities with scripting in Lectora.

Discussion (5)

Thanks @chris_willis for the rapid response; however, I am looking to put checks/balances in place so that we are truly testing the learner fairly. For example, if I were to ask the following question with multiple responses....

What colour are the leaves in the tree? Select 3.

a) Red

b) Green

c) Yellow

d) Purple

And then have JQuery do the following for me...

1. Not allow the user to click a 4th option if they've already selected 3, and display a message saying they've already selected 3 if they go for a 4th option.

2. Keep the SUBMIT button disabled until they've selected 3 options.

Hi, @andrew-robertson - You've stumbled on an article from our archives. Lectora has gotten a lot smarter since that was written!

If you use one of the standard question types available in Lectora you can double click the ? icon in the Explorer, and set attempts like this:

I've attached an example.

You will need to download the attached zip, then remove the .zip extension. The file is a PKG file but interestingly our forum doesn't support that format (we'll have to fix that!).

The example can be imported and will work in Desktop or Online. For Lectora Online you have to update the JavaScript action named OnShowRunJS there are comments as to what to update.

The example shows how to set "known" names for objects and then use the Lectora Object API to do things like disable / enable buttons and to show or hide text blocks.

You will also see that triv$ is used, if you have a current version of desktop or if you use online then that is how you can access the built in jQuery object.

Additionally you will see the use of getDisplayWindow() and getDisplayDocument() which are necessary to support our seamless play publish option.

Hope this helps show some possibilities with scripting in Lectora.

@wheels & @chris_willis - you two are amazing. Appreciate the support. If could buy you a coffee (or beer), I would. Cheers and enjoy the impending weekend.

@andrew-robertson - Lectora users like you help us better understand how to make Lectora the most powerful and versatile eLearning authoring tool available!

That (and the aforementioned coffee) is what gets me up in the morning. As for the weekend ...

Cheers! :D