Difference between revisions of "Rotate answer options/sub questions"

From Catglobe Wiki
Jump to: navigation, search
(Challenge)
 
(3 intermediate revisions by the same user not shown)
Line 6: Line 6:
  
 
I want to control the rotation by setting explicitly the first item in a range after rotation  
 
I want to control the rotation by setting explicitly the first item in a range after rotation  
 +
 +
=== Rotate answer options  ===
  
 
'''Example'''  
 
'''Example'''  
  
I have a list of drinks as answer options  
+
*I have a list of drinks as answer options
  
 
[[Image:QuestionTips Rotate 1.jpg]]  
 
[[Image:QuestionTips Rotate 1.jpg]]  
  
I want to have Mirinda as the top answer option in the list and keep None of the above in its original position  
+
*I want to have Mirinda as the top answer option in the list and keep None of the above in its original position
 +
 
 +
[[Image:QuestionTips Rotate 2.jpg]] 
 +
 
 +
'''Solution'''
  
[[Image:QuestionTips Rotate 2.jpg]] 
+
Set the rotation range from 0-5 with rotation index is 3
  
== Solution  ==
+
'''Code'''
  
Set the rotation range from 0-5 with rotation index is 3
+
*Add a Single question to Questionnaire editor
 +
*Go to menu Properties -> Question scripts -> Java script and input below script
  
== Code ==
+
<br> <source lang="javascript">
<source lang="javascript" line="1">
 
 
quest.rotateAnswerOptions(0, 5, 3);
 
quest.rotateAnswerOptions(0, 5, 3);
</source>
+
</source>  
 +
 
 +
''{{note}} quest.rotateAnswerOptions(startIndex, endIndex, rotateIndex): rotate answer options in a range specified by startIndex and endIndex, the first item in the range will be rotateIndex ''
 +
 
 +
<br>
 +
 
 +
[[Image:RotateAnswerOptions.jpg]]
 +
 
 +
=== Rotate sub questions  ===
 +
 
 +
'''Example'''
 +
 
 +
*I have a single grid question like below image<br>
 +
 
 +
[[Image:RotateSubQuestions1.jpg]]<br>
 +
 
 +
*I want to have Mirinda as the top sub question in the list<br>
 +
 
 +
[[Image:RotateSubQuestions2.jpg]]<br>
 +
 
 +
'''Solution'''
 +
 
 +
Set the rotation range&nbsp;from 0-5 with rotation index is 3
 +
 
 +
'''Code'''
 +
 
 +
*Add a Single grid question to Questionnaire editor
 +
*Go to menu Properties -&gt; Question scripts -&gt; Java script and input below script
 +
 
 +
<br> <source lang="javascript">
 +
quest.rotateSubQuestions(0, 5, 3);
 +
</source>
 +
 
 +
''{{note}} quest.rotateSubQuestions(startIndex, endIndex, rotateIndex): rotate sub questions in a range specified by startIndex and endIndex, the first item in the range will be rotateIndex ''
 +
 
 +
<br>
 +
 
 +
[[Image:RotateSubQuestions.jpg]]<br>
 +
 
 +
=== Source  ===
 +
 
 +
Questionnaire Resource Id on cg site: 159730

Latest revision as of 05:23, 6 January 2012

Rotate answer options/sub questions

In order to synchronize the answer option/sub question rotation among more than one questions

As a questionnaire creator

I want to control the rotation by setting explicitly the first item in a range after rotation

Rotate answer options

Example

  • I have a list of drinks as answer options

QuestionTips Rotate 1.jpg

  • I want to have Mirinda as the top answer option in the list and keep None of the above in its original position

QuestionTips Rotate 2.jpg 

Solution

Set the rotation range from 0-5 with rotation index is 3

Code

  • Add a Single question to Questionnaire editor
  • Go to menu Properties -> Question scripts -> Java script and input below script


quest.rotateAnswerOptions(0, 5, 3);

Note Note: quest.rotateAnswerOptions(startIndex, endIndex, rotateIndex): rotate answer options in a range specified by startIndex and endIndex, the first item in the range will be rotateIndex


RotateAnswerOptions.jpg

Rotate sub questions

Example

  • I have a single grid question like below image

RotateSubQuestions1.jpg

  • I want to have Mirinda as the top sub question in the list

RotateSubQuestions2.jpg

Solution

Set the rotation range from 0-5 with rotation index is 3

Code

  • Add a Single grid question to Questionnaire editor
  • Go to menu Properties -> Question scripts -> Java script and input below script


quest.rotateSubQuestions(0, 5, 3);

Note Note: quest.rotateSubQuestions(startIndex, endIndex, rotateIndex): rotate sub questions in a range specified by startIndex and endIndex, the first item in the range will be rotateIndex


RotateSubQuestions.jpg

Source

Questionnaire Resource Id on cg site: 159730