From 82c90a89760d3bb4c9559ed5059f90dd8d94686a Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Tue, 13 Oct 2020 20:46:11 +0200 Subject: [PATCH] wip #3947 @1 --- .../Controllers/Admin/Base/QuizController.php | 2 + .../Admin/Operations/ReportOperation.php | 39 +++ composer.json | 3 +- composer.lock | 315 +++++++++++++++++- .../crud/buttons/quiz/report.blade.php | 4 + 5 files changed, 361 insertions(+), 2 deletions(-) create mode 100644 app/Http/Controllers/Admin/Operations/ReportOperation.php create mode 100644 resources/views/vendor/backpack/crud/buttons/quiz/report.blade.php diff --git a/app/Http/Controllers/Admin/Base/QuizController.php b/app/Http/Controllers/Admin/Base/QuizController.php index efb7eec0f..22f026f08 100644 --- a/app/Http/Controllers/Admin/Base/QuizController.php +++ b/app/Http/Controllers/Admin/Base/QuizController.php @@ -7,6 +7,7 @@ use App\Http\Controllers\Admin\Operations\DownloadOperation; use App\Http\Controllers\Admin\Operations\ImportOperation; use App\Http\Controllers\Admin\Operations\LogOperation; use App\Http\Controllers\Admin\Operations\PreviewOperation; +use App\Http\Controllers\Admin\Operations\ReportOperation; use Cubist\Backpack\app\Magic\Controllers\CubistMagicController; class QuizController extends CubistMagicController @@ -15,6 +16,7 @@ class QuizController extends CubistMagicController use DownloadOperation; use ImportOperation; use LogOperation; + use ReportOperation; function setupListOperation() { diff --git a/app/Http/Controllers/Admin/Operations/ReportOperation.php b/app/Http/Controllers/Admin/Operations/ReportOperation.php new file mode 100644 index 000000000..e7c67243e --- /dev/null +++ b/app/Http/Controllers/Admin/Operations/ReportOperation.php @@ -0,0 +1,39 @@ +crud->addButtonFromView('line', 'report', 'quiz.report', 'end'); + } + + protected function report($id) + { + $spreadsheet = new Spreadsheet(); + + $sheet = $spreadsheet->getActiveSheet(); + $sheet->setTitle('USERS'); + + $sheet = $spreadsheet->createSheet(); + $sheet->setTitle('DATA'); + $sheet->setCellValue('A1', 'Hello World !'); + + $writer = new Xlsx($spreadsheet); + $tmp = Files::tempnam(); + $writer->save($tmp); + + return response()->download($tmp, 'report_' . $id . '_' . date('YmdHi') . '.xlsx')->deleteFileAfterSend(); + } +} diff --git a/composer.json b/composer.json index 4f24d4cbd..ea8ee72ec 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,8 @@ "ext-zip": "*", "cubedesigners/userdatabase": "dev-master", "cubist/cms-back": "dev-master", - "league/csv": "^9.6" + "league/csv": "^9.6", + "phpoffice/phpspreadsheet": "^1.15" }, "require-dev": { "facade/ignition": "^2.3", diff --git a/composer.lock b/composer.lock index 7ed5a3f3d..b0f9440c3 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b61ac3e9f828d211f747b8170cb9726d", + "content-hash": "b363d708ea1214f29e5b04cd7c489912", "packages": [ { "name": "backpack/backupmanager", @@ -3291,6 +3291,171 @@ ], "time": "2020-05-30T13:11:16+00:00" }, + { + "name": "markbaker/complex", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/MarkBaker/PHPComplex.git", + "reference": "9999f1432fae467bc93c53f357105b4c31bb994c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/MarkBaker/PHPComplex/zipball/9999f1432fae467bc93c53f357105b4c31bb994c", + "reference": "9999f1432fae467bc93c53f357105b4c31bb994c", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0", + "phpcompatibility/php-compatibility": "^9.0", + "phpdocumentor/phpdocumentor": "2.*", + "phploc/phploc": "^4.0", + "phpmd/phpmd": "2.*", + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.3", + "sebastian/phpcpd": "^4.0", + "squizlabs/php_codesniffer": "^3.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "Complex\\": "classes/src/" + }, + "files": [ + "classes/src/functions/abs.php", + "classes/src/functions/acos.php", + "classes/src/functions/acosh.php", + "classes/src/functions/acot.php", + "classes/src/functions/acoth.php", + "classes/src/functions/acsc.php", + "classes/src/functions/acsch.php", + "classes/src/functions/argument.php", + "classes/src/functions/asec.php", + "classes/src/functions/asech.php", + "classes/src/functions/asin.php", + "classes/src/functions/asinh.php", + "classes/src/functions/atan.php", + "classes/src/functions/atanh.php", + "classes/src/functions/conjugate.php", + "classes/src/functions/cos.php", + "classes/src/functions/cosh.php", + "classes/src/functions/cot.php", + "classes/src/functions/coth.php", + "classes/src/functions/csc.php", + "classes/src/functions/csch.php", + "classes/src/functions/exp.php", + "classes/src/functions/inverse.php", + "classes/src/functions/ln.php", + "classes/src/functions/log2.php", + "classes/src/functions/log10.php", + "classes/src/functions/negative.php", + "classes/src/functions/pow.php", + "classes/src/functions/rho.php", + "classes/src/functions/sec.php", + "classes/src/functions/sech.php", + "classes/src/functions/sin.php", + "classes/src/functions/sinh.php", + "classes/src/functions/sqrt.php", + "classes/src/functions/tan.php", + "classes/src/functions/tanh.php", + "classes/src/functions/theta.php", + "classes/src/operations/add.php", + "classes/src/operations/subtract.php", + "classes/src/operations/multiply.php", + "classes/src/operations/divideby.php", + "classes/src/operations/divideinto.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mark Baker", + "email": "mark@lange.demon.co.uk" + } + ], + "description": "PHP Class for working with complex numbers", + "homepage": "https://github.com/MarkBaker/PHPComplex", + "keywords": [ + "complex", + "mathematics" + ], + "time": "2020-08-26T10:42:07+00:00" + }, + { + "name": "markbaker/matrix", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/MarkBaker/PHPMatrix.git", + "reference": "9567d9c4c519fbe40de01dbd1e4469dbbb66f46a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/MarkBaker/PHPMatrix/zipball/9567d9c4c519fbe40de01dbd1e4469dbbb66f46a", + "reference": "9567d9c4c519fbe40de01dbd1e4469dbbb66f46a", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0", + "phpcompatibility/php-compatibility": "^9.0", + "phpdocumentor/phpdocumentor": "2.*", + "phploc/phploc": "^4.0", + "phpmd/phpmd": "2.*", + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.3", + "sebastian/phpcpd": "^4.0", + "squizlabs/php_codesniffer": "^3.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "Matrix\\": "classes/src/" + }, + "files": [ + "classes/src/functions/adjoint.php", + "classes/src/functions/antidiagonal.php", + "classes/src/functions/cofactors.php", + "classes/src/functions/determinant.php", + "classes/src/functions/diagonal.php", + "classes/src/functions/identity.php", + "classes/src/functions/inverse.php", + "classes/src/functions/minors.php", + "classes/src/functions/trace.php", + "classes/src/functions/transpose.php", + "classes/src/operations/add.php", + "classes/src/operations/directsum.php", + "classes/src/operations/subtract.php", + "classes/src/operations/multiply.php", + "classes/src/operations/divideby.php", + "classes/src/operations/divideinto.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mark Baker", + "email": "mark@demon-angel.eu" + } + ], + "description": "PHP Class for working with matrices", + "homepage": "https://github.com/MarkBaker/PHPMatrix", + "keywords": [ + "mathematics", + "matrix", + "vector" + ], + "time": "2020-08-28T17:11:00+00:00" + }, { "name": "maximebf/debugbar", "version": "v1.16.3", @@ -3766,6 +3931,102 @@ ], "time": "2018-07-02T15:55:56+00:00" }, + { + "name": "phpoffice/phpspreadsheet", + "version": "1.15.0", + "source": { + "type": "git", + "url": "https://github.com/PHPOffice/PhpSpreadsheet.git", + "reference": "a8e8068b31b8119e1daa5b1eb5715a3a8ea8305f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/a8e8068b31b8119e1daa5b1eb5715a3a8ea8305f", + "reference": "a8e8068b31b8119e1daa5b1eb5715a3a8ea8305f", + "shasum": "" + }, + "require": { + "ext-ctype": "*", + "ext-dom": "*", + "ext-fileinfo": "*", + "ext-gd": "*", + "ext-iconv": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-simplexml": "*", + "ext-xml": "*", + "ext-xmlreader": "*", + "ext-xmlwriter": "*", + "ext-zip": "*", + "ext-zlib": "*", + "maennchen/zipstream-php": "^2.1", + "markbaker/complex": "^1.5|^2.0", + "markbaker/matrix": "^1.2|^2.0", + "php": "^7.2|^8.0", + "psr/http-client": "^1.0", + "psr/http-factory": "^1.0", + "psr/simple-cache": "^1.0" + }, + "require-dev": { + "dompdf/dompdf": "^0.8.5", + "friendsofphp/php-cs-fixer": "^2.16", + "jpgraph/jpgraph": "^4.0", + "mpdf/mpdf": "^8.0", + "phpcompatibility/php-compatibility": "^9.3", + "phpunit/phpunit": "^8.5|^9.3", + "squizlabs/php_codesniffer": "^3.5", + "tecnickcom/tcpdf": "^6.3" + }, + "suggest": { + "dompdf/dompdf": "Option for rendering PDF with PDF Writer (doesn't yet support PHP8)", + "jpgraph/jpgraph": "Option for rendering charts, or including charts with PDF or HTML Writers", + "mpdf/mpdf": "Option for rendering PDF with PDF Writer", + "tecnickcom/tcpdf": "Option for rendering PDF with PDF Writer (doesn't yet support PHP8)" + }, + "type": "library", + "autoload": { + "psr-4": { + "PhpOffice\\PhpSpreadsheet\\": "src/PhpSpreadsheet" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Maarten Balliauw", + "homepage": "https://blog.maartenballiauw.be" + }, + { + "name": "Mark Baker", + "homepage": "https://markbakeruk.net" + }, + { + "name": "Franck Lefevre", + "homepage": "https://rootslabs.net" + }, + { + "name": "Erik Tilt" + }, + { + "name": "Adrien Crivelli" + } + ], + "description": "PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine", + "homepage": "https://github.com/PHPOffice/PhpSpreadsheet", + "keywords": [ + "OpenXML", + "excel", + "gnumeric", + "ods", + "php", + "spreadsheet", + "xls", + "xlsx" + ], + "time": "2020-10-11T13:20:59+00:00" + }, { "name": "phpoption/phpoption", "version": "1.7.5", @@ -4146,6 +4407,58 @@ ], "time": "2020-06-29T06:28:15+00:00" }, + { + "name": "psr/http-factory", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-factory.git", + "reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-factory/zipball/12ac7fcd07e5b077433f5f2bee95b3a771bf61be", + "reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be", + "shasum": "" + }, + "require": { + "php": ">=7.0.0", + "psr/http-message": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interfaces for PSR-7 HTTP message factories", + "keywords": [ + "factory", + "http", + "message", + "psr", + "psr-17", + "psr-7", + "request", + "response" + ], + "time": "2019-04-30T12:38:16+00:00" + }, { "name": "psr/http-message", "version": "1.0.1", diff --git a/resources/views/vendor/backpack/crud/buttons/quiz/report.blade.php b/resources/views/vendor/backpack/crud/buttons/quiz/report.blade.php new file mode 100644 index 000000000..6fdee9f70 --- /dev/null +++ b/resources/views/vendor/backpack/crud/buttons/quiz/report.blade.php @@ -0,0 +1,4 @@ +@if($entry->getAttribute('logattempts')) + Report +@endif -- 2.39.5