diff --git a/Backend/Controllers/Group/GetGroup.php b/Backend/Controllers/Group/GetGroup.php index be2e0bf..9a961a1 100644 --- a/Backend/Controllers/Group/GetGroup.php +++ b/Backend/Controllers/Group/GetGroup.php @@ -2,11 +2,11 @@ require_once "../../../bootstrap.php"; use Backend\Models\Group; -if (isset($_POST["groupId"])){ -$groups = Group::find($_POST["groupId"]); +if (isset($_GET["groupId"])){ +$groups = Group::find($_GET["groupId"]); } -elseif(isset($_POST["gameJameId"])){ - $groups = Group::where("game_jam_id",$_POST["gameJameId"]); +elseif(isset($_GET["gameJameId"])){ + $groups = Group::where("game_jam_id",$_GET["gameJameId"])->get(); } else{ $groups = Group::all(); diff --git a/Backend/Controllers/Group/Group.php b/Backend/Controllers/Group/Group.php index 73b23af..e23a1c9 100644 --- a/Backend/Controllers/Group/Group.php +++ b/Backend/Controllers/Group/Group.php @@ -3,6 +3,7 @@ require_once "../../../bootstrap.php"; use Backend\Models\Group; use Backend\Models\Password; +session_start(); /** * @param string $token diff --git a/Backend/Controllers/Polls/GetVote.php b/Backend/Controllers/Polls/GetVote.php new file mode 100644 index 0000000..e283e74 --- /dev/null +++ b/Backend/Controllers/Polls/GetVote.php @@ -0,0 +1,10 @@ +get()->toJson(JSON_PRETTY_PRINT); + +} diff --git a/Backend/Controllers/Polls/GetWinner.php b/Backend/Controllers/Polls/GetWinner.php new file mode 100644 index 0000000..f5eeb7b --- /dev/null +++ b/Backend/Controllers/Polls/GetWinner.php @@ -0,0 +1,25 @@ +get(); + $winningGroup = array(); + $i = -1; + foreach ($groups as $group){ + $x = Vote::where('group_id', $group->id)->count(); + if($x>$i){ + $winningGroup = array(); + array_push($winningGroup,$group); + $i = $x; + } + elseif ($i === $x){ + array_push($winningGroup,$group); + } + } + header('Content-Type: application/json;charset=UTF-8'); + echo $winningGroup->toJson(JSON_PRETTY_PRINT); +} +