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'] = 'Desktop';
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
$systemStats['courseAmount'] = $this->db->count_all('Courses');
65
//Get amount of examples
66
$systemStats['exampleAmount'] = $this->db->count_all('Examples');
68
//Get amount of quizzes
69
$systemStats['quizAmount'] = $this->db->count_all('Quizzes');
77
* This function returns an array with course stats.
80
public function getCourseStats($courseID) {
81
//Dummy-array to be filled
83
'exampleAmount' => '[unknown]',
84
'quizAmount' => '[unknown]'
87
$this->db->where('courseID', $courseID);
88
$this->db->from('Examples');
89
$courseStats['exampleAmount'] = $this->db->count_all_results();
91
$this->db->where('courseID', $courseID);
92
$this->db->from('Quizzes');
93
$courseStats['quizAmount'] = $this->db->count_all_results();
b'\\ No newline at end of file'