• Resolved allansjackson

    (@allansjackson)


    Hi There
    I want to set up a form where users can answer multiple choice questions and be shown different responses based on their scores. I have figured out how to add fields and calculate the score but I don’t know how to make the calculated field display a text string based on that score, say Fail or Pass.

    Do I create a field for each option and somehow hide them until a score has been calculated?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @allansjackson

    The process is very simple. You only should to include an IF operation as part of the equation.

    I’ll try to describe the process with a hypothetical example:

    Assuming you have five radio buttons fields: fieldname1, fieldname2, fieldname3, fieldname4, and fieldname5

    Each of them with two choices: Yes and No, whose values are: 1 and 0 respectively.

    And you want calculate the average of user’s answer, and respond fail if the average is lesser than 3, and Pass if its greater than or equal to 3.

    In this hypothetical example, you can insert a calculated field in the form with a equation similar to:

    
    IF((fieldname1+fieldname2+fieldname3+fieldname4+fieldname5)/5 < 3, 'Fail', 'Pass')
    

    and that’s all.
    Best regards.

    Thread Starter allansjackson

    (@allansjackson)

    Thanks very much for the information. Would this also work if you had three conditions such as Genius, Pass and Fail. What would the syntax be for the case where 1&2 = fail 3&4= pass and 5&6= genius.

    Plugin Author codepeople

    (@codepeople)

    Hello @allansjackson

    You can nesting multiple IF operations, but in my opinion, would be more readable implement the equation with function structure, and conditional javascript statements if (Javascript is a case sensitive language, please do not confuse the conditional statement if with the IF operation)

    So, the equation would be similar to:

    
    (function(){
    var average = (fieldname1+fieldname2+fieldname3+fieldname4+fieldname5)/5;
    if(average<3) return 'fail';
    if(average<5) return 'pass';
    return 'genius';
    })()
    

    and that’s all.
    Best regards.

    Thread Starter allansjackson

    (@allansjackson)

    Hi there
    Thanks for your informative replies. I have figured out most of what I need to do on a sample page here: https://www.yourdirectorsadvocate.com.au/temp/.

    Where would I put the CSS to change the base font of the form and maybe increase the size of the text in the calculated field.
    Thanks

    Plugin Author codepeople

    (@codepeople)

    Hello @allansjackson

    The plugin gives you a total control over the fields appearance. You can enter the styles definitions through the “Customize Form Design” attribute in the “Forms Settings” tab:

    The list of class names assigned to the fields and form’s elements is available in the following entry of the plugin’s FAQ:

    https://cff.dwbooster.com/faq#q82

    As you can see the calculated fields have assigned the class name: cff-calculated-field however, a field has different components: the label, the input box, and the span tag with the instructions for users. So, assuming you want to increase the font-size in the input tags of calculated fields, in this case you can enter the following style definition:

    
    .cff-calculated-field input{font-size:1.5em !important;}
    

    trough the “Customize Form Design” attribute.

    Best regards.

    Thread Starter allansjackson

    (@allansjackson)

    Great, thanks very much. Your support has been fantastic.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Show text based on value’ is closed to new replies.