Skip to content

Commit

Permalink
fix el_filled out
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianStorz committed Nov 1, 2024
1 parent e58b908 commit 016e0ab
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function getUniquieIds(Person $person)
{
return $this->createQueryBuilder('e')
->join('e.questionnaire', 'q')
->select('e.local_change_index, q.id')
->select('e.local_change_index, q.type')
->where('e.person = :person')
->groupBy('e.local_change_index')
->addGroupBy('q.id')
Expand Down
12 changes: 6 additions & 6 deletions src/Service/Gamification/PersonGamificationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public function genericGoalProgress(PbsUserDTO $pbsUserDTO, string $type)
}
break;
case 'filledOut':
if ($this->checkElFilledOut($person)) {
if ($this->getElFilledOut($person) === 7) {
$pgp->setElFilledOut(true);
}
break;
Expand Down Expand Up @@ -250,7 +250,7 @@ public function getPersonGamificationDTO(PbsUserDTO $pbsUserDTO, string $locale)
$goalDTOs[] = GamificationGoalMapper::createFromEntity($goal, $locale, $personGamification->getHasSharedEl(), 0);
break;
case 'EL_FILL_OUT': // TODO add check
$goalDTOs[] = GamificationGoalMapper::createFromEntity($goal, $locale, $personGamification->getElFilledOut(), 0);
$goalDTOs[] = GamificationGoalMapper::createFromEntity($goal, $locale, $personGamification->getElFilledOut(), $this->getElFilledOut($person));
break;
case 'SHARE_1':
$completed = $personGamification->getAccessGrantedCount() >= 1;
Expand Down Expand Up @@ -292,14 +292,14 @@ public function getPersonGamificationDTO(PbsUserDTO $pbsUserDTO, string $locale)
* Every questionnaire has 7 aspects which can be answered, if all 7 of them have been answered the goal
* is completed
*/
private function checkElFilledOut(Person $person): bool
private function getElFilledOut(Person $person): int
{
$counters = [0, 0];
$counters = ['Questionnaire::Group::Default' => 0, 'Questionnaire::Group::Canton' => 0];
$localIdAndQuestionnaireId = $this->gamificationQuapEventRepository->getUniquieIds($person);
foreach ($localIdAndQuestionnaireId as $item) {
$counters[$item['id']]++;
$counters[$item['type']]++;
}
return $counters[0] === 7 || $counters[1] === 7;
return max($counters['Questionnaire::Group::Canton'], $counters['Questionnaire::Group::Default']);
}

public function logEvent(array $changedIds, AggregatedQuap $aggregatedQuap, PbsUserDTO $pbsUserDTO)
Expand Down

0 comments on commit 016e0ab

Please sign in to comment.