anchored header to top of the screen with instructions and selection counter

Many of you may have had long list option questions also long statements making it difficult to show everything on a single screen, even if you try to break it into 2 or 3 columns

This solution allows the user to see the question instructions in a header that stays anchored at the top of the screen as the user scrolls down to see the other available statements

The selection number is also updated as you select or deselect the options, in this particular case when working with a multiple answer question type.

Again I’m using jQuery so don’t forget to add the library in your skin.

In the instruction tab, will include the instruction text and the selection counter as below:

Please select all that apply, but you must select at least 10 statements.
You have selected 0 statements

then we need some styling
So continue adding this, you can also define all these styles right in the Confirmit styles menu.


and finally the javascript, that has two parts, one is to make the header anchored at the top and the other one is for updating the selection counter as you select or deselect the answers.


Here’s a link to see everything together
http://jsfiddle.net/confirmitexpert/GBv58/embedded/result/

It works in all browsers, but the jsfiddle link above doesn’t work in IE, so please fell free to use Firefox, Chrome etc.

Give it a try and let me know what you think!

Twitter like countdown characters for open ends

Since in Confirmit there’s no option to limit the characters in a text area, here’s a simple script that will show a nice countdown, as you type, twitter like, and will also limit the number of characters to a max

Or course, you can set up a custom validation that will check for the open end length in confirmit validation tab, the advantage of this script is that is very visual, and the respondent doesn’t have to hit the next button and get an error message back.

First make sure you include the jQuery library in your skin header.

The script below works with one textarea per page, but it can be easily customized to work with more

In the open end instruction tab, place the following script:



To explain a bit what the script does, the limit here is set to 120 characters, and you can change that,

The span will be updated as you type, when the limit is reached, will truncate the text and re-set it back to the text area.

Also when it gets to the 0 remaining, I'm adding the "errorquestion" class to the countdown span, that's the default confirmit error CSS style class for the error messages, so the respondents will get one more hint to see when they have reached the limit

Happy coding everyone!

Confirmit dynamic questions with a twist

We know Confirmit has the option to trigger a second question (or more) based on a previous question answer, you may find this called dynamic questions.
You need to use a page object and add the questions inside then choose “triggers” on the ones you need to have them triggered.
You can define complex logic and all the other functionality such as text piping, question masking etc. can be controlled by the trigger function, so you can take advantage of all these.

That’s a pretty cool feature that allows you to chain some logic and have it working on the same page.

The downside of this is that the positioning on the screen of the second question is not always easy.
Also the logic is only evaluated when the page is submitted (when the respondent clicks the Next button), and sometime is hard to follow when the logic is complex.

I will present a different alternative for the triggers (or dynamic questions):

The set up will be the same, 2 questions on the same page, the second will be triggered by answering an option from the first question. In this example I’m using 2 multiple questions.
The second question will show up right under the option that triggers it, so its answers will nicely align under it.

In the answer label we need to use for triggering the second question will insert an empty div tag with a class, let`s call it “willTrigger”, this will help us identify which one is the one we will need to check if is clicked (checked) or not.

In my example I have this answer label to trigger the second question

Product ingredients

Here`s the script that makes all this possible, again I`m using jQuery, so don`t forget to include a reference to jQuery library in your skin:

$(function(){
    //the fieldset_q8m below is the second question fieldset name, so if your question is q11 that will change to fieldset_q11
    var trigered = $('#fieldset_q8m').parents('.questionarea');
    trigered.addClass("hidden1").removeClass('questionarea').hide();
    //add an empty tdr/td
    $('.willTrigger').closest('tr').after('<tr><td colspan=2>');
    //and populate with the hidden div
    $('.willTrigger').parents('tr').next('tr').find('td').html(trigered);
    //test input change, will also hide the error message if the answer was de-selected
    $('.willTrigger').closest('tr').find('input').change(function(){
        $(this).is(':checked')?trigered.show():trigered.hide(), $('.error_msg').hide();
    });

    // here will bind a bit of logic checking if the second question was answered
    $('form').bind('submit', function(){
        if($('.willTrigger').closest('tr').find('input').prop('checked') && !trigered.find('input:checked').length>0){
            $('.error_msg').show();
            return false;
        }
        else {
            return true;
        }
    });
});

I also created a custom style in the confirmit css styles, named “hidden1”, I’m adding to the triggered question

.hidden1{
    margin-left:10px;
}

so that its answers will be nicely aligned under, creating the impression of being part of the first question answer, like an inline answer list

Will also create some logic to check if the second question is answered before the form is submitted, so will need to create an error message like

Please select at least one ingredient

and also define this in the confirmit style list

.error_msg{
    display:none;
}

or just add the “display:none” inline


The “errorquestion” class is the default error style already defined in confrmit

The erro message div add it in the first question “instruction” tab, the script can also be placed there.

Here’s a fiddle example to see how it works, click on the “Product ingredients” and try to click next without giving any other answers there, see how the script detects the missing answers and reacts.

http://jsfiddle.net/confirmitexpert/rvPCK/embedded/result/

Do you often use the Confirmit default capabilities, or like to create everything from scratch, and have it fully customized?

Let respondent change the questionnaire language on the fly

After I published the last post I was thinking if the language example I picked was relevant or not, in fact, there’s a simpler way for an user to change the current language, in real time, without so much complex code and option changes I described in the previous post.

Here’s an easier way to let the user change the language.

Everything happens in the theme (main theme)
There`s no need to change any of the options from the “survey Settings”, link security like “unencrypted QID” or allow changing the previous answers etc, this will work with the default settings.

First we need a button or similar element,

<div class="navigationarea">
<input class="navbutton confirmit-nav" onclick="changeLanguage()" alt="" value="Switch to ^CurrentLang()=='9'?'French':'English'^" size="20" type="button"/>
</div>

As you can notice, the onclick event calls this changeLanguage() function, and its content is below:

function changeLanguage(){
    var lang= "^CurrentLang()^";
    location.href="^GetRespondentUrl()^"+String.fromCharCode(38)+(lang=="9"?"l=12":"l=9");
}

So far so good, everything works, but still there’s this screen

You have already completed parts of the questionnaire.
Press OK to continue.

Every time you click the button you get this screen (with the default settings)

To make the process smoother we will detect that page, “Internal_Continue_survey_on_entry_text”, hide its content, (please make sure you use the same wrapper class for the div that surrounds your content if not please replace it with your own), and submit the form

$(function(){
   if( $("#Internal_Continue_survey_on_entry_text").length>0 ) {
       $(".wrapper").hide();
       document.ctlform.submit();
   }
});

So let’s add everything together, please place this let’s say at the end of your main theme, right after the navigation component. In the layout tab use the code editor, not the WYSIWYG.
Don’t forget to include the jQuery library in the external js
“External Javascript Url” like https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js

All added together below


<div class="navigationarea">
<input class="navbutton confirmit-nav" onclick="changeLanguage()" alt="" value="Switch to ^CurrentLang()=='9'?'French':'English'^" size="20" type="button"/>
</div>

Easy real-time survey interaction

Today’s subject is about a nice technique that allows you, I mean the respondent, to interact with almost anything from inside the survey in a very transparent way, whenever they want and are allowed, of course.

You may find this helpful if you do iPad/mobile surveys on-site as well.

This can go from changing the theme UI (don’t think about setting up any cookies though!), the language, till changing or going into a specific module then come back and complete the rest.

The example I picked is to let the respondent change the questionnaire language in real time (you need to have the language and the corresponding texts added already in Confirmit) and this can be extended to anything else you may think about.

The set up is easy, and as you can see in the image below we need some variables:

setup folder

“language” is the background “language”, and let’s say we’ve got English and French, precodes 9 and 12.
“l” we’re using to control the current language, this reflects in the language the questionnaire is displayed in.
the “set language” script has the following content:

if(! f('l').toBoolean()) f('l').set(f('language').get());

the “qleft” is an open end that stores the survey current question ID (is updated every time the page loads)
and below is the “scripts” node content, I’ve added it here to quickly see how “qleft” gets updated with the questionID, the function setQLeft being called from the theme

function setQLeft(){
  var currentForm=CurrentForm();
  
  if (currentForm!="lch") f('qleft').set(currentForm);
}

function langDisplay(){
  return f('l').get()=='9'?"French":"English";
}

Notice the test if currentForm!=”lch” so we don’t set it if this question, otherwise we end up in a loop

The langDisplay helps in the survey theme, returning the language string you want to switch into

next there’s a condition node set to false, meaning this will be never executed in the normal flow

“lch” is an info question type with the content as follows

wait...

The next script node is setting the new language, and then redirects them where they left

f('l').get()=='9'?f('l').set('12'):f('l').set('9');

Redirect(GetRespondentUrl()+"&__qid="+f('qleft').get(),true );

and lastly, the script to redirect back where they left

if ( f('q1').toBoolean() && f('qleft').toBoolean() ) {
  Redirect(  GetRespondentUrl() + "&__qid=" + f('qleft').get(), true);
}

Next step is to add and call some of these function from inside the theme since we need to make them visible and allow the respondents interact with them somehow.

main theme layout custom change language button

As you can notice -red square- setQLeft is called every time the page loads, and once it’s executed it writes the questionID (currentForm) so the last question id if there are multiple per page

the second – green square- is a javascript function that will change the location url and sends him to the specific questionid lch (language change)
Tips String.fromCharCode(38), I used this instead of simple adding the “&” character, Confirmit always replaces the “&” with “& amp;”

and third – blue square- a button that runs at on click the function above, and also notice its value is defined as a function call from langDisplay that returns the language you want to change into

^setQLeft()^


Last you need to make some changes in the Survey Settings tab
“General Options”
Uncheck “Disable unencrypted QID request parameter (recommended to prevent respondents from tampering with the survey urls to skip to specific questions)”
“Web Options”
Check “Allow respondents to change their original answers”

The reason I used the question id as the solution to jump between questions was because you can control exactly where and how.

I learned you can do something similar now using the blocks and calling them when you jump, but didn’t have the opportunity to test everything, maybe you guys are already using this approach?

Confirmit is wiping out the content from masked fields

Here’s something I want to share with you, just to make you aware of how confirmit works when using masking.
I had a open text list with four answers and had the the last element hidden using a code mask script, nset(3);
The forth field I was updating from a script I placed before the question,
f(‘q1’)[‘4’].set(‘test’);

The issue was when checking data, even if the script was running correctly, there was nothing in the last field even if at the time the question was displayed, the “test” was still there, but after submitting (clicking on the next button) the content was wiped out.

So the conclusion is if the elements are masked, their content will be wiped out after you advance to the next question.
As a solution I moved the script after the question, and everything worked well.

Tips to make your survey mobile ready

If you planned to also target the mobile users here are some great tips you may want to follow:

  • First it’s the survey length. Don’t plan for more than 10 questions, who will stay on mobile anyways?
  • Keep the question texts clear and short, no long answers and just a few options
  • Use only basic question types, single, multi, open ends.
  • When it comes to define a survey layout, remove all unnecessary css and javascript, don’t use fixed width and height, or make them 240 x 320. And also, don’t forget to add these two metatags
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, width=device-width">
    <meta name="apple-touch-fullscreen" content="YES"/>
    

Confirmit Flex – Question extension

I was checking the other day what’s new in Confirmit 16.

Going through the new available Flex extensions, one in particular caught my attention, it’s the “Questions extension”, and seems to have a lot of potential.

If it’s true you can use it to define new question types and make them available as new question types in the then that’s something I was begging for good years now…

Nicely done, and by the way, the name Flex is most of the time confused with the well known Adobe Flex and I had to always explain that there’s no connection between one and the other, even though, you may have a Flex Confirmit extension built in Flex(Adobe) 😉

Custom libraries of functions defined in Confirmit

I bet you have now lots of custom scripts, functions, validations etc. you may have stored in a survey, a survey template or a library (I can’t really see the reason for a “library” besides the different project type)

What worries me and maybe you is that everyone can alter them once they are dragged in a project, and not only…

The alternative is to create your own function libraries.

Here are some pros: You have control so nobody else can change their behavior, they are already loaded, so ready to use, no worries to include folders with libraries of functions in a project.
The usage is transparent for the user, just let them know the class and the available methods like custom.3Dgridvalidation()

I won’t focus now on explaining how to build one, Confirmit has a good documentation for this “Custom Code Library” you can get from their extranet site.