Skip to content

Commit

Permalink
frontend_helper is now clear of old types.
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronschmitz committed Jun 23, 2012
1 parent d673c68 commit 5d93eb5
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 40 deletions.
13 changes: 6 additions & 7 deletions application/controllers/admin/browse.php
Expand Up @@ -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'];
Expand Down
4 changes: 2 additions & 2 deletions application/helpers/SurveyRuntimeHelper.php
Expand Up @@ -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;"';
}
Expand Down
41 changes: 10 additions & 31 deletions application/helpers/frontend_helper.php
Expand Up @@ -324,17 +324,18 @@ 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 '{%' "
. "ORDER BY {{conditions}}.qid,{{conditions}}.cfieldname";
$result=dbExecuteAssoc($query) or safeDie($query."<br />"); //Checked
$conditionsfound = $result->count();

$querytoken = "SELECT {{conditions}}.*, '' as type "
$querytoken = "SELECT {{conditions}}.*, 'Display' as class "
. "FROM {{conditions}} "
. "WHERE "
. " {{conditions}}.qid=$value_question->id "
Expand All @@ -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)
{
Expand Down Expand Up @@ -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();
Expand Down
20 changes: 20 additions & 0 deletions application/modules/CheckQuestion.php
Expand Up @@ -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");
Expand Down
15 changes: 15 additions & 0 deletions application/modules/QuestionModule.php
Expand Up @@ -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);
}
Expand Down

0 comments on commit 5d93eb5

Please sign in to comment.