2
class Stats extends CI_Model {
4
function __construct() {
6
$this->load->library('user_agent');
11
* This function returns an array with user stats.
14
public function getUserStats() {
15
//Dummy-array to be filled
17
'agentType' => 'unknown',
18
'agentName' => 'unknown',
19
'agentVersion' => 'unknown',
20
'agentPlatform' => 'unknown',
21
'agentString' => 'unknown'
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();
30
//If user is using a mobile browser
31
elseif ($this->agent->is_mobile()) {
32
$userStats['agentType'] = 'mobile';
33
$userStats['agentName'] = $this->agent->mobile();
36
elseif ($this->agent->is_robot()) {
37
$userStats['agentType'] = 'robot';
38
$userStats['agentName'] = $this->agent->robot();
42
$userStats['agentPlatform'] = $this->agent->platform();
43
$userStats['agentString'] = $this->agent->agent_string();
51
* This function returns an array with system stats.
54
public function getSystemStats() {
55
//Dummy-array to be filled
57
'courseAmount' => 'unknown',
58
'exampleAmount' => 'unknown',
59
'quizAmount' => 'unknown'
62
//Get amount of courses
63
$query = $this->db->get('Courses');
64
$systemStats['courseAmount'] = $query->num_rows();
66
//Get amount of examples
67
$query = $this->db->get('Examples');
68
$systemStats['exampleAmount'] = $query->num_rows();
70
//Get amount of quizzes
71
$query = $this->db->get('Quizzes');
72
$systemStats['quizAmount'] = $query->num_rows();
80
* This function returns an array with course stats.
83
public function getCourseStats() {
84
//Dummy-array to be filled
86
'exampleAmount' => 'unknown',
87
'quizAmount' => 'unknown'
b'\\ No newline at end of file'