diff --git a/backend/app/Http/Controllers/TrackController.php b/backend/app/Http/Controllers/TrackController.php index afa21f4..d29502a 100644 --- a/backend/app/Http/Controllers/TrackController.php +++ b/backend/app/Http/Controllers/TrackController.php @@ -76,11 +76,19 @@ public function proposals(Request $request) abort(403); } - $proposals = Proposal::where('track_id', $track->id)->where('status', $request->proposalStatus)->with('opinions', 'opinions.user')->get(); + $proposals = Proposal::where('track_id', $track->id) + ->where('status', $request->proposalStatus) + ->with('opinions', 'opinions.user') + ->get(); + + $opinions = Proposal::where('track_id', $track->id) + ->with('opinions') + ->get(); return [ 'proposals' => $proposals, 'users' => $track->users, + 'opinions' => $opinions ]; } diff --git a/frontend/src/components/OpinionStats.vue b/frontend/src/components/OpinionStats.vue new file mode 100644 index 0000000..07ce13f --- /dev/null +++ b/frontend/src/components/OpinionStats.vue @@ -0,0 +1,44 @@ + + + + Opinion Stats + Durchschnittswert aller Stimmen: {{ new Intl.NumberFormat('de-DE').format(vote_average) }} + + Durschnittswert pro User + + + + + + + + + \ No newline at end of file diff --git a/frontend/src/views/orga/ProposalsTrack.vue b/frontend/src/views/orga/ProposalsTrack.vue index f9d1c30..d0a3cf2 100644 --- a/frontend/src/views/orga/ProposalsTrack.vue +++ b/frontend/src/views/orga/ProposalsTrack.vue @@ -13,6 +13,7 @@ import Column from "primevue/column"; import Accordion from "primevue/accordion"; import AccordionTab from "primevue/accordiontab"; import Button from "primevue/button"; +import OpinionStats from "../../components/OpinionStats.vue"; const router = useRouter(); const route = useRoute(); @@ -21,6 +22,7 @@ const proposals = ref([]); const toast = useToast(); const proposalStatus = ref("created"); const trackUsers = ref([]); +const trackOpions = ref([]); onMounted(async () => { await loadPoposals(); @@ -33,6 +35,9 @@ const loadPoposals = async () => { const response = await client.get(`track/proposals?slug=${route.params.slug}&proposalStatus=${proposalStatus.value}`) let data = response.data.proposals trackUsers.value = response.data.users + trackOpions.value = response.data.opinions.flatMap((track) => { + return track.opinions + }) data = data.map((proposal) => { return { @@ -215,5 +220,7 @@ const rowClass = (data) => { + +
Durchschnittswert aller Stimmen: {{ new Intl.NumberFormat('de-DE').format(vote_average) }}