Skip to content

Commit be08774

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents a5cd3f8 + 8416801 commit be08774

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

public/main/gradebook/lib/fe/flatviewtable.class.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,15 @@ public function display_graph_by_resource()
165165
$resource_list = $new_list;
166166
$i = 1;
167167
// Cache definition
168-
$cachePath = api_get_path(SYS_ARCHIVE_PATH);
168+
$cachePath = api_get_path(SYS_ARCHIVE_PATH) . 'chart/';
169+
if (!file_exists($cachePath)) {
170+
mkdir($cachePath, 0755, true);
171+
}
172+
173+
if (!is_writable($cachePath)) {
174+
chmod($cachePath, 0755);
175+
}
176+
169177
foreach ($resource_list as $key => $resource) {
170178
// Reverse array, otherwise we get highest values first
171179
$resource = array_reverse($resource, true);
@@ -196,9 +204,8 @@ public function display_graph_by_resource()
196204
$myCache = new pCache(['CacheFolder' => substr($cachePath, 0, strlen($cachePath) - 1)]);
197205
$chartHash = $myCache->getHash($dataSet);
198206
if ($myCache->isInCache($chartHash)) {
199-
$imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
207+
$imgPath = $cachePath.$chartHash;
200208
$myCache->saveFromCache($chartHash, $imgPath);
201-
$imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
202209
} else {
203210
/* Create the pChart object */
204211
$widthSize = 480;
@@ -294,11 +301,10 @@ public function display_graph_by_resource()
294301
/* Render the picture (choose the best way) */
295302

296303
$myCache->writeToCache($chartHash, $myPicture);
297-
$imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
304+
$imgPath = $cachePath.$chartHash;
298305
$myCache->saveFromCache($chartHash, $imgPath);
299-
$imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
300306
}
301-
echo '<img src="'.$imgPath.'" >';
307+
echo '<img src="data:image/png;base64,' . base64_encode(file_get_contents($imgPath)) . '" >';
302308
if (0 == $i % 2 && 0 != $i) {
303309
echo '<br /><br />';
304310
} else {

0 commit comments

Comments
 (0)