-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlecture.php
281 lines (267 loc) · 10.6 KB
/
lecture.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
<?php
if (!isset($_GET['id']) and !isset($_GET['cid'])) {
header('location: index.php');
}
$savecnt = array();
$contentid;
$opmd="";
$title="Lecture | Taalem | Online Course Learning";
require_once 'header.php';
if (!isset($_SESSION['regid'])) {
header('location: index.php');
}
if (!isset($_GET['id'])) {
$cid = $_GET['cid'];
$enroll = $dc->getRow("select * from courseenroll where courseid='$cid' and regid='$_SESSION[regid]'");
if (empty($enroll)) {
header("location: index.php");
}
$getcntid = $dc->getTable("SELECT contentid,contenturl from content where courseid='$cid' and contenttype != 'doc'");
if ($getcntid->num_rows > 0) {
while ($cnnrw = mysqli_fetch_assoc($getcntid)) {
$contime = $dc->getRow("select timeplayed from playtime where contentid='$cnnrw[contentid]' and regid='$_SESSION[regid]'");
if (empty($contime)) {
$contentid = $cnnrw['contentid'];
break;
}else{
$cucntime = getContentDuration($cnnrw['contenturl']);
$insec = getInSeconds($cucntime);
if ($insec == $contime['timeplayed']) {
$savecnt[] = $cnnrw['contentid'];
$stime = 0;
continue;
}else{
$contentid = $cnnrw['contentid'];
$stime = $contime['timeplayed'];
break;
}
// $contime['timeplayed'];
}
}
if (!isset($contentid)) {
$contentid = $savecnt[0];
}
}else{
header("location: index.php");
}
// $contentid = $getcntid['contentid'];
}else{
$getcid = $dc->getRow("select courseid from content where contentid='$_GET[id]'");
$enroll = $dc->getRow("select * from courseenroll where courseid='$getcid[courseid]' and regid='$_SESSION[regid]'");
if (empty($enroll)) {
header("location: index.php");
}
$contentid = $_GET['id'];
}
function showContentsl($secid){
global $dc;
$complete = "";
$content = $dc->getTable("select contentid,contentname,contenttype,contenturl from content where sectionid='$secid'");
while ($cntrw = mysqli_fetch_assoc($content)) {
$contime = $dc->getRow("select timeplayed from playtime where contentid='$cntrw[contentid]' and regid='$_SESSION[regid]'");
if ($cntrw['contenttype'] != 'doc') {
$cucntime = getContentDuration($cntrw['contenturl']);
$insec = getInSeconds($cucntime);
if ($insec == $contime['timeplayed']) {
$complete = "completed";
}
echo '<p><i class="fas fa-video a-black"></i><a href="lecture.php?id='.$cntrw['contentid'].'" class="a-black">'.$cntrw['contentname'].'</a><br/><span class="text-success">'.$complete.'</span><span class="float-right a-black">'.getContentDuration($cntrw['contenturl']).'</span></p><hr/>';
}
}
}
$content = $dc->getRow("select cn.contentname,cn.contenturl, c.courseid, c.coursetype, c.coursename,c.instid,i.instname from content cn, course c, instructor i WHERE cn.courseid=c.courseid and c.instid = i.regid and cn.contentid='$contentid'");
if (isset($_GET['cid'])) {
$coid = $_GET['cid'];
}else{
$coid = $getcid['courseid'];
}
$totalcnt=$dc->getRow("select count(contentid) as totalcontent from content where courseid='$coid'");
$totalf=$dc->getRow("select noc,cmpdate from cmprecord where courseid='$coid' and regid='$_SESSION[regid]'");
if ($totalf['noc'] == '') {
$totalf['noc'] = 0;
}
if ($totalf['noc'] == $totalcnt['totalcontent']) {
if ($totalf['cmpdate'] == '') {
$cudate = date("Y-m-d");
$ss = $dc->saveRecord("update cmprecord set cmpdate = '$cudate' where courseid='$coid' and regid='$_SESSION[regid]'");
}
if ($content['coursetype'] != 'free') {
$opmd= '$("#completed").modal("show");';
}
}
if (isset($_POST['btnque'])) {
$currenttime = date("Y-m-d H:i:s");
$getemail = $dc->getRow("select email from register where regid='$_SESSION[regid]'");
$apsub = "<p>Have Query on Your Lecture</p>";
$apmessage = "<p>".$_SESSION['username']." Ask Question About your Lecture : ".$content['contentname']."<br/>Question : ".$_POST['que']."<br/> You Can Reply with Email : ".$getemail['email']." </p>";
$savemsg = $dc->saveRecord("insert into message(msgdatetime,subject,message,senderregid,receiverregid,status) values('$currenttime','$apsub','$apmessage','$_SESSION[regid]','$content[instid]',0)");
}
?>
<div class="titlepage">
<h3><?= $content['contentname'] ?></h3>
<p><a href="<?= URL ?>" class="a-white"><i class="fas fa-home"></i></a> <i class="fas fa-angle-right a-white"></i> <a href="<?= URL.'cart.php' ?>" class="a-white"> Course </a> <i class="fas fa-angle-right a-white"></i> <a href="<?= URL.'singlecourse.php' ?>" class="a-white"> Single Course </a></p>
</div>
<div class="container-fluid p-5">
<div class="row">
<div class="col-md-9">
<div class="show-video">
<video id="video-active" width="100%" controlslist="nodownload" controls>
<source src="content/<?= $content['contenturl'] ?>#t=<?= $stime ?>" type="video/mp4">
Your browser does not support the video tag.
</video>
</div>
<div>
<?php
$np = $dc->getTable("select contentid from content where ( contentid = IFNULL((select min(contentid) from content where contentid > '$contentid'),0) or contentid = IFNULL((select max(contentid) from content where contentid < '$contentid'),0)) and courseid='$content[courseid]' and contenttype != 'doc'");
while($nprw = mysqli_fetch_assoc($np)){
if ($nprw['contentid'] < $contentid) {
echo '<a href="lecture.php?id='.$nprw['contentid'].'" class="btn btn-primary">Previous</a>';
}
if ($nprw['contentid'] > $contentid) {
echo '<a href="lecture.php?id='.$nprw['contentid'].'" id="nextbtn" class="btn btn-primary float-right">Next</a>';
}
}
?>
<div class="clearfix"></div>
</div>
</div>
<?php
$totalcnt=$dc->getRow("select count(contentid) as totalcontent from content where courseid='$coid'");
$totalf=$dc->getRow("select noc from cmprecord where courseid='$coid' and regid='$_SESSION[regid]'");
if ($totalf['noc'] == '') {
$totalf['noc'] = 0;
}
?>
<div class="col-md-3 vdlist">
<h5 class="float-left">Lectures List</h5>
<h5 class="float-right" title="Lectures complete"><?= $totalf['noc'] ?>/<?= $totalcnt['totalcontent'] ?></h5>
<div class="clearfix"></div>
<div class="vdlist-inner">
<div id="accordion">
<?php
$collapes = 1;
$sections = $dc->getTable("select sectionid,sectionname,sectiondesc from section where courseid='$content[courseid]'");
while ($secrw = mysqli_fetch_assoc($sections)) {
?>
<div class="card">
<div class="card-header">
<a class="card-link a-black" data-toggle="collapse" data-parent="#accordion" href="#collapse<?= $collapes ?>" style="display:block;">
<i class="fas fa-angle-down mr-2"></i><?= $secrw['sectionname'] ?>
</a>
</div>
<div id="collapse<?= $collapes ?>" class="collapse show">
<div class="card-body">
<?php showContentsl($secrw['sectionid']); ?>
</div>
</div>
</div>
<?php
$collapes++;
} ?>
</div>
</div>
</div>
</div>
</div>
<div class="container mx-5">
<div class="row">
<div class="col-md-12">
<h2><?= $content['contentname'] ?></h2>
<h3 class="text-muted" style="margin:0;"><?= $content['coursename'] ?></h3>
<h5 class="text-muted">By <?= $content['instname'] ?></h5>
</div>
</div>
<div class="row mt-3">
<div class="col-md-12">
<h4>Have Any Query About This Lecture ?</h4>
<form action="" method="post">
<input type="text" name="que" class="form-control mb-2" style="width: 40%;">
<input type="submit" name="btnque" class="btn btn-primary" value="Send">
</form>
</div>
</div>
</div>
<div class="modal fade" id="completed" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel"><b>Course Completed</b></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<h3 class="text-muted">Congratulations You Completed the Course</h3>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<a href="certificate.php?cid=<?= $coid ?>" class="btn btn-primary">Get Certificate</a>
</div>
</div>
</div>
</div>
<?php require_once 'footer.php'; ?>
<script>
var curtime;
var regid=<?php echo $_SESSION['regid']; ?>;
var cntid=<?= $contentid ?>;
var coid=<?= $coid ?>;
var cmp;
var cntt= 1;
$(document).ready(function(){
<?= $opmd ?>
$("#video-active").on(
"timeupdate",
function(event){
console.log(Math.round(this.currentTime));
curtime = Math.round(this.currentTime);
if (Math.round(this.currentTime) == Math.round(this.duration)){
if (cntt==1) {
$.ajax({
url: "inc/savetime.php",
method: "get",
data: { rgid: regid, coid: coid },
success:function(data){
console.log(data);
}
});
}
cntt++;
if ($('#nextbtn').length) {
$('#nextbtn')[0].click();
}else{
$.ajax({
url: "inc/savetime.php",
method: "get",
data: { ctime: curtime, rgid: regid, cnid: cntid },
success:function(data){
console.log(data);
}
});
window.location = "lecture.php?cid="+coid;
}
}
});
});
window.onbeforeunload = function() //When the user leaves the page(closes the window/tab, clicks a link)...
{
var regid=<?php echo $_SESSION['regid']; ?>;
var cntid=<?= $contentid ?>; //Find out how long it's been.
var xmlhttp; //Make a variable for a new ajax request.
if (window.XMLHttpRequest) //If it's a decent browser...
{
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest(); //Open a new ajax request.
}
else //If it's a bad browser...
{
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); //Open a different type of ajax call.
}
var url = "inc/savetime.php?ctime="+curtime+"&rgid="+regid+"&cnid="+cntid; //Send the time on the page to a php script of your choosing.
xmlhttp.open("GET",url,false); //The false at the end tells ajax to use a synchronous call which wont be severed by the user leaving.
xmlhttp.send(null); //Send the request and don't wait for a response.
}
</script>
</body>
</html>