Browse Source

Alternative uitslag

master
Rogier Neeleman 8 years ago
parent
commit
4661d4368f
  1. 27
      application/controllers/Uitslag.php
  2. 16
      application/models/Uitslag_model.php
  3. 8
      application/views/uitslag_groep.php

27
application/controllers/Uitslag.php

@ -29,12 +29,13 @@ class Uitslag extends CI_Controller @@ -29,12 +29,13 @@ class Uitslag extends CI_Controller
$maxpuntenraw = $this->Uitslag_model->get_max_punten();
// Totaal bepalen
$onderdelen = $this->Uitslag_model->get_lijst_detail();
$totaal = 0;
foreach ($onderdelen as $onderdeel) {
$scoremax = $this->Uitslag_model->get_max_punten_detail($onderdeel['spelgebiedid'], $onderdeel['onderdeelid']);
$totaal = $totaal + ($scoremax['maxscore']*$scoremax['gewicht']);
$totaalgewicht = 0;
foreach ($spelgebieden as $spelgebied) {
$scoremax = $this->Uitslag_model->get_max_punten_detail($spelgebied['id']);
$totaalgewicht = $totaalgewicht + $scoremax['gewicht'];
}
$totaalpsg = 1000/$totaalgewicht;
foreach ($maxpuntenraw as $max) {
$maxpunten[$max['spelgebiedid']]['maxscore'] = $max['maxscore'];
@ -47,8 +48,8 @@ class Uitslag extends CI_Controller @@ -47,8 +48,8 @@ class Uitslag extends CI_Controller
$scores = $this->Uitslag_model->get_subgroep_punten($subgroep['id']);
foreach ($scores as $score) {
// $scoreitem = (($score['score']/$maxpunten[$score['spelgebiedid']]['maxscore'])*100)*$maxpunten[$score['spelgebiedid']]['gewicht'];
$scoreitem = (($score['score']/$totaal)*1000)*$maxpunten[$score['spelgebiedid']]['gewicht'];
$scoremaxsg = $this->Uitslag_model->get_max_punten_detail($score['spelgebiedid']);
$scoreitem = ($score['score']/$scoremaxsg['maxscore']) * $totaalpsg * $scoremaxsg['gewicht'];
$data['uitslag'][$subgroep['id']][$score['spelgebiedid']] = $scoreitem;
$data['uitslag'][$subgroep['id']]['total'] = $data['uitslag'][$subgroep['id']]['total'] + $scoreitem;
}
@ -75,23 +76,27 @@ class Uitslag extends CI_Controller @@ -75,23 +76,27 @@ class Uitslag extends CI_Controller
// Get data
$this->load->model('Uitslag_model');
$onderdelen = $this->Uitslag_model->get_lijst_detail();
$spelgebieden = $this->Uitslag_model->get_spelgebieden_list();
$data['subgroepinfo'] = $this->Uitslag_model->get_subgroep($subgroepid);
// Data order
$totaal = 0;
foreach ($onderdelen as $onderdeel) {
$scoremax = $this->Uitslag_model->get_max_punten_detail($onderdeel['spelgebiedid'], $onderdeel['onderdeelid']);
$totaal = $totaal + ($scoremax['maxscore']*$scoremax['gewicht']);
$totaalgewicht = 0;
foreach ($spelgebieden as $spelgebied) {
$scoremax = $this->Uitslag_model->get_max_punten_detail($spelgebied['id']);
$totaalgewicht = $totaalgewicht + $scoremax['gewicht'];
}
$totaalpsg = 1000/$totaalgewicht;
foreach ($onderdelen as $onderdeel) {
$scoremax = $this->Uitslag_model->get_max_punten_detail($onderdeel['spelgebiedid'], $onderdeel['onderdeelid']);
$scoremaxsg = $this->Uitslag_model->get_max_punten_detail($onderdeel['spelgebiedid']);
$score = $this->Uitslag_model->get_punten_detail($subgroepid, $onderdeel['spelgebiedid'], $onderdeel['onderdeelid']);
$data['scores'][$onderdeel['spelgebiedid']]['naam'] = $onderdeel['spelgebied'];
$data['scores'][$onderdeel['spelgebiedid']]['onderdeel'][$onderdeel['onderdeelid']]['naam'] = $onderdeel['onderdeel'];
$data['scores'][$onderdeel['spelgebiedid']]['onderdeel'][$onderdeel['onderdeelid']]['scoremax'] = round(($scoremax['maxscore']/$totaal)*1000*$scoremax['gewicht'],0);
$data['scores'][$onderdeel['spelgebiedid']]['onderdeel'][$onderdeel['onderdeelid']]['score'] = round(($score['score']/$totaal)*1000*$scoremax['gewicht'], 0);
$data['scores'][$onderdeel['spelgebiedid']]['onderdeel'][$onderdeel['onderdeelid']]['scoremax'] = ($scoremax['maxscore']/$scoremaxsg['maxscore']) * $totaalpsg * $scoremax['gewicht'];
$data['scores'][$onderdeel['spelgebiedid']]['onderdeel'][$onderdeel['onderdeelid']]['score'] = ($score['score']/$scoremaxsg['maxscore']) * $totaalpsg * $scoremax['gewicht'];
}
// Header

16
application/models/Uitslag_model.php

@ -162,25 +162,27 @@ class Uitslag_model extends CI_Model @@ -162,25 +162,27 @@ class Uitslag_model extends CI_Model
return $query->row_array();
}
public function get_max_punten_detail($spelgebiedid, $onderdeelid)
public function get_max_punten_detail($spelgebiedid, $onderdeelid = NULL)
{
$this->db->select('SUM('.$this->db->dbprefix('vragen').'.score) AS maxscore,
spelgebied.naam AS spelgebied,
spelgebied.id AS spelgebiedid,
onderdeel.naam AS onderdeel,
onderdeel.id AS onderdeelid,
spelgebied.gewicht AS gewicht');
$this->db->from('vragen');
$this->db->where('vragen.regioid', $this->session->regio);
$this->db->where('vragen.jaar', date('Y'));
if (!empty($onderdeelid)) {
$this->db->where('vragen.onderdeelid', $onderdeelid);
}
$this->db->where('onderdeel.spelgebiedid', $spelgebiedid);
$this->db->where('vragen.onderdeelid', $onderdeelid);
$this->db->join('onderdeel', 'vragen.onderdeelid=onderdeel.id', 'left');
$this->db->join('spelgebied', 'onderdeel.spelgebiedid=spelgebied.id', 'left');
$this->db->group_by('spelgebied.id, onderdeel.id');
if (!empty($onderdeelid)) {
$this->db->group_by('spelgebied.id, onderdeel.id');
} else {
$this->db->group_by('spelgebied.id');
}
$this->db->order_by('spelgebied.id, onderdeel.id', 'ASC');

8
application/views/uitslag_groep.php

@ -25,8 +25,8 @@ @@ -25,8 +25,8 @@
$scoremaxtot=0;
foreach ($spelgebied['onderdeel'] as $onderdeel) { ?>
<td><?php echo $onderdeel['naam']; ?></td>
<td class="text-right"><?php echo $onderdeel['score']; $scoretot = $scoretot + $onderdeel['score']; ?></td>
<td class="text-right"><?php echo $onderdeel['scoremax']; $scoremaxtot = $scoremaxtot + $onderdeel['scoremax']; ?></td>
<td class="text-right"><?php echo round($onderdeel['score'],0); $scoretot = $scoretot + $onderdeel['score']; ?></td>
<td class="text-right"><?php echo round($onderdeel['scoremax'],0); $scoremaxtot = $scoremaxtot + $onderdeel['scoremax']; ?></td>
<td class="text-right"><?php echo round(($onderdeel['score']/$onderdeel['scoremax'])*100, 0)."%"; ?></td>
</tr>
<tr>
@ -36,8 +36,8 @@ @@ -36,8 +36,8 @@
$totalmax=$totalmax+$onderdeel['scoremax'];
} ?>
<td class="active"><strong>Subtotaal:</strong></td>
<td class="text-right active"><strong><?php echo $scoretot; ?></strong></td>
<td class="text-right active"><strong><?php echo $scoremaxtot; ?></strong></td>
<td class="text-right active"><strong><?php echo round($scoretot,0); ?></strong></td>
<td class="text-right active"><strong><?php echo round($scoremaxtot,0); ?></strong></td>
<td class="text-right active"><strong><?php echo round(($scoretot/$scoremaxtot)*100, 0); ?>%</strong></td>
</tr>
<?php } ?>

Loading…
Cancel
Save