Browse Source

User input added

master
Rogier Neeleman 9 years ago
parent
commit
68ab4c78f1
  1. 187
      application/controllers/Beoordelen.php
  2. 25
      application/controllers/Dashboard.php
  3. 106
      application/models/Beoordelen_model.php
  4. 6
      application/views/dashboard_user.php
  5. 20
      application/views/user_lijsten.php
  6. 23
      application/views/user_ronde.php
  7. 41
      application/views/user_score.php
  8. 39
      application/views/user_subgroep.php

187
application/controllers/Beoordelen.php

@ -0,0 +1,187 @@ @@ -0,0 +1,187 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Logout Class
*/
class Beoordelen extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->library('session');
if(! $this->session->userdata('validated')){
redirect(base_url('/login'));
}
}
public function index()
{
redirect(base_url('/beoordelen/lijst'));
}
public function lijst()
{
$data['title'] = 'JOS';
// Get data
$this->load->model('Beoordelen_model');
$lijsten = $this->Beoordelen_model->get_lijst();
// Data prepare
foreach ($lijsten as $lijst)
{
$data['lijsten'][$lijst['id']] = $lijst['naam'];
}
// Header
$this->load->view('header');
// login page
$this->load->view('user_lijsten', $data);
// Footer
$this->load->view('footer');
}
public function ronde()
{
// Check input
$lijstid = $this->security->xss_clean($this->input->post('lijstid'));
if ($lijstid OR $this->session->userdata('lijstid')) {
if ($lijstid) {
$this->session->set_userdata('lijstid', $lijstid);
} else {
$lijstid = $this->session->userdata('lijstid');
}
} else {
redirect(base_url('/beoordelen/lijst'));
}
// Check is ronde question is possible
$this->load->model('Beoordelen_model');
$rondes = $this->Beoordelen_model->get_rondes($lijstid)->ronde;
if ($rondes == 1) {
$this->session->set_userdata('ronde', '1');
redirect(base_url('/beoordelen/subgroep'));
}
for ($i=1; $i <= $rondes; $i++) {
$data['ronde'][$i] = $i;
}
// Make page
// Header
$this->load->view('header');
// login page
$this->load->view('user_ronde', $data);
// Footer
$this->load->view('footer');
}
public function subgroep()
{
// Check input
$ronde = $this->security->xss_clean($this->input->post('ronde'));
if ($ronde OR $this->session->userdata('ronde')) {
if ($ronde) {
$this->session->set_userdata('ronde', $ronde);
} else {
$ronde = $this->session->userdata('ronde');
}
} else {
redirect(base_url('/beoordelen/ronde'));
}
// Get groepdata
$this->load->model('Beoordelen_model');
$subgroepen = $this->Beoordelen_model->get_subgroepen();
// Prepare data
$data['subgroepen'] = array();
foreach ($subgroepen as $subgroep)
{
if (!$this->Beoordelen_model->check_score($this->session->userdata('ronde'), $this->session->userdata('lijstid'), $subgroep['id'])) {
$data['subgroepen'][$subgroep['id']] = $subgroep['nummer'].'. '.$subgroep['themanaam'];
}
}
// Header
$this->load->view('header');
// login page
$this->load->view('user_subgroep', $data);
// Footer
$this->load->view('footer');
}
public function score()
{
// Check input
$subgroepid = $this->security->xss_clean($this->input->post('subgroepid'));
if (!$subgroepid) {
redirect(base_url('/beoordelen/subgroep'));
}
$data['subgroepid'] = $subgroepid;
// Get questions
$this->load->model('Beoordelen_model');
$data['vragen'] = $this->Beoordelen_model->get_vragen();
// Header
$this->load->view('header');
// login page
$this->load->view('user_score', $data);
// Footer
$this->load->view('footer');
}
public function score_save()
{
// Check input
$ronde = $this->session->userdata('ronde');
$lijstid = $this->session->userdata('lijstid');
$subgroepid = $this->security->xss_clean($this->input->post('subgroepid'));
// Score items ophalen
$this->load->model('Beoordelen_model');
$vragen = $this->Beoordelen_model->get_vragen();
// Op te slaan data klaarzetten
$i = 0;
foreach ($vragen as $vraag)
{
$score[$i]['vraagid'] = $vraag['id'];
// Check for type of awnser
if ($vraag['antwoord'] == 0) {
if ($this->input->post($vraag['id']) == 1) {
$score[$i]['score'] = $vraag['score'];
} else {
$score[$i]['score'] = 0;
}
} elseif ($vraag['antwoord'] == 1) {
$score[$i]['score'] = $this->input->post($vraag['id']);
}
$i++;
}
// Data opslaan
$this->Beoordelen_model->store_score($ronde, $subgroepid, $score);
// Redirecten naar nieuwe ploeg
redirect(base_url().'beoordelen/subgroep');
}
}

25
application/controllers/Dashboard.php

@ -18,7 +18,30 @@ class Dashboard extends CI_Controller @@ -18,7 +18,30 @@ class Dashboard extends CI_Controller
public function index()
{
echo "UID: ".$this->session->id;
if ($this->session->admin == '1' OR $this->session->superadmin == '1') {
redirect(base_url('/dashboard/admin'));
} else {
redirect(base_url('/dashboard/user'));
}
}
public function admin()
{
}
public function user()
{
$data['title'] = 'JOS';
// Header
$this->load->view('header');
// login page
$this->load->view('dashboard_user', $data);
// Footer
$this->load->view('footer');
}
}

106
application/models/Beoordelen_model.php

@ -0,0 +1,106 @@ @@ -0,0 +1,106 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Regio model
*/
class Beoordelen_model extends CI_Model
{
public function __construct()
{
parent::__construct();
}
public function get_lijst()
{
$this->db->select('id, naam');
$this->db->from('lijst');
$this->db->where('jaar', date('Y'));
$this->db->where('regioid', $this->session->regio);
$this->db->where('actief', '1');
$this->db->order_by('naam', 'ASC');
$query = $this->db->get();
return $query->result_array();
}
public function get_rondes($lijstid)
{
$this->db->select('ronde');
$this->db->from('lijst');
$this->db->where('id', $lijstid);
$this->db->where('regioid', $this->session->regio);
$this->db->where('jaar', date('Y'));
$this->db->where('actief', '1');
$query = $this->db->get();
return $query->row();
}
public function get_subgroepen()
{
$this->db->select('id, naam, themanaam, nummer');
$this->db->from('subgroep');
$this->db->where('regioid', $this->session->regio);
$this->db->where('jaar', date('Y'));
$this->db->order_by('nummer', 'ASC');
$query = $this->db->get();
return $query->result_array();
}
public function get_vragen()
{
$this->db->select('id, score, vraag, antwoord, score');
$this->db->from('vragen');
$this->db->where('regioid', $this->session->regio);
$this->db->where('lijstid', $this->session->lijstid);
$this->db->where('jaar', date('Y'));
$this->db->order_by('volgorde', 'ASC');
$query = $this->db->get();
return $query->result_array();
}
public function check_score($ronde, $lijstid, $subgroepid)
{
$this->db->from('resultaat');
$this->db->where('resultaat.regioid', $this->session->regio);
$this->db->where('resultaat.ronde', $ronde);
$this->db->where('vragen.lijstid', $lijstid);
$this->db->where('resultaat.subgroepid', $subgroepid);
$this->db->join('vragen', 'resultaat.vraagid=vragen.id');
$query = $this->db->get();
if ($query->num_rows() == 0)
{
return false;
} else {
return true;
}
}
public function store_score($ronde, $subgroepid, $score)
{
foreach ($score as $item)
{
$data = array(
'regioid' => $this->session->regio,
'vraagid' => $item['vraagid'],
'ronde' => $ronde,
'subgroepid' => $subgroepid,
'score' => $item['score'],
'userid' => $this->session->id,
);
$this->db->insert('resultaat', $data);
}
}
}

6
application/views/dashboard_user.php

@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
<div class="container">
<h1>Invoeren scorelijsten</h1>
<p>
<a href='<?php echo base_url();?>beoordelen/'><button type="button" class="btn btn-success btn-lg">Beoordelen</button></a>
</p>
</div>

20
application/views/user_lijsten.php

@ -0,0 +1,20 @@ @@ -0,0 +1,20 @@
<div class="container">
<h1>De volgende lijsten zijn beschikbaar:</h1>
<?php echo form_open(base_url().'beoordelen/ronde'); ?>
<div class="row">
<div class="col-xs-2 col-sm-2 col-sm-offset-4">
<?php echo form_dropdown('lijstid', $lijsten); ?>
</div>
</div>
<p>
<div class="row">
<div class="col-xs-2 col-sm-2 col-xs-offset-4 col-sm-offset-5">
<button type="submit" class="btn btn-primary btn-lg">Kies</button>
</div>
</div>
</p>
<?php echo form_close(); ?>
</div>

23
application/views/user_ronde.php

@ -0,0 +1,23 @@ @@ -0,0 +1,23 @@
<div class="container">
<h1>Kies de ronde</h1>
<?php // $attributes = array('class' => 'form-horizontal', 'role' => 'form');?>
<?php echo form_open(base_url().'beoordelen/subgroep')."\n"; ?>
<div class="row">
<div class="col-xs-2 col-sm-2 col-xs-offset-3 col-sm-offset-4">
<label>Ronde</label>
</div>
<div class="col-xs-2 col-sm-2">
<?php echo form_dropdown('ronde', $ronde); ?>
</div>
</div>
<p>
<div class="row">
<div class="col-xs-2 col-sm-2 col-xs-offset-4 col-sm-offset-5">
<button type="submit" class="btn btn-primary btn-lg">Volgende</button>
</div>
</div>
<?php echo form_close(); ?>
</p>
</div>

41
application/views/user_score.php

@ -0,0 +1,41 @@ @@ -0,0 +1,41 @@
<div class="container">
<div class="starter-template">
<h1>Geef de score aan</h1>
<?php echo form_open(base_url().'beoordelen/score_save'); ?>
<?php echo form_hidden('subgroepid', $subgroepid); ?>
<?php
foreach ($vragen as $vraag)
{ ?>
<div class="row">
<div class="col-xs-9 col-sm-6 col-sm-offset-3">
<?php echo $vraag['vraag']; ?>
</div>
<div class="col-xs-3 col-sm-1">
<?php if ($vraag['antwoord'] == 0) {
echo ': '.form_checkbox($vraag['id'], '1');
} else {
for ($i=1; $i <= $vraag['score']; $i++) {
$score[$i] = $i;
}
echo form_dropdown($vraag['id'], $score);
} ?>
</div>
</div>
<?php } ?>
<p>
<div class="row">
<div class="col-xs-2 col-sm-2 col-xs-offset-4 col-sm-offset-5">
<button type="submit" class="btn btn-success btn-lg">Opslaan</button>
</div>
</div>
<?php echo form_close(); ?>
</div>
</div>

39
application/views/user_subgroep.php

@ -0,0 +1,39 @@ @@ -0,0 +1,39 @@
<div class="container">
<div class="starter-template">
<h1>Kies de ploeg</h1>
<?php if (count($subgroepen) != 0) { ?>
<?php echo form_open(base_url().'beoordelen/score'); ?>
<div class="row">
<div class="col-xs-2 col-sm-2 col-sm-offset-5 col-xs-offset-2">
<?php echo form_dropdown('subgroepid', $subgroepen); ?>
</div>
</div>
<p>
<div class="row">
<div class="col-xs-2 col-sm-2 col-xs-offset-4 col-sm-offset-5">
<button type="submit" class="btn btn-primary btn-lg">Volgende</button>
</div>
</div>
<?php echo form_close(); ?>
<?php } else { ?>
<div class="row">
<div class="col-xs-10 col-sm-4 col-xs-offset-1 col-sm-offset-4">
Er zijn geen groepen meer te beoordelen.
</div>
</div>
<div class="row">
<div class="col-xs-2 col-sm-2 col-xs-offset-4 col-sm-offset-5">
<button type="button" class="btn btn-success btn-lg" disabled="disabled">
<span class="glyphicon glyphicon-ok"></span>
</button>
</div>
</div>
<?php } ?>
</div>
</div>
Loading…
Cancel
Save