How do I customize carry forward statements?

Ansh_ParAnsh_Par Community Member Qubie ✭

How do I customize carry forward statements?

Hello! I am trying to customize some carry forward statements. I have a constant sum question and I want to carry forward the top 5 statements by inputted numerical value from that into my next question. Does anyone know how to do this?

Tagged:

Best Answer

  • Ansh_ParAnsh_Par Qubie ✭
    edited September 2018 Accepted Answer

    Figured it out: Here is the syntax for anyone that needs it:

    Qualtrics.SurveyEngine.addOnPageSubmit(function(type) {
    var $jq = jQuery.noConflict();
    var answers = $jq('.Selection input').map(function(val) {
    return $(this).getValue();
    });
    var questions = $jq('.Selection label span').map(function(val) {
    return $(this).innerHTML;
    });
    zip = []
    for(var i = 0; i < answers.length; i++) {
    zip.push([parseInt(answers[i]), questions[i]]);
    }
    zip.sort(function(a, b) {
    return b[0] - a[0];
    });
    top_5 = zip.slice(0, 5).map(function(val) { return val[1]});
    console.log(top_5);

    Qualtrics.SurveyEngine.setEmbeddedData('top_5_questions', top_5);
    

    Just make sure you create a 'top_5_questions' variable in survey flow in order for this to work with embedded data.

Answers

  • RKTRKT Community Member Guru ✭✭

    @Ansh_Par ,
    carry forward statements cannot be customized

  • Ansh_ParAnsh_Par Community Member Qubie ✭

    @RKT If I have a list of 20 statements in a constant sum, is there no way then to have a follow-up question on only the top 5 of those from the values that the user inputs?

  • TomGTomG Raleigh, NCCommunity Member, Product Ideas Wizard ✭✭✭✭✭

    @Ansh_Par,

    With carryover the closest you an get is to carryover all the statements greater than some fixed number.

    To carryover the top 5, you'll need a process (web service or JavaScript) to rank the statements and set embedded data flags for the top 5. Then use those flags in display logic for each statement in the follow-up question.

  • Ansh_ParAnsh_Par Community Member Qubie ✭

    @TomG Thank you! I am not super familiar with JavaScript and how to set embedded data flags. Could you potentially give me an example of what that would like like. Here is a simplified version of the question set I am working with:

  • christopeterchristopeter BangaloreCommunity Member Guru ✭✭

    Make two arrays one with labels and one with codes for each option. Run a loop and store first 5 maximum values and there labels in embedded data. Than use these 5 in next question.

  • Ansh_ParAnsh_Par Community Member Qubie ✭

    I am struggling a little with what syntax I would use to do this (have not used JavaScript before). How would I refer to the individual entries and then how do you store something in embedded data?

  • TomGTomG Raleigh, NCCommunity Member, Product Ideas Wizard ✭✭✭✭✭

    @Ansh_Par - I sent you a private message.

  • christopeterchristopeter BangaloreCommunity Member Guru ✭✭

    @tomg

    Can you paste syntax here I have similar requirement.

  • christopeterchristopeter BangaloreCommunity Member Guru ✭✭

    Sorry @Tomg

    I saw your message and can't pay for this Java script code.

    Anyone who can help in free.

  • TomGTomG Raleigh, NCCommunity Member, Product Ideas Wizard ✭✭✭✭✭

    @christxy - Why do you expect programmers that have skills and knowledge you don't possess to work for free? Do you expect your Docter, Lawyer, Accountant, Car Mechanic, Plumber, Electrician, Hair Stylist, etc. to work for free too?

Sign In to Comment