View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 04324 | Bug reports | Survey editing | public | 2010-05-10 09:58 | 2010-06-08 21:51 |
| Reporter | CarbonaCat | Assigned To | lemeur | ||
| Priority | normal | Severity | tweak | ||
| Status | closed | Resolution | fixed | ||
| Product Version | 1.90b | ||||
| Summary | 04324: Patch: Allow dropdowns for arrays | ||||
| Description | This patch allows to use dropdowns in the "array" question type, instead of radios. | ||||
| Steps To Reproduce | N/A | ||||
| Additional Information | -Allows the use of the "use_dropdown" attribute for the "Array" question type (common.php). The zip file contains both old and new files, as well as the corresponding diffs. | ||||
| Tags | No tags attached. | ||||
| Attached Files | dropdown4arrays-svn8746.diff (6,157 bytes)
Index: common.php
===================================================================
--- common.php (revision 8748)
+++ common.php (working copy)
@@ -3983,16 +3983,16 @@
"caption"=>$clang->gT('Input box width'));
$qattributes["use_dropdown"]=array(
- "types"=>"1",
+ "types"=>"1F",
'category'=>$clang->gT('Other'),
'sortorder'=>100,
'inputtype'=>'singleselect',
'options'=>array(0=>$clang->gT('No'),
1=>$clang->gT('Yes')),
'default'=>0,
- "help"=>$clang->gT('Use dual dropdown boxes instead of dual scales'),
- "caption"=>$clang->gT('Dual dropdown'));
-
+ "help"=>$clang->gT('Use dropdown boxes instead of scales'),
+ "caption"=>$clang->gT('Dropdown'));
+
$qattributes["scale_export"]=array(
"types"=>"CEFGHLMOPWYZ1!:",
'category'=>$clang->gT('Other'),
Index: qanda.php
===================================================================
--- qanda.php (revision 8748)
+++ qanda.php (working copy)
@@ -5276,8 +5276,17 @@
}
$columnswidth=100-$answerwidth;
+ if ($qidattributes['use_dropdown'] == 1)
+ {
+ $useDropdownLayout = true;
+ }
+ else
+ {
+ $useDropdownLayout = false;
+ }
+
$lresult = db_execute_assoc($lquery); //Checked
- if ($lresult->RecordCount() > 0)
+ if ($useDropdownLayout === false && $lresult->RecordCount() > 0)
{
while ($lrow=$lresult->FetchRow())
{
@@ -5453,7 +5462,124 @@
$answer = $answer_start . $answer_cols . $answer_head .$answer . "\t</tbody>\n</table>\n";
}
- else
+ elseif ($useDropdownLayout === true && $lresult->RecordCount() > 0)
+ {
+ while ($lrow=$lresult->FetchRow())
+ $labels[]=Array('code' => $lrow['code'],
+ 'answer' => $lrow['answer']);
+ $ansquery = "SELECT question FROM {$dbprefix}questions WHERE parent_qid={$ia[0]} AND question like '%|%' ";
+ $ansresult = db_execute_assoc($ansquery); //Checked
+ if ($ansresult->RecordCount()>0) {$right_exists=true;$answerwidth=$answerwidth/2;} else {$right_exists=false;}
+ // $right_exists is a flag to find out if there are any right hand answer parts. If there arent we can leave out the right td column
+ if ($qidattributes['random_order']==1) {
+ $ansquery = "SELECT * FROM {$dbprefix}questions WHERE parent_qid={$ia[0]} AND language='".$_SESSION['s_lang']."' ORDER BY ".db_random();
+ }
+ else
+ {
+ $ansquery = "SELECT * FROM {$dbprefix}questions WHERE parent_qid={$ia[0]} AND language='".$_SESSION['s_lang']."' ORDER BY question_order";
+ }
+ $ansresult = db_execute_assoc($ansquery); //Checked
+ $anscount = $ansresult->RecordCount();
+ $fn=1;
+
+ $numrows = count($labels);
+ if ($ia[6] != 'Y' && $shownoanswer == 1)
+ {
+ ++$numrows;
+ }
+ if ($right_exists)
+ {
+ ++$numrows;
+ }
+ $cellwidth = round( ($columnswidth / $numrows ) , 1 );
+
+ $answer_start = "\n<table class=\"question\" summary=\"".str_replace('"','' ,strip_tags($ia[3]))." - an array type question\" >\n";
+
+ $answer = "\t<tbody>\n";
+ $trbc = '';
+ $inputnames=array();
+
+ while ($ansrow = $ansresult->FetchRow())
+ {
+ $myfname = $ia[1].$ansrow['title'];
+ $trbc = alternation($trbc , 'row');
+ $answertext=answer_replace($ansrow['question']);
+ $answertextsave=$answertext;
+ if (strpos($answertext,'|'))
+ {
+ $answertext=substr($answertext,0, strpos($answertext,'|'));
+ }
+ /* Check if this item has not been answered: the 'notanswered' variable must be an array,
+ containing a list of unanswered questions, the current question must be in the array,
+ and there must be no answer available for the item in this session. */
+
+ if (strpos($answertext,'|')) {$answerwidth=$answerwidth/2;}
+
+ if ((is_array($notanswered)) && (array_search($ia[1], $notanswered) !== FALSE) && ($_SESSION[$myfname] == '') ) {
+ $answertext = '<span class="errormandatory">'.$answertext.'</span>';
+ }
+ // Get array_filter stuff
+ list($htmltbody2, $hiddenfield)=return_array_filter_strings($ia, $qidattributes, $thissurvey, $ansrow, $myfname, $trbc, $myfname);
+ $answer .= $htmltbody2;
+
+ $answer .= "<tr class=\"$trbc\">\n"
+ . "\t<th class=\"answertext\">\n$answertext"
+ . $hiddenfield
+ . "<input type=\"hidden\" name=\"java$myfname\" id=\"java$myfname\" value=\"";
+ if (isset($_SESSION[$myfname]))
+ {
+ $answer .= $_SESSION[$myfname];
+ }
+ $answer .= "\" />\n\t</th>\n";
+
+ $answer .= "\t<td >\n"
+ . "<select name=\"$myfname\" id=\"answer$myfname\" onchange=\"$checkconditionFunction(this.value, this.name, this.type);\">\n";
+
+ if (!isset($_SESSION[$myfname]) || $_SESSION[$myfname] =='')
+ {
+ $answer .= "\t<option value=\"\" ".SELECTED.'>'.$clang->gT('Please choose')."...</option>\n";
+ }
+
+ foreach ($labels as $lrow)
+ {
+ $answer .= "\t<option value=\"".$lrow['code'].'" ';
+ if (isset($_SESSION[$myfname]) && $_SESSION[$myfname] == $lrow['code'])
+ {
+ $answer .= SELECTED;
+ }
+ $answer .= '>'.$lrow['answer']."</option>\n";
+ }
+ // If not mandatory and showanswer, show no ans
+ if ($ia[6] != 'Y' && $shownoanswer == 1)
+ {
+ $answer .= "\t<option value=\"\" ";
+ if (!isset($_SESSION[$myfname]) || $_SESSION[$myfname] == '')
+ {
+ $answer .= SELECTED;
+ }
+ $answer .= '>'.$clang->gT('No answer')."</option>\n";
+ }
+ $answer .= "</select>\n";
+
+ if (strpos($answertextsave,'|'))
+ {
+ $answertext=substr($answertextsave,strpos($answertextsave,'|')+1);
+ $answer .= "\t<th class=\"answertextright\">$answertext</th>\n";
+ }
+ elseif ($right_exists)
+ {
+ $answer .= "\t<td class=\"answertextright\"> </td>\n";
+ }
+
+ $answer .= "</tr>\n</tbody>";
+ $inputnames[]=$myfname;
+ //IF a MULTIPLE of flexi-redisplay figure, repeat the headings
+ $fn++;
+ }
+
+ $answer = $answer_start . $answer . "\t</tbody>\n</table>\n";
+ }
+ else
{
$answer = "\n<p class=\"error\">".$clang->gT("Error: There are no answer options for this question and/or they don't exist in this language.")."</p>\n";
$inputnames='';
| ||||
| Bug heat | 8 | ||||
| Complete LimeSurvey version number (& build) | 8691 | ||||
| I will donate to the project if issue is resolved | |||||
| Browser | All | ||||
| Database type & version | MySQL | ||||
| Server OS (if known) | Windows XP SP2 | ||||
| Webserver software & version (if known) | WAMP | ||||
| PHP Version | 5.3 | ||||
|
Hi Thibault, can you preview this patch and give some advice? |
|
|
Thibault, the user asked at the forum if he can help to bring this feature forward. |
|
|
[QUOTE]Thibault, the user asked at the forum if he can help to bring this feature forward.[/QUOTE] Sure, the best would be to provide a patch against the limesurvey-dev/ branch. [QUOTE]Do you think we should add it to the 1.90RC1 milestones?[/QUOTE] I'm afraid not, there was a feature freeze decided when 1.90beta was released (Wednesday, 05 May 2010). this will be for 1.91. Thibault |
|
|
[QUOTE]Sure, the best would be to provide a patch against the limesurvey-dev/ branch.[/QUOTE] CarbonaCat, can you provide a .diff patch against the latest SVN/beta3 version of Limesurvey 1.90? |
|
|
Sure, I'll do that in the afternoon (Sorry for the lack of reaction, I had a prolonged weekend due the the Lundi de Pentecote :P) |
|
|
I attached the diff file against the revision 08746. |
|
|
Thibault, can you have a look and if it looks fine put it on the feature list for the next 1.9x release? |
|
|
Implemented in rev 8752 in the limesurvey_dev branch. Please stay tuned in case we find bugs, we may contact you ;-) |
|
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2010-05-10 09:58 | CarbonaCat | New Issue | |
| 2010-05-10 09:58 | CarbonaCat | Status | new => assigned |
| 2010-05-10 09:58 | CarbonaCat | Assigned To | => user372 |
| 2010-05-10 09:58 | CarbonaCat | File Added: dropdown4arrays-build8691.zip | |
| 2010-05-10 15:50 | Mazi | Assigned To | user372 => lemeur |
| 2010-05-10 15:50 | Mazi | Note Added: 11744 | |
| 2010-05-21 14:43 | Mazi | Note Added: 11901 | |
| 2010-05-21 17:39 | lemeur | Note Added: 11906 | |
| 2010-05-22 14:38 | Mazi | Note Added: 11944 | |
| 2010-05-22 14:38 | Mazi | Status | assigned => feedback |
| 2010-05-25 09:29 | CarbonaCat | Note Added: 11950 | |
| 2010-05-25 09:29 | CarbonaCat | Status | feedback => assigned |
| 2010-05-25 11:56 | CarbonaCat | File Added: dropdown4arrays-svn8746.diff | |
| 2010-05-25 11:57 | CarbonaCat | Note Added: 11951 | |
| 2010-05-25 15:35 | CarbonaCat | Issue Monitored: CarbonaCat | |
| 2010-05-26 13:58 | Mazi | Note Added: 11966 | |
| 2010-05-26 23:45 | lemeur | Note Added: 11994 | |
| 2010-05-26 23:45 | lemeur | Status | assigned => resolved |
| 2010-05-26 23:45 | lemeur | Resolution | open => fixed |
| 2010-06-08 21:51 | c_schmitz | Status | resolved => closed |
| 2010-10-25 00:17 | c_schmitz | Category | Survey Design => Survey design |
| 2019-11-01 17:25 | c_schmitz | Category | Survey design => Survey editing |
| 2021-08-12 14:40 | guest | Bug heat | 6 => 8 |