Skip to content

Commit

Permalink
Merge pull request #145 from VSVverkeerskunde/feature/VSVGVQ-145
Browse files Browse the repository at this point in the history
VSVGVQ-145 Show general statistics during the quiz in the company dashboard.
  • Loading branch information
Luc Wollants committed Oct 16, 2018
2 parents 4a4d717 + e09766a commit 8817e10
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 6 deletions.
3 changes: 3 additions & 0 deletions config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,9 @@ services:
tags: ['controller.service_arguments']

VSV\GVQ_API\Dashboard\Controllers\DashboardViewController:
arguments:
$year: '@quiz_year'
$statisticsService: '@statistics_service'
tags: ['controller.service_arguments']

VSV\GVQ_API\Report\Controllers\ReportViewController:
Expand Down
25 changes: 25 additions & 0 deletions src/Dashboard/Controllers/DashboardViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,28 @@
use VSV\GVQ_API\Company\Models\Company;
use VSV\GVQ_API\Company\Repositories\CompanyRepository;
use VSV\GVQ_API\Dashboard\Service\DashboardService;
use VSV\GVQ_API\Question\ValueObjects\Year;
use VSV\GVQ_API\Statistics\Models\TopScore;
use VSV\GVQ_API\Statistics\Service\StatisticsService;
use VSV\GVQ_API\User\Repositories\UserRepository;

class DashboardViewController extends CompanyAwareController
{
/**
* @var Year
*/
private $year;

/**
* @var DashboardService
*/
private $dashboardService;

/**
* @var StatisticsService
*/
private $statisticsService;

/**
* @var SerializerInterface
*/
Expand All @@ -30,22 +42,28 @@ class DashboardViewController extends CompanyAwareController
private $responseFactory;

/**
* @param Year $year
* @param UserRepository $userRepository
* @param CompanyRepository $companyRepository
* @param DashboardService $dashboardService
* @param StatisticsService $statisticsService
* @param SerializerInterface $serializer
* @param ResponseFactory $responseFactory
*/
public function __construct(
Year $year,
UserRepository $userRepository,
CompanyRepository $companyRepository,
DashboardService $dashboardService,
StatisticsService $statisticsService,
SerializerInterface $serializer,
ResponseFactory $responseFactory
) {
parent::__construct($userRepository, $companyRepository);

$this->year = $year;
$this->dashboardService = $dashboardService;
$this->statisticsService = $statisticsService;
$this->serializer = $serializer;
$this->responseFactory = $responseFactory;
}
Expand Down Expand Up @@ -81,6 +99,10 @@ public function dashboard(?string $companyId): Response
}
}

$passedUniqueParticipantCounts = $this->statisticsService->getPassedUniqueParticipantCounts();
$passedUniqueParticipantPercentage = $this->statisticsService->getPassedUniqueParticipantPercentages();
$detailedTopScoreAverages = $this->statisticsService->getDetailedTopScoreAverages();

return $this->render(
'dashboard/dashboard.html.twig',
[
Expand All @@ -91,6 +113,9 @@ public function dashboard(?string $companyId): Response
'average' => $average,
'topScores' => $firstTenTopScores,
'showTopScoresCard' => count($allTopScores) > 0,
'passedUniqueParticipantCounts' => $passedUniqueParticipantCounts,
'passedUniqueParticipantPercentage' => $passedUniqueParticipantPercentage,
'detailedTopScoreAverages' => $detailedTopScoreAverages,
]
);
}
Expand Down
46 changes: 40 additions & 6 deletions templates/dashboard/dashboard.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@

<p>{% trans %}Dashboard.welcome{% endtrans %}</p>

<div class="row justify-content-between">
<div class="col-md-6 col-lg-4">
<div class="row justify-content-around">
<div class="col-md-6 col-lg-5">
<div class="card text-center mb-4">
<div class="card-header">
<h3 class="card-title">{% trans %}Dashboard.ratio.title{% endtrans %}</h3>
Expand Down Expand Up @@ -96,11 +96,43 @@
</div>
</div>
{% endif %}


</div>
<div class="col-md-6 col-lg-4">
<!-- ADD SECOND COL CONTENT HERE -->

<div class="col-md-6 col-lg-5">
<div class="card text-center mb-4">
<div class="card-header">
<h3 class="card-title">{% trans %}Statistics.title.general{% endtrans %}</h3>
</div>
<div class="card-body">
<table class="table table-borderless">
<thead class="thead-dark thead-primary text-center">
<tr>
<td class="border-0"></td>
<th>{% trans %}Statistics.subheader.NL{% endtrans %}</th>
<th>{% trans %}Statistics.subheader.FR{% endtrans %}</th>
<th class="border-right">{% trans %}Statistics.subheader.Total{% endtrans %}</th>
</tr>
</thead>
<tbody>
<tr class="border-top">
<th class="fit" scope="row" data-toggle="tooltip" title="{% trans %}Statistics.info.passed{% endtrans %}">
{% trans %}Statistics.row.passed{% endtrans %}</th>
{% include 'dashboard/statistics_row.html.twig' with {'counts': passedUniqueParticipantCounts} %}
</tr>
<tr class="border-top">
<th class="fit" scope="row" data-toggle="tooltip" title="{% trans %}Statistics.info.percentage{% endtrans %}">
{% trans %}Statistics.row.percentage{% endtrans %}</th>
{% include 'dashboard/statistics_row.html.twig' with {'counts': passedUniqueParticipantPercentage} %}
</tr>
<tr class="border-top">
<th class="fit" scope="row" data-toggle="tooltip" title="{% trans %}Statistics.info.topscore{% endtrans %}">
{% trans %}Statistics.row.topscore{% endtrans %}</th>
{% include 'dashboard/statistics_row.html.twig' with {'counts': detailedTopScoreAverages} %}
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>

Expand All @@ -110,6 +142,8 @@
{{ parent() }}
<script>
$(document).ready(function () {
$('[data-toggle="tooltip"]').tooltip();
$('#company').change(function () {
var url = $("#apply").attr('href').slice(0, -36);
url = url + $('#company').val();
Expand Down
3 changes: 3 additions & 0 deletions templates/dashboard/statistics_row.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<td>{{ counts['quiz_total_nl'] }}</td>
<td>{{ counts['quiz_total_fr'] }}</td>
<td>{{ counts['quiz_total'] }}</td>

0 comments on commit 8817e10

Please sign in to comment.