Fix getNumberOfQuestionRandomByCategory and getNumberMaxQuestionByCat

1.10.x
Angel Fernando Quiroz Campos 9 years ago
parent c1114824e4
commit 79078610bb
  1. 45
      main/exercice/TestCategory.php

@ -455,17 +455,20 @@ class TestCategory
{
$nbquestionresult = 0;
$tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId);
for ($i=0; $i < count($tabcatid); $i++) {
if ($tabcatid[$i] > 0 && $tabcatid[$i] > 0) { // 0 = no category for this questio
$nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $tabcatid[$i]);
if ($nbQuestionInThisCat > $in_nbrandom) {
$nbquestionresult += $in_nbrandom;
}
else {
$nbquestionresult += $nbQuestionInThisCat;
}
}
}
foreach ($tabcatid as $category) {
if (empty($category['id'])) {
continue;
}
$nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $category['id']);
if ($nbQuestionInThisCat > $in_nbrandom) {
$nbquestionresult += $in_nbrandom;
} else {
$nbquestionresult += $nbQuestionInThisCat;
}
}
return $nbquestionresult;
}
@ -701,14 +704,18 @@ class TestCategory
$res_num_max = 0;
// foreach question
$tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId);
for ($i=0; $i < count($tabcatid); $i++) {
if ($tabcatid[$i] > 0) { // 0 = no category for this question
$nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $tabcatid[$i]);
if ($nbQuestionInThisCat > $res_num_max) {
$res_num_max = $nbQuestionInThisCat;
}
}
}
foreach ($tabcatid as $category) {
if (empty($category['id'])) {
continue;
}
$nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $category['id']);
if ($nbQuestionInThisCat > $res_num_max) {
$res_num_max = $nbQuestionInThisCat;
}
}
return $res_num_max;
}

Loading…
Cancel
Save