diff --git a/public/main/gradebook/lib/fe/flatviewtable.class.php b/public/main/gradebook/lib/fe/flatviewtable.class.php
index 41c783a148..d819d9b171 100644
--- a/public/main/gradebook/lib/fe/flatviewtable.class.php
+++ b/public/main/gradebook/lib/fe/flatviewtable.class.php
@@ -165,7 +165,15 @@ class FlatViewTable extends SortableTable
$resource_list = $new_list;
$i = 1;
// Cache definition
- $cachePath = api_get_path(SYS_ARCHIVE_PATH);
+ $cachePath = api_get_path(SYS_ARCHIVE_PATH) . 'chart/';
+ if (!file_exists($cachePath)) {
+ mkdir($cachePath, 0755, true);
+ }
+
+ if (!is_writable($cachePath)) {
+ chmod($cachePath, 0755);
+ }
+
foreach ($resource_list as $key => $resource) {
// Reverse array, otherwise we get highest values first
$resource = array_reverse($resource, true);
@@ -196,9 +204,8 @@ class FlatViewTable extends SortableTable
$myCache = new pCache(['CacheFolder' => substr($cachePath, 0, strlen($cachePath) - 1)]);
$chartHash = $myCache->getHash($dataSet);
if ($myCache->isInCache($chartHash)) {
- $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
+ $imgPath = $cachePath.$chartHash;
$myCache->saveFromCache($chartHash, $imgPath);
- $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
} else {
/* Create the pChart object */
$widthSize = 480;
@@ -294,11 +301,10 @@ class FlatViewTable extends SortableTable
/* Render the picture (choose the best way) */
$myCache->writeToCache($chartHash, $myPicture);
- $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
+ $imgPath = $cachePath.$chartHash;
$myCache->saveFromCache($chartHash, $imgPath);
- $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
}
- echo '
';
+ echo '
';
if (0 == $i % 2 && 0 != $i) {
echo '
';
} else {