Skip to content

Commit

Permalink
Port some more switch statements from em_manager_helper - still a lon…
Browse files Browse the repository at this point in the history
…g ways to go.
  • Loading branch information
aaronschmitz committed Jul 31, 2012
1 parent 73b1512 commit a4c432d
Show file tree
Hide file tree
Showing 32 changed files with 587 additions and 414 deletions.
271 changes: 45 additions & 226 deletions application/helpers/expressions/em_manager_helper.php

Large diffs are not rendered by default.

32 changes: 31 additions & 1 deletion application/modules/ArrayQuestion.php
Expand Up @@ -2,7 +2,7 @@
abstract class ArrayQuestion extends QuestionModule
{
protected $children;

protected function getChildren()
{
if ($this->children) return $this->children;
Expand Down Expand Up @@ -53,5 +53,35 @@ public function createFieldmap($type=null)
}
return $map;
}

public function jsVarNameOn()
{
return 'java'.$this->fieldname;
}

public function getCsuffix()
{
return $this->aid;
}

public function getSqsuffix()
{
return '_' . $this->aid;
}

public function getVarName()
{
return $this->title . '_' . $this->aid;
}

public function getQuestion()
{
return $this->sq;
}

public function getRowDivID()
{
return $this->fieldname;
}
}
?>
68 changes: 52 additions & 16 deletions application/modules/CheckQuestion.php
Expand Up @@ -276,7 +276,7 @@ protected function getChildren()
$ansquery = "SELECT * FROM {{questions}} WHERE parent_qid=$this->id AND scale_id=0 AND language='".$_SESSION['survey_'.$this->surveyid]['s_lang']."' ORDER BY question_order";
}
$ansresult = dbExecuteAssoc($ansquery)->readAll(); //Checked

if (trim($aQuestionAttributes['exclude_all_others'])!='' && $aQuestionAttributes['random_order']==1)
{
//if exclude_all_others is set then the related answer should keep its position at all times
Expand All @@ -296,7 +296,7 @@ protected function getChildren()
}
return $this->children = $ansresult;
}

protected function getOther()
{
if ($this->other) return $this->other;
Expand All @@ -320,7 +320,7 @@ public function getTitle()
}
return $this->text;
}

public function getHelp()
{
$clang=Yii::app()->lang;
Expand All @@ -336,7 +336,7 @@ public function getHelp()
}
return '';
}

public function createFieldmap($type=null)
{
$clang = Yii::app()->lang;
Expand Down Expand Up @@ -399,21 +399,21 @@ public function createFieldmap($type=null)
$other['q']=$q;
$map[$other['fieldname']]=$other;
}

return $map;
}

public function getExtendedAnswer($value, $language)
{
if($value=="Y") return $language->gT("Yes")." [$value]";
return $value;
}

public function getQuotaValue($value)
{
return array($this->surveyid.'X'.$this->gid.'X'.$this->id.$value => 'Y');
}

public function setAssessment()
{
if (isset($_SESSION['survey_'.$this->surveyid][$this->fieldname]) && $_SESSION['survey_'.$this->surveyid][$this->fieldname] == "Y")
Expand All @@ -425,7 +425,7 @@ public function setAssessment()
}
return true;
}

public function getDBField()
{
if ($this->aid != 'other' && strpos($this->aid,'comment')===false && strpos($this->aid,'othercomment')===false)
Expand All @@ -437,7 +437,7 @@ public function getDBField()
return "text";
}
}

public function prepareConditions($row)
{
if (preg_match("/^\+(.*)$/",$row['cfieldname'],$cfieldnamematch))
Expand All @@ -450,7 +450,7 @@ public function prepareConditions($row)
"subqid"=>$cfieldnamematch[1].'NAOK'
);
}

return array("cfieldname"=>$rows['cfieldname'].$rows['value'],
"value"=>$row['value'],
"matchfield"=>$row['cfieldname'],
Expand All @@ -474,7 +474,7 @@ public function transformResponseValue($export, $value, $options)
}
return parent::transformResponseValue($export, $value, $options);
}

public function getFullAnswer($answerCode, $export, $survey)
{
if (mb_substr($this->fieldname, -5, 5) == 'other' || mb_substr($this->fieldname, -7, 7) == 'comment')
Expand All @@ -497,7 +497,7 @@ public function getFullAnswer($answerCode, $export, $survey)
}
}
}

public function getFieldSubHeading($survey, $export, $code)
{
//This section creates differing output from the old code base, but I do think
Expand Down Expand Up @@ -538,15 +538,15 @@ public function getFieldSubHeading($survey, $export, $code)
return ' '.$export->getCommentSubHeading();
}
}

public function getSPSSAnswers()
{
if ($this->aid == 'other' || strpos($this->aid,'comment') !== false) return array();
$answers[] = array('code'=>1, 'value'=>$clang->gT('Yes'));
$answers[] = array('code'=>0, 'value'=>$clang->gT('Not Selected'));
return $answers;
}

public function getSPSSData($data, $iLength, $na)
{
if ($this->aid == 'other' || strpos($this->aid,'comment') !== false)
Expand All @@ -558,7 +558,43 @@ public function getSPSSData($data, $iLength, $na)
return "'0'";
}
}


public function jsVarNameOn()
{
return 'java'.$this->fieldname;
}

public function onlyNumeric()
{
$attributes = $this->getAttributeValues();
return array_key_exists('other_numbers_only', $attributes) && $attributes['numbers_only'] == 1 && preg_match('/other$/',$this->fieldname);
}

public function getCsuffix()
{
return $this->aid;
}

public function getSqsuffix()
{
return '_' . $this->aid;
}

public function getVarName()
{
return $this->title . '_' . $this->aid;
}

public function getQuestion()
{
return $this->sq;
}

public function getRowDivID()
{
return $this->fieldname;
}

public function availableAttributes($attr = false)
{
$attrs=array("array_filter","array_filter_exclude","array_filter_style","assessment_value","display_columns","em_validation_q","em_validation_q_tip","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
12 changes: 11 additions & 1 deletion application/modules/ColumnRadioArrayQuestion.php
Expand Up @@ -139,7 +139,17 @@ public function getAnswerHTML()
//public function getDataEntry($idrow, $fnames, $language) - inherited

//public function getInputNames() - inherited


public function getSqsuffix()
{
return '';
}

public function getRowDivID()
{
return null;
}

public function availableAttributes($attr = false)
{
$attrs=array("statistics_showgraph","statistics_graphtype","hide_tip","hidden","page_break","public_statistics","random_order","parent_order","scale_export","random_group");
Expand Down
42 changes: 37 additions & 5 deletions application/modules/CommentCheckQuestion.php
Expand Up @@ -64,7 +64,7 @@ public function getAnswerHTML()
$answer_main = '';

$fn = 1;

if($this->getOther() == 'Y')
{
$label_width = 25;
Expand Down Expand Up @@ -207,9 +207,9 @@ public function getDataEntry($idrow, &$fnames, $language)
}

//public function getTitle() - inherited

//public function getHelp() - inherited

public function createFieldmap($type=null)
{
$clang = Yii::app()->lang;
Expand Down Expand Up @@ -238,12 +238,44 @@ public function createFieldmap($type=null)
}
return $map;
}

public function getQuotaValue($value)
{
return false;
}


public function jsVarNameOn()
{
if (preg_match("/(other|comment)$/",$this->fieldname))
{
return 'answer' . $this->fieldname;
}
else
{
return $jsVarName;
}
}

public function getSqsuffix()
{
if (preg_match("/comment$/", $q->fieldname))
{
return '';
} else {
return '_' . $this->aid;
}
}

public function getRowDivID()
{
if (preg_match("/comment$/", $q->fieldname))
{
return null;
} else {
return $this->fieldname;
}
}

public function availableAttributes($attr = false)
{
$attrs=array("array_filter","array_filter_exclude","array_filter_style","assessment_value","em_validation_q","em_validation_q_tip","exclude_all_others","exclude_all_others_auto","statistics_showgraph","hide_tip","hidden","max_answers","min_answers","other_comment_mandatory","other_numbers_only","other_replace_text","page_break","public_statistics","random_order","parent_order","scale_export","random_group");
Expand Down
24 changes: 18 additions & 6 deletions application/modules/CommentListQuestion.php
Expand Up @@ -184,11 +184,11 @@ public function getDataEntry($idrow, &$fnames, $language)
.htmlspecialchars($idrow[$q->fieldname]) . "</textarea>\n";
return $output;
}

//public function getTitle() - inherited

//public function getHelp() - inherited

public function createFieldmap($type=null)
{
$clang = Yii::app()->lang;
Expand All @@ -206,7 +206,7 @@ public function createFieldmap($type=null)
$map[$comment['fieldname']]=$comment;
return $map;
}

public function getFullAnswer($answerCode, $export, $survey)
{
$answers = $survey->getAnswers($this->id);
Expand All @@ -221,7 +221,7 @@ public function getFullAnswer($answerCode, $export, $survey)
return $answerCode;
}
}

public function getFieldSubHeading($survey, $export, $code)
{
if ($this->aid == 'comment')
Expand All @@ -230,7 +230,19 @@ public function getFieldSubHeading($survey, $export, $code)
}
return '';
}


public function jsVarNameOn()
{
if ($this->aid == 'comment')
{
return 'answer' . $this->fieldname;
}
else
{
return 'java' . $this->fieldname;
}
}

public function availableAttributes($attr = false)
{
$attrs=array("alphasort","statistics_showgraph","statistics_graphtype","hide_tip","hidden","page_break","public_statistics","random_order","parent_order","use_dropdown","scale_export","random_group");
Expand Down
8 changes: 4 additions & 4 deletions application/modules/DateQuestion.php
Expand Up @@ -274,24 +274,24 @@ public function filter($value, $type)
return $datetimeobj->convert("Y-m-d H:i:s");
}
}

public function getExtendedAnswer($value, $language)
{
$qidattributes = getQuestionAttributeValues($this->id);
$dateformatdetails = getDateFormatDataForQID($qidattributes, $this->surveyid);
return convertDateTimeFormat($value,"Y-m-d H:i:s",$dateformatdetails['phpdate']);
}

public function loadAnswer($value)
{
return $value==null?'':$value;
}

public function getDBField()
{
return 'datetime';
}

public function availableAttributes($attr = false)
{
$attrs=array("dropdown_dates","dropdown_dates_year_min","dropdown_dates_year_max","statistics_showgraph","statistics_graphtype","hide_tip","hidden","reverse","page_break","date_format","dropdown_dates_minute_step","dropdown_dates_month_style","random_group");
Expand Down

0 comments on commit a4c432d

Please sign in to comment.