-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvideostatistics.php
137 lines (115 loc) · 4.45 KB
/
videostatistics.php
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?php
/**
* Author : Jeevan
* Url : https://jeevanism.com
* Project : https://www.bhimonlineclassroom.in
* Period : May 2020
* File : To diplsay statistics ( total video classes, teachers, date, hits etc)
*/
include('./_head.php'); // include header markup
$phits = array(); // need to add the total number of page hits of videos
$teacherlist = array(); // create array of teachers
$vids = $pages->find("template=singlevideo,sort=-phits"); // get single video type pages
foreach ($vids as $v){
$i= $v->phits;
$t=$v->createdby->title;
$phits[$i]=$i;
$teacherlist[$t]=$t;
}
$totalpageviews = array_sum($phits); // total number of views
$teacherno = count($teacherlist ); // total teachers
$totalvideos = count($vids); // total videos
$teacherlist= array_unique($teacherlist); // remove any duplicat entries
$countofteachers=count($teacherlist); // total number of teachers
$teachervideoslink= $teachervideoslink.'?teacher=';
?>
<section class=" portfolio ">
<div class="row ">
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="alert alert-primary footertext" role="alert" >
<?php echo $totalvideos;?> Videos added <i class="fa fa-caret-right" aria-hidden="true"></i>
<?php echo $totalpageviews;?> times viewed <i class="fa fa-caret-right" aria-hidden="true"></i>
<?php echo $countofteachers;?> Tutors
<span class="text-right"> <i class="fa fa-area-chart" aria-hidden="true"></i> The analytics shown here based on Website Visits : Actual figures may vary </span>
</div></div>
<div class="col-lg-8 col-md-12 col-sm-12 ">
<div class="card card-subj footertext rounded ">
<h4 class="text-center">Video Statitics</h4>
<!--tabular display of video statitics -->
<table class="table table-hover">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Video Name</th>
<th scope="col">Tutor Name </th>
<th scope="col">View Count</th>
<th scope="col">Added Date</th>
</tr>
</thead>
<tbody>
<?php
$i=1;
foreach($vids as $v)
{
$lastupdated=date("Y-m-d",$v->modified);
?>
<tr>
<th scope="row"><?php echo $i;?></th>
<td><i class="fa fa-youtube" aria-hidden="true"></i> <a href="<?php echo $v->httpUrl;?>"><?php echo $v->title;?></a></td>
<td><i class="fa fa-user-circle-o" aria-hidden="true"></i> <a href="<?php echo $teachervideoslink.$v->createdby->title;?>"><?php echo $v->createdby->title;?></a></td>
<td><i class="fa fa-eye" aria-hidden="true"></i> <?php echo $v->phits;?></td>
<td><i class="fa fa-calendar" aria-hidden="true"></i> <?php echo $lastupdated;?></td>
</tr>
<?php $i++;}?>
</tbody>
</table>
<!--tabular display of video statitics ends -->
</div></div>
<div class="col-lg-4 col-md-6 col-sm-12 ">
<div class="card card-subj footertext rounded ">
<h4 class="text-center">Tutors Statitics</h4>
<!--tabular display of Tutors statitics ends -->
<table class="table table-hover">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Tutor Name</th>
<th scope="col">Videos Added</th>
</tr>
</thead>
<tbody>
<?php
/**
* get the number of videos posted various tutors and
*/
$field = $fields->get('createdby');
$all_options = $field->type->getOptions($field);
$videoarray = array();
foreach($all_options as $v)
{
$nofvideos= $pages->find("template=singlevideo,createdby=$v->title");
$videoaaddedby=$v->title; // the tutor who added the video
$nofvideoss=count($nofvideos);
$videoarray[] = array(
'nofvid'=>$nofvideoss,
'nameof'=>$videoaaddedby
); // array for video info w.r.t the tutor and the videos belongd to that tutor
}
$nofvideosss=rsort($videoarray); // sort the descending order
$q=1;
foreach($videoarray as $v){
$nofvid = $v['nofvid'];
$nameoff= $v['nameof'];
?>
<tr>
<th scope="row"><?php echo $q;?></th>
<td><i class="fa fa-user-circle-o" aria-hidden="true"></i> <a href="<?php echo $teachervideoslink.$nameoff;?>"><?php echo $nameoff;?></a></td>
<td><i class="fa fa-youtube" aria-hidden="true"></i> <?php echo $nofvid;?> </td>
</tr>
<?php $q++;}
?>
</tbody>
</table>
</div></div>
</div>
</section><?php include('./_foot.php'); // include footer markup ?>