/lenasys/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/trunk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
	class Stats extends CI_Model {
	
		function __construct() {
			parent::__construct();
			$this->load->library('user_agent');
		}


		/*
		 *	This function returns an array with user stats.
		 */ 
		 		
		public function getUserStats() {
			//Dummy-array to be filled
			$userStats = array(
				'agentType' => 'unknown',
				'agentName' => 'unknown',
				'agentVersion' => 'unknown',
				'agentPlatform' => 'unknown',
				'agentString' => 'unknown'	
			);
		
			//If user is using a web browser
			if($this->agent->is_browser()) {
				$userStats['agentType'] = 'browser';
				$userStats['agentName'] = $this->agent->browser();
				$userStats['agentVersion'] = $this->agent->version();
			}
			//If user is using a mobile browser
			elseif ($this->agent->is_mobile()) {
				$userStats['agentType'] = 'mobile';
				$userStats['agentName'] = $this->agent->mobile();
			}
			//If user is a robot
			elseif ($this->agent->is_robot()) {
				$userStats['agentType'] = 'robot';
				$userStats['agentName'] = $this->agent->robot();
			}
			
			//Common stats
			$userStats['agentPlatform'] = $this->agent->platform();
			$userStats['agentString'] = $this->agent->agent_string();
			
			//Return result
			return $userStats;
		}
		
		
		/*
		 *	This function returns an array with system stats.
		 */ 		
		
		public function getSystemStats() {
			//Dummy-array to be filled
			$systemStats = array(
				'courseAmount' => 'unknown',
				'exampleAmount' => 'unknown',
				'quizAmount' => 'unknown'	
			);
			
			//Get amount of courses
			$query = $this->db->get('Courses');
			$systemStats['courseAmount'] = $query->num_rows();
			
			//Get amount of examples
			$query = $this->db->get('Examples');
			$systemStats['exampleAmount'] = $query->num_rows();
			
			//Get amount of quizzes
			$query = $this->db->get('Quizzes');
			$systemStats['quizAmount'] = $query->num_rows();
			
			//Return result
			return $systemStats;
		}
		
		
		/*
		 *	This function returns an array with course stats.
		 */ 
		
		public function getCourseStats() {
			//Dummy-array to be filled
			$courseStats = array(
				'exampleAmount' => 'unknown',
				'quizAmount' => 'unknown'	
			);
			
			//Return result
			return $courseStats;	
		}
	}
?>