Counters for PGR Questions | XM Community
Solved

Counters for PGR Questions


Userlevel 2
Badge +1
I have a survey where respondents drag and drop items to groups in a PGR question, and have set validation such that an exact number of items is allowed in each group. Of course, if a respondent places more or less groups than the exact number allowed in each one, they'll get an error message upon trying to go to the next page.

However, we're interested in two things: a) showing respondents exactly how many items they've already included in each group as they're dragging and dropping, and b) if possible, showing an error message whenever more items are added to a group than allowed (i.e. in real-time, before the respondent even clicks on the "next" button). Right now, we're actually using the PGR question to have people categorize into groups, where the ranking within each group does not matter at all, and as such I made the "ranking" that shows up for an item when it's dragged into a group to be hidden. We could instead just leave the ranking information on the items whenever they're dragged into a group as visible (to have a version of a "count") as that will of course show the items as numbered with a "ranking" in each group. However, we think this will potentially give respondents the impression that they are indeed ranking the groups, so we ideally just want a counter next to each group that indicates how many items have been placed in that group.

As an additional extra feature, if there was some way to have an error message be triggered whenever that count surpassed the maximum amount of items allowed (already specified with validation), that would be fantastic.
icon

Best answer by DRRTGCC 20 June 2018, 23:50

View original

4 replies

Userlevel 2
Badge +1
Figured this out; it's rather simple with some JQuery. Because I can't paste JQuery or Javascript code on here, even when formatted, I'm including a snapshot of the code I use, which updates the counter variables whenever the mouse is moved on the page. Anyone who might want to use this just needs to replace the selectors for the groups, and of course include in the question HTML a `<span class="total0"></span>` and `<span class="total100"></span>` , or however they wish to name their variables, along with whatever formatting or extra text they want to display those counters with. Hope this helps!

!
Just wondering, will this definitely work OK if you have randomization of the choice order?
Userlevel 2
Badge +1
I currently have my questions randomizing the order the "Items" are presented and it works fine. As for randomizing the "Groups", I think it should still work. The "group0", "group1", etc. id's I think should just be referring to whichever group is placed in some positions around the page, so as long as you're just counting in the same way for all of them it should work fine. Of course, you'd probably lose the way to refer specifically to the count of a specific group (say by putting that in the HTML of your question and saying "You have picked X items to be in group Y", if group Y could for any respondent be group0, group3, group7, etc. (though I'm sure there might be a way to find out which group is in what position?).
Thanks for responding so quickly! I actually think I have found a quick solution to my problem using block randomisation.

Leave a Reply