diff options
| author | nsfisis <nsfisis@gmail.com> | 2024-03-09 14:35:37 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2024-03-09 14:35:37 +0900 |
| commit | ac5fd153e36f3cceb96ffd9e7af9ca967d9b9215 (patch) | |
| tree | 035364b46573a9bd08e52b4ffc2c9f4b3357ec70 | |
| parent | b53a20bb6c7cf9ee9ce3f8d0e536be0cb8710203 (diff) | |
| download | phperkaigi-2024-albatross-ac5fd153e36f3cceb96ffd9e7af9ca967d9b9215.tar.gz phperkaigi-2024-albatross-ac5fd153e36f3cceb96ffd9e7af9ca967d9b9215.tar.zst phperkaigi-2024-albatross-ac5fd153e36f3cceb96ffd9e7af9ca967d9b9215.zip | |
show ranking chart for admin users
| -rw-r--r-- | services/app/src/App.php | 4 | ||||
| -rw-r--r-- | services/app/templates/admin_answer_list.html.twig | 5 |
2 files changed, 8 insertions, 1 deletions
diff --git a/services/app/src/App.php b/services/app/src/App.php index b2ffba0..aef1b12 100644 --- a/services/app/src/App.php +++ b/services/app/src/App.php @@ -954,7 +954,9 @@ final class App 'error' => 'not_found', ])->withStatus(404); } - if ($quiz->isRankingHidden()) { + $currentUser = $this->getCurrentUser($request); + $isAdmin = $currentUser !== null ? $currentUser->is_admin : false; + if ($quiz->isRankingHidden() && !$isAdmin) { return $this->makeJsonResponse($response, [ 'error' => 'forbidden', ])->withStatus(403); diff --git a/services/app/templates/admin_answer_list.html.twig b/services/app/templates/admin_answer_list.html.twig index 68f0089..5d07d92 100644 --- a/services/app/templates/admin_answer_list.html.twig +++ b/services/app/templates/admin_answer_list.html.twig @@ -38,4 +38,9 @@ {% endfor %} </tbody> </table> + + <div> + <canvas id="chart" data-quiz-id="{{ quiz.quiz_id }}"></canvas> + <script type="module" src="{{ base_path() }}/assets/chart.js"></script> + </div> {% endblock %} |
