Questions, advanced scripting

Problem:
Dear support.
I’m new to AP and currently trying to move some of our learning material from Captivate to AP.
On one slide in Captivate we have 11 questions. In each of the questions the user has to enter a number and(!) choose one of two options. Only if the number and the selected option are correct, the question is correct. The whole slide is correct, if, e.g., 80% of alle questions are answered correctly.
What would be the best strategy to realize this in AP? Do you have a tutorial for advanced scripting of questions? Programming this question in JS would be an option for me.
Best wishes
Ludger

ActivePresenter version: 8.3

OS: Windows 10

Notes:

Hi Ludger,

Could you please share the output of your project created in Captivate so we can take a look at? Alternatively, you can send us a video when you work with the output. (You can send it to support@atomisystems.com).

Besides, please let us know if you just want to show the result to users only, or you want to receive the report data?

Regards,
Yen

Dear Yen,
unfortuneatly the project in Captivate does not work any more since the former developers heavily relied on (AS) plugins which are no longer supported.
My idea would be, that the user gets a visual feedback which of the 11 questions on the slide are answered wrong (marked red) and that they get an overall feedback for the whole slide. Each question consists of text input (number) and a select field (e.g., a symbol). Example: correct: 100 €, wrong: 99 €, 100 $).
Best wishes
Ludger

Dear Yen,
just to share some of my recent thoughts with you:
Would it be suitable to use an embedded web object (iframe) for programming the question(s) with HTML and JS? Can the slide communicate with the web object and vice versa (e.g., on submit event)? Can the web object access resources from the project (e.g., for using images)? What object in the slide could be used as “question” to track the overal results and execute the normal events (on correct etc.)?
Also handling the modes of the session (e.g., Review mode) must be taken into account.
Best wishes
Ludger

Hi Ludger,

Please check this sample project custom_question.approj (380 KB)
ActivePresenter doesn’t support select fields, so I use radio buttons.

You can see the script in On Click event of Submit button.
Please note that the script only shows feedback to the user, it’s not possible to change the report data except the total score (in case you use SCORM, xAPI or HTTP report).

Regards

Dear Toan,
thank you very much. The structure of the question is correct.
Setting a score for the “slide” would be critical to us. Would it be possible to use some kind of “hidden question” to set a score that contributes to overall success of the presentation?
Best wishes
Ludger

Hi Ledge,

If you need a custom total score, please see my answer in this thread:

If you need the “slide score”, you can use a hidden text entry object:

  1. Delete its correct, incorrect messages and actions
  2. Set it initial hidden so users don’t see it
  3. Set it score, correct value, max attempt…
  4. Call the following script when submitting the slide
if (slide_is_correct)
  prez.object('text entry name').value('text entry correct value').submit();
else
  prez.object('text entry name').value('an incorrect value').submit();

Regards

Dear Toan,
thank you very much. This seems to work fine. I’m confident that I can now realize the question.
Best wishes
Ludger

Dear support,
in the meantime I was able to realize the question with scripting. It will need some further fine tuning (review mode etc.) but in general it works. Thank you for that.
Now I have a slide with 11 questions, each of them consists of a combination of one drag&drop element with several fill in the blank elements. Actually the user has to fill in the gaps in mathematical formulas. Sample:
Question 1: [Drop text 1 here] Formula = [m] x [g]
Question 2: [Drop text 2 here] Formula = [q] / [t] = [m] x [g]
Each questions should be evaluated separatly once the user “submits the slide”. The slide is marked correct if all 11 questions are correct.
Do you have any suggestion how to realize this in AP?
Thanks in advance and best wishes
Ludger

… one further note: It would be great if we could at least define two options for the blanks, since [m] x [g] and [g] x [m] are correct. Is this possible in AP?

Hi Ludger,

You can use JavaScript to do that. It’s similar to the sample project above.
For example:

// To check if a drag-drop is correct:
// find the drop target in which a drag source is dropped
var dropTarget = prez.object('a drag source name').dropTarget;
var dropCorrect = false;
if (dropTarget && dropTarget.name() == 'correct drop target name')
  dropCorrect = true;

// To check if two blanks are correct
var blank1 = prez.object('blank 1 name').value();
var blank2 = prez.object('blank 2 name').value();
var blankCorrect = false;
if ((blank1 == 'm' && blank2 == 'g') || (blank1 == 'g' && blank2 == 'm'))
  blankCorrect = true;

// question correct
var questionCorrect = dropCorrect && blankCorrect;

Regards

Dear Toan,
thank you very much. Could you please provide me a hint how to identify if a d&d is incomplete? As far as I see the dropTarget is undefined in case the answer is wrong or incomplete.
Thank you.
Best wishes
Ludger

Hi Ludger,

If dropTarget property of a drag source is not evaluated to true (e.g. undefined, null), the drag source is not dropped into any drop target yet.

if (dragSource.dropTarget) {
  // drag source is dropped into a drop target
} else {
  // drag source is not dropped into any drop target
}

Regards

Dear Toan,
How would I check if one of the drop targets on the slide is “empty”? Would I need to iterate through all dragSources with dropTarget property and count?
Best wishes
Ludger

Hi Ludger,

You can use the following scripts to get a list of drag sources dropped into a drop target

var dragSources = dropTargetObject.dropHelper.droppedObjects(); // dragSources is an array
if (dragSources.length == 0) {
  // drop target is empty
}

Regards

Dear Toan,
thank you very much. This worked fine so far and I was able to complete the question. Now I need to do some further fine tuning (e.g. providing feedback via object states).
I found that when switching between slides the text input elements loose the user’s input while the d&d elements keep their positions. Is this something I could influence?
Also I wonder if my scripts could access the list of correct values for each element?
Best wishes
Ludger

Hi Ludger,

To keep the user input value, you need to submit the text input object (by using submit(); API or Submit action)

Unfortunately, there’s no function to get the list of correct values for each object. You need to define that list from the correct values you entered in the UI.

Regards

Dear Toan,
one more question:

Is it possible to use the slide’s onload event to define an focusout-event for all input fields in the slide?
I tried $(prez.slide.node).find(‘input’) to get a list of all input fields in the slide. This works but submit() does not work on the resulting objects. I’d asume that I need to receive the objects by using your API rather than by using Jquery. Do you provide any method for this?
Many thanks and best wishes
Ludger

Hi Ludger,

You need to get ActivePresenter text entry object to call its submit() function.
For example:

var textEntryObject = prez.object('text entry object name');
var textInputDom = $(textEntryObject.node).find('input')[0];
$(textInputDom).focusout(function() {
  textEntryObject.submit();
});

Regards

Dear Toan,
thank you for your quick reply, as always. Is there a way to retrieve AP objects without the name? I want to keep things as simple as possible.
Best wishes
Ludger