Skip to content

Commit

Permalink
Fixex issue #09464: Mandatory ranking anking question cannot go to ne…
Browse files Browse the repository at this point in the history
…xt question if it's filtered by another question

Dev: review relevance of sub question by number of relevance of answers.
Dev: when rewriting Question object/EM : need a function for mandatory :)
  • Loading branch information
Shnoulle committed Jun 20, 2015
1 parent 90633da commit dd9c86c
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions application/helpers/expressions/em_manager_helper.php
Expand Up @@ -5972,7 +5972,6 @@ function _ValidateQuestion($questionSeq,$force=false)
$qrel=true; // assume relevant unless discover otherwise
$prettyPrintRelEqn=''; // assume no relevance eqn by default
$qid=$qInfo['qid'];

$gid=$qInfo['gid'];
$qhidden = $qInfo['hidden'];
$debug_qmessage='';
Expand Down Expand Up @@ -6042,7 +6041,8 @@ function _ValidateQuestion($questionSeq,$force=false)
if ($qInfo['type'] == 'X') {
$sgqas = array(); // Boilerplate questions can be ignored
}
else {
else
{
$sgqas = explode('|',$LEM->qid2code[$qid]);
}
foreach ($sgqas as $sgqa)
Expand All @@ -6054,6 +6054,23 @@ function _ValidateQuestion($questionSeq,$force=false)
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);

This comment has been minimized.

Copy link
@olleharstedt

olleharstedt Oct 2, 2019

Contributor

Hi ho! Can you explain what's going on here? Why are you counting each row and compare with "count relevant"?

This comment has been minimized.

Copy link
@Shnoulle

Shnoulle Oct 2, 2019

Author Collaborator

If i remind : $sgqa = [QCODE_1,QCODE_2,QCODE_3 …]

If rank > count(relevance) : the THIS sgqa is irrelevant

Maybe there are an issue here array_filter($LEM->subQrelInfo[$qid],function($sqRankAnwsers){ return $sqRankAnwsers['result']; } ?

This comment has been minimized.

Copy link
@Shnoulle

Shnoulle Oct 2, 2019

Author Collaborator

I confirm the issue with count : $iCountRelevant === -13

This comment has been minimized.

Copy link
@Shnoulle

Shnoulle Oct 2, 2019

Author Collaborator

OK ! $sgqa === 7 … because there are 7 columlns. A123 have 23 value, if you check 3 : there are 20 irrelevant line.
7 - 20 === -13 …

The fix can be

$iCountRelevant=isset($iCountRelevant) ? $iCountRelevant : count($LEM->subQrelInfo[$qid])-count(array_filter($LEM->subQrelInfo[$qid],function($sqRankAnwsers){ return !$sqRankAnwsers['result']; }));

at

$iCountRelevant=isset($iCountRelevant) ? $iCountRelevant : count($sgqas)-count(array_filter($LEM->subQrelInfo[$qid],function($sqRankAnwsers){ return !$sqRankAnwsers['result']; }));

And (maybe) add a else { at

not needed : default don't do anything

This comment has been minimized.

Copy link
@Shnoulle

Shnoulle Oct 2, 2019

Author Collaborator

/me still hate this big spaghetti code in EM, but don't find a good wau to fixing it differently now.

This comment has been minimized.

Copy link
@olleharstedt

olleharstedt Oct 2, 2019

Contributor

Thanks a lot for the feedback! Holiday in Germany tomorrow, but I'll get back on it on Friday. I'll also try to add a unit test for each bug (the old and the new).

This comment has been minimized.

Copy link
@olleharstedt

olleharstedt Oct 4, 2019

Contributor

I have no idea how or why, but seems like your suggestion fixes it.

This comment has been minimized.

Copy link
@Shnoulle

Shnoulle Oct 4, 2019

Author Collaborator

with max_columns : $sgqa goes to 1 to 7 (here) : it's done for this (limit the number of columns).

$LEM->subQrelInfo[$qid] it's not columns … here, here the information about answers …

This comment has been minimized.

Copy link
@Shnoulle

Shnoulle Oct 4, 2019

Author Collaborator

Without this settings

/* Ranking specific : max DB answer */
:

count($sgqa) == count($LEM->subQrelInfo[$qid]) == count(answers)

But with this settings count($sgqa) != count($LEM->subQrelInfo[$qid]) …

With ranking (and single choice ?) subQrelInfo give information about answers ?

$iCountRelevant=isset($iCountRelevant) ? $iCountRelevant : count(array_filter($LEM->subQrelInfo[$qid],function($sqRankAnwsers){ return $sqRankAnwsers['result']; }));
if($iCountRank > $iCountRelevant)
{
$foundSQrelevance=true;
$irrelevantSQs[] = $sgqa;
}
else
{
$relevantSQs[] = $sgqa;
}
continue;
}

foreach ($LEM->subQrelInfo[$qid] as $sq)
{
switch ($sq['qtype'])
Expand Down Expand Up @@ -6255,7 +6272,6 @@ function _ValidateQuestion($questionSeq,$force=false)
}
}
} // end of processing relevant question for sub-questions

if (($LEM->debugLevel & LEM_PRETTY_PRINT_ALL_SYNTAX) == LEM_PRETTY_PRINT_ALL_SYNTAX)
{
// TODO - why is array_unique needed here?
Expand Down

0 comments on commit dd9c86c

Please sign in to comment.