/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: a11andoh
  • Date: 2013-05-24 11:28:43 UTC
  • mto: This revision was merged to the branch mainline in revision 97.
  • Revision ID: a11andoh@student.his.se-20130524112843-360je7hu7q13r171
added the cms controller to load all content pages.
added first time registration controller to load the views for the registration
pages.
added and fixed temporarypages for the controllers 
and edited the models to be able to get active courses.

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