Browse Source

Deeluitwerking scores en bugfix in het totaaloverzicht.

master
Rogier Neeleman 8 years ago
parent
commit
75254a0ee0
  1. 56
      application/controllers/Uitslag.php
  2. 79
      application/models/Uitslag_model.php
  3. 53
      application/views/uitslag_groep.php
  4. 2
      application/views/uitslag_ranking.php

56
application/controllers/Uitslag.php

@ -28,6 +28,14 @@ class Uitslag extends CI_Controller @@ -28,6 +28,14 @@ class Uitslag extends CI_Controller
$spelgebieden = $this->Uitslag_model->get_spelgebieden_list();
$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']);
}
foreach ($maxpuntenraw as $max) {
$maxpunten[$max['spelgebiedid']]['maxscore'] = $max['maxscore'];
$maxpunten[$max['spelgebiedid']]['naam'] = $max['naam'];
@ -39,7 +47,8 @@ class Uitslag extends CI_Controller @@ -39,7 +47,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']/$maxpunten[$score['spelgebiedid']]['maxscore'])*100)*$maxpunten[$score['spelgebiedid']]['gewicht'];
$scoreitem = (($score['score']/$totaal)*1000)*$maxpunten[$score['spelgebiedid']]['gewicht'];
$data['uitslag'][$subgroep['id']][$score['spelgebiedid']] = $scoreitem;
$data['uitslag'][$subgroep['id']]['total'] = $data['uitslag'][$subgroep['id']]['total'] + $scoreitem;
}
@ -59,4 +68,49 @@ class Uitslag extends CI_Controller @@ -59,4 +68,49 @@ class Uitslag extends CI_Controller
$this->load->view('footer');
}
public function groep($subgroepid)
{
$data['page'] = 'uitslag';
// Get data
$this->load->model('Uitslag_model');
// $scores = $this->Uitslag_model->get_subgroep_detail($subgroepid);
$onderdelen = $this->Uitslag_model->get_lijst_detail();
// 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']);
}
foreach ($onderdelen as $onderdeel) {
$scoremax = $this->Uitslag_model->get_max_punten_detail($onderdeel['spelgebiedid'], $onderdeel['onderdeelid']);
$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);
}
/*
foreach ($scores as $score) {
$scoremax = $this->Uitslag_model->get_max_punten_detail($score['spelgebiedid'], $score['onderdeelid']);
$data['scores'][$score['spelgebiedid']]['naam'] = $score['spelgebied'];
$data['scores'][$score['spelgebiedid']]['onderdeel'][$score['onderdeelid']]['naam'] = $score['onderdeel'];
$data['scores'][$score['spelgebiedid']]['onderdeel'][$score['onderdeelid']]['scoremax'] = 100*$scoremax['gewicht'];
$data['scores'][$score['spelgebiedid']]['onderdeel'][$score['onderdeelid']]['score'] = round(($score['score']/$scoremax['maxscore'])*100*$scoremax['gewicht'], 0);
} */
// Header
$this->load->view('header', $data);
// Ranking page
$this->load->view('uitslag_groep', $data);
// Footer
$this->load->view('footer');
}
}

79
application/models/Uitslag_model.php

@ -91,4 +91,83 @@ class Uitslag_model extends CI_Model @@ -91,4 +91,83 @@ class Uitslag_model extends CI_Model
return $query->result_array();
}
public function get_lijst_detail()
{
$this->db->select('spelgebied.naam AS spelgebied,
spelgebied.id AS spelgebiedid,
onderdeel.naam AS onderdeel,
onderdeel.id AS onderdeelid
');
$this->db->from('onderdeel');
$this->db->where('onderdeel.regioid', $this->session->regio);
$this->db->where('onderdeel.jaar', date('Y'));
$this->db->join('spelgebied', 'onderdeel.spelgebiedid=spelgebied.id', 'left');
// $this->db->group_by('spelgebied.id, onderdeel.id');
$this->db->order_by('spelgebied.naam, onderdeel.naam', 'ASC');
$query = $this->db->get();
return $query->result_array();
}
public function get_punten_detail($subgroepid, $spelgebiedid, $onderdeelid)
{
$this->db->select('SUM('.$this->db->dbprefix('resultaat').'.score/'.$this->db->dbprefix('lijst').'.ronde) AS score,
spelgebied.naam AS spelgebied,
spelgebied.id AS spelgebiedid,
onderdeel.naam AS onderdeel,
onderdeel.id AS onderdeelid
');
$this->db->from('resultaat');
$this->db->where('resultaat.regioid', $this->session->regio);
$this->db->where('vragen.jaar', date('Y'));
$this->db->where('resultaat.subgroepid', $subgroepid);
$this->db->where('vragen.onderdeelid', $onderdeelid);
$this->db->where('onderdeel.spelgebiedid', $spelgebiedid);
$this->db->join('vragen', 'resultaat.vraagid=vragen.id', 'left');
$this->db->join('onderdeel', 'vragen.onderdeelid=onderdeel.id', 'left');
$this->db->join('spelgebied', 'onderdeel.spelgebiedid=spelgebied.id', 'left');
$this->db->join('lijst', 'vragen.lijstid=lijst.id', 'left');
$this->db->group_by('vragen.onderdeelid');
$this->db->order_by('spelgebied.naam, onderdeel.naam', 'ASC');
$query = $this->db->get();
return $query->row_array();
}
public function get_max_punten_detail($spelgebiedid, $onderdeelid)
{
$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'));
$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');
$this->db->order_by('spelgebied.id, onderdeel.id', 'ASC');
$query = $this->db->get();
return $query->row_array();
}
}

53
application/views/uitslag_groep.php

@ -0,0 +1,53 @@ @@ -0,0 +1,53 @@
<div class="container">
<hr>
<div class="row">
<div class="col-md-6 col-md-offset-3">
<?php $total=0; $totalmax=0; ?>
<table class="table table-condensed ">
<thead>
<tr>
<th>Spelgebied</th>
<th>Onderdeel</th>
<th>Score</th>
<th>Maximaal</th>
<th>Percentage</th>
</tr>
</thead>
<tbody>
<?php foreach ($scores as $spelgebied) { ?>
<tr>
<td><strong><?php echo $spelgebied['naam']; ?></strong></td>
<?php $scoretot=0;
$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']/$onderdeel['scoremax'])*100, 0)."%"; ?></td>
</tr>
<tr>
<td></td>
<?php $total=$total+$onderdeel['score'];
$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/$scoremaxtot)*100, 0); ?>%</strong></td>
</tr>
<?php } ?>
</tbody>
<thead>
<tr class="active">
<th></th>
<th>Totaal:</th>
<th class="text-right"><?php echo $total; ?></th>
<th class="text-right"><?php echo $totalmax; ?></th>
<th class="text-right"><?php echo round(($total/$totalmax)*100, 0); ?>%</th>
</tr>
</thead>
</table>
</div>
</div
</div>

2
application/views/uitslag_ranking.php

@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
<?php foreach ($subgroepen as $subgroep) { ?>
<tr>
<td><?php echo $subgroep['nummer']?></td>
<td><?php echo $subgroep['themanaam']?></td>
<td><a href="<?php echo base_url('/uitslag/groep/'.$subgroep['id']); ?>"><?php echo $subgroep['themanaam']?></a></td>
<td><?php echo $subgroep['groepsnaam']?></td>
<?php foreach ($spelgebieden as $spelgebied) {
if (isset($uitslag[$subgroep['id']][$spelgebied['id']])) {

Loading…
Cancel
Save