Copy link to clipboard
Copied
Hi
I am using CP 7.0.1.237.
We want to use Text Area widget for a custom quiz and verify an answer. While we figured out how to verify the existence of certain keywords, we are not able to figure out how to verify that the content should NOT contain certain keywords. For example, we want to ensure that the text entered in this widget should not contain "Transformation" and "Non-compliant".
Is this possible at all?
Thanks
Sreekanth
Sreekanth, it works perfectly. Created this conditional action with 4 decisions. I used the learning interaction Scrolling Text in CP8 (because now you can control the variable - which means I could have a Reset button):
First decision:
Second decision (third is similar to this one)
Fourth and last decision
I put the words in variables ( v_first ... v_fifth),, that is a reflex I have since I'm using shared actions that much. The associated variable for the TEB (which you can now reset to an empty va
...Copy link to clipboard
Copied
Hello Sreekanth,
You don't tell what has to happen, but I would just use the ELSE part of a conditional action, and put Continue in the THEN part. It is pretty easy if the condition is not containing 'word1' OR 'word2' with that logic. For a combination with AND I should need bit more time to figure something out if it is possible at all, am still bit sleepy (being not a morning type at all). It will need more decisions in that case. Otherwise you'll need JS. For that combi
Didn't try out the D&D question of yesterday, had to finish some accountancy (most hated task, always procastrinating).
Lieve
Copy link to clipboard
Copied
The main problem here is that although Captivate's Conditional Advanced Actions allow you to search for string values using the Contains operator, there is no Does Not Contain equivalent operator. So you can find words in a variable's string value, but you cannot find words that are missing from it. At least you can't do so via Advanced Actions.
As Lieve suggests, you might be wiser to pursue JavaScript for this one.
Copy link to clipboard
Copied
Thanks Rod. Don't have the JS skillset. So, I guess I have to drop the idea of using this type of question for now.
Sreekanth
Copy link to clipboard
Copied
Hi Lieve
We are basically validating the content in the widget and showing appropriate feedback. Since the user can enter anything in the widget, we are only tracking the keywords. To be precise, we are trying to create an AA like this, where the text entry should contain the words Organizational, Behavioral, and Managerial but not the words Transformation and Non-Compliance. If the entry contains any of the "illegal" words, then incorrect feedback caption should appear.
If
varTA (which is the variable assigned to the widget) contains Organizational AND
varTA contains Behavioral AND
varTA contains Managerial
varTA does not contain Transformation
varTA does not contain "non-compliance"
then
Show CorrectFeedback
Increment varScore by 1
else
Show IncorrectFeedback
However, I don't see "does not contain" option in AA dialog box. I am actually wondering if Adobe added "contains" why not "does not contain", unless I am missing something here.
Sreekanth
Copy link to clipboard
Copied
No, there is no negative equivalent. And on the whole, even for other operators, the negative ones not always work as expected. An combination like you explained is not possible. You probably did see my post about using the TextArea widget for this kind of questions.
JS will perhaps be the easiest way, but I'm not yet convinced it cannot be done with Advanced actions. Will tell you when I give up. My first idea is to use an extra tracking variable and split up the combined condition in 3 decisions.
Lieve
Copy link to clipboard
Copied
Sreekanth, it works perfectly. Created this conditional action with 4 decisions. I used the learning interaction Scrolling Text in CP8 (because now you can control the variable - which means I could have a Reset button):
First decision:
Second decision (third is similar to this one)
Fourth and last decision
I put the words in variables ( v_first ... v_fifth),, that is a reflex I have since I'm using shared actions that much. The associated variable for the TEB (which you can now reset to an empty var in CP8) is v_TextArea and the boolean that will decide if the positive feedback (StarOK) has to be shown is v_TA_OK. If you want to show a negative feedback, put that in the ELSE part of the last decision.
FYI: it took 15 minutes, including creating assets and variables and testing. Personally I would have needed more time to do it in JS, but that is just me.
Lieve
Copy link to clipboard
Copied
Maybe I'm not understanding something here, but how does this give us the ability to find when a string of text DOES NOT contain a given word?
I can see how this Conditional Action checks for values using Contain operator, but how does it deliver an equivalent to Does Not Contain?
(e.g verify a given paragraph DOES NOT CONTAIN the words 'Transformation' or 'Non-Compliance'.
Am I missing something?
Copy link to clipboard
Copied
I created it for the example of Sreekanth, and it works perfectly. Logic is
in the tracking boolean and the fact that CP always executes each decision,
in sequence. I am not a programmer, this does not replace the missing
operator, it is a workaround. Maybe wrong understanding again from my part.
Will leave explanation of JS to you and quit in that case.
Copy link to clipboard
Copied
As per my understanding, the key lies in the order of decision blocks.
First, actions for the words that should be in the widget, if all the three words exist, it will assign v_TA_OK with 1. Next, it moves to the next decision box. Here, it checks whether the "illegal word" exists. If it is, it will assign the v_TA_OK with 0. Same with 3rd one. In the fourth decision, if v_TA_OK is (still) 1, it shows the correct feedback, that is starOK.
Lieve, please correct me if I am wrong.
Sreekanth
Copy link to clipboard
Copied
Indeed. The final decision, that is always executed after the first three decisions, is the only one that will show/hide something on the slide. I kept it as simple as possible, for the moment no second attempt, only show Correct or Incorrect feedback. That final decision checks the Boolean variable v_TA_OK. That variable will only have the value 1 is all three first decisions result in Correct: the three first words have to be in the TextArea variable, and the 4/5th word cannot be in that variable. It seems certainly bit cumbersome for a skilled programmer, but as I'm a bit skilled in Advanced actions, it will be done by me quicker than with JS, where testing takes more time. But I totally agree that the JS-solution (hope Rod explains it) is much more polished, and my solution is just a workaround. Having tested it, it works as you want, Sreekanth.
Lieve
Copy link to clipboard
Copied
Here's what the solution might look like in JavaScript. This would be for SWF output and aimed at Cp 7. For Cp 8, this would still work for SWF output, but you'd probably want to take advantage of the new unified JS API that gets and sets Cp variables for both SWF and HTML5 output. You can read more about that here: Common JS interface
//Get the text area value from Captivate (SWF output Only)
var cpTextAreaValue = document.Captivate.cpEIGetValue('m_VarHandle.v_TextArea);
//convert the value to lower case to properly compare
cpTextAreaValue = cpTextAreaValue.toLowerCase();
//Check if text area value contains the words "transformation" or "non-compliant"
if(cpTextAreaValue.indexof('organizational') > -1 && cpTextAreaValue.indexof('behavioral ') > -1 && cpTextAreaValue.indexof('managerial') > -1 && cpTextAreaValue.indexof('transformation') < 0 && cpTextAreaValue.indexof('non-compliant') < 0){
//the text area has the correct answer so increment varScore
//get the current score from Captivate
var score = document.Captivate.cpEIGetValue('m_VarHandle.varScore');
//increment score by 1
score++;
//set score in Captivate
document.Captivate.cpEISetValue('m_VarHandle.varScore', score);
} else {
//the text area does not have the correct answer so show message to user inside of Captivate
document.Captivate.cpEISetValue('m_VarHandle.v_message', 'Answer is not correct');
}
This JS has not been tested. Note that the "does not contain" operator is done using the "indexof" operator in JS.
Jim Leichliter
Copy link to clipboard
Copied
Thanks, Jim! Now there is a solution to anyone's taste
Lieve
Copy link to clipboard
Copied
Thanks Jim. I will check this out tomorrow.
Sreekanth