Skip to content
Snippets Groups Projects
Commit 142b27e1 authored by tomaszrudowski's avatar tomaszrudowski
Browse files

added percent correct

parent 968ddda7
No related branches found
No related tags found
1 merge request!1Master
...@@ -24,10 +24,17 @@ class Voter extends Model ...@@ -24,10 +24,17 @@ class Voter extends Model
} }
public function getMajorityVotesStatsAttribute() { public function getMajorityVotesStatsAttribute() {
$correct = $this->majorityVotes()->where('vote', '=', true)->count();
$incorrect = $this->majorityVotes()->where('vote', '=', false)->count();
$all = $correct + $incorrect;
$percentCorrect = $all > 0 ? round(100*$correct/$all, 3) : null;
return [ return [
'correct' => $this->majorityVotes()->where('vote', '=', true)->count(), 'correct' => $correct,
'incorrect' => $this->majorityVotes()->where('vote', '=', false)->count() 'incorrect' => $incorrect,
'percent_correct' => $percentCorrect
]; ];
} }
} }
Source diff could not be displayed: it is too large. Options to address this: view the blob.
...@@ -152,24 +152,27 @@ ...@@ -152,24 +152,27 @@
<table class="table table-sm table-responsive-sm"> <table class="table table-sm table-responsive-sm">
<thead> <thead>
<tr> <tr>
<th>ID</th>
<th>Expertise<br><i class="text-muted">(1-100)</i></th>
<th>Confidence<br><i class="text-muted">(1-100)</i></th> <th>Confidence<br><i class="text-muted">(1-100)</i></th>
<th>Following<br><i class="text-muted">(1-100)</i></th>
<th>Leadership<br><i class="text-muted">(1-100)</i></th> <th>Leadership<br><i class="text-muted">(1-100)</i></th>
<th>Following<br><i class="text-muted">(1-100)</i></th>
<th>Group</th> <th>Group</th>
<th>Expertise<br><i class="text-muted">(1-100)</i></th>
<th>Correct<br>(percent)<br><i class="text-muted">(majority)</i></th>
<th>Correct<br><i class="text-muted">(majority)</i></th> <th>Correct<br><i class="text-muted">(majority)</i></th>
<th>Incorrect<br><i class="text-muted">(majority)</i></th> <th>Incorrect<br><i class="text-muted">(majority)</i></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr v-for="voter in voters"> <tr v-for="voter in voters">
<th>{{voter.id}}</th>
<td>{{voter.expertise}}</td>
<td>{{voter.confidence}}</td> <td>{{voter.confidence}}</td>
<td>{{voter.following}}</td>
<td>{{voter.leadership}}</td> <td>{{voter.leadership}}</td>
<td>{{voter.following}}</td>
<td>{{voter.group}}</td> <td>{{voter.group}}</td>
<td>{{voter.expertise}}</td>
<td>
<span v-if="voter.majority_votes_stats.percent_correct">{{voter.majority_votes_stats.percent_correct}}</span>
<span v-else>N/A</span>
</td>
<td>{{voter.majority_votes_stats.correct}}</td> <td>{{voter.majority_votes_stats.correct}}</td>
<td>{{voter.majority_votes_stats.incorrect}}</td> <td>{{voter.majority_votes_stats.incorrect}}</td>
</tr> </tr>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment