View Issue Details

This issue affects 1 person(s).
 6
IDProjectCategoryView StatusLast Update
05390Bug reportsLimeSurvey Websitepublic2011-08-15 16:59
Reporteruser15197Assigned Toc_schmitz  
PrioritylowSeverityminor 
Status closedResolutionfixed 
Product Version1.91+ 
Summary05390: Max. number of answers with multiple choice question not checked in demo.limesurvey.org
Description

When setting Logic : Maximum Answers in advanced settings for Multiple choice question, I expect that when taking the survey it would fire a pop-up when a user gives more answers than set in the Maximum Answers.

This does not happen, all answers are recorded even if more than the Maximum Answers

Steps To Reproduce

Survey id 23261 (http://demo.limesurvey.org/index.php?sid=23261&newtest=Y&lang=en)

Additional Information

obviously this is on your demo installation

TagsNo tags attached.
Attached Files
inverse_diff_10625-10028.diff (39,517 bytes)   
--- /Users/ptroxler/Downloads/2011-08-10/limesurvey/qanda.php
+++ qanda.php
@@ -10,7 +10,7 @@
  * other free or open source software licenses.
  * See COPYRIGHT.php for copyright notices and details.
  *
- * $Id: qanda.php 10625 2011-08-02 15:57:30Z c_schmitz $
+ * $Id: qanda.php 10028 2011-05-01 15:47:16Z texens $
  */
 
 // Security Checked: POST, GET, SESSION, REQUEST, returnglobal, DB
@@ -87,13 +87,24 @@
         ."{$dbprefix}conditions.cfieldname";
         $cresult = db_execute_assoc($cquery) or safe_die ("OOPS<br />$cquery<br />".$connect->ErrorMsg());     //Checked
 
-        $cquerytoken =	"SELECT c.qid, c.scenario, c.cqid, c.cfieldname, c.value, '' as type, 0 as sid, 0 as gid, c.method, q.gid as srcgid "
-        ."FROM {$dbprefix}conditions c, {$dbprefix}questions q "
-        ."WHERE c.qid=q.qid "
-        ."AND c.qid=$ia[0] "
-        ."AND c.cfieldname LIKE '{%' "
-        ."ORDER BY c.scenario, c.cqid, c.cfieldname";
-
+        $cquerytoken =	"SELECT {$dbprefix}conditions.qid, "
+        ."{$dbprefix}conditions.scenario, "
+        ."{$dbprefix}conditions.cqid, "
+        ."{$dbprefix}conditions.cfieldname, "
+        ."{$dbprefix}conditions.value, "
+        ."'' as type, "
+        ."0 as sid, "
+        ."0 as gid, "
+        ."{$dbprefix}conditions.method,"
+        ."questionssrc.gid as srcgid "
+        ."FROM {$dbprefix}conditions, {$dbprefix}questions as questionssrc "
+        ."WHERE {$dbprefix}conditions.qid=questionssrc.qid "
+        ."AND {$dbprefix}conditions.qid=$ia[0] "
+        ."AND {$dbprefix}conditions.cfieldname LIKE '{%' "
+        ."ORDER BY {$dbprefix}conditions.scenario, "
+        ."{$dbprefix}conditions.cqid, "
+        ."{$dbprefix}conditions.cfieldname";
+    
         $cresulttoken = db_execute_assoc($cquerytoken) or safe_die ("OOPS<br />$cquerytoken<br />".$connect->ErrorMsg());     //Checked
 
         while ($tempcrow = $cresulttoken->FetchRow())
@@ -133,7 +144,7 @@
             $cfieldnamelist[$condkey] = $condarr[2];
         }
         array_multisort($scenariolist,SORT_ASC,$cqidlist,SORT_ASC,$cfieldnamelist,SORT_ASC,$conditions);
-
+        
         return $conditions;
     }
     else
@@ -376,13 +387,9 @@
 
     $mandatorys=array();
     $mandatoryfns=array();
-    $ansquery = "SELECT * FROM {$dbprefix}questions
-                 WHERE parent_qid={$ia[0]} AND language='".$_SESSION['s_lang']."' and scale_id=0
-                 ORDER BY question_order, title";
+    $ansquery = "SELECT * FROM {$dbprefix}questions WHERE parent_qid={$ia[0]} AND language='".$_SESSION['s_lang']."' and scale_id=0 ORDER BY question_order, title";
     $ansresult = db_execute_assoc($ansquery);
-    $ans2query = "SELECT * FROM {$dbprefix}questions
-                  WHERE parent_qid={$ia[0]} AND language='".$_SESSION['s_lang']."' and scale_id=1
-                  ORDER BY question_order, title";
+    $ans2query = "SELECT * FROM {$dbprefix}questions WHERE parent_qid={$ia[0]} AND language='".$_SESSION['s_lang']."' and scale_id=1 ORDER BY question_order, title";
     $ans2result = db_execute_assoc($ans2query);
 
     while ($ans2row=$ans2result->FetchRow())
@@ -411,7 +418,7 @@
                     $mandatoryfns[]=$ia[1];
                 }
             }
-        }
+        } 
         elseif (trim($qidattributes['array_filter_exclude'])!='')
         {
             //This particular one may not be mandatory if it's hidden
@@ -469,7 +476,7 @@
     $ans1result = db_execute_assoc($ans1query);   //Checked
     $ans1count = $ans1result->RowCount();
 
-    // Get Answer Scale 2
+    // Get Answer Scale 2    
     $ans2query="SELECT qid "
             ."FROM {$dbprefix}answers "
             ."WHERE qid={$ia[0]} "
@@ -481,7 +488,7 @@
 
     while ($subrow = $subresult->FetchRow())
     {
-        // first answer set
+        // first answer set     
         if ($ans1count > 0)
         {
             $mandatorys[]=$ia[1].$subrow['title']."#0";
@@ -575,7 +582,7 @@
     ,'input_error_class' => ''// provides a class.
     ,'essentials' => ''
     );
-
+	
     switch ($ia[4])
     {
         case 'X': //BOILERPLATE QUESTION
@@ -708,7 +715,7 @@
             if ($qidattributes['min_num_of_files'] != 0)
             {
                 if (trim($qidattributes['min_num_of_files']) != 0)
-                {
+                {                                         
                     $qtitle .= "<br />\n<span class = \"questionhelp\">"
                     .sprintf($clang->gT("At least %d files must be uploaded for this question"), $qidattributes['min_num_of_files'])."<span>";
                     $question_text['help'] .= ' '.sprintf($clang->gT("At least %d files must be uploaded for this question"), $qidattributes['min_num_of_files']);
@@ -791,10 +798,10 @@
 
     $qtitle .= validation_message($ia);
     $question_text['valid_message'] = validation_message($ia);
-
+    
     $qtitle .= $ia[4] == "|" ? file_validation_message($ia) : "";
     $question_text['file_valid_message'] = $ia[4] == "|" ? file_validation_message($ia) : "";
-
+    
     if(!empty($question_text['man_message']) || !empty($question_text['valid_message']) || !empty($question_text['file_valid_message']))
     {
         $question_text['input_error_class'] = ' input-error';// provides a class to style question wrapper differently if there is some kind of user input error;
@@ -1157,7 +1164,7 @@
 				}
 				answer.blur();
 				answer.onfocus=function() {answer.blur();};
-			}
+			}		
 		};
 	//-->
 	</script>";
@@ -1210,7 +1217,7 @@
 			subcookiejar.bake('limesurvey_timers', timeleftobject, 7)\n";
         if($disable_next > 0) {
             $output .= "
-		if(document.getElementById('movenextbtn') !== null && timeleft > $disable_next) {
+		if(document.getElementById('movenextbtn') !== null && timeleft > $disable_next) { 
 			document.getElementById('movenextbtn').disabled=true;
 		} else if (document.getElementById('movenextbtn') !== null && $disable_next > 1 && timeleft <= $disable_next) {
 		    document.getElementById('movenextbtn').disabled=false;
@@ -1218,7 +1225,7 @@
         }
         if($disable_prev > 0) {
             $output .= "
-		if(document.getElementById('moveprevbtn') !== null && timeleft > $disable_prev) {
+		if(document.getElementById('moveprevbtn') !== null && timeleft > $disable_prev) { 
 			document.getElementById('moveprevbtn').disabled=true;
 		} else if (document.getElementById('moveprevbtn') !== null && $disable_prev > 1 && timeleft <= $disable_prev) {
 		    document.getElementById('moveprevbtn').disabled=false;
@@ -1281,11 +1288,11 @@
 			  }
 			  warning2hide--;
 			}
-			var secs = timeleft % 60;
+			var secs = timeleft % 60; 
 			if (secs < 10) secs = '0'+secs;
 			var T1 = (timeleft - secs) / 60;
 			var mins = T1 % 60; if (mins < 10) mins = '0'+mins;
-			var hours = (T1 - mins) / 60;
+			var hours = (T1 - mins) / 60; 
 			if (hours < 10) hours = '0'+hours;
 			var d2hours='';
 			var d2mins='';
@@ -1385,7 +1392,7 @@
 			$filter_select = TRUE;
 		}
 	}
-
+	
 	if
     (isset($qidattributes['array_filter_exclude']) &&
 	(
@@ -1400,7 +1407,7 @@
     )
     {
         $selected = getArrayFilterExcludesForQuestion($ia[0]);
-        if (isset($ansrow['code'])) $ansrow['title'] = $ansrow['code'];
+        if (isset($ansrow['code'])) $ansrow['title'] = $ansrow['code'];  
         if (!empty($selected) && !in_array($ansrow['title'],$selected))
         {
 			$filter_select = TRUE;
@@ -1410,7 +1417,7 @@
 			$filter_select = FALSE;
 		}
 	}
-	return $filter_select;
+	return $filter_select; 
 }
 
 function return_array_filter_strings($ia, $qidattributes, $thissurvey, $ansrow, $rowname, $trbc='', $valuename, $method="tbody", $class=null) {
@@ -1554,7 +1561,7 @@
     )
     {
         $selected = getArrayFilterExcludesForQuestion($ia[0]);
-        if (isset($ansrow['code'])) $ansrow['title'] = $ansrow['code'];
+        if (isset($ansrow['code'])) $ansrow['title'] = $ansrow['code'];  
         if (!empty($selected) && !in_array($ansrow['title'],$selected))
         {
             $htmltbody2 = "\n\n\t<$method id='javatbd$rowname'>\n";
@@ -1625,8 +1632,8 @@
 // ---------------------------------------------------------------
 function do_5pointchoice($ia)
 {
-    global $clang, $imageurl;
-	global $js_header_includes, $css_header_includes;
+    global $clang;
+	global $js_header_includes, $css_header_includes;	
 
     if ($ia[8] == 'Y')
     {
@@ -1684,12 +1691,12 @@
     						$('#answer$ia[1]'+value).attr('checked','checked');
     					}
     				}
-
+    					
     			});
 			</script>
 			";
     }
-
+    
     if($qidattributes['slider_rating']==2){
 	    if(!IsSet($_SESSION[$ia[1]]) OR $_SESSION[$ia[1]]==''){
 	    	$value=1;
@@ -1699,12 +1706,12 @@
     	$answer.="
     		<div style=\"float:left;\">
     		<div style=\"text-align:center; margin-bottom:6px; width:370px;\"><div style=\"width:2%; float:left;\">1</div><div style=\"width:46%;float:left;\">2</div><div style=\"width:4%;float:left;\">3</div><div style=\"width:46%;float:left;\">4</div><div style=\"width:2%;float:left;\">5</div></div><br/>
-    	 	<div id=\"{$id}sliderBg\" style=\"background-image:url('{$imageurl}/sliderBg.png'); text-align:center; background-repeat:no-repeat; height:22px; width:396px;\">
+    	 	<div id=\"{$id}sliderBg\" style=\"background-image:url('./images/sliderBg.png'); text-align:center; background-repeat:no-repeat; height:22px; width:396px;\">
     	 	<center>
     		<div id=\"{$id}slider\" style=\"width:365px;\"></div>
     		</center>
     		</div></div>
-    	 	<div id=\"{$id}emoticon\" style=\"text-align:left; margin:10px; padding-left:10px;\"><img id=\"{$id}img1\" style=\"margin-left:10px;\" src=\".{$imageurl}/emoticons/{$value}.png\"/><img id=\"{$id}img2\" style=\"margin-left:-31px;margin-top:-31px;\" src=\"{$imageurl}/emoticons/{$value}.png\" /></div>
+    	 	<div id=\"{$id}emoticon\" style=\"text-align:left; margin:10px; padding-left:10px;\"><img id=\"{$id}img1\" style=\"margin-left:10px;\" src=\"./images/emoticons/{$value}.png\"/><img id=\"{$id}img2\" style=\"margin-left:-31px;margin-top:-31px;\" src=\"./images/emoticons/{$value}.png\" /></div>
 			<script type=\"text/javascript\">
 				$('#$id').hide();
 				var value=$value;
@@ -1720,7 +1727,7 @@
 				max: 5,
 				step: 1,
 				slide: function(event,ui){
-						$('#{$id}img2').attr('src','{$imageurl}/emoticons/'+ui.value+'.png');
+						$('#{$id}img2').attr('src','./images/emoticons/'+ui.value+'.png');
 						$('#{$id}img2').fadeIn(time);
 						$('#$id input').each(function(){ $(this).removeAttr('checked');});
     					$('#answer$ia[1]'+ui.value).attr('checked','checked');
@@ -1731,16 +1738,16 @@
     					});
     				}
 				});
-				$('#{$id}slider a').css('background-image', 'url(\'{$imageurl}/slider.png\')');
+				$('#{$id}slider a').css('background-image', 'url(\'./images/slider.png\')');
 				$('#{$id}slider a').css('width', '11px');
 				$('#{$id}slider a').css('height', '28px');
 				$('#{$id}slider a').css('border', 'none');
-				//$('#{$id}slider').css('background-image', 'url(\'{$imageurl}/sliderBg.png\')');
+				//$('#{$id}slider').css('background-image', 'url(\'./images/sliderBg.png\')');
 				$('#{$id}slider').css('visibility','hidden');
 				$('#{$id}slider a').css('visibility', 'visible');
 			</script>
 			";
-
+    
     }
     return array($answer, $inputnames);
 }
@@ -1753,6 +1760,7 @@
 {
     global $clang, $js_header_includes, $css_header_includes, $thissurvey;
     $qidattributes=getQuestionAttributes($ia[0],$ia[4]);
+    $js_header_includes[] = '/scripts/jquery/jquery-ui.js';
     $js_header_includes[] = '/scripts/jquery/lime-calendar.js';
 
 
@@ -1910,7 +1918,7 @@
     {
         if ($clang->langcode !== 'en')
         {
-        $js_header_includes[] = '/scripts/jquery/locale/jquery.ui.datepicker-'.$clang->langcode.'.js';
+        $js_header_includes[] = '/scripts/jquery/locale/ui.datepicker-'.$clang->langcode.'.js';
         }
         $css_header_includes[]= '/scripts/jquery/css/start/jquery-ui.css';
 
@@ -1949,9 +1957,9 @@
                         <input  type='hidden' name='dateformat{$ia[1]}' id='dateformat{$ia[1]}' value='{$dateformatdetails['jsdate']}'  />
                         <input  type='hidden' name='datelanguage{$ia[1]}' id='datelanguage{$ia[1]}' value='{$clang->langcode}'  />
                         <input  type='hidden' name='dateyearrange{$ia[1]}' id='dateyearrange{$ia[1]}' value='{$minyear}:{$maxyear}'  />
-
+                        
 			         </p>
-			         <p class=\"tip\">
+			         <p class=\"tip\">                      
 				         ".sprintf($clang->gT('Format: %s'),$dateformatdetails['dateformat'])."
 			         </p>";
     }
@@ -2019,7 +2027,7 @@
 
     if (trim($qidattributes['other_replace_text'])!='')
     {
-        $othertext=$qidattributes['other_replace_text'];
+        $othertext=$clang->gT($qidattributes['other_replace_text']);
     }
     else
     {
@@ -2059,10 +2067,10 @@
     $ansresult = db_execute_assoc($ansquery) or safe_die('Couldn\'t get answers<br />'.$ansquery.'<br />'.$connect->ErrorMsg());    //Checked
 
     if (!isset($optCategorySeparator))
-    {
+    {                                       
         while ($ansrow = $ansresult->FetchRow())
         {
-            $opt_select = '';
+            $opt_select = '';  
             if ($_SESSION[$ia[1]] == $ansrow['code'])
             {
                 $opt_select = SELECTED;
@@ -2310,7 +2318,7 @@
 
     if (trim($qidattributes['other_replace_text'])!='')
     {
-        $othertext=$qidattributes['other_replace_text'];
+        $othertext=$clang->gT($qidattributes['other_replace_text']);
     }
     else
     {
@@ -2644,7 +2652,7 @@
             {
                 $check_ans = '';
             }
-            $answer .= '<option value=""'.$check_ans.'>'.$clang->gT('No answer')."</option>\n";
+            $answer .= '<option value=""'.$check_ans.'>'.$clang->gT('No answer')."</option>\n"; 
         }
         $answer .= '	</select>
 </p>
@@ -2857,7 +2865,7 @@
     $answer .= "\t<td style=\"text-align:left; white-space:nowrap;\" class='rank output'>\n"
         . "\t<table border='0' cellspacing='1' cellpadding='0'>\n"
         . "\t<tr><td></td><td><strong>".$clang->gT("Your Ranking").":</strong></td></tr>\n";
-
+    
     $answer .= $ranklist
     . "\t</table>\n"
     . "\t</td>\n"
@@ -2920,10 +2928,10 @@
 
     // Find out if any questions have attributes which reference this questions
     // based on value of attribute. This could be array_filter and array_filter_exclude
-
+    
     $attribute_ref=false;
     $inputnames=array();
-
+    
     $qaquery = "SELECT qid,attribute FROM ".db_table_name('question_attributes')." WHERE value LIKE '".strtolower($ia[2])."' and (attribute='array_filter' or attribute='array_filter_exclude')";
     $qaresult = db_execute_assoc($qaquery);     //Checked
     while($qarow = $qaresult->FetchRow())
@@ -2932,10 +2940,10 @@
         $qresult = db_execute_assoc($qquery);     //Checked
         if ($qresult->RecordCount() > 0)
         {
-            $attribute_ref = true;
+            $attribute_ref = true;    
         }
     }
-
+      
     if ($ia[8] == 'Y' || $attribute_ref === true)
     {
         $checkconditionFunction = "checkconditions";
@@ -2949,7 +2957,7 @@
 
     if (trim($qidattributes['other_replace_text'])!='')
     {
-        $othertext=$qidattributes['other_replace_text'];
+        $othertext=$clang->gT($qidattributes['other_replace_text']);
     }
     else
     {
@@ -2983,7 +2991,7 @@
     $maxanswscript = '';
 
     $exclude_all_others_auto = trim($qidattributes["exclude_all_others_auto"]);
-
+    
     if ($exclude_all_others_auto=='1'){
         $autoArray['list'][]=$ia[1];
         $autoArray[$ia[1]]['parent'] = $ia[1];
@@ -3014,7 +3022,7 @@
         $maxanswscript = "\t<script type='text/javascript'>\n"
         . "\t<!--\n"
         . "function limitmaxansw_{$ia[0]}(me)\n"
-        . "{\n"
+        . "\t{\n"
         . "\tmax=$maxansw\n"
         . "\tcount=0;\n"
         . "\tif (max == 0) { return count; }\n";
@@ -3025,7 +3033,7 @@
     $minansw=0;
     $minanswscript = "";
 
-    if ((int)$qidattributes['min_answers']>0)
+    if ((int)$qidattributes['min_answers']>0) 
     {
         $minansw=trim($qidattributes["min_answers"]);
         $minanswscript = "<script type='text/javascript'>\n"
@@ -3059,7 +3067,7 @@
         $position=0;
         foreach ($ansresult as $answer)
         {
-            if ((trim($qidattributes['exclude_all_others']) != '')  &&    ($answer['title']==trim($qidattributes['exclude_all_others'])))
+            if ((trim($qidattributes['exclude_all_others']) != '')  &&    ($answer['title']==trim($qidattributes['exclude_all_others']))) 
             {
                 if ($position==$answer['question_order']-1) break; //already in the right position
                 $tmp  = array_splice($ansresult, $position, 1);
@@ -3090,7 +3098,7 @@
     $colcounter = 1;
     $startitem='';
     $postrow = '';
-    $trbc='';
+    $trbc='';         
     foreach ($ansresult as $ansrow)
     {
         $myfname = $ia[1].$ansrow['title'];
@@ -3166,6 +3174,7 @@
         .  $ansrow['question']
         .  "</label>\n";
 
+        // --> END NEW FEATURE - SAVE
 
         if ($maxansw > 0) {$maxanswscript .= "\tif (document.getElementById('answer".$myfname."').checked) { count += 1; }\n";}
         if ($minansw > 0) {$minanswscript .= "\tif (document.getElementById('answer".$myfname."').checked) { count += 1; }\n";}
@@ -3241,24 +3250,45 @@
         {
             $answer .= ' value="'.htmlspecialchars($_SESSION[$myfname],ENT_QUOTES).'"';
         }
-        $answer .= " onkeyup='$checkconditionFunction(this.value, this.name, this.type);if ($.trim($(\"#answer{$myfname}\").val())!=\"\" && !document.getElementById(\"answer{$myfname}cbox\").checked) {\$(\"#answer{$myfname}cbox\").attr(\"checked\",\"checked\");} $numbersonly ".$callmaxanswscriptcheckbox."' />";
-        $answer .= '<input type="hidden" name="java'.$myfname.'" id="java'.$myfname.'" value="';
+        $answer .= " onkeyup='$checkconditionFunction(this.value, this.name, this.type);'";
+        $answer .= " onkeypress='if ($.trim($(\"#answer{$myfname}\").val())!=\"\") {document.getElementById(\"answer{$myfname}cbox\").checked=true;}$numbersonly' ".$callmaxanswscriptother.' />
+		<input type="hidden" name="java'.$myfname.'" id="java'.$myfname.'" value="';
 
         if ($maxansw > 0)
         {
+            //
             // For multiplechoice question there is no DB field for the other Checkbox
+            // so in fact I need to assume that other_comment_mandatory is set to true
             // I've added a javascript which will warn a user if no other comment is given while the other checkbox is checked
             // For the maxanswer script, I will alert the participant
             // if the limit is reached when he checks the other cbox
             // even if the -other- input field is still empty
-            $maxanswscript .= "\tif (document.getElementById('answer".$myfname."cbox').checked ) { count += 1; }\n";
+            // This will be differetn for the minansw script
+            // ==> hence the 1==2
+            if (1==2 || $qidattributes['other_comment_mandatory']==1)
+            {
+                $maxanswscript .= "\tif (document.getElementById('answer".$myfname."').value != '' && document.getElementById('answer".$myfname."cbox').checked ) { count += 1; }\n";
+            }
+            else
+            {
+                $maxanswscript .= "\tif (document.getElementById('answer".$myfname."').value != '' || document.getElementById('answer".$myfname."cbox').checked ) { count += 1; }\n";
+            }
         }
         if ($minansw > 0)
         {
             //
             // For multiplechoice question there is no DB field for the other Checkbox
+            // so in fact I need to assume that other_comment_mandatory is set to true
             // We only count the -other- as valid if both the cbox and the other text is filled
-            $minanswscript .= "\tif (document.getElementById('answer".$myfname."').value != '' && document.getElementById('answer".$myfname."cbox').checked ) { count += 1; }\n";
+            // ==> hence the 1==1
+            if (1==1 || $qidattributes['other_comment_mandatory']==1)
+            {
+                $minanswscript .= "\tif (document.getElementById('answer".$myfname."').value != '' && document.getElementById('answer".$myfname."cbox').checked ) { count += 1; }\n";
+            }
+            else
+            {
+                $minanswscript .= "\tif (document.getElementById('answer".$myfname."').value != '' || document.getElementById('answer".$myfname."cbox').checked ) { count += 1; }\n";
+            }
         }
 
 
@@ -3289,22 +3319,21 @@
     $answer .= $wrapper['whole-end'];
     if ( $maxansw > 0 )
     {
-        $maxanswscript .= "
-        if (count > max)
-        {
-            alert('".sprintf($clang->gT("Please choose at most %d answers for question \"%s\"","js"), $maxansw, trim(javascript_escape(str_replace(array("\n", "\r"), "", $ia[3]),true,true)))."');
-            if (me.type == 'checkbox') {me.checked = false;}
-            if (me.type == 'text') {
-                me.value = '';
-                if (document.getElementById('answer'+me.name + 'cbox') ){
-                    document.getElementById('answer'+me.name + 'cbox').checked = false;
-                }
-            }
-            return max;
-        }
-}
-//-->
-</script>\n";
+        $maxanswscript .= "\tif (count > max)\n"
+        . "{\n"
+        . "alert('".sprintf($clang->gT("Please choose at most %d answer(s) for question \"%s\"","js"), $maxansw, trim(javascript_escape(str_replace(array("\n", "\r"), "", $ia[3]),true,true)))."');\n"
+        . "if (me.type == 'checkbox') {me.checked = false;}\n"
+        . "if (me.type == 'text') {\n"
+        . "\tme.value = '';\n"
+        . "\tif (document.getElementById(me.name + 'cbox') ){\n"
+        . " document.getElementById(me.name + 'cbox').checked = false;\n"
+        . "\t}\n"
+        . "}"
+        . "return max;\n"
+        . "}\n"
+        . "\t}\n"
+        . "\t//-->\n"
+        . "\t</script>\n";
         $answer = $maxanswscript . $answer;
     }
 
@@ -3362,14 +3391,14 @@
     if (count($excludeallothers)>0)
     {
         $excludeallotherscript .= "
-		    if (document.getElementById(value).checked)
-		    {
-		        $excludeallotherscripton
-		    }
-		    else
-		    {
-		        $excludeallotherscriptoff
-		    }
+		if (document.getElementById(value).checked)
+		{
+		$excludeallotherscripton
+		}
+		else
+		{
+		$excludeallotherscriptoff
+		}
 		}
 		//-->
 		</script>";
@@ -3397,10 +3426,10 @@
         $qresult = db_execute_assoc($qquery);     //Checked
         if ($qresult->RecordCount() > 0)
         {
-            $attribute_ref = true;
+            $attribute_ref = true;    
         }
     }
-
+    
     if ($ia[8] == 'Y' || $attribute_ref == true)
     {
         $checkconditionFunction = "checkconditions";
@@ -3425,7 +3454,7 @@
 
     if (trim($qidattributes['other_replace_text'])!='')
     {
-        $othertext=$qidattributes['other_replace_text'];
+        $othertext=$clang->gT($qidattributes['other_replace_text']);
     }
     else
     {
@@ -3467,18 +3496,13 @@
         ;
     }
 
-    $qquery = "SELECT other FROM {$dbprefix}questions
-               WHERE qid=".$ia[0]." AND language='".$_SESSION['s_lang']."' and parent_qid=0";
+    $qquery = "SELECT other FROM {$dbprefix}questions WHERE qid=".$ia[0]." AND language='".$_SESSION['s_lang']."' and parent_qid=0";
     $qresult = db_execute_assoc($qquery);     //Checked
     while ($qrow = $qresult->FetchRow()) {$other = $qrow['other'];}
     if ($qidattributes['random_order']==1) {
-        $ansquery = "SELECT * FROM {$dbprefix}questions
-                     WHERE parent_qid=$ia[0]  AND language='".$_SESSION['s_lang']."'
-                     ORDER BY ".db_random();
+        $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";
+        $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()*2;
@@ -3501,7 +3525,7 @@
         $myfname = $ia[1].$ansrow['title'];
         $trbc='';
         /* Check for array_filter */
-
+        
         list($htmltbody2, $hiddenfield)=return_array_filter_strings($ia, $qidattributes, $thissurvey, $ansrow, $myfname, $trbc, $myfname, "li");
 
         if($label_width < strlen(trim(strip_tags($ansrow['question']))))
@@ -3544,7 +3568,7 @@
         ."<input class='text' type='text' size='40' id='answer$myfname2' name='$myfname2' title='".$clang->gT("Make a comment on your choice here:")."' value='";
         if (isset($_SESSION[$myfname2])) {$answer_main .= htmlspecialchars($_SESSION[$myfname2],ENT_QUOTES);}
         // --> START NEW FEATURE - SAVE
-        $answer_main .= "'  onclick='cancelBubbleThis(event);' onkeyup='if (jQuery.trim($(\"#answer{$myfname2}\").val())!=\"\") { document.getElementById(\"answer{$myfname}\").checked=true;$checkconditionFunction(document.getElementById(\"answer{$myfname}\").value,\"$myfname\",\"checkbox\");}' onkeyup='".$callmaxanswscriptcheckbox2."(document.getElementById(\"answer{$myfname}\"))' />\n\t</label>\n</span>\n"
+        $answer_main .= "'  onclick='cancelBubbleThis(event);' onkeypress='if (jQuery.trim($(\"#answer{$myfname2}\").val())!=\"\") { document.getElementById(\"answer{$myfname}\").checked=true;$checkconditionFunction(document.getElementById(\"answer{$myfname}\").value,\"$myfname\",\"checkbox\");}' onkeyup='".$callmaxanswscriptcheckbox2."(document.getElementById(\"answer{$myfname}\"))' />\n\t</label>\n</span>\n"
 
         . "\t</li>\n";
         // --> END NEW FEATURE - SAVE
@@ -3613,7 +3637,7 @@
     {
         $maxanswscript .= "\tif (count > max)\n"
         . "{\n"
-        . "alert('".sprintf($clang->gT("Please choose at most %d answers for question \"%s\"","js"), $maxansw, trim(javascript_escape($ia[3],true,true)))."');\n"
+        . "alert('".sprintf($clang->gT("Please choose at most %d answer(s) for question \"%s\"","js"), $maxansw, trim(javascript_escape($ia[3],true,true)))."');\n"
         . "var commentname='answer'+me.name+'comment';\n"
         . "if (me.type == 'checkbox') {\n"
         . "\tme.checked = false;\n"
@@ -3704,7 +3728,7 @@
 
     // Fetch question attributes
     $_SESSION['fieldname'] = $ia[1];
-
+    
     // Basic uploader
   /*  $basic  = '<br /><br /><table border="0" cellpadding="10" cellspacing="10" align="center">'
                     .'<tr>';
@@ -3765,19 +3789,14 @@
         $scriptloc = 'uploader.php';
     }
 
-    $uploadbutton = "<h2><a id='upload_".$ia[1]."' class='upload' href='{$scriptloc}?sid={$surveyid}&amp;fieldname={$ia[1]}&amp;qid={$ia[0]}&amp;preview="
-    ."{$questgrppreview}&amp;show_title={$qidattributes['show_title']}&amp;show_comment={$qidattributes['show_comment']}&amp;pos=".($pos?1:0)."'>" .$clang->gT('Upload files'). "</a></h2><br /><br />";
+    $uploadbutton = "<h2><a id='upload_".$ia[1]."' class='upload' href='$scriptloc?sid=$surveyid&fieldname=".$ia[1]."&qid=".$ia[0]."&preview="
+    .$questgrppreview."&show_title=".$qidattributes['show_title']."&show_comment="
+    .$qidattributes['show_comment']."&pos=".($pos?1:0)."'>Upload files</a></h2><br /><br />";
 
-    $answer = "<script type='text/javascript'>
-        var translt = {
-             title: '" . $clang->gT('Upload your files') . "',
-             returnTxt: '" . $clang->gT('Return to survey') . "'
-            };
-    </script>\n";
     if ($pos)
-        $answer .= "<script type='text/javascript' src='../scripts/modaldialog.js'></script>";
+        $answer = "<script type='text/javascript' src='../scripts/modaldialog.js'></script>";
     else
-        $answer .= "<script type='text/javascript' src='scripts/modaldialog.js'></script>";
+        $answer = "<script type='text/javascript' src='scripts/modaldialog.js'></script>";
 
     // Modal dialog
     $answer .= $uploadbutton;
@@ -3786,25 +3805,15 @@
     $answer .= "<input type='hidden' id='".$ia[1]."_filecount' name='".$ia[1]."_filecount' value=";
 
     if (array_key_exists($ia[1]."_filecount", $_SESSION))
-    {
-        $tempval = $_SESSION[$ia[1]."_filecount"];
-        if (is_numeric($tempval))
-        {
-            $answer .= $tempval . " />";
-        }
-        else
-        {
-            $answer .= "0 />";
-        }
-    }
-    else {
+        $answer .= $_SESSION[$ia[1]."_filecount"]." />";
+    else
         $answer .= "0 />";
-    }
 
     $answer .= "<div id='".$ia[1]."_uploadedfiles'></div>";
 
+    //$answer .= '<br />Trouble uploading files? Try the <a href="#" onclick="showBasic()">Simple Uploader</a><div id="basic">'.$basic.'</div>';
+
     $answer .= '<script type="text/javascript">
-                    var surveyid = '.$surveyid.';
                     $(document).ready(function(){
                         var fieldname = "'.$ia[1].'";
                         var filecount = $("#"+fieldname+"_filecount").val();
@@ -3815,7 +3824,7 @@
                         displayUploadedFiles(json, filecount, fieldname, show_title, show_comment, pos);
                     });
                 </script>';
-
+    
     $answer .= '<script type="text/javascript">
                     $(".basic_'.$ia[1].'").change(function() {
                         var i;
@@ -3957,13 +3966,13 @@
         {
             //question attribute "display_rows" is set -> we need a textarea to be able to show several rows
             $drows=$qidattributes['display_rows'];
-
+             
             //extend maximum chars if this is set to short text default of 255
             if($maxsize == 255)
             {
                 $maxsize=65525;
             }
-
+             
             //some JS to check max possible input
             $answer = "<script type='text/javascript'>
                <!--
@@ -3988,7 +3997,7 @@
                 $answer_main .= "\t<li>\n"
                 . "<label for=\"answer$myfname\">{$ansrow['question']}</label>\n"
                 . "\t<span>\n".$prefix."\n".'
-				<textarea class="textarea '.$kpclass.'" name="'.$myfname.'" id="answer'.$myfname.'"
+				<textarea class="textarea '.$kpclass.'" name="'.$myfname.'" id="answer'.$myfname.'" 
 				rows="'.$drows.'" cols="'.$tiwidth.'" onkeyup="textLimit(\'answer'.$myfname.'\', '.$maxsize.'); '.$checkconditionFunction.'(this.value, this.name, this.type);" '.$numbersonly.'>';
 
                 if($label_width < strlen(trim(strip_tags($ansrow['question']))))
@@ -4037,7 +4046,7 @@
                 $fn++;
                 $inputnames[]=$myfname;
             }
-
+             
         }
     }
 
@@ -4297,7 +4306,7 @@
                 $sliderleft="<div class=\"slider_lefttext\">$sliderleft</div>";
                 $sliderright="<div class=\"slider_righttext\">$sliderright</div>";
             }
-
+             
             if ($slider_layout === false)
             {
                 $answer_main .= "\t<li>\n<label for=\"answer$myfname\">{$theanswer}</label>\n";
@@ -4318,8 +4327,8 @@
             {
                 $sSeperator = getRadixPointData($thissurvey['surveyls_numberformat']);
                 $sSeperator = $sSeperator['seperator'];
-
-
+                
+                
                 $answer_main .= "<span class=\"input\">\n\t".$prefix."\n\t<input class=\"text $kpclass\" type=\"text\" size=\"".$tiwidth.'" name="'.$myfname.'" id="answer'.$myfname.'" value="';
                 if (isset($_SESSION[$myfname]))
                 {
@@ -4345,6 +4354,7 @@
                     $slider_showmax='';
                 }
 
+                $js_header_includes[] = '/scripts/jquery/jquery-ui.js';
                 $js_header_includes[] = '/scripts/jquery/lime-slider.js';
 
                 if (isset($_SESSION[$myfname]) && $_SESSION[$myfname] != '')
@@ -4358,7 +4368,7 @@
                     $displaycallout_atstart=1;
                 }
                 elseif ($slider_middlestart != '')
-                {
+                { 
                     $slider_startvalue = $slider_middlestart;
                     $displaycallout_atstart=0;
                 }
@@ -4786,7 +4796,7 @@
             $strBuild .= "4";
         if ($qidattributes['location_postal'])
             $strBuild .= "5";
-
+        
         $currentLocation = $currentLatLong[0] . " " . $currentLatLong[1];
         $answer = "
         	<script type=\"text/javascript\">
@@ -4794,7 +4804,7 @@
         	</script>
             <p class=\"question\">
             <input type=\"hidden\" name=\"$ia[1]\" id=\"answer$ia[1]\" value=\"{$_SESSION[$ia[1]]}\">
-
+            
             <input class=\"text location\" type=\"text\" size=\"20\" name=\"$ia[1]_c\"
                 id=\"answer$ia[1]_c\" value=\"$currentLocation\"
                 onkeyup=\"$checkconditionFunction(this.value, this.name, this.type)\" />
@@ -4810,7 +4820,7 @@
             $js_header_includes[] = "http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key={$googleMapsAPIKey}";
         elseif ($qidattributes['location_mapservice']==2)
             $js_header_includes[] = "http://www.openlayers.org/api/OpenLayers.js";
-
+            
 	    if (isset($qidattributes['hide_tip']) && $qidattributes['hide_tip']==0)
             {
                 $answer .= "<br />\n<span class=\"questionhelp\">"
@@ -5538,12 +5548,12 @@
                 $answertext = "<span class='errormandatory'>{$answertext}</span>";
             }
             $trbc = alternation($trbc , 'row');
-
+             
             // Get array_filter stuff
             list($htmltbody2, $hiddenfield)=return_array_filter_strings($ia, $qidattributes, $thissurvey, $ansrow, $myfname, $trbc, $myfname);
 
             $answer_t_content .= $htmltbody2;
-
+             
             $answer_t_content .= "<tr class=\"$trbc\">\n"
             . "\t<th class=\"answertext\">\n"
             . $hiddenfield
@@ -5814,7 +5824,7 @@
    {
        $useDropdownLayout = false;
    }
-
+   
     $lresult = db_execute_assoc($lquery);   //Checked
     if ($useDropdownLayout === false && $lresult->RecordCount() > 0)
     {
@@ -5915,7 +5925,7 @@
 				$fn++;
 			}
 			$answer .= $htmltbody2;
-
+             
             $answer .= "<tr class=\"$trbc\">\n"
             . "\t<th class=\"answertext\">\n$answertext"
             . $hiddenfield
@@ -5967,7 +5977,7 @@
                 $answer .= " onclick=\"$checkconditionFunction(this.value, this.name, this.type)\"  />\n</label>\n\t</td>\n";
                 // --> END NEW FEATURE - SAVE
             }
-
+             
             $answer .= "</tr>\n";
             $inputnames[]=$myfname;
             //IF a MULTIPLE of flexi-redisplay figure, repeat the headings
@@ -6003,7 +6013,7 @@
                            '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;}
+       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();
@@ -6055,7 +6065,7 @@
            // 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
@@ -6065,7 +6075,7 @@
                $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";
 
@@ -6094,8 +6104,8 @@
                $answer .= '>'.$clang->gT('No answer')."</option>\n";
            }
            $answer .= "</select>\n";
-
-           if (strpos($answertextsave,'|'))
+               
+           if (strpos($answertextsave,'|')) 
            {
                $answertext=substr($answertextsave,strpos($answertextsave,'|')+1);
                $answer .= "\t<th class=\"answertextright\">$answertext</th>\n";
@@ -6104,7 +6114,7 @@
            {
                $answer .= "\t<td class=\"answertextright\">&nbsp;</td>\n";
            }
-
+           
            $answer .= "</tr>\n</tbody>";
            $inputnames[]=$myfname;
            //IF a MULTIPLE of flexi-redisplay figure, repeat the headings
@@ -6662,12 +6672,12 @@
                     $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;
-
+             
             if (strpos($answertext,'|')) {$answertext=substr($answertext,0, strpos($answertext,'|'));}
 
             $trbc = alternation($trbc , 'row');
@@ -6701,7 +6711,7 @@
                     $answer .= "\t<td class=\"answer_cell_00$ld\">\n"
                     . "<label for=\"answer{$myfname2}\">\n"
                     . "\t<input type=\"hidden\" name=\"java{$myfname2}\" id=\"java{$myfname2}\" $myfname2_java_value />\n";
-
+                     
                     if($inputboxlayout == false) {
                         $answer .= "\t<select class=\"multiflexiselect\" name=\"$myfname2\" id=\"answer{$myfname2}\" title=\""
                         . html_escape($labelans[$thiskey]).'"'
@@ -6731,7 +6741,7 @@
                     }
                     $answer .= "</label>\n"
                     . "\t</td>\n";
-
+                     
                     $inputnames[]=$myfname2;
                     $thiskey++;
                 }
@@ -7109,7 +7119,7 @@
                 $odd_even = alternation($odd_even);
                 $mycolumns .= "<col class=\"$odd_even\" width=\"$cellwidth%\" />\n";
             }
-
+             
         }
         if ($right_exists)
         {
@@ -7310,7 +7320,7 @@
                 . "\t</td>\n";
                 // --> END NEW FEATURE - SAVE
             }
-
+             
             $answer .= "</tr>\n";
         	$answer .= "\t</tbody>\n";
             // $inputnames[]=$myfname;
@@ -7602,6 +7612,6 @@
     } //while
     return $text;
 }
+      
 
-
-// Closing PHP tag intentionally left out - yes, it is okay
+// Closing PHP tag intentionally left out - yes, it is okay       
inverse_diff_10625-10028.diff (39,517 bytes)   
Bug heat6
Complete LimeSurvey version number (& build)0
I will donate to the project if issue is resolvedYes
Browsersafari
Database type & version0
Server OS (if known)your demo server
Webserver software & version (if known)0
PHP Version0
Git branch / Pull Request URL

Users monitoring this issue

There are no users monitoring this issue.

Activities

user15197

2011-08-10 18:02

  ~16007

I guess there are some " and . missing in quanda.php, lines 3293 to 3307

user15197

2011-08-10 19:07

  ~16008

after installing on my own server i could not reproduce the problem, the pop up gets triggered properly. so this is a snafu on your demo installation ... somewhat unhandy, but hey ...

user15197

2011-08-10 19:15

  ~16009

the install (through Installatron from my hosting provider) is Ver. 1.91 build 10030

quanda.php looks correct there ... so I guess this is a bug and you'd want to fix it rather sooner than later (I'm not going to change my install for the time being as it is working, however, I'll attach a diff of the two quanda.php

DenisChenu

DenisChenu

2011-08-11 16:34

developer   ~16019

Last edited: 2011-08-11 16:44

You have javascript deactivated ?

IF javascript are activated, then you can't select more than X answer.

Same for Min answer too.

Without javascript : no control :)

And please :send the complete file ;)

user15197

2011-08-11 17:58

  ~16021

@shnoulle: if you had read my notes properly you should have noticed that this is not a client/javscript issue :P

(a) min works on the demo when max does not work
(b) min & max works on the 1.91 build 10030 with the same client

so either your demo server is serving rubbish or there is a bug in 1.91+

DenisChenu

DenisChenu

2011-08-11 18:18

developer   ~16024

Last edited: 2011-08-11 18:35

Ho sorry, i only test with the last version, never on the demo

Last version is 10670

:)

I confirm it work on Build 10670 :).
I don't know the number of demo version ;)

user15197

2011-08-11 18:36

  ~16029

so you think it's safe to upgrade to latest version?

user15197

2011-08-11 20:43

  ~16036

did an upgrade (which did not proceed from step 3 to step 4 for whatever reasons ...) and can confirm that the min/max thingy works there OK

so this has to do with a fishy demo install which you might want to fix when practicable

DenisChenu

DenisChenu

2011-08-12 10:04

developer   ~16039

Send to Carsten : update demo.limesurvey.org ;).

c_schmitz

c_schmitz

2011-08-15 16:59

administrator   ~16059

Demo updated.

Issue History

Date Modified Username Field Change
2011-08-10 17:31 user15197 New Issue
2011-08-10 18:02 user15197 Note Added: 16007
2011-08-10 19:07 user15197 Note Added: 16008
2011-08-10 19:15 user15197 Note Added: 16009
2011-08-10 19:18 user15197 File Added: inverse_diff_10625-10028.diff
2011-08-10 19:18 user15197 Issue Monitored: user15197
2011-08-11 16:29 DenisChenu Assigned To => DenisChenu
2011-08-11 16:29 DenisChenu Status new => assigned
2011-08-11 16:34 DenisChenu Note Added: 16019
2011-08-11 16:44 DenisChenu Note Edited: 16019
2011-08-11 17:58 user15197 Note Added: 16021
2011-08-11 18:18 DenisChenu Note Added: 16024
2011-08-11 18:32 DenisChenu Note Edited: 16024
2011-08-11 18:35 DenisChenu Note Edited: 16024
2011-08-11 18:36 user15197 Note Added: 16029
2011-08-11 20:43 user15197 Note Added: 16036
2011-08-12 10:04 DenisChenu Assigned To DenisChenu => c_schmitz
2011-08-12 10:04 DenisChenu Note Added: 16039
2011-08-12 10:05 DenisChenu Priority normal => low
2011-08-12 10:05 DenisChenu Category Survey taking => LimeSurvey Website
2011-08-12 10:05 DenisChenu Summary Max. number of answers with multiple choice question not checked => Max. number of answers with multiple choice question not checked in demo.limesurvey.org
2011-08-15 16:59 c_schmitz Note Added: 16059
2011-08-15 16:59 c_schmitz Status assigned => closed
2011-08-15 16:59 c_schmitz Resolution open => fixed