1
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
3
class ViewStudentsController extends CI_Controller {
5
public function index()
7
/* headData manages the <head>-tag and loads corresponding CSS.
8
* The views that are entered will load CSS with same name.
9
* Ex. test_header will load test_header.css
11
$this->load->library('session');
13
'cssFiles' => array('header', 'examplesMenu', 'examplesBody'),
14
'jsFiles' => array('header', 'examplesMenu', 'examplesBody', 'userControls')
16
$this->load->view('headTag', array('headTagData' => $headTagData));
18
$this->load->helper('form');
20
// Loading model to retrieve login data
21
$this->load->model('user');
23
'userType' => $this->user->getUserType(), // Loads different header for teacher/student
24
'userName' => $this->user->getUserName()
27
$this->load->view('header', $userInfo);
29
/* Loads used models */
30
$this->load->model('viewstudents');
32
// menuData loads items to the menu.
34
$allStudents = array();
36
/* Loads categorydata into array */
37
$query = $this->viewstudents->getStudents();
40
foreach ($query as $student)
42
array_push($allStudents, $student->userName);
45
/*Menu for examples page showing categories */
46
$this->load->view('examplesMenu', array('titles' => $allTitles));
48
/* Loads body for examples page */
50
$this->load->view('viewStudentsBody', array('students' => $allStudents));
55
public function validate() {
56
//Load required library
57
$this->load->library('form_validation');
59
//Sets validation rules
60
$this->form_validation->set_rules('username', 'Username', 'trim|required|xss_clean');
61
$this->form_validation->set_rules('password', 'Password', 'trim|required|xss_clean');
64
if($this->form_validation->run() == FALSE) {
65
//Field validation failed. Display login form (with error message).
66
$this->drawLoginForm(validation_errors());
68
$username = $this->input->post('username');
69
$password = $this->input->post('password');
72
if ($this->user->login($username, $password)) {
73
redirect(base_url().'home', 'refresh');
75
$this->drawLoginForm('Access denied!');
82
/* End of file ExamplesController.php */
83
/* Location: ./application/controllers/ExamplesController.php */
b'\\ No newline at end of file'