diff --git a/application/controllers/Beoordelen.php b/application/controllers/Beoordelen.php new file mode 100644 index 0000000..226d83d --- /dev/null +++ b/application/controllers/Beoordelen.php @@ -0,0 +1,187 @@ +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'); + } +} \ No newline at end of file diff --git a/application/controllers/Dashboard.php b/application/controllers/Dashboard.php index 0f02dc2..3db3540 100644 --- a/application/controllers/Dashboard.php +++ b/application/controllers/Dashboard.php @@ -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'); } } \ No newline at end of file diff --git a/application/models/Beoordelen_model.php b/application/models/Beoordelen_model.php new file mode 100644 index 0000000..a350ddc --- /dev/null +++ b/application/models/Beoordelen_model.php @@ -0,0 +1,106 @@ +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); + + } + } +} \ No newline at end of file diff --git a/application/views/dashboard_user.php b/application/views/dashboard_user.php new file mode 100644 index 0000000..e5ee7c6 --- /dev/null +++ b/application/views/dashboard_user.php @@ -0,0 +1,6 @@ +
+

Invoeren scorelijsten

+

+ +

+
\ No newline at end of file diff --git a/application/views/user_lijsten.php b/application/views/user_lijsten.php new file mode 100644 index 0000000..dbb2f1a --- /dev/null +++ b/application/views/user_lijsten.php @@ -0,0 +1,20 @@ +
+

De volgende lijsten zijn beschikbaar:

+ + + +
+
+ +
+
+

+

+
+ +
+
+

+ + +
diff --git a/application/views/user_ronde.php b/application/views/user_ronde.php new file mode 100644 index 0000000..1738c6b --- /dev/null +++ b/application/views/user_ronde.php @@ -0,0 +1,23 @@ +
+

Kies de ronde

+ + 'form-horizontal', 'role' => 'form');?> + + +
+
+ +
+
+ +
+
+

+

+
+ +
+
+ +

+
\ No newline at end of file diff --git a/application/views/user_score.php b/application/views/user_score.php new file mode 100644 index 0000000..29c671b --- /dev/null +++ b/application/views/user_score.php @@ -0,0 +1,41 @@ +
+ +
+

Geef de score aan

+ + + + + + +
+
+ +
+
+ +
+
+ + +

+ +

+
+ +
+
+ + + +
+
diff --git a/application/views/user_subgroep.php b/application/views/user_subgroep.php new file mode 100644 index 0000000..ce1027c --- /dev/null +++ b/application/views/user_subgroep.php @@ -0,0 +1,39 @@ +
+ +
+

Kies de ploeg

+ + + + + +
+
+ +
+
+

+

+
+ +
+
+ + + +
+
+ Er zijn geen groepen meer te beoordelen. +
+
+
+
+ +
+
+ + +
+
\ No newline at end of file