--- original/limesurvey/application/helpers/expressions/em_manager_helper.php	2018-11-15 14:36:18.000000000 +0100
+++ fixed/limesurvey/application/helpers/expressions/em_manager_helper.php	2018-11-21 15:58:06.301022756 +0100
@@ -6271,6 +6270,9 @@
                 } else {
                     $sgqas = explode('|',$LEM->qid2code[$qid]);
                 }
+		if($qInfo['type']=='R') {
+                    $updatedValues=$LEM->ProcessCurrentResponses();
+		}
                 foreach ($sgqas as $sgqa) {
                     // for each subq, see if it is part of an array_filter or array_filter_exclude
                     if (!isset($LEM->subQrelInfo[$qid])) {
@@ -6279,22 +6281,20 @@
                     }
                     $foundSQrelevance=false;
                     if($qInfo['type']=='R') {
-                        // Relevance of subquestion for ranking question depend of the count of relevance of answers.
-                        $iCountRank=(isset($iCountRank) ? $iCountRank+1 : 1);
-                        // Relevant count is : Total answers less Unrelevant answers. subQrelInfo give only array with relevance equation, not this without any relevance.
-                        $iCountRelevant=isset($iCountRelevant) ? $iCountRelevant : count($sgqas)-count(array_filter($LEM->subQrelInfo[$qid],function($sqRankAnwsers){ return !$sqRankAnwsers['result']; }));
-                        if($iCountRank >  $iCountRelevant)
-                        {
+                        $firstsgqa = array_keys($LEM->subQrelInfo[$qid])[0];
+                        if(count($updatedValues) > 0){
+                            $sgqa_base = isset($sgqa_base) ? $sgqa_base : $LEM->subQrelInfo[$qid][$firstsgqa]['sgqa']; 
+                            $key = $sgqa_base . $updatedValues[$sgqa]['value'];
+                            if($updatedValues[$sgqa]['value'] && $LEM->subQrelInfo[$qid][$key]['result']){
+                                $relevantSQs[] = $sgqa;
+                            } else {
                             $irrelevantSQs[] = $sgqa;
                         }
-                        else
-                        {
+                        } else {
                             $relevantSQs[] = $sgqa;
                         }
-                        // This just remove the last ranking : don't control validity of answers done: user can rank irrelevant answers .... See Bug #09774
                         continue;
                     }
-
                     foreach ($LEM->subQrelInfo[$qid] as $sq)
                     {
                         switch ($sq['qtype'])
