Skip to content

Commit

Permalink
[READY] Fix 15369 and details and separations in ranking filter (#1325)
Browse files Browse the repository at this point in the history
Dev: details and separations in ranking filter
Dev: typo
Fixed issue #15369: Ranking with filter didn't save all value
Dev: get count of answers by model …
Dev: remove TODO FIXIT because it's done …
Dev: more details
  • Loading branch information
Shnoulle authored and olleharstedt committed Oct 7, 2019
1 parent 017cc15 commit f441cd5
Showing 1 changed file with 26 additions and 21 deletions.
47 changes: 26 additions & 21 deletions application/helpers/expressions/em_manager_helper.php
Expand Up @@ -6262,40 +6262,45 @@ public function _ValidateQuestion($questionSeq,$force=false)
} else {
$sgqas = explode('|',$LEM->qid2code[$qid]);
}
/* With ranking we don't check for relevance in each subquestion, just need the max numbers of answers */
/* $sgqa and subQrelInfo are not the same information */
if($qInfo['type']=='R') {
/** @var integer counter to have current rank number (subquestion) */
$iCountRank = 0;

$language=isset($_SESSION[$LEM->sessid]['s_lang']) ?$_SESSION[$LEM->sessid]['s_lang'] : App()->language;
/** @var integer Get total of answers (all potential answers) **/
$answersCount = \Answer::model()->count('qid = :qid and language = :language',array(':qid'=>$qid,':language'=>$language));

/** @var integer Get number of answers currently filtered (unrelevant) **/
$answersFilteredCount = count(array_filter($LEM->subQrelInfo[$qid],
function ($sqRankAnwsers) {
return !$sqRankAnwsers['result'];
}
));
/** var integer the answers available **/
$iCountRelevant = $answersCount - $answersFilteredCount;
// No need to control if upper than max_columns : count on $sgqa and count($sgqa) == max_columns
}
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])) {
$relevantSQs[] = $sgqa;
continue;
}
$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($LEM->subQrelInfo[$qid]) - count(
array_filter(
$LEM->subQrelInfo[$qid],
function ($sqRankAnwsers) {
return !$sqRankAnwsers['result'];
}
)
);

if($iCountRank > $iCountRelevant)
{
/* Get next rank */
$iCountRank++;
/* If rank is upper than available answer : then it's unrelevant */
if($iCountRank > $iCountRelevant) {
$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;
}

$foundSQrelevance=false;
foreach ($LEM->subQrelInfo[$qid] as $sq)
{
switch ($sq['qtype'])
Expand Down

0 comments on commit f441cd5

Please sign in to comment.