Skip to content

Commit

Permalink
Remove the final traces of type from EM!
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronschmitz committed Aug 13, 2012
1 parent 550133e commit 8d3d9ef
Show file tree
Hide file tree
Showing 18 changed files with 180 additions and 130 deletions.
8 changes: 4 additions & 4 deletions application/helpers/expressions/em_manager_helper.php
Expand Up @@ -2426,7 +2426,6 @@ private function setVariableAndTokenMappingsForExpressionManager($surveyid,$forc
{
continue; // not an SGQA value
}
$type = $fielddata['type']; //AJS
$q->mandatory = $q->mandatory;
$fieldNameParts = explode('X',$q->fieldname);
$q->aid = (isset($q->aid) ? $q->aid : '');
Expand Down Expand Up @@ -2594,8 +2593,9 @@ private function setVariableAndTokenMappingsForExpressionManager($surveyid,$forc
. "','sgqa':'" . $q->fieldname
. "','qid':" . $q->id
. ",'gid':" . $q->gid
. ",'type':'" . $type //AJS Javascript!
. "','default':'" . (is_null($q->default) ? '' : $q->default)
. ",'shownscript': function(value, attr, varName) {" . $q->getShownJS()
. "},'valuescript': function(value, attr, varName) {" . $q->getValueJS()
. "},'default':'" . (is_null($q->default) ? '' : $q->default)
. "','rowdivid':'" . (is_null($rowdivid) ? '' : $rowdivid)
. "','onlynum':'" . ($onlynum ? '1' : '')
. "','gseq':" . $q->groupcount
Expand Down Expand Up @@ -5608,7 +5608,7 @@ static function GetRelevanceAndTailoringJavaScript()
if (count($neededCanonicalAttr) > 0)
{
$jsParts[] = "var LEMvarNameAttr = {\n";
$jsParts[] = implode(",\n",$neededCanonicalAttr); //AJS This outputs type to javascript!
$jsParts[] = implode(",\n",$neededCanonicalAttr);
$jsParts[] = "};\n";
}
}
Expand Down
8 changes: 7 additions & 1 deletion application/modules/CheckQuestion.php
Expand Up @@ -205,7 +205,7 @@ public function getAnswerHTML()
$answer .= htmlspecialchars($dispVal,ENT_QUOTES);
}
$answer .= "\" onkeyup='if ($.trim(this.value)!=\"\") { \$(\"#answer{$myfname}cbox\").attr(\"checked\",\"checked\"); } else { \$(\"#answer{$myfname}cbox\").attr(\"checked\",\"\"); }; $(\"#java{$myfname}\").val(this.value);$oth_checkconditionFunction(this.value, this.name, this.type); LEMflagMandOther(\"$myfname\",\$(\"#answer{$myfname}cbox\").attr(\"checked\"));'/>";
$answer .="\" />";

$answer .="<script type='text/javascript'>\n";
$answer .="$('#answer{$myfname}').bind('keyup blur',function(){\n";
$answer .= " if ($.trim($(this).val())!=\"\") { \$(\"#answer{$myfname}cbox\").attr(\"checked\",true); } else { \$(\"#answer{$myfname}cbox\").attr(\"checked\",false); }; $(\"#java{$myfname}\").val($(this).val());$oth_checkconditionFunction(this.value, this.name, this.type); LEMflagMandOther(\"$myfname\",\$(\"#answer{$myfname}cbox\").attr(\"checked\"));\n";
Expand Down Expand Up @@ -650,6 +650,12 @@ public function availableOptions()
return array('other' => true, 'valid' => false, 'mandatory' => true);
}

public function getShownJS()
{
return 'if (typeof attr.question === "undefined" || value == "") return "";'
. 'return htmlspecialchars_decode(attr.question);';
}

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
7 changes: 7 additions & 0 deletions application/modules/CommentCheckQuestion.php
Expand Up @@ -317,6 +317,13 @@ public function getAdditionalValParts()
return $valParts;
}

public function getShownJS()
{
return 'if (typeof attr.question === "undefined" || value == "") return "";'
. 'if (varName.match(/comment$/)) return value;'
. 'return htmlspecialchars_decode(attr.question);';
}

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
19 changes: 19 additions & 0 deletions application/modules/CommentListQuestion.php
Expand Up @@ -339,6 +339,25 @@ public function availableOptions()
return array('other' => false, 'valid' => false, 'mandatory' => true);
}

public function getShownJS()
{
return 'if (varName.match(/comment$/)) return value;'
. 'which_ans = "0~" + value;'
. 'if (typeof attr.answers[which_ans] === "undefined") return value;'
. 'answerParts = attr.answers[which_ans].split("|");'
. 'answerParts.shift();'
. 'return answerParts.join("|");';
}

public function getValueJS()
{
return 'if (varName.match(/comment$/)) return value;'
. 'which_ans = "0~" + value;'
. 'if (typeof attr.answers[which_ans] === "undefined") return "";'
. 'answerParts = attr.answers[which_ans].split("|");'
. 'return answerParts[0];';
}

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
2 changes: 1 addition & 1 deletion application/modules/DateQuestion.php
Expand Up @@ -300,7 +300,7 @@ public function getHeaderIncludes()

$includes = array(Yii::app()->getConfig("generalscripts").'date.js' => 'js');
if (trim($aQuestionAttributes['dropdown_dates'])==0) {
$includes[Yii::app()->getConfig("generalscripts").'jquery/lime-calendar.js'] = 'js';
$includes[Yii::app()->getConfig("generalscripts").'date.js'] = 'js';
if ($clang->langcode !== 'en')
{
$includes[Yii::app()->getConfig("generalscripts").'jquery/locale/jquery.ui.datepicker-'.$clang->langcode.'.js'] = 'js';
Expand Down
19 changes: 19 additions & 0 deletions application/modules/DualRadioArrayQuestion.php
Expand Up @@ -743,6 +743,25 @@ public function includeRelevanceStatus()
return true;
}

public function getShownJS()
{
return 'prefix = (attr.jsName.match(/#1$/)) ? "1" : "0";'
. 'which_ans = prefix + "~" + value;'
. 'if (typeof attr.answers[which_ans] === "undefined") return "";'
. 'answerParts = attr.answers[which_ans].split("|");'
. 'answerParts.shift();'
. 'return answerParts.join("|");';
}

public function getValueJS()
{
return 'prefix = (attr.jsName.match(/#1$/)) ? "1" : "0";'
. 'which_ans = prefix + "~" + value;'
. 'if (typeof attr.answers[which_ans] === "undefined") return "";'
. 'answerParts = attr.answers[which_ans].split("|");'
. 'return answerParts[0];';
}

public function availableAttributes($attr = false)
{
$attrs=array("answer_width","repeat_headings","array_filter","array_filter_exclude","array_filter_style","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
14 changes: 7 additions & 7 deletions application/modules/FileQuestion.php
Expand Up @@ -267,10 +267,10 @@ public function filter($value, $type)
case 'dataentryinsert':
if (!strpos($this->fieldname, "_filecount"))
{
$this->dataentry = json_decode(stripslashes($value));
$dataentry = json_decode(stripslashes($value));
$filecount = 0;

for ($i = 0; $filecount < count($this->dataentry); $i++)
for ($i = 0; $filecount < count($dataentry); $i++)
{
if ($_FILES[$q->fieldname."_file_".$i]['error'] != 4)
{
Expand All @@ -280,20 +280,20 @@ public function filter($value, $type)

if (move_uploaded_file($_FILES[$this->fieldname."_file_".$i]['tmp_name'], $target))
{
$this->dataentry[$filecount]->filename = basename($target);
$this->dataentry[$filecount]->name = $name;
$this->dataentry[$filecount]->size = $size;
$dataentry[$filecount]->filename = basename($target);
$dataentry[$filecount]->name = $name;
$dataentry[$filecount]->size = $size;
$pathinfo = pathinfo($_FILES[$q->fieldname."_file_".$i]['name']);
$phparray[$filecount]->ext = $pathinfo['extension'];
$filecount++;
}
}
}
return ls_json_encode($this->dataentry);
return ls_json_encode($dataentry);
}
else
{
return count($this->dataentry);
return count(json_decode(stripslashes($value)));
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions application/modules/FiveRadioArrayQuestion.php
Expand Up @@ -197,6 +197,16 @@ public function getVarAttributeValueNAOK($name, $default, $gseq, $qseq, $ansArra
return LimeExpressionManager::GetVarAttribute($name,'code',$default,$gseq,$qseq);
}

public function getShownJS()
{
return 'return value;';
}

public function getValueJS()
{
return 'return value;';
}

public function availableAttributes($attr = false)
{
$attrs=array("answer_width","array_filter","array_filter_exclude","array_filter_style","em_validation_q","em_validation_q_tip","exclude_all_others","statistics_showgraph","statistics_graphtype","hide_tip","hidden","max_answers","min_answers","page_break","public_statistics","random_order","parent_order","random_group");
Expand Down
5 changes: 5 additions & 0 deletions application/modules/GenderQuestion.php
Expand Up @@ -138,6 +138,11 @@ public function getVarAttributeShown($name, $default, $gseq, $qseq, $ansArray)
}
}

public function getShownJS()
{
return 'return (typeof attr.answers[value] === "undefined") ? "" : attr.answers[value];';
}

public function availableAttributes($attr = false)
{
$attrs=array("display_columns","statistics_showgraph","statistics_graphtype","hide_tip","hidden","page_break","public_statistics","scale_export","random_group");
Expand Down
10 changes: 10 additions & 0 deletions application/modules/IDRadioArrayQuestion.php
Expand Up @@ -266,6 +266,16 @@ public function getVarAttributeShown($name, $default, $gseq, $qseq, $ansArray)
}
}

public function getShownJS()
{
return 'return (typeof attr.answers[value] === "undefined") ? "" : attr.answers[value];';
}

public function getValueJS()
{
return 'return value;';
}

public function availableAttributes($attr = false)
{
$attrs=array("answer_width","array_filter","array_filter_exclude","array_filter_style","em_validation_q","em_validation_q_tip","exclude_all_others","statistics_showgraph","statistics_graphtype","hide_tip","hidden","max_answers","min_answers","page_break","public_statistics","random_order","parent_order","scale_export","random_group");
Expand Down
19 changes: 19 additions & 0 deletions application/modules/ListQuestion.php
Expand Up @@ -662,6 +662,25 @@ public function availableOptions()
return array('other' => true, 'valid' => false, 'mandatory' => true);
}

public function getShownJS()
{
return 'if (varName.match(/_other$/)) return value;'
. 'which_ans = "0~" + value;'
. 'if (typeof attr.answers[which_ans] === "undefined") return value;'
. 'answerParts = attr.answers[which_ans].split("|");'
. 'answerParts.shift();'
. 'return answerParts.join("|");';
}

public function getValueJS()
{
return 'if (varName.match(/_other$/)) return value;'
. 'which_ans = "0~" + value;'
. 'if (typeof attr.answers[which_ans] === "undefined") return "";'
. 'answerParts = attr.answers[which_ans].split("|");'
. 'return answerParts[0];';
}

public function availableAttributes($attr = false)
{
$attrs=array("alphasort","array_filter","array_filter_exclude","array_filter_style","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","time_limit","time_limit_action","time_limit_disable_next","time_limit_disable_prev","time_limit_countdown_message","time_limit_timer_style","time_limit_message_delay","time_limit_message","time_limit_message_style","time_limit_warning","time_limit_warning_display_time","time_limit_warning_message","time_limit_warning_style","time_limit_warning_2","time_limit_warning_2_display_time","time_limit_warning_2_message","time_limit_warning_2_style");
Expand Down
10 changes: 10 additions & 0 deletions application/modules/QuestionModule.php
Expand Up @@ -485,6 +485,16 @@ public function screenshotCount()
return 1;
}

public function getShownJS()
{
return 'return value;';
}

public function getValueJS()
{
return 'return value;';
}

public function availableOptions()
{
return array('other' => false, 'valid' => false, 'mandatory' => true);
Expand Down
17 changes: 17 additions & 0 deletions application/modules/RadioArrayQuestion.php
Expand Up @@ -435,6 +435,23 @@ public function getVarAttributeValueNAOK($name, $default, $gseq, $qseq, $ansArra
}
}

public function getShownJS()
{
return 'which_ans = "0~" + value;'
. 'if (typeof attr.answers[which_ans] === "undefined") return value;'
. 'answerParts = attr.answers[which_ans].split("|");'
. 'answerParts.shift();'
. 'return answerParts.join("|");';
}

public function getValueJS()
{
return 'which_ans = "0~" + value;'
. 'if (typeof attr.answers[which_ans] === "undefined") return "";'
. 'answerParts = attr.answers[which_ans].split("|");'
. 'return answerParts[0];';
}

public function availableAttributes($attr = false)
{
$attrs=array("answer_width","repeat_headings","array_filter","array_filter_exclude","array_filter_style","em_validation_q","em_validation_q_tip","exclude_all_others","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
17 changes: 17 additions & 0 deletions application/modules/RankingQuestion.php
Expand Up @@ -444,6 +444,23 @@ public function getMandatoryTip()
return $clang->gT('Please rank all items').'.';
}

public function getShownJS()
{
return 'which_ans = "0~" + value;'
. 'if (typeof attr.answers[which_ans] === "undefined") return value;'
. 'answerParts = attr.answers[which_ans].split("|");'
. 'answerParts.shift();'
. 'return answerParts.join("|");';
}

public function getValueJS()
{
return 'which_ans = "0~" + value;'
. 'if (typeof attr.answers[which_ans] === "undefined") return "";'
. 'answerParts = attr.answers[which_ans].split("|");'
. 'return answerParts[0];';
}

public function availableAttributes($attr = false)
{
$attrs=array("statistics_showgraph","statistics_graphtype","hide_tip","hidden","max_answers","min_answers","page_break","public_statistics","random_order","showpopups","samechoiceheight","samelistheight", "parent_order","rank_title","choice_title","random_group");
Expand Down
10 changes: 10 additions & 0 deletions application/modules/TenRadioArrayQuestion.php
Expand Up @@ -184,6 +184,16 @@ public function availableAttributes($attr = false)
return $attr?in_array($attr,$attrs):$attrs;
}

public function getShownJS()
{
return 'return value;';
}

public function getValueJS()
{
return 'return value;';
}

public function availableOptions()
{
return array('other' => false, 'valid' => false, 'mandatory' => true);
Expand Down
5 changes: 5 additions & 0 deletions application/modules/YNQuestion.php
Expand Up @@ -158,6 +158,11 @@ public function getVarAttributeShown($name, $default, $gseq, $qseq, $ansArray)
}
}

public function getShownJS()
{
return 'return (typeof attr.answers[value] === "undefined") ? "" : attr.answers[value];';
}

public function availableAttributes($attr = false)
{
$attrs=array("statistics_showgraph","statistics_graphtype","hide_tip","hidden","page_break","public_statistics","scale_export","random_group");
Expand Down
10 changes: 10 additions & 0 deletions application/modules/YNRadioArrayQuestion.php
Expand Up @@ -247,6 +247,16 @@ public function getVarAttributeShown($name, $default, $gseq, $qseq, $ansArray)
}
}

public function getShownJS()
{
return 'return (typeof attr.answers[value] === "undefined") ? "" : attr.answers[value];';
}

public function getValueJS()
{
return 'return value;';
}

public function availableAttributes($attr = false)
{
$attrs=array("answer_width","array_filter","array_filter_exclude","array_filter_style","em_validation_q","em_validation_q_tip","exclude_all_others","statistics_showgraph","statistics_graphtype","hide_tip","hidden","max_answers","min_answers","page_break","public_statistics","random_order","parent_order","scale_export","random_group");
Expand Down

0 comments on commit 8d3d9ef

Please sign in to comment.