/lenasys/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/trunk

« back to all changes in this revision

Viewing changes to codeigniter/application/controllers/ViewStudentsController.php

  • Committer: Gustav Hatvigsson
  • Date: 2013-05-21 12:01:01 UTC
  • mfrom: (82.1.1 lenasys)
  • Revision ID: gustav.hartvigsson@gmail.com-20130521120101-ch0ps106uaovyh5u
merged the missing things...

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 
1
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2
2
 
3
3
class ViewStudentsController extends CI_Controller {
4
4
 
5
 
        public function index() {
 
5
        public function index()
 
6
        {
 
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
 
10
                 */
 
11
                $this->load->library('session');
 
12
                $headTagData = array(
 
13
                        'cssFiles' => array('header', 'examplesMenu', 'examplesBody'),
 
14
                        'jsFiles' => array('header', 'examplesMenu', 'examplesBody', 'userControls')
 
15
                );
 
16
                $this->load->view('headTag', array('headTagData' => $headTagData));
 
17
                
 
18
                $this->load->helper('form');
 
19
                
 
20
                // Loading model to retrieve login data
6
21
                $this->load->model('user');
7
 
                $this->load->model('admin/admin_model');
8
 
 
9
 
                if(!$this->user->isLoggedIn() || $this->user->getUserType() != "Teacher") {
10
 
                        echo "You do not have access to this page.";
11
 
                        return;
12
 
                }
13
 
 
14
 
                // NOTE: viewstudents is a deprecated model. Should eventually be replaced by a proper model
 
22
                $userInfo = array(
 
23
                        'userType' => $this->user->getUserType(), // Loads different header for teacher/student
 
24
                        'userName' => $this->user->getUserName()
 
25
                );
 
26
                
 
27
                $this->load->view('header', $userInfo);
 
28
                        
 
29
                /* Loads used models */
15
30
                $this->load->model('viewstudents');
16
 
 
17
 
                $userName = $this->user->getUserName();
18
 
                $userType = $this->user->getUserType();
19
 
                
20
 
                //Creates an array with the necessary css- and jsfiles needed for the views that are about to be shown.
21
 
                $headTagData = array(
22
 
                        'cssFiles' => array('bannermenu', 'sidemenu', 'dummieContent', 'viewStudents', 'body'),//cms tillfällig sida
23
 
                        'jsFiles' => array('bannermenu', 'viewStudents')
24
 
                );
25
 
                
26
 
                //Puts the array above in <head></head>
27
 
                $this->load->view('headTag', array('headTagData' => $headTagData));     
28
 
 
29
 
                $students = $this->viewstudents->getStudents();
30
 
                
31
 
                $this->load->view('viewStudentsBody', array('students' => $students));
32
 
        }
33
 
 
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";
38
 
                        return;
 
31
                
 
32
                // menuData loads items to the menu.
 
33
                $allTitles = array();
 
34
                $allStudents = array();
 
35
                
 
36
                /* Loads categorydata into array */
 
37
                $query = $this->viewstudents->getStudents();
 
38
 
 
39
                
 
40
                foreach ($query as $student)
 
41
                {
 
42
                        array_push($allStudents, $student->userName);
39
43
                }
 
44
                
 
45
                /*Menu for examples page showing categories */
 
46
                $this->load->view('examplesMenu', array('titles' => $allTitles));
 
47
                
 
48
                /* Loads body for examples page */
 
49
                
 
50
                $this->load->view('viewStudentsBody', array('students' => $allStudents));       
40
51
 
41
 
                $data = array(
42
 
                        'name' => $this->input->post('name');
43
 
                );
44
52
        }
 
53
 
45
54
        
46
55
        public function validate() {
47
56
                //Load required library