diff --git a/application/controllers/admin/browse.php b/application/controllers/admin/browse.php index 443d15ed813..49c11d8b191 100644 --- a/application/controllers/admin/browse.php +++ b/application/controllers/admin/browse.php @@ -136,13 +136,12 @@ public function view($iSurveyId, $iId, $sBrowseLang = '') foreach ($fieldmap as $field) { - if ($field['fieldname'] == 'lastpage' || $field['fieldname'] == 'submitdate') - continue; - if ($field['type'] == 'interview_time') - continue; - if ($field['type'] == 'page_time') - continue; - if ($field['type'] == 'answer_time') + $q = $field['q']; + if ($q->fieldname == 'lastpage' || + $q->fieldname == 'submitdate' || + $q->fieldname == 'interview_time' || + $q->fieldname == 'page_time' || + $q->fieldname == 'answer_time') continue; $question = $field['question']; diff --git a/application/helpers/SurveyRuntimeHelper.php b/application/helpers/SurveyRuntimeHelper.php index e9cc8188e31..979a4244588 100644 --- a/application/helpers/SurveyRuntimeHelper.php +++ b/application/helpers/SurveyRuntimeHelper.php @@ -928,12 +928,12 @@ function checkconditions(value, name, type, evt_type) } $n_q_display = ''; - if ($qinfo['hidden'] && $qinfo['info']['type'] != '*') + if ($qinfo['hidden'] && $qinfo['info']['type'] != '*') //AJS { continue; // skip this one } - if (!$qinfo['relevant'] || ($qinfo['hidden'] && $qinfo['info']['type'] == '*')) + if (!$qinfo['relevant'] || ($qinfo['hidden'] && $qinfo['info']['type'] == '*')) //AJS { $n_q_display = ' style="display: none;"'; } diff --git a/application/helpers/frontend_helper.php b/application/helpers/frontend_helper.php index 818b5a65f8c..955ee1efbff 100644 --- a/application/helpers/frontend_helper.php +++ b/application/helpers/frontend_helper.php @@ -324,9 +324,10 @@ function checkconfield($value) $scenario = $scenariorow['scenario']; $currentcfield=""; - $query = "SELECT {{conditions}}.*, {{questions}}.type " + $query = "SELECT {{conditions}}.*, {{question_types}}.clas " . "FROM {{conditions}}, {{questions}} " . "WHERE {{conditions}}.cqid={{questions}}.qid " + . "AND {{questions}}.tid={{question_types}}.tid " . "AND {{conditions}}.qid=$value_question->id " . "AND {{conditions}}.scenario=$scenario " . "AND {{conditions}}.cfieldname NOT LIKE '{%' " @@ -334,7 +335,7 @@ function checkconfield($value) $result=dbExecuteAssoc($query) or safeDie($query."
"); //Checked $conditionsfound = $result->count(); - $querytoken = "SELECT {{conditions}}.*, '' as type " + $querytoken = "SELECT {{conditions}}.*, 'Display' as class " . "FROM {{conditions}} " . "WHERE " . " {{conditions}}.qid=$value_question->id " @@ -357,36 +358,14 @@ function checkconfield($value) foreach ($aAllCondrows as $rows) { - if (preg_match("/^\+(.*)$/",$rows['cfieldname'],$cfieldnamematch)) - { // this condition uses a single checkbox as source - $rows['type'] = "+".$rows['type']; - $rows['cfieldname'] = $cfieldnamematch[1]; - } - - if($rows['type'] == "M" || $rows['type'] == "P") - { - $matchfield=$rows['cfieldname'].$rows['value']; - $matchmethod=$rows['method']; - $matchvalue="Y"; - } - else - { - $matchfield=$rows['cfieldname']; - $matchmethod=$rows['method']; - $matchvalue=$rows['value']; - } - $cqval[]=array("cfieldname"=>$rows['cfieldname'], - "value"=>$rows['value'], - "type"=>$rows['type'], - "matchfield"=>$matchfield, - "matchvalue"=>$matchvalue, - "matchmethod"=>$matchmethod - ); - if ($rows['cfieldname'] != $currentcfield) + $q = createQuestion($rows['class']); + $val = $q->prepareConditions(); + $cqval[]=$val; + if ($val['cfieldname'] != $currentcfield) { - $container[]=$rows['cfieldname']; + $container[]=$val['cfieldname']; } - $currentcfield=$rows['cfieldname']; + $currentcfield=$val['cfieldname']; } if ($conditionsfound > 0) { @@ -2000,7 +1979,7 @@ function buildsurveysession($surveyid,$previewGroup=false) // Fix totalquestions by substracting Test Display questions $iNumberofQuestions=dbExecuteAssoc("SELECT count(*)\n" ." FROM {{questions}}" - ." WHERE type in ('X','*')\n" + ." WHERE tid in (15,22)\n" //AJS Not sure how to do this. ." AND sid={$surveyid}" ." AND language='".$_SESSION['survey_'.$surveyid]['s_lang']."'" ." AND parent_qid=0")->read(); diff --git a/application/modules/CheckQuestion.php b/application/modules/CheckQuestion.php index 0129b1a400f..901af5354c8 100644 --- a/application/modules/CheckQuestion.php +++ b/application/modules/CheckQuestion.php @@ -424,6 +424,26 @@ public function setAssessment() return true; } + public function prepareConditions($row) + { + if (preg_match("/^\+(.*)$/",$row['cfieldname'],$cfieldnamematch)) + { // this condition uses a single checkbox as source + return array("cfieldname"=>$cfieldnamematch[1], + "value"=>$row['value'], + "matchfield"=>$row['cfieldname'], + "matchvalue"=>$row['value'], + "matchmethod"=>$row['method'] + ); + } + + return array("cfieldname"=>$rows['cfieldname'].$rows['value'], + "value"=>$row['value'], + "matchfield"=>$row['cfieldname'], + "matchvalue"=>"Y", + "matchmethod"=>$row['method'] + ); + } + public function availableAttributes($attr = false) { $attrs=array("array_filter","array_filter_exclude","array_filter_style","assessment_value","display_columns","exclude_all_others","exclude_all_others_auto","statistics_showgraph","hide_tip","hidden","max_answers","min_answers","other_numbers_only","other_replace_text","page_break","public_statistics","random_order","parent_order","scale_export","random_group"); diff --git a/application/modules/QuestionModule.php b/application/modules/QuestionModule.php index 9fdb8328afc..67d825751d2 100644 --- a/application/modules/QuestionModule.php +++ b/application/modules/QuestionModule.php @@ -206,6 +206,21 @@ public function setAssessment() return false; } + public function prepareConditions($row) + { + if (preg_match("/^\+(.*)$/",$row['cfieldname'],$cfieldnamematch)) + { // this condition uses a single checkbox as source + $row['cfieldname'] = $cfieldnamematch[1]; + } + + return array("cfieldname"=>$row['cfieldname'], + "value"=>$row['value'], + "matchfield"=>$row['cfieldname'], + "matchvalue"=>$row['value'], + "matchmethod"=>$row['method'] + ); + } + abstract public function availableAttributes($attr = false); abstract public function questionProperties($prop = false); }