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]'
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();
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();
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();
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]'
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');
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');
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');
75
72
return $systemStats;
80
77
* This function returns an array with course stats.
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]'
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();
91
96
return $courseStats;