Update json to csv ok

This commit is contained in:
Fred Tempez 2024-04-12 09:52:39 +02:00
parent c0d14596a7
commit 6bc8636692

View File

@ -30,16 +30,17 @@ if (
foreach ($this->getData(['enrolment']) as $courseId => $users) { foreach ($this->getData(['enrolment']) as $courseId => $users) {
$filename = self::DATA_DIR . $courseId . '/report.csv'; $filename = self::DATA_DIR . $courseId . '/report.csv';
$fp = fopen($filename, 'w'); $fp = fopen($filename, 'w');
foreach ($users as $userId => $userData) { foreach ($users as $userId => $userData) {
$history = $userData['history']; $history = array_key_exists('history', $userData) ? $userData['history'] : null;
foreach ($history as $pageId => $timestamps) {
foreach ($timestamps as $timestamp) { if (is_array($history)) {
fputcsv($fp, [$userId, $pageId, $timestamp]); foreach ($history as $pageId => $timestamps) {
foreach ($timestamps as $timestamp) {
fputcsv($fp, [$userId, $pageId, $timestamp], ';');
}
} }
} }
} }
fclose($fp); fclose($fp);
} }
//$this->setData(['core', 'dataVersion', 1800]); //$this->setData(['core', 'dataVersion', 1800]);