Skip to content

Commit

Permalink
Dev: unrelevant to irrelevant for Expression Manager class
Browse files Browse the repository at this point in the history
  • Loading branch information
Shnoulle committed Jun 19, 2017
1 parent e59189d commit 7bf6bc9
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion application/core/LS_Twig_Extension.php
Expand Up @@ -162,7 +162,7 @@ public static function getAllQuestionClasses($iQid)

/* Add the relevance class */
if (!$lemQuestionInfo['relevant']){
$aQuestionClass .= ' ls-unrelevant';
$aQuestionClass .= ' ls-irrelevant';
$aQuestionClass .= ' ls-hidden';
}

Expand Down
2 changes: 1 addition & 1 deletion application/helpers/SurveyRuntimeHelper.php
Expand Up @@ -1293,7 +1293,7 @@ public static function getQuestionReplacement($aQuestionQanda)
/* Add the relevance class */
if (!$lemQuestionInfo['relevant'])
{
$aQuestionClass[]='ls-unrelevant';
$aQuestionClass[]='ls-irrelevant';
$aQuestionClass[]='ls-hidden';
}
if ($lemQuestionInfo['hidden']){ /* Can use aQuestionAttributes too */
Expand Down
6 changes: 3 additions & 3 deletions application/helpers/expressions/em_manager_helper.php
Expand Up @@ -6206,7 +6206,7 @@ function _ValidateQuestion($questionSeq,$force=false)
{
$relevantSQs[] = $sgqa;
}
// This just remove the last ranking : don't control validity of answers done: user can rank unrelevant answers .... See Bug #09774
// This just remove the last ranking : don't control validity of answers done: user can rank irrelevant answers .... See Bug #09774
continue;
}

Expand Down Expand Up @@ -6675,7 +6675,7 @@ function _ValidateQuestion($questionSeq,$force=false)
/**
* Control value against value from survey : see #11611
*/
$sgqas = explode('|',$LEM->qid2code[$qid]); /* Must remove all session alert, even if unrelevant or hidden */
$sgqas = explode('|',$LEM->qid2code[$qid]); /* Must remove all session alert, even if irrelevant or hidden */
foreach($sgqas as $sgqa)
{
$validityString=self::getValidityString($sgqa);
Expand Down Expand Up @@ -10323,7 +10323,7 @@ private static function checkValidityAnswer($type,$value,$sgq,$qinfo)
break;
case '!': //List - dropdown
case 'L': //LIST drop-down/radio-button list
if(substr($sgq,-5)!='other')// We must validate $value==="0", then don't use empty. $value is not set if unrelevant , then don't use $value!==null
if(substr($sgq,-5)!='other')// We must validate $value==="0", then don't use empty. $value is not set if irrelevant , then don't use $value!==null
{
if($value=="-oth-")
{
Expand Down
2 changes: 1 addition & 1 deletion application/helpers/frontend_helper.php
Expand Up @@ -1914,7 +1914,7 @@ function checkCompletedQuota($surveyid,$return=false)
////Create filtering
// Array of field with quota array value
$aQuotaFields=array();
// Array of fieldnames with relevance value : EM fill $_SESSION with default value even is unrelevant (em_manager_helper line 6548)
// Array of fieldnames with relevance value : EM fill $_SESSION with default value even is irrelevant (em_manager_helper line 6548)
$aQuotaRelevantFieldnames=array();
// To count number of hidden questions
$aQuotaQid=array();
Expand Down
6 changes: 3 additions & 3 deletions application/helpers/qanda_helper.php
Expand Up @@ -679,16 +679,16 @@ function currentRelevecanceClass($surveyId,$baseName,$name,$aQuestionAttributes)
if ((!isset($_SESSION["survey_{$surveyId}"]['relevanceStatus'][$sExclude]) || $_SESSION["survey_{$surveyId}"]['relevanceStatus'][$sExclude])
&& (isset($_SESSION["survey_{$surveyId}"][$sExclude]) && $_SESSION["survey_{$surveyId}"][$sExclude] == "Y")
) {
return "ls-unrelevant ls-disabled";
return "ls-irrelevant ls-disabled";
}
}
}

$filterStyle=!empty($aQuestionAttributes['array_filter_style']); // Currently null/0/false=> hidden , 1 : disabled
if($filterStyle) {
return "ls-unrelevant ls-disabled";
return "ls-irrelevant ls-disabled";
}
return "ls-unrelevant ls-hidden";
return "ls-irrelevant ls-hidden";
}
/**
* @param string $rowname
Expand Down
2 changes: 1 addition & 1 deletion application/helpers/questionIndexHelper.php
Expand Up @@ -133,7 +133,7 @@ private function getIndexItemsGroups($type)
$groupInfo['step'] = $step + 1;
$stepInfo = isset($stepInfos[$step]) ? $stepInfos[$step]: array('show'=>true,'anyUnanswered'=>null,'anyErrors'=>null);
if( ($type>1 || $groupInfo['step'] <= $sessionLem['maxstep'])
&& LimeExpressionManager::GroupIsRelevant($groupInfo['gid']) // $stepInfo['show'] is incomplete (for unrelevant group after the 'not submitted due to error group') GroupIsRelevant control it really
&& LimeExpressionManager::GroupIsRelevant($groupInfo['gid']) // $stepInfo['show'] is incomplete (for irrelevant group after the 'not submitted due to error group') GroupIsRelevant control it really
){
/* string to EM : leave fix (remove script , flatten other ...) to view */
$stepIndex[$step]=array(
Expand Down
4 changes: 2 additions & 2 deletions assets/packages/limesurvey/survey.css
Expand Up @@ -12,8 +12,8 @@
/**
* Expression manager relevance system
*/
.js .ls-hidden.ls-unrelevant {display:none}/* 3 class , and don't hide without javascript*/
.ls-unrelevant{}
.js .ls-hidden.ls-irrelevant {display:none}/* 3 class , and don't hide without javascript*/
.ls-irrelevant{}
.js .ls-disabled{opacity:0.4;}


Expand Down
16 changes: 8 additions & 8 deletions assets/packages/limesurvey/survey.js
Expand Up @@ -23,18 +23,18 @@ function triggerEmRelevanceQuestion(){
/* Action on this question */
$("[id^='question']").on('relevance:on',function(event,data) {
if(event.target != this) return; /* @todo : attach only to this. Use http://stackoverflow.com/a/6411507/2239406 solution for now. Don't want to stop propagation. */
$(this).removeClass("ls-unrelevant ls-hidden");
$(this).removeClass("ls-irrelevant ls-hidden");
});
$("[id^='question']").on('relevance:off',function(event,data) {
if(event.target != this) return;
$(this).addClass("ls-unrelevant ls-hidden");
$(this).addClass("ls-irrelevant ls-hidden");
});
/* In all in one mode : need updating group too */
$(".allinone [id^='group-']:not(.ls-unrelevant) [id^='question']").on('relevance:on',function(event,data) {
$(".allinone [id^='group-']:not(.ls-irrelevant) [id^='question']").on('relevance:on',function(event,data) {
if(event.target != this) return;
$(this).closest("[id^='group-']").removeClass("ls-hidden");
});
$(".allinone [id^='group-']:not(.ls-unrelevant) [id^='question']").on('relevance:off',function(event,data) {
$(".allinone [id^='group-']:not(.ls-irrelevant) [id^='question']").on('relevance:off',function(event,data) {
if(event.target != this) return;
if($(this).closest("[id^='group-']").find("[id^='question']").length==$(this).closest("[id^='group-']").find("[id^='question'].ls-hidden").length){
$(this).closest("[id^='group-']").addClass("ls-hidden");
Expand All @@ -45,19 +45,19 @@ function triggerEmRelevanceQuestion(){
function triggerEmRelevanceGroup(){
$("[id^='group-']").on('relevance:on',function(event,data) {
if(event.target != this) return;
$(this).removeClass("ls-unrelevant ls-hidden");
$(this).removeClass("ls-irrelevant ls-hidden");
});
$("[id^='group-']").on('relevance:off',function(event,data) {
if(event.target != this) return;
$(this).addClass("ls-unrelevant ls-hidden");
$(this).addClass("ls-irrelevant ls-hidden");
});
}
/* On sub-question and answers-list */
function triggerEmRelevanceSubQuestion(){
$("[id^='question']").on('relevance:on',"[id^='javatbd']",function(event,data) {
if(event.target != this) return; // not needed now, but after (2016-11-07)
data = $.extend({style:'hidden'}, data);
$(this).removeClass("ls-unrelevant ls-"+data.style);
$(this).removeClass("ls-irrelevant ls-"+data.style);
if(data.style=='disabled'){
$(event.target).find('input').prop("disabled", false );
}
Expand All @@ -69,7 +69,7 @@ function triggerEmRelevanceSubQuestion(){
$("[id^='question']").on('relevance:off',"[id^='javatbd']",function(event,data) {
if(event.target != this) return; // not needed now, but after (2016-11-07)
data = $.extend({style:'hidden'}, data);
$(this).addClass("ls-unrelevant ls-"+data.style);
$(this).addClass("ls-irrelevant ls-"+data.style);
if(data.style=='disabled'){
$(event.target).find('input').prop("disabled", true );
}
Expand Down
12 changes: 6 additions & 6 deletions assets/packages/template-default/template-core.js
Expand Up @@ -92,31 +92,31 @@ function triggerEmClassChangeTemplate(){
});
}
/**
* Hide question if all sub-questions is hidden
* Hide/show question if all sub-questions is hidden
* @see core/package/limesurvey/survey.js:triggerEmRelevanceSubQuestion
* @see https://bugs.limesurvey.org/view.php?id=10055 (partial)
* Must be before ready (event happen before ready)
*/
function hideQuestionWithRelevanceSubQuestion(){
$("[id^='question']").on('relevance:on',"[id^='javatbd']",function(event,data) {
$("[id^='question']:not(.ls-irrelevant)").on('relevance:on',"[id^='javatbd']",function(event,data) {
if(event.target != this) return; // not needed now, but after (2016-11-07)
data = $.extend({style:'hidden'}, data);
if(data.style=='hidden'){
$(this).closest("[id^='question']:not(.ls-unrelevant)").removeClass("ls-hidden")
$(this).closest("[id^='question']").removeClass("ls-hidden")
}
});
$("[id^='question']").on('relevance:off',"[id^='javatbd']",function(event,data) {
$("[id^='question']:not(.ls-hidden)").on('relevance:off',"[id^='javatbd']",function(event,data) {
if(event.target != this) return; // not needed now, but after (2016-11-07)
data = $.extend({style:'hidden'}, data);
if(data.style=='hidden'){
if($(this).closest("[id^='question']").find("[id^='javatbd']:visible").length==0){
$(this).closest("[id^='question']").addClass("ls-hidden");// ls-hidden only is used only for Equation question type actually (but think must fix and use another class)
$(this).closest("[id^='question']").addClass("ls-hidden");
}
}
});
}
/**
* Hide parent multiple list
* Hide/show parent multiple list
* @see core/package/limesurvey/survey.js:triggerEmRelevanceSubQuestion
* @see https://bugs.limesurvey.org/view.php?id=11787
* Must be before ready (event happen before ready)
Expand Down

0 comments on commit 7bf6bc9

Please sign in to comment.