Commit af62cd5a authored by SuliacLavenant's avatar SuliacLavenant Committed by Regis
Browse files

#81 cumuled time event ranking issue with progress and #76 #77

parent e454cf17
......@@ -8,16 +8,16 @@
"packages": [
{
"name": "composer/package-versions-deprecated",
"version": "1.11.99.1",
"version": "1.11.99.2",
"source": {
"type": "git",
"url": "https://github.com/composer/package-versions-deprecated.git",
"reference": "7413f0b55a051e89485c5cb9f765fe24bb02a7b6"
"reference": "c6522afe5540d5fc46675043d3ed5a45a740b27c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/package-versions-deprecated/zipball/7413f0b55a051e89485c5cb9f765fe24bb02a7b6",
"reference": "7413f0b55a051e89485c5cb9f765fe24bb02a7b6",
"url": "https://api.github.com/repos/composer/package-versions-deprecated/zipball/c6522afe5540d5fc46675043d3ed5a45a740b27c",
"reference": "c6522afe5540d5fc46675043d3ed5a45a740b27c",
"shasum": ""
},
"require": {
......@@ -61,7 +61,7 @@
"description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)",
"support": {
"issues": "https://github.com/composer/package-versions-deprecated/issues",
"source": "https://github.com/composer/package-versions-deprecated/tree/1.11.99.1"
"source": "https://github.com/composer/package-versions-deprecated/tree/1.11.99.2"
},
"funding": [
{
......@@ -77,7 +77,7 @@
"type": "tidelift"
}
],
"time": "2020-11-11T10:22:58+00:00"
"time": "2021-05-24T07:46:03+00:00"
},
{
"name": "doctrine/annotations",
......@@ -153,16 +153,16 @@
},
{
"name": "doctrine/cache",
"version": "1.11.1",
"version": "1.11.2",
"source": {
"type": "git",
"url": "https://github.com/doctrine/cache.git",
"reference": "163074496dc7c3c7b8ccbf3d4376c0187424ed81"
"reference": "9c53086695937c50c47936ed86d96150ffbcf60d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/cache/zipball/163074496dc7c3c7b8ccbf3d4376c0187424ed81",
"reference": "163074496dc7c3c7b8ccbf3d4376c0187424ed81",
"url": "https://api.github.com/repos/doctrine/cache/zipball/9c53086695937c50c47936ed86d96150ffbcf60d",
"reference": "9c53086695937c50c47936ed86d96150ffbcf60d",
"shasum": ""
},
"require": {
......@@ -232,7 +232,7 @@
],
"support": {
"issues": "https://github.com/doctrine/cache/issues",
"source": "https://github.com/doctrine/cache/tree/1.11.1"
"source": "https://github.com/doctrine/cache/tree/1.11.2"
},
"funding": [
{
......@@ -248,7 +248,7 @@
"type": "tidelift"
}
],
"time": "2021-05-18T16:45:32+00:00"
"time": "2021-05-20T14:57:29+00:00"
},
{
"name": "doctrine/collections",
......@@ -1609,16 +1609,16 @@
},
{
"name": "friendsofphp/proxy-manager-lts",
"version": "v1.0.4",
"version": "v1.0.5",
"source": {
"type": "git",
"url": "https://github.com/FriendsOfPHP/proxy-manager-lts.git",
"reference": "587bfddfd9847c1d0417c4cf07d1dbf19aa6d136"
"reference": "006aa5d32f887a4db4353b13b5b5095613e0611f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/FriendsOfPHP/proxy-manager-lts/zipball/587bfddfd9847c1d0417c4cf07d1dbf19aa6d136",
"reference": "587bfddfd9847c1d0417c4cf07d1dbf19aa6d136",
"url": "https://api.github.com/repos/FriendsOfPHP/proxy-manager-lts/zipball/006aa5d32f887a4db4353b13b5b5095613e0611f",
"reference": "006aa5d32f887a4db4353b13b5b5095613e0611f",
"shasum": ""
},
"require": {
......@@ -1675,7 +1675,7 @@
],
"support": {
"issues": "https://github.com/FriendsOfPHP/proxy-manager-lts/issues",
"source": "https://github.com/FriendsOfPHP/proxy-manager-lts/tree/v1.0.4"
"source": "https://github.com/FriendsOfPHP/proxy-manager-lts/tree/v1.0.5"
},
"funding": [
{
......@@ -1687,7 +1687,7 @@
"type": "tidelift"
}
],
"time": "2021-05-19T14:35:49+00:00"
"time": "2021-05-22T16:11:15+00:00"
},
{
"name": "laminas/laminas-code",
......
......@@ -123,7 +123,7 @@ class EventController extends AbstractController
'event' => $event,
'eventCourses' => $event->getEventCourses(),
'participants' => $event->getParticipants(),
'ranking' => $this->extractRanking($id),
'ranking' => $event->extractRanking($this->getDoctrine()->getRepository(ParticipantMakeEventCourse::class)),
'forms' => $formsView,
]
);
......@@ -354,71 +354,11 @@ class EventController extends AbstractController
'event' => $event,
'eventCourses' => $event->getEventCourses(),
'participants' => $event->getParticipants(),
'ranking' => $this->extractRanking($id),
'ranking' => $event->extractRanking($this->getDoctrine()->getRepository(ParticipantMakeEventCourse::class)),
'participantForm' => $participantForm->createView(),
'error' => $error,
'success' => $success,
]
);
}
public function extractRanking(int $eventId): array
{
$participants = $this->getDoctrine()->getRepository(Event::class)->find($eventId)->getParticipants();
$eventCourses = $this->getDoctrine()->getRepository(Event::class)->find($eventId)->getEventCourses();
$score = [];
$totalTime = [];
$ranking = [[], [], [], [], [], []];
if ($participants[0] !== null and $eventCourses[0] !== null) {
for ($i = 0; $i < sizeof($participants); $i++) {
$score[$i] = 0;
$totalTime[$i] = 0;
$ranking[2][$i] = 0;
$ranking[3][$i] = array();
$ranking[5][$i] = array();
foreach ($eventCourses as $eventCourse) {
$participantMakeEventCourse = $this->getDoctrine()->getRepository(ParticipantMakeEventCourse::class)->find(array("eventCourse" => $eventCourse, "participant" => $participants->get($i)));
if ($participantMakeEventCourse->getTrack() !== null) {
$eventCourseScore = $participantMakeEventCourse->getScore();
$eventCourseTime = $participantMakeEventCourse->getTrack()->getTotalTime() + ($participantMakeEventCourse->getNbMissingPunchPenalty() * $participantMakeEventCourse->getEventCourse()->getMissingPunchPenalty() * 60000);
if ($participantMakeEventCourse->getEventCourse()->getOverTimePenalty() === 0) {
$eventCourseTime += ($participantMakeEventCourse->getNbOverTimePenalty() * $participantMakeEventCourse->getEventCourse()->getOverTimePenalty() * 60000);
}
$ranking[2][$i] += 1;
$score[$i] += $eventCourseScore;
$totalTime[$i] += $eventCourseTime;
array_push($ranking[3][$i], array($eventCourseScore, $participantMakeEventCourse->getNbMissingPunchPenalty(), $participantMakeEventCourse->getNbOverTimePenalty(), $eventCourseTime));
} else {
array_push($ranking[3][$i], array("-", "-", "-", "-"));
}
array_push($ranking[5][$i], array($participantMakeEventCourse->isModified()));
}
$ranking[1][$i] = $score[$i];
$ranking[4][$i] = $totalTime[$i];
}
if ($eventCourses[0]->getEvent()->getType() === 0 or $eventCourses[0]->getEvent()->getType() === 1) {
while (sizeof($score) !== 0) {
$max = max($score);
array_push($ranking[0], array_search($max, $score));
unset($score[array_search($max, $score)]);
}
} elseif ($eventCourses[0]->getEvent()->getType() === 2) {
$zeros = array();
while (sizeof($totalTime) !== 0) {
$min = min($totalTime);
if ($min === 0) {
array_push($zeros, array_search($min, $totalTime));
} else {
array_push($ranking[0], array_search($min, $totalTime));
}
unset($totalTime[array_search($min, $totalTime)]);
}
foreach ($zeros as $zero) {
array_push($ranking[0], $zero);
}
}
}
return $ranking;
}
}
......@@ -123,7 +123,7 @@ class Event
if ($participantMakeEventCourse->getTrack() !== null) {
$participantMakeEventCourse->extractFromTrack();
$time = $participantMakeEventCourse->getTrack()->getTotalTime() + ($participantMakeEventCourse->getNbMissingPunchPenalty() * $participantMakeEventCourse->getEventCourse()->getMissingPunchPenalty() * 60000);
if($participantMakeEventCourse->getEventCourse()->getOverTimePenalty()===0){
if ($participantMakeEventCourse->getEventCourse()->getOverTimePenalty() === 0) {
$time += ($participantMakeEventCourse->getNbOverTimePenalty() * $participantMakeEventCourse->getEventCourse()->getOverTimePenalty() * 60000);
}
if ($minTime > $time) {
......@@ -135,7 +135,7 @@ class Event
$participantMakeEventCourse = $participantMakeEventCourseRepository->find(array("eventCourse" => $eventCourse, "participant" => $participant));
if ($participantMakeEventCourse->getTrack() !== null) {
$time = $participantMakeEventCourse->getTrack()->getTotalTime() + ($participantMakeEventCourse->getNbMissingPunchPenalty() * $participantMakeEventCourse->getEventCourse()->getMissingPunchPenalty() * 60000);
if($participantMakeEventCourse->getEventCourse()->getOverTimePenalty()===0){
if ($participantMakeEventCourse->getEventCourse()->getOverTimePenalty() === 0) {
$time += ($participantMakeEventCourse->getNbOverTimePenalty() * $participantMakeEventCourse->getEventCourse()->getOverTimePenalty() * 60000);
}
$participantMakeEventCourse->setScore(1000 * (($minTime * 1000) / ($time * 1000)));
......@@ -208,4 +208,68 @@ class Event
}
return $csv;
}
public function extractRanking($participantMakeEventCourseRepository): array
{
$participants = $this->participant;
$eventCourses = $this->eventCourses;
$score = [];
$totalTime = [];
$ranking = [];
$ranking["rank"] = array();
if ($participants[0] !== null and $eventCourses[0] !== null) {
for ($i = 0; $i < sizeof($participants); $i++) {
$score[$i] = 0;
$totalTime[$i] = 0;
$ranking["progress"][$i] = 0;
$ranking["eventCourse"][$i] = array();
$ranking["modified"][$i] = array();
foreach ($eventCourses as $eventCourse) {
$participantMakeEventCourse = $participantMakeEventCourseRepository->find(array("eventCourse" => $eventCourse, "participant" => $participants->get($i)));
if ($participantMakeEventCourse->getTrack() !== null) {
$eventCourseScore = $participantMakeEventCourse->getScore();
$eventCourseTime = $participantMakeEventCourse->getTrack()->getTotalTime();
if ($this->type === 0 or $this->type === 2) {
$eventCourseTime += ($participantMakeEventCourse->getNbMissingPunchPenalty() * $participantMakeEventCourse->getEventCourse()->getMissingPunchPenalty() * 1000);
if ($participantMakeEventCourse->getEventCourse()->getOverTimePenalty() !== 0) {
$eventCourseTime += ($participantMakeEventCourse->getNbOverTimePenalty() * $participantMakeEventCourse->getEventCourse()->getOverTimePenalty() * 1000);
}
}
$ranking["progress"][$i] += 1;
$score[$i] += $eventCourseScore;
$totalTime[$i] += $eventCourseTime;
array_push($ranking["eventCourse"][$i], array($eventCourseScore, $participantMakeEventCourse->getNbMissingPunchPenalty(), $participantMakeEventCourse->getNbOverTimePenalty(), $eventCourseTime));
} else {
array_push($ranking["eventCourse"][$i], array("-", "-", "-", "-"));
}
array_push($ranking["modified"][$i], $participantMakeEventCourse->isModified());
}
$ranking["totalScore"][$i] = $score[$i];
$ranking["totalTime"][$i] = $totalTime[$i];
}
if ($this->type === 0 or $this->type === 1) {
while (sizeof($score) !== 0) {
$max = max($score);
array_push($ranking["rank"], array_search($max, $score));
unset($score[array_search($max, $score)]);
}
} elseif ($this->type === 2) {
$nbCourses = sizeof($this->getEventCourses());
for ($progress = $nbCourses; $progress > 0; $progress--) {
$minTime = INF;
$min = null;
foreach ($totalTime as $totalTime1) {
if ($totalTime1 < $minTime) {
$id = array_search($totalTime1, $totalTime);
if ($ranking["progress"][$id] === $progress) {
array_push($ranking["rank"], $id);
unset($totalTime[$id]);
}
}
}
}
}
}
return $ranking;
}
}
......@@ -71,28 +71,28 @@
</tr>
</thead>
<tbody>
{% if ranking[0]!=[] %}
{% for rank in range(0, ranking[0]|length-1) %}
{% if ranking["rank"]!=[] %}
{% for rank in range(0, ranking["rank"]|length-1) %}
<tr>
<th scope="row">{{ rank+1 }}</th>
<td>{{ participants.get(ranking[0][rank]).nickname }}</td>
<td>{{ participants.get(ranking["rank"][rank]).nickname }}</td>
{% if event.type == 0 or event.type == 1 %}
<td>{{ ranking[1][ranking[0][rank]] }}</td>
<td>{{ ranking["totalScore"][ranking["rank"][rank]] }}</td>
{% elseif event.type ==2 %}
<td class="msTime">{{ ranking[4][ranking[0][rank]] }}</td>
<td class="msTime">{{ ranking["totalTime"][ranking["rank"][rank]] }}</td>
{% endif %}
<td>{{ ranking[2][ranking[0][rank]] }}/{{ eventCourses|length }}</td>
<td>{{ ranking["progress"][ranking["rank"][rank]] }}/{{ eventCourses|length }}</td>
{% for eventCourse in range(0, eventCourses|length-1) %}
{% if event.type == 0 or event.type == 1 %}
<td>{{ ranking[3][ranking[0][rank]][eventCourse][0] }}
( {{ ranking[3][ranking[0][rank]][eventCourse][1] }}
| {{ ranking[3][ranking[0][rank]][eventCourse][2] }} )
<td>{{ ranking["eventCourse"][ranking["rank"][rank]][eventCourse][0] }}
( {{ ranking["eventCourse"][ranking["rank"][rank]][eventCourse][1] }}
| {{ ranking["eventCourse"][ranking["rank"][rank]][eventCourse][2] }} )
</td>
{% elseif event.type ==2 %}
<td>
<span class="msTime">{{ ranking[3][ranking[0][rank]][eventCourse][3] }}</span>
( {{ ranking[3][ranking[0][rank]][eventCourse][1] }}
| {{ ranking[3][ranking[0][rank]][eventCourse][2] }} )
<span class="msTime">{{ ranking["eventCourse"][ranking["rank"][rank]][eventCourse][3] }}</span>
( {{ ranking["eventCourse"][ranking["rank"][rank]][eventCourse][1] }}
| {{ ranking["eventCourse"][ranking["rank"][rank]][eventCourse][2] }} )
</td>
{% endif %}
{% endfor %}
......
......@@ -71,31 +71,31 @@
</tr>
</thead>
<tbody>
{% if ranking[0]!=[] %}
{% for rank in range(0, ranking[0]|length-1) %}
{% if ranking["rank"]!=[] %}
{% for rank in range(0, ranking["rank"]|length-1) %}
<tr>
<th scope="row">{{ rank+1 }}</th>
<td>{{ participants.get(ranking[0][rank]).nickname }}</td>
<td>{{ participants.get(ranking["rank"][rank]).nickname }}</td>
{% if event.type == 0 or event.type == 1 %}
<td>{{ ranking[1][ranking[0][rank]] }}</td>
<td>{{ ranking["totalScore"][ranking["rank"][rank]] }}</td>
{% elseif event.type ==2 %}
<td class="msTime">{{ ranking[4][ranking[0][rank]] }}</td>
<td class="msTime">{{ ranking["totalTime"][ranking["rank"][rank]] }}</td>
{% endif %}
<td>{{ ranking[2][ranking[0][rank]] }}/{{ eventCourses|length }}</td>
<td>{{ ranking["progress"][ranking["rank"][rank]] }}/{{ eventCourses|length }}</td>
{% for eventCourse in range(0, eventCourses|length-1) %}
{% if event.type == 0 or event.type == 1 %}
<td>{{ ranking[3][ranking[0][rank]][eventCourse][0] }}
( {{ ranking[3][ranking[0][rank]][eventCourse][1] }}
| {{ ranking[3][ranking[0][rank]][eventCourse][2] }} )
{% if ranking[5][ranking[0][rank]][eventCourse][0] %}
<td>{{ ranking["eventCourse"][ranking["rank"][rank]][eventCourse][0] }}
( {{ ranking["eventCourse"][ranking["rank"][rank]][eventCourse][1] }}
| {{ ranking["eventCourse"][ranking["rank"][rank]][eventCourse][2] }} )
{% if ranking["modified"][ranking["rank"][rank]][eventCourse] %}
<button type="button" class="btn btn-success" data-toggle="modal"
data-target="#modify-{{ participants.get(ranking[0][rank]).id }}-{{ eventCourses[eventCourse].id }}">{% trans %}my_events.modify{% endtrans %}</button>
data-target="#modify-{{ participants.get(ranking["rank"][rank]).id }}-{{ eventCourses[eventCourse].id }}">{% trans %}my_events.modify{% endtrans %}</button>
{% else %}
<button type="button" class="btn btn-warning" data-toggle="modal"
data-target="#modify-{{ participants.get(ranking[0][rank]).id }}-{{ eventCourses[eventCourse].id }}">{% trans %}my_events.modify{% endtrans %}</button>
data-target="#modify-{{ participants.get(ranking["rank"][rank]).id }}-{{ eventCourses[eventCourse].id }}">{% trans %}my_events.modify{% endtrans %}</button>
{% endif %}
<div class="modal fade"
id="modify-{{ participants.get(ranking[0][rank]).id }}-{{ eventCourses[eventCourse].id }}"
id="modify-{{ participants.get(ranking["rank"][rank]).id }}-{{ eventCourses[eventCourse].id }}"
tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
......@@ -106,10 +106,10 @@
<span aria-hidden="true">&times;</span>
</button>
</div>
{% form_theme forms[ranking[0][rank]][eventCourse] 'bootstrap_4_layout.html.twig' %}
{{ form_start(forms[ranking[0][rank]][eventCourse]) }}
{% form_theme forms[ranking["rank"][rank]][eventCourse] 'bootstrap_4_layout.html.twig' %}
{{ form_start(forms[ranking["rank"][rank]][eventCourse]) }}
<div class="modal-body">
{{ form_row(forms[ranking[0][rank]][eventCourse].track) }}
{{ form_row(forms[ranking["rank"][rank]][eventCourse].track) }}
</div>
<div class="modal-footer">
<button type="submit"
......@@ -117,25 +117,25 @@
<button type="button" class="btn btn-primary"
data-dismiss="modal">{% trans %}my_event.track.modify.abort{% endtrans %}</button>
</div>
{{ form_end(forms[ranking[0][rank]][eventCourse]) }}
{{ form_end(forms[ranking["rank"][rank]][eventCourse]) }}
</div>
</div>
</div>
</td>
{% elseif event.type ==2 %}
<td>
<span class="msTime">{{ ranking[3][ranking[0][rank]][eventCourse][3] }}</span>
({{ ranking[3][ranking[0][rank]][eventCourse][1] }}
|{{ ranking[3][ranking[0][rank]][eventCourse][2] }})
{% if ranking[5][ranking[0][rank]][eventCourse][0] %}
<span class="msTime">{{ ranking["eventCourse"][ranking["rank"][rank]][eventCourse][3] }}</span>
({{ ranking["eventCourse"][ranking["rank"][rank]][eventCourse][1] }}
|{{ ranking["eventCourse"][ranking["rank"][rank]][eventCourse][2] }})
{% if ranking["modified"][ranking["rank"][rank]][eventCourse]%}
<button type="button" class="btn btn-success" data-toggle="modal"
data-target="#modify-{{ participants.get(ranking[0][rank]).id }}-{{ eventCourses[eventCourse].id }}">{% trans %}my_events.modify{% endtrans %}</button>
data-target="#modify-{{ participants.get(ranking["rank"][rank]).id }}-{{ eventCourses[eventCourse].id }}">{% trans %}my_events.modify{% endtrans %}</button>
{% else %}
<button type="button" class="btn btn-warning" data-toggle="modal"
data-target="#modify-{{ participants.get(ranking[0][rank]).id }}-{{ eventCourses[eventCourse].id }}">{% trans %}my_events.modify{% endtrans %}</button>
data-target="#modify-{{ participants.get(ranking["rank"][rank]).id }}-{{ eventCourses[eventCourse].id }}">{% trans %}my_events.modify{% endtrans %}</button>
{% endif %}
<div class="modal fade"
id="modify-{{ participants.get(ranking[0][rank]).id }}-{{ eventCourses[eventCourse].id }}"
id="modify-{{ participants.get(ranking["rank"][rank]).id }}-{{ eventCourses[eventCourse].id }}"
tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
......@@ -146,10 +146,10 @@
<span aria-hidden="true">&times;</span>
</button>
</div>
{% form_theme forms[ranking[0][rank]][eventCourse] 'bootstrap_4_layout.html.twig' %}
{{ form_start(forms[ranking[0][rank]][eventCourse]) }}
{% form_theme forms[ranking["rank"][rank]][eventCourse] 'bootstrap_4_layout.html.twig' %}
{{ form_start(forms[ranking["rank"][rank]][eventCourse]) }}
<div class="modal-body">
{{ form_row(forms[ranking[0][rank]][eventCourse].track) }}
{{ form_row(forms[ranking["rank"][rank]][eventCourse].track) }}
</div>
<div class="modal-footer">
<button type="submit"
......@@ -157,7 +157,7 @@
<button type="button" class="btn btn-primary"
data-dismiss="modal">{% trans %}my_event.track.modify.abort{% endtrans %}</button>
</div>
{{ form_end(forms[ranking[0][rank]][eventCourse]) }}
{{ form_end(forms[ranking["rank"][rank]][eventCourse]) }}
</div>
</div>
</div>
......
......@@ -3,6 +3,7 @@
namespace App\Tests;
use App\Entity\Event;
use App\Entity\Participant;
use App\Entity\ParticipantMakeEventCourse;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
......@@ -25,15 +26,260 @@ class EventTest extends KernelTestCase
$this->assertSame($nbParticipantMakeEventCourse, count($this->entityManager->getRepository(Event::class)->findAll()) + 1);
}
public function testUpdateCheckNbOT()
{
$theEvent = null;
foreach ($this->entityManager->getRepository(Event::class)->findAll() as $event) {
if ($event->getName() === "Championship") {
$theEvent = $event;
break;
}
}
$theParticipant = null;
foreach ($theEvent->getParticipants() as $participant) {
if ($participant->getNickName() === "Eric") {
$theParticipant = $participant;
break;
}
}
$theEventCourse = null;
foreach ($theEvent->getEventCourses() as $eventCourse) {
if ($eventCourse->getCourse()->getName() === "Luc") {
$theEventCourse = $eventCourse;
break;
}
}
$participantMakeEventCourse = $this->entityManager->getRepository(ParticipantMakeEventCourse::class)->find(array("eventCourse" => $theEventCourse, "participant" => $theParticipant));
$theEvent->update($this->entityManager, $this->entityManager->getRepository(ParticipantMakeEventCourse::class));
$this->assertSame(3, $participantMakeEventCourse->getNbOverTimePenalty());
}
public function testUpdateCheckNbPM()
{
$theEvent = null;
foreach ($this->entityManager->getRepository(Event::class)->findAll() as $event) {
if ($event->getName() === "Championship") {
$theEvent = $event;
break;
}
}
$theParticipant = null;
foreach ($theEvent->getParticipants() as $participant) {
if ($participant->getNickName() === "Eric") {
$theParticipant = $participant;
break;
}
}
$theEventCourse = null;
foreach ($theEvent->getEventCourses() as $eventCourse) {
if ($eventCourse->getCourse()->getName() === "Luc") {
$theEventCourse = $eventCourse;
break;
}
}
$participantMakeEventCourse = $this->entityManager->getRepository(ParticipantMakeEventCourse::class)->find(array("eventCourse" => $theEventCourse, "participant" => $theParticipant));
$theEvent->update($this->entityManager, $this->entityManager->getRepository(ParticipantMakeEventCourse::class));
$this->assertSame(1, $participantMakeEventCourse->getNbMissingPunchPenalty());
}
public function testUpdateChampionshipCheckScoreFirst()
{
$theEvent = null;
foreach ($this->entityManager->getRepository(Event::class)->findAll() as $event) {
if ($event->getName() === "Championship") {
$theEvent = $event;
break;
}
}
$theParticipant = null;
foreach ($theEvent->getParticipants() as $participant) {
if ($participant->getNickName() === "Suliac") {
$theParticipant = $participant;
break;
}
}
$theEventCourse = null;
foreach ($theEvent->getEventCourses() as $eventCourse) {
if ($eventCourse->getCourse()->getName() === "Luc") {
$theEventCourse = $eventCourse;
break;
}
}
$participantMakeEventCourse = $this->entityManager->getRepository(ParticipantMakeEventCourse::class)->find(array("eventCourse" => $theEventCourse, "participant" => $theParticipant));
$theEvent->update($this->entityManager, $this->entityManager->getRepository(ParticipantMakeEventCourse::class));
$this->assertSame(1000, $participantMakeEventCourse->getScore());
}
public function testUpdateChampionshipCheckScoreSecond()
{
$theEvent = null;
foreach ($this->entityManager->getRepository(Event::class)->findAll() as $event) {
if ($event->getName() === "Championship") {
$theEvent = $event;
break;
}
}
$theParticipant = null;
foreach ($theEvent->getParticipants() as $participant) {
if ($participant->getNickName() === "Eric") {
$theParticipant = $participant;
break;
}
}
$theEventCourse = null;
foreach ($theEvent->getEventCourses() as $eventCourse) {
if ($eventCourse->getCourse()->getName() === "Luc") {
$theEventCourse = $eventCourse;
break;
}
}
$participantMakeEventCourse = $this->entityManager->getRepository(ParticipantMakeEventCourse::class)->find(array("eventCourse" => $theEventCourse, "participant" => $theParticipant));
$theEvent->update($this->entityManager, $this->entityManager->getRepository(ParticipantMakeEventCourse::class));
$this->assertSame(741, $participantMakeEventCourse->getScore());
}
public function testGetCSV()
{
$theEvent = null;
foreach($this->entityManager->getRepository(Event::class)->findAll() as $event){
if($event->getName==="Chamionship"){
foreach ($this->entityManager->getRepository(Event::class)->findAll() as $event) {
if ($event->getName() === "Championship") {
$theEvent = $event;
break;
}
}
$csv = $theEvent->getCSV($this->entityManager->getRepository(ParticipantMakeEventCourse::class));