/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/models/stats.php

  • Committer: Gustav Hatvigsson
  • Date: 2013-05-30 12:02:31 UTC
  • mfrom: (85.1.28 lenasys)
  • Revision ID: gustav.hartvigsson@gmail.com-20130530120231-ttqgqjqw2w8enn7g
Merged Ohlsons changes:
added function to get ssn and name for the registrationspages in the user model.
added the registrationpage for students.
edited the registration page for instructors
edited the css for both the registrationpages
minor fix to registration css

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
        class Stats extends CI_Model {
 
3
        
 
4
                function __construct() {
 
5
                        parent::__construct();
 
6
                        $this->load->library('user_agent');
 
7
                }
 
8
 
 
9
 
 
10
                /*
 
11
                 *      This function returns an array with user stats.
 
12
                 */ 
 
13
                                
 
14
                public function getUserStats() {
 
15
                        //Dummy-array to be filled
 
16
                        $userStats = array(
 
17
                                'agentType' => '[unknown]',
 
18
                                'agentName' => '[unknown]',
 
19
                                'agentVersion' => '[unknown]',
 
20
                                'agentPlatform' => '[unknown]',
 
21
                                'agentString' => '[unknown]'    
 
22
                        );
 
23
                
 
24
                        //If user is using a web browser
 
25
                        if($this->agent->is_browser()) {
 
26
                                $userStats['agentType'] = 'Desktop';
 
27
                                $userStats['agentName'] = $this->agent->browser();
 
28
                                $userStats['agentVersion'] = $this->agent->version();
 
29
                        }
 
30
                        //If user is using a mobile browser
 
31
                        elseif ($this->agent->is_mobile()) {
 
32
                                $userStats['agentType'] = 'Mobile';
 
33
                                $userStats['agentName'] = $this->agent->mobile();
 
34
                        }
 
35
                        //If user is a robot
 
36
                        elseif ($this->agent->is_robot()) {
 
37
                                $userStats['agentType'] = 'Robot';
 
38
                                $userStats['agentName'] = $this->agent->robot();
 
39
                        }
 
40
                        
 
41
                        //Common stats
 
42
                        $userStats['agentPlatform'] = $this->agent->platform();
 
43
                        $userStats['agentString'] = $this->agent->agent_string();
 
44
                        
 
45
                        //Return result
 
46
                        return $userStats;
 
47
                }
 
48
                
 
49
                
 
50
                /*
 
51
                 *      This function returns an array with system stats.
 
52
                 */             
 
53
                
 
54
                public function getSystemStats() {
 
55
                        //Dummy-array to be filled
 
56
                        $systemStats = array(
 
57
                                'courseAmount' => '[unknown]',
 
58
                                'exampleAmount' => '[unknown]',
 
59
                                'quizAmount' => '[unknown]'     
 
60
                        );
 
61
                        
 
62
                        //Get amount of courses
 
63
                        $systemStats['courseAmount'] = $this->db->count_all('Courses');
 
64
                        
 
65
                        //Get amount of examples
 
66
                        $systemStats['exampleAmount'] = $this->db->count_all('Examples');
 
67
                        
 
68
                        //Get amount of quizzes
 
69
                        $systemStats['quizAmount'] = $this->db->count_all('Quizzes');
 
70
                        
 
71
                        //Return result
 
72
                        return $systemStats;
 
73
                }
 
74
                
 
75
                
 
76
                /*
 
77
                 *      This function returns an array with course stats.
 
78
                 */ 
 
79
                
 
80
                public function getCourseStats($courseID) {
 
81
                        //Dummy-array to be filled
 
82
                        $courseStats = array(
 
83
                                'exampleAmount' => '[unknown]',
 
84
                                'quizAmount' => '[unknown]'     
 
85
                        );
 
86
                        
 
87
                        $this->db->where('courseID', $courseID);
 
88
                        $this->db->from('Examples');
 
89
                        $courseStats['exampleAmount'] = $this->db->count_all_results();
 
90
                        
 
91
                        $this->db->where('courseID', $courseID);
 
92
                        $this->db->from('Quizzes');
 
93
                        $courseStats['quizAmount'] = $this->db->count_all_results();
 
94
                        
 
95
                        //Return result
 
96
                        return $courseStats;    
 
97
                }
 
98
        }
 
99
?>
 
 
b'\\ No newline at end of file'