• Resolved sameagol

    (@sameagol)


    Hi, I’m wondering about the functionality of the formula editor. I would like to be able to have an if() then statement. For example:

    if(x > a){result = a}else{result = x}

    I like the plugin, but I can’t use it without this kind of functionality.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Contributor ustimenko

    (@ustimenko)

    You can have two results and for first use formula x>a
    and for 1nd — NOT(x>a)

    But I think you need something like Computed variables add-on.

    Thread Starter sameagol

    (@sameagol)

    I appreciate the timely response. Can variables store non-booleans, like ints or floats?

    Plugin Contributor ustimenko

    (@ustimenko)

    @sameagol varaibles can store ints, floats and strings.

    Computed vars operates with ints/floats.

    NOt-zero var in result’s formula becomes true.

    See here for tech details: https://github.com/garex/wp-testing/blob/368b6ae10f009443e4cc8ba2675c7589433fe7b5/src/Model/Compilable.php#L93:L117

    Thread Starter sameagol

    (@sameagol)

    I see how it takes ints, floats, and strings.

    I’m still trying to figure out how to store something like this in variables:

    if(x > a){result = a}else{result = x}

    Can this be done using computed variables:

    [result = a] [x > a]
    [result = x] [x >= a]

    Plugin Contributor ustimenko

    (@ustimenko)

    Yes.

    For example in compuvars:

    is_x_big: x > a
    is_x_less: NOT(is_x_big)
    is_result_a: is_x_big
    is_result_x: is_x_less

    Then in formulas just:

    result a: is_result_a
    result x: is_result_x

    Thread Starter sameagol

    (@sameagol)

    I am sorry for being unclear. In your example, you have two results, result a and result b.

    I am looking for functionality which can assign either a or x to the same result.

    if(x > a){result = a}else{result = x}

    I hope this is possible! Thanks again for all the answers.

    Plugin Contributor ustimenko

    (@ustimenko)

    By “result” I understand a piece of text, that we show to respondent on results page.

    Result will show if it’s formula is true.

    1. What do you understand by “result”?
    2. Why do you need it?
    3. Where do you want it to use?
    Thread Starter sameagol

    (@sameagol)

    I should not have used the word “result.” I mean variable.

    For example, I want to find the minimum of two variables and assign it to a different variable.

    a is a variable
    x is a variable

    minOfVariables = min(a,x)

    I assume, if this is possible, one would have to have some kind of if statement, like:

    if (x > a){minOfVariables = a}else{minOfVariables = x}

    The reason I want to do this is because I’m doing some math on the scale scores. When doing math on these, it is important to be able to find the minimum or maximum of two variables to use later on.

    Plugin Contributor ustimenko

    (@ustimenko)

    I’m still don’t understand the whole image.

    Such if can be replaced by math.

    Currently there is no “if”s in plugin and I dont’ plan to introduce em.

    If your case is too advanced, then you shouldn’t use this plugin or can use it but with custom written addon, that uses some of plugin’s extension points.

    Thread Starter sameagol

    (@sameagol)

    Ok, thanks for the support. I’ll consider a custom addon, though I’m hesitant because I’m new to web code and wordpress. Thanks again!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Formula Editing’ is closed to new replies.