How to embed a matrix of values and return a value through INDEX equivalent

liss_SKliss_SK GermanyCommunity Member Qubie ✭

How to embed a matrix of values and return a value through INDEX equivalent

Hello,
I am performing a decision game through qualtrics. People decide to accept or reject project proposals on the bases of threshold values.
Therefore I need to incorporate a matrix of threshold values (picture attached). Is there a way I can do that?

My second problem is getting those values into my survey. Unfortunately i am not a programmer, but maybe you can help me with that.
I need a Java code similar to INDEX that can access the matrix and return the threshold as embedded data. The rows and collums in the matrix reflect embedded data „number of proposals to come" and „number of projects left to choose“.

Thank you

Answers

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

    Define your matrix as an array or arrays:

    var matrix = [
        [235, 235, 235, 235, 235, 235, 235, 235, 235, 235, 235], //0
        [881, 235, 235, 235, 235, 235, 235, 235, 235, 235, 235], //1
        // ...2 through 39...
        [881, 851.5, 833.57, 816.88, 800.73, 784.91, 769.29, 753.82, 738.46, 723.18, 707.07] //40
    ]
    

    Then access a value by row and column index:

    var val = matrix[30][2]; //val = 819.52
    
  • liss_SKliss_SK GermanyCommunity Member Qubie ✭

    Thank you so much for your answer. Maybe you can help me with one more thing. I can't make it work together with embedded data. I need the column to be a value which is an embedded datapoint ${e://Field/Count}, and the row to be ${e://Field/CountQ}. And then the resulting value should be added as an embedded data "Threshold" again. Can you show me what the Code would look like?
    Best

    var matrix = [
    [235, 235, 235, 235, 235, 235, 235, 235, 235, 235, 235],//0
    [881, 235, 235, 235, 235, 235, 235, 235, 235, 235, 235],//1
    [881, 558, 235, 235, 235, 235, 235, 235, 235, 235, 235],
    [881, 638, 477, 235, 235, 235, 235, 235, 235, 235, 235],
    [881, 684, 558, 431, 235, 235, 235, 235, 235, 235, 235],
    [881, 714, 608, 507, 401, 235, 235, 235, 235, 235, 235],
    [881, 735, 644, 558, 471, 380, 235, 235, 235, 235, 235],
    [881, 752, 671, 595, 520, 444, 363, 235, 235, 235, 235],
    [881, 764, 692, 624, 558, 491, 423, 351, 235, 235, 235],
    [881, 775, 709, 648, 587, 528, 467, 406, 340, 235, 235],
    [881, 783, 723, 667, 612, 558, 503, 448, 392, 332, 235],//10
    [881, 791, 735, 683, 632, 582, 533, 483, 432, 380, 324],
    [881, 797, 745, 697, 650, 604, 558, 511, 465, 418, 370],
    [881, 802, 754, 709, 665, 622, 579, 536, 493, 450, 406],
    [881, 807, 762, 719, 678, 638, 597, 558, 518, 477, 437],
    [881, 811, 768, 728, 690, 652, 614, 576, 539, 501, 463],
    [881, 815, 774, 737, 700, 664, 628, 593, 558, 522, 487],
    [881, 818, 780, 744, 709, 675, 641, 608, 574, 541, 507],
    [881, 821, 785, 751, 717, 685, 653, 621, 589, 558, 526],
    [881, 824, 789, 756, 725, 694, 663, 633, 603, 573, 542],
    [881, 826, 793, 762, 732, 702, 673, 644, 615, 586, 558],//20
    [881, 829, 797, 767, 738, 710, 682, 654, 626, 599, 571],
    [881, 831, 800, 771, 744, 717, 690, 663, 637, 610, 584],
    [881, 833, 803, 776, 749, 723, 697, 671, 646, 621, 595],
    [881, 834, 806, 780, 754, 729, 704, 679, 655, 630, 606],
    [881, 836, 809, 783, 758, 734, 710, 686, 663, 639, 616],
    [881, 838, 811, 786, 763, 739, 716, 693, 670, 648, 625],
    [881, 839, 813, 790, 767, 744, 722, 699, 677, 655, 634],
    [881, 840, 816, 793, 770, 748, 727, 705, 684, 663, 642],
    [881, 842, 818, 795, 774, 752, 731, 711, 690, 670, 649],
    [881, 843, 820, 798, 777, 756, 736, 716, 696, 676, 656],//30
    [881, 844, 821, 800, 780, 760, 740, 721, 701, 682, 663],
    [881, 845, 823, 803, 783, 763, 744, 725, 706, 688, 669],
    [881, 846, 825, 805, 785, 767, 748, 729, 711, 693, 675],
    [881, 847, 826, 807, 788, 770, 751, 733, 716, 698, 680],
    [881, 848, 827, 809, 790, 772, 755, 737, 720, 703, 685],
    [881, 849, 829, 810, 793, 775, 758, 741, 724, 707, 690],
    [881, 849, 830, 812, 795, 778, 761, 744, 728, 711, 695],
    [881, 850, 831, 814, 797, 780, 764, 748, 732, 716, 700],
    [881, 851, 832, 815, 799, 783, 767, 751, 735, 719, 704],
    [881, 851, 834, 817, 801, 785, 769, 754, 738, 723, 708],//40
    ]

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

    @liss_SK said:
    Thank you so much for your answer. Maybe you can help me with one more thing. I can't make it work together with embedded data. I need the column to be a value which is an embedded datapoint ${e://Field/Count}, and the row to be ${e://Field/CountQ}. And then the resulting value should be added as an embedded data "Threshold" again. Can you show me what the Code would look like?

    var threshold = matrix[parseInt("${e://Field/CountQ}")][parseInt("${e://Field/Count}"];
    Qualtrics.SurveyEngine.setEmbeddedData("Threshold", threshold);
    
Sign In to Comment