/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-28 14:01:47 UTC
  • mfrom: (119.1.1 lenasys)
  • Revision ID: gustav.hartvigsson@gmail.com-20130528140147-2ewydr3yibwkoizh
Merged Wiksröm:s changes:

Edited courses data, making it more testable with different visble/public settings

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'] = 'browser';
 
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
                        $query = $this->db->get('Courses');
 
64
                        $systemStats['courseAmount'] = $query->num_rows();
 
65
                        
 
66
                        //Get amount of examples
 
67
                        $query = $this->db->get('Examples');
 
68
                        $systemStats['exampleAmount'] = $query->num_rows();
 
69
                        
 
70
                        //Get amount of quizzes
 
71
                        $query = $this->db->get('Quizzes');
 
72
                        $systemStats['quizAmount'] = $query->num_rows();
 
73
                        
 
74
                        //Return result
 
75
                        return $systemStats;
 
76
                }
 
77
                
 
78
                
 
79
                /*
 
80
                 *      This function returns an array with course stats.
 
81
                 */ 
 
82
                
 
83
                public function getCourseStats() {
 
84
                        //Dummy-array to be filled
 
85
                        $courseStats = array(
 
86
                                'exampleAmount' => 'unknown',
 
87
                                'quizAmount' => 'unknown'       
 
88
                        );
 
89
                        
 
90
                        //Return result
 
91
                        return $courseStats;    
 
92
                }
 
93
        }
 
94
?>
 
 
b'\\ No newline at end of file'