/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-31 06:15:46 UTC
  • mfrom: (90.1.20 lenasys2)
  • Revision ID: gustav.hartvigsson@gmail.com-20130531061546-vj8z28sq375kvghq
Merged Jonsson:s changes:
Fixed the layout on cms index so the arrows and dots marks expanded objects.
Fixed so the course content is sorted by course occasion and not by name

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'