Drag slider question view

From Catglobe Wiki
Jump to: navigation, search

<accesscontrol>Main:MyGroup</accesscontrol>

Drag slider question view

The drag slider question view transforms a scale grid question into a vertical scale where sub questions, which must be specified as images, can be dragged up or down to the level of the scale.

Setting up the resources

The drag slider needs two attachments in order to work, a Flash-file which creates the question view and a JavaScript-file which wraps the Flash-file to simplify the usage in question script.

The following step-by-step guide describes a best practice for placing question views, it will walk you through setting up the drag slider on your Catglobe site.

The guide assumes that it is the first question view you are adding to the site, so some steps can be skipped if the basic structure has already been established.

Before you start, you must have the necessary navigation and resource access, talk with your site administrator about that, she might have to give you additional permissions to complete the steps below.

1. Go to 'folders'
2. Create a folder called 'Common resources' below 'SYSTEM' if it doesn't exist already, leave inheritance on
3. Create a folder called 'Question views' below the folder 'Common resources' if it doesn't exist already, leave inheritance on, leave inheritance on
4. Create a folder called 'Drag slider' below the folder 'Question views' if it doesn't exist already, leave inheritance on
5. Open the attachment tab of the 'Drag slider' folder and upload the two files DragSlider.js and DragSlider.swf, make sure to keep the names including the file extension, it will make it easier to recognize the files in the next step
6. Go to 'tools > Projects and folders > Attachments'
7. Search by name for 'DragSlider' anywhere in name, given that you named the attachments according to the suggested naming in the step above
8. Select the attachment from the list, press Ctrl-C, open a text editor such as Notepad, paste the value from the clipboard, get the GUID out of it (this feature will not work in other browsers except Internet Explorer)

Example: 369734,20eb9e88-69cc-4b03-bbe0-b0dbda53d285<img src=notype.gif></img> Common resources\Question Views\DragSlider Fri May 14 12:44:04 UTC+0700 2010 Hjarnaa, Ulrik (ulrikhjarnaa) Fri May 14 12:44:04 UTC+0700 2010 Hjarnaa, Ulrik (ulrikhjarnaa) Fri May 14 12:44:04 UTC+0700 2010 Hjarnaa, Ulrik (ulrikhjarnaa) 9.104 KB 36685371 DragSlider

9. You should extract the GUIDs only, note them down now together with their filename, you will need it for setting up the question:
DragSlider.js: 20eb9e88-69cc-4b03-bbe0-b0dbda53d285
DragSlider.swf: e8397d22-22cd-439b-932b-e36fe68b88c4
10. Create a group called 'Drag slider access' under the folder 'Drag slider'
11. Give the group 'Drag slider access' observer access to the folder 'Drag slider'
12. Add the user with username 'anonymous' to the group 'Drag slider access', this is necessary for test links and anonymous access to work
13. All respondents participating in questionnaires using the DragSlider must be added to the group 'Drag slider access' else they will not be able to see the drag slider when answering the questionnaire

Respondents can be added to the 'Drag slider access' group dynamically through a dummy question in the beginning of the questionnaire to avoid adding respondents unecessarily to the group.

We have the necessary resources setup, and the GUIDs we need to configure the question script in the next section.

Configuration of the question

The drag slider must be configured for a scale grid, where each sub question must contain an img tag pointing to the picture which should be displayed.

Since there is only one scale the minimum and maximum values for the first sub question are used to define the extremeties of the scale, likewise the first sub question is also used to define the minimum and maximum text.

The other sub questions should still contain minimum and maximum values since the navigation engine validates the inputted values, and minimum and maximum text should also be added, as i makes it easier to process collected data afterwards.

Below is shown an example in QSL of a scale grid question configured with the drag slider question view, it's ready to be imported to your questionnaire and modified to fit your needs.

When using this example you must remember to replace 'JavaScript GUID', and 'Flash GUID' with those GUIDs you found in the previous section, keep the quotes. You can insert the images from the questionnaire editor, they should be uploaded to the questionnaire template then inserted into the sub questions. And you can edit some flash view configuration as you need (size of flash, pictures size,..).

QUESTIONNAIRE
[
	HTML=true;
	NEXT_BUTTON_VISIBLE = true;
	BACK_BUTTON_VISIBLE = true;
	REQUIRED = true;
]

QUESTION DragSlider SCALEGRID
[
JAVA_SCRIPT = "
// Enter the GUID for the JavaScript attachment
var javaScriptGuid = 'JavaScript GUID';

// Enter the GUID for the Flash attachment
var flashGuid = 'Flash GUID';

// Enter the dimension for the Flash 
var flashWidth = 500;
var flashHeight = 400;

// Insert the flash
quest.text += '<p><object width="' + flashWidth + '" height="' + flashHeight +  '" id="dragSliderFlash"
 classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0">
<param name="quality" value="high">
<param name="movie" value="../../Attachments/GetAttachment.aspx?noattach=true&rid=' + flashGuid + '">
<embed src="../../Attachments/GetAttachment.aspx?noattach=true&rid=' + flashGuid + '" quality="high" 
width="' + flashWidth + '" height="' + flashHeight +  '" name="dragSliderFlash" 
pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash">
</embed></object></p>';

// Modify the question after the DOM has finished loading to get jQuery access
quest.onInit = function()
{
   // Load the JavaScript attachment
   $.getScript(
      '../../Attachments/GetAttachment.aspx?rid=' + javaScriptGuid,
      function()
      {
         // Create an instance of the drag slider
         var myDragSlider = new DragSlider(quest);
         
         // Do some configuration
	 myDragSlider.config.imageThumbnailConfiguration.imageHeight = 60;
	 myDragSlider.config.imageThumbnailConfiguration.imageWidth = 60;
	 myDragSlider.config.imageThumbnailConfiguration.imageSpace = 10;
		 
         myDragSlider.config.scale.fontColor = 'FF0000';
         myDragSlider.config.scale.fontSize = '12';
	 myDragSlider.config.scale.fontText = 'Arial';
     
         // Initalize the drag slider
         myDragSlider.init();
      }
   );
};";
]
How do you feel about these brands?
SQ: [
REVERSE = false;
MAX_TEXT = "Positive trend";
MIN_TEXT = "Negative trend";
MIN_VALUE = 1;
MAX_VALUE = 10;
DISCRETE = false;
STEP = 1;
] <img height="62" src="path to image 1" style="border: 0" width="61">
SQ: [
REVERSE = false;
MAX_TEXT = "Positive trend";
MIN_TEXT = "Negative trend";
MIN_VALUE = 1;
MAX_VALUE = 10;
DISCRETE = false;
STEP = 1;
] <img height="62" src="path to image 2" style="border: 0" width="61">
SQ: [
REVERSE = false;
MAX_TEXT = "Positive trend";
MIN_TEXT = "Negative trend";
MIN_VALUE = 1;
MAX_VALUE = 10;
DISCRETE = false;
STEP = 1;
] <img height="62" src="path to image 3" style="border: 0" width="61">
SQ: [
REVERSE = false;
MAX_TEXT = "Positive trend";
MIN_TEXT = "Negative trend";
MIN_VALUE = 1;
MAX_VALUE = 10;
DISCRETE = false;
STEP = 1;
] <img height="62" src="path to image 4" style="border: 0" width="61">
SQ: [
REVERSE = false;
MAX_TEXT = "Positive trend";
MIN_TEXT = "Negative trend";
MIN_VALUE = 1;
MAX_VALUE = 10;
DISCRETE = false;
STEP = 1;
] <img height="62" src="path to image 5" style="border: 0" width="61">

The image path will look something like the following:

../../Images/GetImage.aspx?rid=8b8121cc-5ae5-4679-857b-12302efe70aa

If you already have a scale grid question which you want to apply the drag slider question view to, then you just copy and paste the following JavaScript into the question script property for the question:

// Enter the GUID for the JavaScript attachment
var javaScriptGuid = 'JavaScript GUID';

// Enter the GUID for the Flash attachment
var flashGuid = 'Flash GUID';

// Enter the dimension for the Flash 
var flashWidth = 500;
var flashHeight = 400;

// Insert the flash
quest.text += '<p><object width="' + flashWidth + '" height="' + flashHeight +  '" id="dragSliderFlash"
 classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0">
<param name="quality" value="high">
<param name="movie" value="../../Attachments/GetAttachment.aspx?noattach=true&rid=' + flashGuid + '">
<embed src="../../Attachments/GetAttachment.aspx?noattach=true&rid=' + flashGuid + '" quality="high" 
width="' + flashWidth + '" height="' + flashHeight +  '" name="dragSliderFlash" 
pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash">
</embed></object></p>';

// Modify the question after the DOM has finished loading to get jQuery access
quest.onInit = function()
{
   // Load the JavaScript attachment
   $.getScript(
      '../../Attachments/GetAttachment.aspx?rid=' + javaScriptGuid,
      function()
      {
         // Create an instance of the drag slider
         var myDragSlider = new DragSlider(quest);
         
         // Do some configuration
	 myDragSlider.config.imageThumbnailConfiguration.imageHeight = 60;
	 myDragSlider.config.imageThumbnailConfiguration.imageWidth = 60;
	 myDragSlider.config.imageThumbnailConfiguration.imageSpace = 10;
		 
         myDragSlider.config.scale.fontColor = 'FF0000';
         myDragSlider.config.scale.fontSize = '12';
	 myDragSlider.config.scale.fontText = 'Arial';
      
         // Initalize the drag slider
         myDragSlider.init();
      }
   );
};

Limitations

In the current implementation it's not possible to use permutations on the sub questions, doing so will lead to bad data, since the chosen values will be coded to sub questions randomly.