Solved
How to create a custom code to move and record the location of two objects?
Hello, I'd like to use the rank question type to create a task where on the left panel I show participants two pictures of virtual chairs and I ask them to drag both chairs to set them up for a virtual conversation. I'd like to then record the location of the two chairs or be able to record the image so I can print it out and measure the distance between the two chairs. Is this doable?
Best answer by mattyb513
@bibi
Why not just calculate it all in code? Use pythagorean's theorem to get the distance in pixels and record that as Embedded Data?
Here's a gist for the JavaScript.
https://gist.github.com/mattbloomfield/8f65a17aecd8c4ee2051d68cc7edbf17
To implement it, you can just make a Text/Graphic question type and add the following HTML:
```html
<div id="ChairContainer">
<div class="chair" id="Chair1">Chair1</div>
<div class="chair" id="Chair2">Chair2</div>
</div>
```
Then add this CSS for the chair images:
```css
/* Place your CSS here */
#Chair1 {
background: url('https://qualtricssfi.az1.qualtrics.com/ControlPanel/Graphic.php?IM=IM_ehS6PmtWQ7AMfHL');
background-size: contain;
background-repeat: no-repeat;
background-position: center center;
}
#Chair2 {
background: url('https://qualtricssfi.az1.qualtrics.com/ControlPanel/Graphic.php?IM=IM_5aNSgsceL6ZeGzP');
background-size: contain;
background-repeat: no-repeat;
background-position: center center;
}
.chair {
height: 250px;
width: 150px;
}
```
And finally, load in jQuery UI for the draggable chairs. Put this in your Header as raw HTML:
```html
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
```
Working Example: https://qualtricssfi.az1.qualtrics.com/jfe/preview/SV_9nSVd3z2CZiTltj?Q_SurveyVersionID=current&Q_CHL=preview
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.

The code I am using, displays the image and the number separately: