1
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
1
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
3
3
class ViewStudentsController extends CI_Controller {
5
public function index() {
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
6
21
$this->load->model('user');
7
$this->load->model('admin/admin_model');
9
if(!$this->user->isLoggedIn() || $this->user->getUserType() != "Teacher") {
10
echo "You do not have access to this page.";
14
// NOTE: viewstudents is a deprecated model. Should eventually be replaced by a proper model
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 */
15
30
$this->load->model('viewstudents');
17
$userName = $this->user->getUserName();
18
$userType = $this->user->getUserType();
20
//Creates an array with the necessary css- and jsfiles needed for the views that are about to be shown.
22
'cssFiles' => array('bannermenu', 'sidemenu', 'dummieContent', 'viewStudents', 'body'),//cms tillfällig sida
23
'jsFiles' => array('bannermenu', 'viewStudents')
26
//Puts the array above in <head></head>
27
$this->load->view('headTag', array('headTagData' => $headTagData));
29
$students = $this->viewstudents->getStudents();
31
$this->load->view('viewStudentsBody', array('students' => $students));
34
public function editStudentDetails() {
35
$this->load->model('user');
36
if(!$this->input->post('username') || !$this->user->isLoggedIn()) {
37
echo "You do not have access to this page";
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));
42
'name' => $this->input->post('name');
46
55
public function validate() {
47
56
//Load required library