Exercises: Fix radar results #3644

pull/3675/head
Julio Montoya 5 years ago
parent f67911dccb
commit 9976e1fa96
  1. 1
      main/exercise/TestCategory.php
  2. 16
      main/exercise/exercise.class.php

@ -395,6 +395,7 @@ class TestCategory
$categoryId = $catInfo['id']; $categoryId = $catInfo['id'];
if (!empty($categoryId)) { if (!empty($categoryId)) {
$result[$categoryId] = [ $result[$categoryId] = [
'id' => $categoryId,
'title' => $catInfo['title'], 'title' => $catInfo['title'],
//'parent_id' => $catInfo['parent_id'], //'parent_id' => $catInfo['parent_id'],
'parent_id' => '', 'parent_id' => '',

@ -10465,11 +10465,13 @@ class Exercise
{ {
$dataSet = []; $dataSet = [];
$labels = []; $labels = [];
$labelsWithId = [];
/** @var Exercise $exercise */ /** @var Exercise $exercise */
foreach ($exercises as $exercise) { foreach ($exercises as $exercise) {
if (empty($labels)) { if (empty($labels)) {
$categoryNameList = TestCategory::getListOfCategoriesNameForTest($exercise->iId); $categoryNameList = TestCategory::getListOfCategoriesNameForTest($exercise->iId);
$labels = array_column($categoryNameList, 'title'); $labels = array_column($categoryNameList, 'title');
$labelsWithId = array_column($categoryNameList, 'title', 'id');
} }
foreach ($userList as $userId) { foreach ($userList as $userId) {
@ -10493,10 +10495,20 @@ class Exercise
ob_end_clean(); ob_end_clean();
$categoryList = $stats['category_list']; $categoryList = $stats['category_list'];
$resultsArray = [];
$tempResult = [];
foreach ($categoryList as $category_id => $category_item) { foreach ($categoryList as $category_id => $category_item) {
$resultsArray[] = round($category_item['score'] / $category_item['total'] * 10); $tempResult[$category_id] = round($category_item['score'] / $category_item['total'] * 10);
} }
$resultsArray = [];
foreach ($labelsWithId as $categoryId => $label) {
if (isset($tempResult[$categoryId])) {
$resultsArray[] = $tempResult[$categoryId];
} else {
$resultsArray[] = 0;
}
}
$dataSet[] = $resultsArray; $dataSet[] = $resultsArray;
} }
} }

Loading…
Cancel
Save