Difference between revisions of "Show more than one questions in the same page"

From Catglobe Wiki
Jump to: navigation, search
(Solutions)
(Solutions)
Line 16: Line 16:
 
<tr>
 
<tr>
 
   <td width="16px" valign="top" align="center">
 
   <td width="16px" valign="top" align="center">
       <input type="radio" onclick="optclick('QUESTION.Q1',0,false);" value="1" name="QUESTION.Q1">
+
       <input type="radio" value="1" name="QUESTION.Q1">
 
   </td>
 
   </td>
 
   <td valign="top" align="left">
 
   <td valign="top" align="left">
       <a href="javascript:optclick('QUESTION.Q1',0,true);" class="option_link">Answer option text 1</a>
+
       Answer option text 1
 
   </td>
 
   </td>
 
</tr>
 
</tr>
Line 26: Line 26:
  
 
Example 2:<br/>
 
Example 2:<br/>
I want to show a single grid question label Q1 in another question, I need to make sure the HTML contains the following code for each answer option and each sub question.<br/>
+
I want to show a single grid question label Q1 in another question, I need to make sure the HTML contains the following code for each answer option and each sub question. Q1 has 2 answer options<br/>
 
<source lang=html4strict>
 
<source lang=html4strict>
 
<tr>
 
<tr>
 
   <td width="16px" valign="top" align="center">
 
   <td width="16px" valign="top" align="center">
       <input type="radio" onclick="optclick('QUESTION.Q1.0',0,false);" value="1" name="QUESTION.Q1.0">
+
       <input type="radio" value="1" name="QUESTION.Q1.0">
 
   </td>
 
   </td>
 +
  <td width="16px" valign="top" align="center">
 +
      <input type="radio" value="2" name="QUESTION.Q1.0">
 +
  </td>
 +
 
</tr>
 
</tr>
  

Revision as of 08:14, 8 March 2010

Introduction

There is a common need of showing more than one questions in the same page, but unfortunately it is not supported by the current editor (we hope it will be possible with the new viewer in a near future)

In the mean time, we need to have some work-arround tips to make it work.

Solutions

The main idea is that when we want to display a question not in its own page, there must be an input element added to that page's html with name following a specific format, non grid question should have name as QUESTION.question_label, grid questions use names as QUESTION.question_label.grid_index

Example 1:

I want to show my single question labeled Q1 in another question with radio buttons, I need to make sure the HTML contains the following code for each answer option.

<tr>
   <td width="16px" valign="top" align="center">
      <input type="radio" value="1" name="QUESTION.Q1">
   </td>
   <td valign="top" align="left">
      Answer option text 1
   </td>
</tr>

Example 2:
I want to show a single grid question label Q1 in another question, I need to make sure the HTML contains the following code for each answer option and each sub question. Q1 has 2 answer options

<tr>
   <td width="16px" valign="top" align="center">
      <input type="radio" value="1" name="QUESTION.Q1.0">
   </td>
   <td width="16px" valign="top" align="center">
      <input type="radio" value="2" name="QUESTION.Q1.0">
   </td>

</tr>

There are basically 3 ways of handling this task.

Use HTML

quest.onInit

quest.getHTML