Skip to content

Commit

Permalink
Port the CreateFieldMap function to the question objects.
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronschmitz committed Jun 4, 2012
1 parent e93b5af commit eb12ae0
Show file tree
Hide file tree
Showing 15 changed files with 595 additions and 447 deletions.
529 changes: 88 additions & 441 deletions application/helpers/common_helper.php

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions application/modules/ArrayQuestion.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,41 @@ protected function getChildren()
}
return $this->children = dbExecuteAssoc($ansquery)->readAll(); //Checked
}

public function createFieldmap($type=null)
{
$map = array();
$abrows = getSubQuestions($this);
foreach ($abrows as $abrow)
{
$fieldname="{$this->surveyid}X{$this->gid}X{$this->id}{$abrow['title']}";
$field['fieldname']=$fieldname;
$field['type']=$type;
$field['sid']=$this->surveyid;
$field['gid']=$this->gid;
$field['qid']=$this->id;
$field['aid']=$abrow['title'];
$field['sqid']=$abrow['qid'];
$field['title']=$this->title;
$field['question']=$this->text;
$field['subquestion']=$abrow['question'];
$field['group_name']=$this->groupname;
$field['mandatory']=$this->mandatory;
$field['hasconditions']=$this->conditionsexist;
$field['usedinconditions']=$this->usedinconditions;
$field['questionSeq']=$this->questioncount;
$field['groupSeq']=$this->randomgid;
$field['preg']=$this->preg;
if(isset($this->default[$abrow['qid']])) $field['defaultvalue']=$this->default[$abrow['qid']];
$field['pq']=$this;
$q = clone $this;
$q->fieldname = $fieldname;
$q->aid=$field['aid'];
$q->question=$abrow['question'];
$field['q']=$q;
$map[$fieldname]=$field;
}
return $map;
}
}
?>
57 changes: 56 additions & 1 deletion application/modules/CheckQuestion.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
class CheckQuestion extends QuestionModule
{
protected $children;
protected $other;
public function getAnswerHTML()
{
global $thissurvey;
Expand Down Expand Up @@ -348,6 +347,62 @@ public function getHelp()
return '';
}

public function createFieldmap($type=null)
{
$clang = Yii::app()->lang;
$map = array();
$abrows = getSubQuestions($this);
foreach ($abrows as $abrow)
{
$fieldname="{$this->surveyid}X{$this->gid}X{$this->id}{$abrow['title']}";
$field['fieldname']=$fieldname;
$field['type']=$type;
$field['sid']=$this->surveyid;
$field['gid']=$this->gid;
$field['qid']=$this->id;
$field['aid']=$abrow['title'];
$field['sqid']=$abrow['qid'];
$field['title']=$this->title;
$field['question']=$this->text;
$field['subquestion']=$abrow['question'];
$field['group_name']=$this->groupname;
$field['mandatory']=$this->mandatory;
$field['hasconditions']=$this->conditionsexist;
$field['usedinconditions']=$this->usedinconditions;
$field['questionSeq']=$this->questioncount;
$field['groupSeq']=$this->randomgid;
$field['preg']=$this->preg;
if(isset($this->default[$abrow['qid']])) $field['defaultvalue']=$this->default[$abrow['qid']];
$field['pq']=$this;
$q = clone $this;
$q->fieldname = $fieldname;
$q->aid=$field['aid'];
$q->question=$abrow['question'];
$field['q']=$q;
$map[$fieldname]=$field;
}
if ($this->other=='Y')
{
$other = parent::createFieldmap($type);
$other = $other[$this->fieldname];
$other['fieldname'].='other';
$other['aid']='other';
$other['subquestion']=$clang->gT("Other");
$other['other']=$this->other;
if (isset($this->default['other'])) $other['defaultvalue']=$this->default['other'];
else unset($other['defaultvalues']);
$q = clone $this;
$q->fieldname .= 'other';
$q->aid = 'other';
$q->default = isset($other['defaultvalues'])?$other['defaultvalues']:null;
$other['q']=$q;
$other['pq']=$this;
$map[$other['fieldname']]=$other;
}

return $map;
}

public function availableAttributes($attr = false)
{
$attrs=array("array_filter","array_filter_exclude","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
27 changes: 27 additions & 0 deletions application/modules/CommentCheckQuestion.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,33 @@ public function getAnswerHTML()

//public function getHelp() - inherited

public function createFieldmap($type=null)
{
$clang = Yii::app()->lang;
$map = array();
$tmp = parent::createFieldmap($type);
foreach($tmp as $field)
{
$comment = $field;
$comment['fieldname'].='comment';
$comment['subquestion']=$comment['aid']=='other'?$clang->gT("Other comment"):$clang->gT("Comment");
if ($comment['aid']!='other') unset($comment['other']);
$comment['aid'].='comment';
unset($comment['defaultvalues']);
unset($comment['sqid']);
unset($comment['preg']);
$q = clone $this;
$q->fieldname .= 'comment';
$q->aid = $comment['aid'];
unset($q->default);
$comment['q']=$q;
$comment['pq']=$this;
$map[$field['fieldname']]=$field;
$map[$comment['fieldname']]=$comment;
}
return $map;
}

public function availableAttributes($attr = false)
{
$attrs=array("array_filter","array_filter_exclude","assessment_value","exclude_all_others","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
19 changes: 19 additions & 0 deletions application/modules/CommentListQuestion.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,25 @@ public function getAnswerHTML()

//public function getHelp() - inherited

public function createFieldmap($type=null)
{
$clang = Yii::app()->lang;
$map = parent::createFieldmap($type);
$comment = $map[$this->fieldname];
$comment['fieldname'].='comment';
$comment['aid']='comment';
$comment['subquestion']=$clang->gT("Comment");
unset($comment['defaultvalue']);
$q = clone $this;
$q->fieldname .= 'comment';
$q->aid='comment';
unset($q->default);
$comment['q']=$q;
$comment['pq']=$this;
$map[$comment['fieldname']]=$comment;
return $map;
}

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
44 changes: 44 additions & 0 deletions application/modules/DualRadioArrayQuestion.php
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,50 @@ public function getAnswerHTML()
return $answer;
}

public function createFieldmap($type=null)
{
$clang = Yii::app()->lang;
$abrows = getSubQuestions($this);
$map = array();
foreach ($abrows as $abrow)
{
$fieldname="{$this->surveyid}X{$this->gid}X{$this->id}{$abrow['title']}#0";
$field['fieldname']=$fieldname;
$field['type']=$type;
$field['sid']=$this->surveyid;
$field['gid']=$this->gid;
$field['qid']=$this->id;
$field['aid']=$abrow['title'];
$field['scale_id']=0;
$field['title']=$this->title;
$field['question']=$this->text;
$field['subquestion']=$abrow['question'];
$field['group_name']=$this->groupname;
$field['scale']=$clang->gT('Scale 1');
$field['mandatory']=$this->mandatory;
$field['hasconditions']=$this->conditionsexist;
$field['usedinconditions']=$this->usedinconditions;
$field['questionSeq']=$this->questioncount;
$field['groupSeq']=$this->randomgid;
$field['pq']=$this;
$q = clone $this;
$q->fieldname = $fieldname;
$q->aid = $field['aid'];
$field['q']=$q;
$field2=$field;
$fieldname2="{$this->surveyid}X{$this->gid}X{$this->id}{$abrow['title']}#1";
$field2['fieldname']=$fieldname2;
$field2['scale_id']=1;
$field2['scale']=$clang->gT('Scale 2');
$q2 = clone $field['q'];
$q2->fieldname = $fieldname;
$field2['q']=$q2;
$map[$fieldname]=$field;
$map[$fieldname2]=$field2;
}
return $map;
}

public function availableAttributes($attr = false)
{
$attrs=array("answer_width","array_filter","array_filter_exclude","dropdown_prepostfix","dropdown_separators","dualscale_headerA","dualscale_headerB","statistics_showgraph","statistics_graphtype","hide_tip","hidden","max_answers","min_answers","page_break","public_statistics","random_order","parent_order","use_dropdown","scale_export","random_group");
Expand Down
40 changes: 40 additions & 0 deletions application/modules/FileQuestion.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,46 @@ public function getFileValidationMessage()
return $qtitle;
}

public function createFieldmap($type=null)
{
$clang = Yii::app()->lang;
$qidattributes= getQuestionAttributeValues($this->id);
for ($i = 1; $i <= $qidattributes['max_num_of_files']; $i++)
{
$fieldname="{$this->surveyid}X{$this->gid}X{$this->id}";
$field['fieldname']=$fieldname;
$field['type']=$type;
$field['sid']=$this->surveyid;
$field['gid']=$this->gid;
$field['qid']=$this->id;
$field['aid']='';
$field['title']=$this->title;
$field['question']=$this->text;
$field['group_name']=$this->groupname;
$field['mandatory']=$this->mandatory;
$field['hasconditions']=$this->conditionsexist;
$field['usedinconditions']=$this->usedinconditions;
$field['questionSeq']=$this->questioncount;
$field['groupSeq']=$this->randomgid;
$field['pq']=$this;
$field['q']=$this;
$field2=$field;
$field['max_files']=$qidattributes['max_num_of_files'];
$fieldname2="{$this->surveyid}X{$this->gid}X{$this->id}_filecount";
$field2['fieldname']=$fieldname2;
$field2['aid']='filecount';
$field2['question']="filecount - ".$this->text;
$q = clone $this;
$q->fieldname = $fieldname;
$q->aid=$field2['aid'];
$q->question=$field2['question'];
$field2['q']=$q;
$map[$fieldname]=$field;
$map[$fieldname2]=$field2;
}
return $map;
}

public function availableAttributes($attr = false)
{
$attrs=array("statistics_showgraph","statistics_graphtype","hide_tip","hidden","page_break","show_title","show_comment","max_filesize","max_num_of_files","min_num_of_files","allowed_filetypes","random_group");
Expand Down
24 changes: 23 additions & 1 deletion application/modules/ListQuestion.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php
class ListQuestion extends QuestionModule
{
protected $other;
public function getAnswerHTML()
{
global $dropdownthreshold;
Expand Down Expand Up @@ -258,6 +257,29 @@ public function getHelp()
return '';
}

public function createFieldmap($type=null)
{
$clang = Yii::app()->lang;
$map = parent::createFieldmap($type);
if($this->other=='Y')
{
$other = $map[$this->fieldname];
$other['fieldname'].='other';
$other['aid']='other';
$other['subquestion']=$clang->gT("Other");
if (isset($this->default['other'])) $other['defaultvalue']=$this->default['other'];
else unset($other['defaultvalue']);
$q = clone $this;
$q->fieldname .= 'other';
$q->aid = 'other';
$q->default = isset($other['defaultvalues'])?$other['defaultvalues']:null;
$other['q']=$q;
$other['pq']=$this;
$map[$other['fieldname']]=$other;
}
return $map;
}

public function availableAttributes($attr = false)
{
$attrs=array("alphasort","array_filter","array_filter_exclude","display_columns","statistics_showgraph","statistics_graphtype","hide_tip","hidden","other_comment_mandatory","other_numbers_only","other_replace_text","page_break","public_statistics","random_order","parent_order","scale_export","random_group");
Expand Down
38 changes: 37 additions & 1 deletion application/modules/MultinumericalQuestion.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,43 @@ protected function getChildren()
}
return $this->children = dbExecuteAssoc($ansquery)->readAll(); //Checked
}


public function createFieldmap($type=null)
{
$map = array();
$abrows = getSubQuestions($this);
foreach ($abrows as $abrow)
{
$fieldname="{$this->surveyid}X{$this->gid}X{$this->id}{$abrow['title']}";
$field['fieldname']=$fieldname;
$field['type']=$type;
$field['sid']=$this->surveyid;
$field['gid']=$this->gid;
$field['qid']=$this->id;
$field['aid']=$abrow['title'];
$field['sqid']=$abrow['qid'];
$field['title']=$this->title;
$field['question']=$this->text;
$field['subquestion']=$abrow['question'];
$field['group_name']=$this->groupname;
$field['mandatory']=$this->mandatory;
$field['hasconditions']=$this->conditionsexist;
$field['usedinconditions']=$this->usedinconditions;
$field['questionSeq']=$this->questioncount;
$field['groupSeq']=$this->randomgid;
$field['preg']=$this->preg;
if(isset($this->default[$abrow['qid']])) $field['defaultvalue']=$this->default[$abrow['qid']];
$field['pq']=$this;
$q = clone $this;
$q->fieldname = $fieldname;
$q->aid=$field['aid'];
$q->question=$abrow['question'];
$field['q']=$q;
$map[$fieldname]=$field;
}
return $map;
}

public function availableAttributes($attr = false)
{
$attrs=array("array_filter","array_filter_exclude","equals_num_value","em_validation_q","em_validation_q_tip","em_validation_sq","em_validation_sq_tip","statistics_showgraph","statistics_graphtype","hide_tip","hidden","max_answers","max_num_value","max_num_value_n","maximum_chars","min_answers","min_num_value","min_num_value_n","page_break","prefix","public_statistics","random_order","parent_order","slider_layout","slider_min","slider_max","slider_accuracy","slider_default","slider_middlestart","slider_showminmax","slider_separator","suffix","text_input_width","random_group");
Expand Down
38 changes: 37 additions & 1 deletion application/modules/MultitextQuestion.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,43 @@ protected function getChildren()
}
return $this->children = dbExecuteAssoc($ansquery)->readAll(); //Checked
}


public function createFieldmap($type=null)
{
$map = array();
$abrows = getSubQuestions($this);
foreach ($abrows as $abrow)
{
$fieldname="{$this->surveyid}X{$this->gid}X{$this->id}{$abrow['title']}";
$field['fieldname']=$fieldname;
$field['type']=$type;
$field['sid']=$this->surveyid;
$field['gid']=$this->gid;
$field['qid']=$this->id;
$field['aid']=$abrow['title'];
$field['sqid']=$abrow['qid'];
$field['title']=$this->title;
$field['question']=$this->text;
$field['subquestion']=$abrow['question'];
$field['group_name']=$this->groupname;
$field['mandatory']=$this->mandatory;
$field['hasconditions']=$this->conditionsexist;
$field['usedinconditions']=$this->usedinconditions;
$field['questionSeq']=$this->questioncount;
$field['groupSeq']=$this->randomgid;
$field['preg']=$this->preg;
if(isset($this->default[$abrow['qid']])) $field['defaultvalue']=$this->default[$abrow['qid']];
$field['pq']=$this;
$q = clone $this;
$q->fieldname = $fieldname;
$q->aid=$field['aid'];
$q->question=$abrow['question'];
$field['q']=$q;
$map[$fieldname]=$field;
}
return $map;
}

public function availableAttributes($attr = false)
{
$attrs=array("array_filter","array_filter_exclude","display_rows","em_validation_q","em_validation_q_tip","em_validation_sq","em_validation_sq_tip","statistics_showgraph","statistics_graphtype","hide_tip","hidden","max_answers","maximum_chars","min_answers","numbers_only","page_break","prefix","random_order","parent_order","suffix","text_input_width","random_group");
Expand Down

0 comments on commit eb12ae0

Please sign in to comment.