/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-29 11:07:14 UTC
  • mfrom: (124.1.1 lenasys)
  • Revision ID: gustav.hartvigsson@gmail.com-20130529110714-4iioizgqujt45riz
Merged Wikströms changes:

Added display of statistics in the sidepane

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
                public function getUserStats() {
15
15
                        //Dummy-array to be filled
16
16
                        $userStats = array(
17
 
                                'agentType' => 'unknown',
18
 
                                'agentName' => 'unknown',
19
 
                                'agentVersion' => 'unknown',
20
 
                                'agentPlatform' => 'unknown',
21
 
                                'agentString' => 'unknown'      
 
17
                                'agentType' => '[unknown]',
 
18
                                'agentName' => '[unknown]',
 
19
                                'agentVersion' => '[unknown]',
 
20
                                'agentPlatform' => '[unknown]',
 
21
                                'agentString' => '[unknown]'    
22
22
                        );
23
23
                
24
24
                        //If user is using a web browser
25
25
                        if($this->agent->is_browser()) {
26
 
                                $userStats['agentType'] = 'browser';
 
26
                                $userStats['agentType'] = 'Desktop';
27
27
                                $userStats['agentName'] = $this->agent->browser();
28
28
                                $userStats['agentVersion'] = $this->agent->version();
29
29
                        }
30
30
                        //If user is using a mobile browser
31
31
                        elseif ($this->agent->is_mobile()) {
32
 
                                $userStats['agentType'] = 'mobile';
 
32
                                $userStats['agentType'] = 'Mobile';
33
33
                                $userStats['agentName'] = $this->agent->mobile();
34
34
                        }
35
35
                        //If user is a robot
36
36
                        elseif ($this->agent->is_robot()) {
37
 
                                $userStats['agentType'] = 'robot';
 
37
                                $userStats['agentType'] = 'Robot';
38
38
                                $userStats['agentName'] = $this->agent->robot();
39
39
                        }
40
40
                        
54
54
                public function getSystemStats() {
55
55
                        //Dummy-array to be filled
56
56
                        $systemStats = array(
57
 
                                'courseAmount' => 'unknown',
58
 
                                'exampleAmount' => 'unknown',
59
 
                                'quizAmount' => 'unknown'       
 
57
                                'courseAmount' => '[unknown]',
 
58
                                'exampleAmount' => '[unknown]',
 
59
                                'quizAmount' => '[unknown]'     
60
60
                        );
61
61
                        
62
62
                        //Get amount of courses
63
 
                        $query = $this->db->get('Courses');
64
 
                        $systemStats['courseAmount'] = $query->num_rows();
 
63
                        $systemStats['courseAmount'] = $this->db->count_all('Courses');
65
64
                        
66
65
                        //Get amount of examples
67
 
                        $query = $this->db->get('Examples');
68
 
                        $systemStats['exampleAmount'] = $query->num_rows();
 
66
                        $systemStats['exampleAmount'] = $this->db->count_all('Examples');
69
67
                        
70
68
                        //Get amount of quizzes
71
 
                        $query = $this->db->get('Quizzes');
72
 
                        $systemStats['quizAmount'] = $query->num_rows();
 
69
                        $systemStats['quizAmount'] = $this->db->count_all('Quizzes');
73
70
                        
74
71
                        //Return result
75
72
                        return $systemStats;
80
77
                 *      This function returns an array with course stats.
81
78
                 */ 
82
79
                
83
 
                public function getCourseStats() {
 
80
                public function getCourseStats($courseID) {
84
81
                        //Dummy-array to be filled
85
82
                        $courseStats = array(
86
 
                                'exampleAmount' => 'unknown',
87
 
                                'quizAmount' => 'unknown'       
 
83
                                'exampleAmount' => '[unknown]',
 
84
                                'quizAmount' => '[unknown]'     
88
85
                        );
89
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
                        
90
95
                        //Return result
91
96
                        return $courseStats;    
92
97
                }