Alternate slides with JavaScript (or advanced Actions)?

I was wondering if someone out there with the knowledge of JavaScript could help me a little...

A colleague came to me with a question about randomization of the slides. We work in Captivate 5.5. The slides are all part of a quiz (but aren't question slides). They have a click box. The idea is that if the user clicks on the box (or off the beaten track), it shows a good (or bad) legend and then jumps to a random slide (new). If the user manages at the end of the slide without selecting anything, their time is running out and they get fried to a random slide and it is regarded as an incorrect answer. The user should see all of the slides in random order, with no recurrence.

I created a tip Action, integrating the widget of random number, and it works. My problem is that the project has 50 blades, and I'm not sure it is very feasible with advanced Actions. As it is, my test with 3 random slides is an action with 4 conditional statements, so I'm not really looking to create one for 50 slides. (I don't know even if Captivate would be able to handle this).

Is there a way (judging) to achieve with JavaScript instead? My vague idea based on my very limited knowledge of programming is:

  1. on enter first Captivate slide, create the array of random slides - 1 slide numbers (because cpCmndGotoSlide index starts at 0)
    so if I had a project where I wanted to shoot random slides 3-8, the would be [2, 3, 4, 5, 6, 7]
  2. Shuffle/random table
  3. set up a variable called slideviews = 0 to keep track of how many slides have been seen (and so which item in the table to move to the next randomly)
  4. Create a function that I'm going to run when I want to access a random slide (whether at the end of a slide or in the success or failure of a click on a square)
    something like... If slideviews < array.length, cpCmndGotoSlide = array [slideviews]; slideviews ++; Another thing, cpCmndGotoSlide is 8 (jump at the end of the slides)

Of course, this lack of things (like the proper syntax and things needed to communicate with captivate)... but is sound logic? Is there a better way to do it?

Come to think of it, the table and the slideviews variable should be saved if we wanted it works with bookmarking... I think that this project will be SCORM 1.2 LMS System.

It would be nice to have a variable user I can access within the Captivate project and I can put in a legend to show the script #. Something like scenario = slideviews (I know that's not the syntax, reading series of JavaScript of Jim Leichliter on CaptivateDev.com, but that's the basic idea.)

Anyway, pointers would be very useful! Thank you.

Edit: I played a little bit; for randomization, I found a code online, and then I wrote something that automatically creates a table and a function for the jump to a slide randomly. Here's what I have so far (not tested in Captivate yet):

var objCP = document.Captivate;

var randomNumbers = []; 

 // The following creates the values for the array: 3 to 52.
 // I want to randomize slides 4-53, using cpCmndGotoSlide (index starting at 0) to jump to them

for(i=3; i<53; i++) {
                    randomNumbers[i-3] = i;
}

var n = randomNumbers.length;
  var tempArr = [];
  for (i = 0; i < n-1; i++ ) {
    // The following line removes one random element from arr
    // and pushes it onto tempArr
    tempArr.push(randomNumbers.splice(Math.floor(Math.random()*randomNumbers.length),1)[0]);
  }
  // Push the remaining item onto tempArr
  tempArr.push(randomNumbers[0]);
  randomNumbers=tempArr;

var slideViews = 0;

var randomSlide = function() {
if (slideViews < 50) {
                    objCP.cpEISetValue("cpCmndGotoSlide", randomNumbers[slideViews]);
                    slideViews++;
                    objCP.cpEISetValue("scenarioNumber", slideViews);
          }
          //after all the slides have been seen, jump to the final results slide
          else {
                    objCP.cpEISetValue("cpCmndGotoSlide", 53);
          }
};

I doubt it will work off the bat, but maybe this is a beginning?

I managed to get things working, so I thought I'd post my (probably a little unwieldy and inefficient) code in case people come across this thread and want a starting point:

var objCP = document. Captivate;
var randomNumbers = [];
var slideViews = 0;
CVS var = 0;

shuffle var = {function (array)}
var m = array.length, t, j;
so that {(m)
j = Math.floor (Math.random () * m-);
t = array [m];
table [m] = array [j];


table [j] = t;
}
};

var jumpSlide = function() {}
If (slideViews < randomNumbers.length) {}
objCP.cpEISetValue ('cpCmndGotoSlide', randomNumbers [slideViews]-1);
slideViews ++;
objCP.cpEISetValue ('scenarioNumber', slideViews);
}
else {}
objCP.cpEISetValue ('cpCmndGotoSlide', 52);
}
};

var randomSlide = function() {}
If (g_objAPI.LMSGetValue ('cmi.comments') = ") {}
for (i = 3; i < 53; i ++) {}
randomNumbers [i-3] = i;
}
Shuffle (randomNumbers);
g_objAPI.LMSSetValue ('cmi.comments', randomNumbers);
resume ++;
jumpSlide();
}
ElseIf (resume = 0) {}
randomNumbers = g_objAPI.LMSGetValue('cmi.comments').split(',');
slideViews = objCP.cpEIGetValue ('scenarioNumber');
resume ++;
jumpSlide();
}
else {}
jumpSlide();
}
};

The random slide order is stored in cmi.comments, and the position in the sequence is stored in a Captivate variable called scenarioNumber. I could have stored the two variables of Captivate in cmi.suspend_data, but in the end, I liked being able to see the numbers when considering the SCORM data. To work around problems with initialization, I made the creation/restoration of the part of random numbers of the function which climbs to a slide randomly, so nothing is actually executed when entering the first slide.

Tags: Adobe Captivate

Similar Questions

  • JavaScript and advanced Actions

    I try to do the following in Captivate 6.0:

    1. Display an animated gif of the dice on a slide in Captivate [work]
    2. When you click on:
      1. Generate a number 1-6 as a result of "the launch" and assign it to a variable [of work]
      2. Show / hide items on the page so that the user can see the result of their deployment and a next button so they can continue to [does not]

    I tried to reach the Show / Hide by:

    • Jump to the current slide, using JavaScript and
    • Advanced action on enter to the slide, which checks if the value of the dice has been set and then show / hide objects as you wish.

    Unfortunately, it seems that when I jump to the same slide using JavaScript, enter it event is not called. If I click back, and then forward on the playback bar, I see the desired result.

    I have included the JavaScript and the tip Action (fixed on enter to the slide) below.

    Is there a way to:

    1. Update the JavaScript so that when I jump to the current slide, enter to be executed? OR
    2. Call my action advanced directly from JavaScript? OR
    3. Get the desired result in a different way... I'm not particularly fussed I used JavaScript or advanced Actions to achieve this!

    Here are the details:

    Variable (set through project-> Variables...)


    Dice_Value = - 1

    Fast action (in between)

    If Dice_Value is greater than or equal to 1

    Hide Dice_Animation

    Hide Dice_Click_Box

    See the Dice_Value_Text

    See the Dice_Next

    See the Dice_Next_Caption

    On the other

    See the Dice_Animation
    See the Dice_Click_Box
    Hide Dice_Value_Text
    Hide Dice_Next
    Hide Dice_Next_Caption

    JavaScript (called when the user clicks on the animation of dice)

    function rollTheDice() {}

    cpObj = document var. Captivate;
    var diceValue = 1;
    currentTime var = cpObj.cpEIGetValue ('cpInfoCurrentTime');
    var lastDigit = parseInt (currentTime.charAt (7));
    {Switch (lastDigit)}

    case 7:

    diceValue = 1;
    break;

    case 8:

    diceValue = 2;
    break;

    case 9:

    diceValue = 4;
    break;

    case 0:

    diceValue = 5;
    break;

    by default:

    diceValue = lastDigit;
    break;

    }
    cpObj.cpEISetValue ('m_VarHandle.Dice_Value', diceValue);
    cpObj.cpEISetValue ('cpCmndGotoSlide', cpObj.cpEIGetValue ('rdinfoCurrentSlide'));
    cpObj.cpEISetValue('rdcmndResume',1);

    }

    rollTheDice();

    If you return to the first image of a slide, the action that is triggered by the event progress on enter is not executed. I'm an advanced user action, Javascript is still just a mystery to me. If I want to enter action to repeat itself, I will return to the slide before the slide that contains a conditional action (slide has already been visited, so setting a variable and checking that one) get immediately to the next slide. This way subsequently enter event repeats. Haven't checked it yet, but maybe browse the framework before the first frame of the current slide will be work as well (micro-navigation), something I have to try it because maybe you need to get a couple of frames further back.

    Lilybiri

  • JavaScript or advanced action help to increment the variable names

    I hope someone with Javascript skill can help me here. And it could also be possible with tip action, but I can't do it.

    I have a 'NombrAl' variable that chooses to enter 1 to 128 on blade.

    I have a series of variables - "but_word_1", "but_word_2" "but_word_3" etc all the way to "but_word_128".  They have text string values.

    I have another variable "spoken_word.

    By clicking on a button, I would like to that Javascript to define "spoken_word' with 'but_word_' + 'NombrAl '.

    e.g. If NombrAl then is 5 - window.cpAPIInterface. setVariableValue ('spoken_word', but_word_5);

    Thank you.

    Try this:

    window.cpAPIInterface.setVariableValue ("spoken_word", window.cpAPIInterface.getVariableValue ("but_word_" + NombrAl));

  • Any idea what's going on with the Panel advanced actions? See img below

    Whenever I try to add a variable action of my script, when I save all the areas where the variable is meant to be end up like that and I have no idea why. It does this with standard actions too.

    advanced actions variables.png

    You are on the first version of 9. This bug has been fixed very quickly (in September or October, 2015). Please install the update of 9.0.1.320 has published a few months ago, which includes the patch as well. It happened to the upgrade of the conditional actions: some have been converted to shared actions.

    Why do you use a conditional action instead of a standard action in this case? Or you have several decisions?

    Be careful with the names: you cannot use the same name twice, not even totally different things. Maybe it wasn't a typo, but I see "opcion22" for a "option 22' for an object with the States and action. It is best to keep to a naming convention for not having problems.

  • Hide various objects on different slides with the same tip Action

    I'm quite new to Captivate and because of that I'm fighting for the search feature, I need. I have a project of say 40 slides. On each slide, I have a button field on the left side guide and when clicked I have a window scroll from left to right, in the main frame of the window.

    Also on each slide is an object that displays specific information (usually in the form of text) with the previous buttons and following attached to it (its actually just a PNG image with the buttons "Previous" and "Next" with click boxes on them).

    The problem I have is when I click on the field guide that I want to hide this information object. I can easily do this in a tip for 1 slide action but when I want to the same tip action allows to always hide the information object of the current slide that I meet problems. If I was able to name objects of the same name is not a problem.

    The only "fast" solution I have is that each object information on each slide set to hide when I open the guide and then visible when I close the guide.

    Is their a better solution or does this supposed same matter?

    Thanks in advance

    Why you not time the objects for the rest of the project, always on top? In this case, you will have an ID (I recommend you even a group). BUT: This means that you cannot use boxes to click but must spend much more flexible form buttons.

    Why I like the shape buttons - Captivate 6! -Captivate Blog

    Apparently you are not familiar with the shared actions nor.

  • Audio management with animation and advanced actions

    Hello everyone,

    I actually try to use Captivate in order to show that a screen with several animations appear one by one with the following procedure:

    http://blogs.Adobe.com/Captivate/2011/05/adding-multiple-click-based-animations-on-a-scree n-with-adobe-captivate - 5.html

    But, I have a voice audio associated with the slide itself, and files audio link to each imported animation.

    I would like to cut the 'master' sound to listen to only a particular sound.

    You have an idea on how to do something like that?

    Thank you very much

    Best regards

    F.Bo

    Hello

    You cannot achieve this with the audio of the slide, but if you attach the audio to an 'invisible' object (perhaps a rectangle with fill transparent and no respect), you can control the audio using actions advanced to show/hide this object. This is how I realized several effects in my last blog. If I want to control audio that I will never insert as slide audio.

    Playtime with audio and widgets

    Thus, the workflow would be to hide animation with its seal and show the invisible object, which now plays the previous slide audio. When the user clicks to see an animation, attach an action to this box click (or button) that hides the invisible object and shows the animation.

    Lilybiri

  • slide/advanced action does not

    Hello

    I am currently using Captivate 6 and I setup a project that has a timer on the question slide 1st and then I implemented a tip action so when then the timer stops it will jump to the slide results otherwise it will continue on the project.
    Here is my Advanced action.

    Untitled.jpg

    The timer variable is v_time that I installed on time and created in the variables.

    I put each slide (excluding the first slide of the question and the results slide) with the topic fast action on the entrance and exit of the slide.

    It's used to work when I tested published in the web browser. I have a copy of one I published in January that works but now for some reason it does not work.

    I think there is a problem with the action of jumping to drag, but I'm not 100% sure.

    I tried to recreate a new project with the same tip action, but it still doesn't work.

    I'm stuck and feel I'm wasting my time. I spent 3 days on this and I'm ripping my hair out.

    Help, please!

    Thanks in advance

    Kim

    Kim, what event you attach the advanced action? If you use the 'old' included with CP clock widget (exist also in previous versions), it has no events, will only change the value of the variable associated user. You have action by another event like a drag event (enter, leaving). You have only a message pops up when the time has elapsed, does not prevent the user to answer the question.

    Second question: what version are you using? Associate you the variable v_time in the properties of the Widget? Did you type the exact "v_time" name, because there is a problem with the timer in 6.0.1 widget, which prevents the seizure of some characters. Maybe it's the issue that you are facing now. You must be sure that the correct name is linked and that the variable exists. Lastly but not least, the values of the variable associated with 6 are now 'true' and 'false', not 0 or 1. I just checked the workflow in this way with the widget timer with 6.0 (have another newer version on 6.1):

    • created a user Vtime variable (because these characters are accepted in the properties of the Widget, no respect underscores and capital V)
    • put the clock on the first question slide widget, timed for the rest of the project, countdown with message and associated Vtime
    • created an advanced action conditional like yours, but with true as a literal value; This action will be triggered by each event on enter for all the slides in question except first

    "For the rest of the project" is the timer? Last tip: never use submit all the with the clock widget, because this feature parce que cette fonctionnalite desactivera will disable jump auto everything.

    Lilybiri

  • Hide advanced action does not work after that triggered the effect

    I have a pretty simple step action that does the following:

    Hide banner

    Apply motion effect to 3 SmartShape from right to left

    Cache: SmartShape3


    SmartShape 3 is essentially half a rectangle rounded, which acts as a banner with text. At the beginning of the slide, it is hidden and sitting almost out of the scene. When you click a button, it does the following:

    See the banner

    Show: SmartShape3

    Applies the effect of movement from left to right to SmartShape

    This gives the illusion that it slides in from the left. The reason why I had it sat a little on the scene at the beginning, is that the effect is slow, so this makes it speed up as it has less distance to travel.

    The idea is the action above in blue is triggered and the banner slide from the left on the stage. Another button is pressed and the Red action is triggered sliding off the stage. But once the motion effect has been run, it does not seem to hide, leave the end of the rounded rectangle visible on the stage.

    I tried to adjust the break lines in the buttons that trigger these actions further pushing them to the bottom of the timeline, but it has no effect. I actually expected to start the path and then hide the shape so fast, that you wouldn't see in fact a large part of the effect as when stocks advanced spear they are super fast.

    Am I missing something or is this just a limitation with effects using advanced Actions?

    You have a misunderstanding about the actions. All orders in a fast action are executed in sequence, but immediately. The effects also have a duration, you don't say how long you have applied.  Can you post a screenshot of the timeline? Have you checked the length of the path, is it enough? You do this using the same temporal effects. BTW, I often apply such an effect using micronavigation instead of applying it. In my last blog, you can see an example:

    More in a... hyperlink - drop-down Menu - Captivate blog

  • Bookmarking in LMS resets advanced actions

    Hello

    I designed a game quite complex in 8 Captivate with notation and emblem for a compulsory course of cyber security for my organization.  I just tested the feature bookmarking for my LMS course, and while the course resumes at the point where I left, I noticed that none of my triggered advanced actions and variables have been selected.  Is it possible to fix this?  Otherwise, it makes bookmarking effectively unusable.

    Thanks in advance.

    Dan

    It would work unless the user clears the shared objects.

    The shared object to repopulate the variables. Then in the slide "menu" run an advanced action to display trophies based on the values of the variables. If you click on the slide in the timeline, you'll see ' on the entry: "in the properties panel, select the drop-down list and choose Advanced action.

  • Show/Hide - advanced action buttons and images

    So, I thought I had a handle on usage shares advanced to show/hide, but apparently not.

    Here's the scenario:

    -Screen where the user must select one of the 6 options

    -When the user clicks on one of the 'boxes' of the option a check should appear and audio should play

    -All other "cases" should be disabled to avoid audio duplication

    Here's what I did to try to get this working:

    -' Boxes' are buttons, click on success:

    * Success box contains audio that plays (this works)

    Success of the button execute advanced action:

    > hide all other buttons on the slide (it does not)

    > display an image of a check mark in the "checkbox" which has been clicked (does not work)

    > go to the next slide (works, audio from the success box once completed)

    Thoughts? Help! Thanks in advance!

    Hello, unknown fan

    Overlay buttons will not work, so let this idea alone.

    I really want to finish this blog post on audio and widgets. Just an idea and will try to be at the time where I found the time to try something. Why don't you attach audio to an initially invisible object that you show with the same advanced action? This object can be a shape with no stroke and a fill alpha of 0% so that it is invisible to the user. You will have time before the sound can play completely before going to the next slide.

    Lilybiri

  • Object hidden in the project after Advanced action

    Scenario:

    I have a slide to preview Quiz set up that allows for the learner to choose to go back to some of the content to look again, or move forward for the quiz.  If they choose to return to the content, I won't have to retake the course (unless they want) so I created a form of "Take the Quiz" I use as button will bring back you to the quiz on any slide.  I placed on the first content slide and set it to display the rest of the way, but then made invisible to begin.

    What I've done so far:

    I have set up variables for each module and created a tip action that has defined the variable for each module to 1 it's over.  Each slide content performs an advanced action on enter to see if all module variables are set to 1.  If they are, the form of "Take the Quiz" appears.

    The problem:

    When the learner clicks to review the documents, the form of "Take the Quiz" don't appears on the initial slide, it was placed on, and not on any other blades.

    The only thing I can think of to get around this problem is to create a distinct "Take the Quiz" form for each slide and have action show them to all.  I would like to avoid that, as some of my courses have quite a few slides.

    Can someone suggest an another course of action for me?  I hope this is enough information, but if you need more, I will be happy to provide it.

    Thank you

    John

    When you set the point where the button shape "Rest of project", have you enabled the option "Always on top"?

  • Best approach advanced actions, mulitple selections of text on a slide with other information...

    Hello

    I have to do a slide that has multiple selections of text on a slide, but using advanced actions to change each Cap. text... for example...

    A cursor with the image for the user to click, when you click on a text caption appears, and in this caption text is a chip-shaped button that says 'Next' when that is clicked then another text Cap comes up with another button which also then said, then when that is clicked on and the cap of the final text is reached says the button then close. User can click on that and returns to the slide of the same hand.

    Was then I intended to do this was advanced use actions is the right approach? (or shared)...

    In addition, if the fact this way, it will affect scorm...?

    Kind regards

    Sabine

    I don't see the connection between your question and SCORM? These buttons are rated?

    If they are a few buttons to display the new text, which is not a score for each button, I would not use that many 'Next' buttons but keep the same button and uses a counter. The content of the text caption could be a variable for which you are editing content after each click. Counter should be used to check if the close button must appear and the next button hidden. This article is such an approach to click for images: Blog after Posterous? - ClickClick - Captivate blog

    And like to have a variable instead of static text, for which you can change the value: 'Beat the system' - save time by creating advanced Actions (Captivate) - Captivate blog

    No response yet on shared or advanced actions, it depends on which version you use, answers on the score and more questions.

  • JavaScript advanced action

    I created a tip action that I called "showMe".

    Then, I tried to trigger JavaScript. I tried

    cp.runJavascript ("showMe");

    cp.runJavascript (showMe);

    and

    cp.runJavascript (cp.model.data.showMe.oca); (I guess).

    but they give just JavaScript errors.

    How to call and advanced action Cp 9 using JavaScript?

    The cp.runJavascript needs another "_self" argument, but it still does not work.

    The Advanced "showMe" action name exists in the IDE, not in the output of HTML5. The only thing that exists in the code is all JavaScript or cpCommands that make up the tip action, that is to say:

    CP. Show ("Something");

    cp.runJavascript ("someFunction () ', '_self'")

    cp.jumpToNextSlide)

    You are on the right track by using the "oca", but does not have the implementation. You have to find the item that has the specific property "oca".

    cp.runJavascript (cp.model.data.slideID.elementID.oca, "_self");

    If you have a button called 'cc_btn' which is configured to display the rest of the project, it would be:

    cp.runJavascript (cp.model.data.cc_btn.oca, "_self");

    It all depends on what is triggering the fast action. You will first need to obtain the id of the slide, once you have that you can browse the 'if' to get the item and property ownership "oca".

  • Audio tour on first visit to several slides except for the first of the slides advanced action does not

    I have 3 different slides in a project who have advanced actions to stream audio on first visit only. When I saw the project, the tip action works only once. Who ever these 3 slides I play first audio aura on the first visit, but the other 2 do not play audio at all. Is it possible that they do not interfere with each other?

    A tip action that I use is less and the others are the same but with different audio files

    Audio on First Slide only Advanced Action.png

    You need a variable to different entry for each slide.

    v_entry1, v_entry2 and so on.

  • JavaScript for loop to execute Advanced Actions - execute Javascript does not?

    I use a loop to check the value of a Cookie.  When I add this using Execute Javascript it works fine but I want to run with certain other actions, if I want to use Of execute advanced Actions. When I add this coded to an action to run Javascript in the breast to perform advanced Actions code disappeared if I open the Script window again once.  I try to remove the code for loop in bold below and then the remaining code remains.  So I think that the problem must be with the loop for, but I don't see anything wrong with this code and I have, as I said that this code works fine if I use Javascript to run on its own. I've attached a video clip below to show what I mean.

    var task1_value = readCookie ("task1");

    function readCookie (name) {}

    var nameEQ = name + '=';

    var CA = document.cookie.split(';');

    for (var i = 0; i < ca.length; i ++) {}

    var c = ca [i];

    even if (c.charAt (0) ==' ') c = c.substring(1,c.length);

    If (c.indexOf (nameEQ) == 0) return c.substring (nameEQ.length, c.length);

    }

    Returns a null value.

    }

    I found that window JavaScript of CP does not like loops.

    Your best bet is to put the function in an external JS file from the top of the page. I always run scripts in an external file. Really helps debug that you do not have to republish Captivate. Just change your code and refresh the browser. If you use external file you can store all your functions there.

    I would also look into using the local storage instead of cookies. Very easy to implement and you can store a ton of information.

    Local storage - dive into HTML5

Maybe you are looking for

  • Notes app has disappeared

    My Notes disappeared on 6 s iPhone app, I can access it by hitting swipe left (appears under Siri Suggestions). How can I restore to its original position?

  • Cannot install virtual surround on my Satellite A100 - 498 (PSAA9E)

    I installed all of the latest Windows Vista Toshiba drivers, including the audio driver (realtek), but I can not install the Toshiba Virtual Sound... I just got this message: "TOSHIBA Virtual Sound does not support your computer", during the installa

  • Satellite A300 PSAG8E - unable to connect to the internet

    Hello. I have Toshiba Satellite A300 PSAG8E (product for Tuerkiye) laptop.My vista ultimate operating system.I can't connect to the internet. I have the new format recently.What should I?

  • Behind closed doors when the fan comes on (HP Pavilion G6)

    I have just bought a HP Pavilion G6 2295sa yesterday and spent the day installing my usual software on it (Office, Visual Studio, etc.). Tonight the fan started to come strong enough (his rattling not or anything like that, just go fast I think). The

  • WMC won't play movies/videos in a desktop session remotely

    I just got my connection Remote Desktop works between my server Media Manager (Windows 7 Ultimate 64 - bit w/Media Center) and my laptop (Windows 8 Pro 64 - bit w/Media Center).  I can remote desktop on the server and the files and applications, of c