Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2020-101
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Sachith Fernando
2020-101
Commits
3cb5caed
Commit
3cb5caed
authored
Oct 22, 2020
by
I.K Seneviratne
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'db_and_monitoring' into 'QA_RELEASE'
Db and monitoring See merge request
!12
parents
65f5c691
4558dc0a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
92 additions
and
86 deletions
+92
-86
MonitorLecturerApp/templates/MonitorLecturerApp/index.html
MonitorLecturerApp/templates/MonitorLecturerApp/index.html
+14
-24
MonitorLecturerApp/templates/MonitorLecturerApp/lecVideo.html
...torLecturerApp/templates/MonitorLecturerApp/lecVideo.html
+2
-0
MonitorLecturerApp/views.py
MonitorLecturerApp/views.py
+76
-62
No files found.
MonitorLecturerApp/templates/MonitorLecturerApp/index.html
View file @
3cb5caed
{% extends 'FirstApp/template.html' %}
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"utf-8"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1, shrink-to-fit=no"
>
<meta
name=
"description"
content=
""
>
<meta
name=
"author"
content=
""
>
<title>
SLPES
</title>
{% load static %}
<!-- Custom fonts for this template-->
<link
rel=
"shortcut icon"
href=
"{% static 'FirstApp/images/favicon.ico' %}"
type=
"image/x-icon"
/>
<link
href=
"{% static 'FirstApp/css/all.min.css' %}"
rel=
"stylesheet"
type=
"text/css"
>
<link
href=
"https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i"
rel=
"stylesheet"
>
<!-- Custom styles for this template-->
<link
href=
"{% static 'FirstApp/css/sb-admin-2.min.css' %}"
rel=
"stylesheet"
>
</head>
<body
id=
"page-top"
>
{% block javascript %}
{% load static %}
<!-- Bootstrap core JavaScript-->
<script
src=
"{% static 'FirstApp/vendor/jquery/jquery.min.js' %}"
></script>
<script
src=
"{% static 'FirstApp/vendor/bootstrap/js/bootstrap.bundle.min.js' %}"
></script>
...
...
@@ -321,6 +302,8 @@
});
</script>
{% endblock %}
<!-- Page Wrapper -->
<div
id=
"wrapper"
>
...
...
@@ -392,7 +375,8 @@
<!-- End of Topbar -->
{% block 'container-fluid' %}
{% load static %}
<!-- Begin Page Content -->
<div
class=
"container-fluid"
>
...
...
@@ -647,6 +631,7 @@
</div>
<!-- /.container-fluid -->
{% endblock %}
</div>
<!-- End of Main Content -->
...
...
@@ -667,6 +652,8 @@
</div>
<!-- End of Page Wrapper -->
{% block 'modal' %}
<!-- Scroll to Top Button-->
<a
class=
"scroll-to-top rounded"
href=
"#page-top"
>
<i
class=
"fas fa-angle-up"
></i>
...
...
@@ -870,6 +857,9 @@
<script
src=
"{% static 'FirstApp/js/demo/chart-area-demo.js' %}"
></script>
<script
src=
"{% static 'FirstApp/js/demo/chart-pie-demo.js' %}"
></script>
{% endblock %}
</body>
</html>
MonitorLecturerApp/templates/MonitorLecturerApp/lecVideo.html
View file @
3cb5caed
...
...
@@ -154,6 +154,8 @@
<tbody>
{% for video in Videos %}
{# {% for video in lecturer_videos %} #}
<tr>
<td>
{{video.name}}
</td>
<td>
{{video.duration}}
</td>
...
...
MonitorLecturerApp/views.py
View file @
3cb5caed
from
django.shortcuts
import
render
from
django.shortcuts
import
render
,
redirect
from
django.http
import
HttpResponse
from
django.conf.urls
import
url
from
rest_framework
import
routers
...
...
@@ -43,68 +43,82 @@ def startup (request) :
def
hello
(
request
):
# page = '<h1>THIS IS MY HOME</h1>' + '<h2> Hello Ishan</h2>' + '<button>Click Me</button>'
obj
=
{
'Message'
:
'Student and Lecturer Performance Enhancement System'
}
folder
=
os
.
path
.
join
(
BASE_DIR
,
os
.
path
.
join
(
'static
\\
FirstApp
\\
lecturer_videos'
))
videoPaths
=
[
os
.
path
.
join
(
folder
,
file
)
for
file
in
os
.
listdir
(
folder
)]
videos
=
[]
durations
=
[]
# retrieve audio details from db
lecture_audio
=
LectureAudio
.
objects
.
all
()
lec_audio_serializer
=
LectureAudioSerializer
(
lecture_audio
,
many
=
True
)
lec_audio_data
=
lec_audio_serializer
.
data
lec_list
=
[]
for
audio
in
lec_audio_data
:
lec_audio_object
=
{}
lec_audio_object
[
"id"
]
=
audio
[
"id"
]
lec_audio_object
[
"date"
]
=
audio
[
"lecturer_date"
]
lec_audio_object
[
"subject"
]
=
audio
[
"subject"
][
"name"
]
lec_audio_object
[
"lecturer"
]
=
audio
[
"lecturer"
][
"fname"
]
+
" "
+
audio
[
"lecturer"
][
"lname"
]
lec_audio_object
[
"lecturer_id"
]
=
audio
[
"lecturer"
][
"id"
]
# append to the list
lec_list
.
append
(
lec_audio_object
)
# the list needs to be sorted by the date
lec_list
.
sort
(
key
=
lambda
date
:
dt
.
strptime
(
str
(
date
[
'date'
]),
"
%
Y-
%
m-
%
d"
),
reverse
=
True
)
# retrieve exsiting lecture recorded videos
lec_video_meta
=
LecturerVideoMetaData
.
objects
.
all
()
lec_video_meta_ser
=
LecturerVideoMetaDataSerializer
(
lec_video_meta
,
many
=
True
)
lec_video_meta_data
=
lec_video_meta_ser
.
data
for
videoPath
in
videoPaths
:
video
=
LecturerVideo
()
video
=
{}
cap
=
cv2
.
VideoCapture
(
videoPath
)
fps
=
cap
.
get
(
cv2
.
CAP_PROP_FPS
)
# OpenCV2 version 2 used "CV_CAP_PROP_FPS"
frame_count
=
int
(
cap
.
get
(
cv2
.
CAP_PROP_FRAME_COUNT
))
duration
=
int
(
frame_count
/
fps
)
durations
.
append
(
duration
)
videoName
=
os
.
path
.
basename
(
videoPath
)
# videoName = videos.append(os.path.basename(videoPath))
durationObj
=
datetime
.
timedelta
(
seconds
=
duration
)
video
[
'path'
]
=
videoPath
video
[
'name'
]
=
videoName
video
[
'duration'
]
=
str
(
durationObj
)
video
[
'video_id'
]
=
None
# checking whether this video already exists
for
recorded_lecture
in
lec_video_meta_data
:
print
(
'recorded lecture: '
,
recorded_lecture
)
if
videoName
==
recorded_lecture
[
'lecturer_video_id'
][
'lecture_video_name'
]:
video
[
'isAvailable'
]
=
True
video
[
'video_id'
]
=
recorded_lecture
[
'lecturer_video_id'
][
'id'
]
videos
.
append
(
video
)
print
(
'Video Name: '
,
video
[
'name'
])
context
=
{
'object'
:
obj
,
'Videos'
:
videos
,
'durations'
:
durations
,
'template_name'
:
'MonitorLecturerApp/template.html'
,
'lec_list'
:
lec_list
}
return
render
(
request
,
'MonitorLecturerApp/index.html'
,
context
)
try
:
admin
=
request
.
session
[
'admin'
]
obj
=
{
'Message'
:
'Student and Lecturer Performance Enhancement System'
}
folder
=
os
.
path
.
join
(
BASE_DIR
,
os
.
path
.
join
(
'static
\\
FirstApp
\\
lecturer_videos'
))
videoPaths
=
[
os
.
path
.
join
(
folder
,
file
)
for
file
in
os
.
listdir
(
folder
)]
videos
=
[]
durations
=
[]
# retrieve audio details from db
lecture_audio
=
LectureAudio
.
objects
.
all
()
lec_audio_serializer
=
LectureAudioSerializer
(
lecture_audio
,
many
=
True
)
lec_audio_data
=
lec_audio_serializer
.
data
lec_list
=
[]
for
audio
in
lec_audio_data
:
lec_audio_object
=
{}
lec_audio_object
[
"id"
]
=
audio
[
"id"
]
lec_audio_object
[
"date"
]
=
audio
[
"lecturer_date"
]
lec_audio_object
[
"subject"
]
=
audio
[
"subject"
][
"name"
]
lec_audio_object
[
"lecturer"
]
=
audio
[
"lecturer"
][
"fname"
]
+
" "
+
audio
[
"lecturer"
][
"lname"
]
lec_audio_object
[
"lecturer_id"
]
=
audio
[
"lecturer"
][
"id"
]
# append to the list
lec_list
.
append
(
lec_audio_object
)
# the list needs to be sorted by the date
lec_list
.
sort
(
key
=
lambda
date
:
dt
.
strptime
(
str
(
date
[
'date'
]),
"
%
Y-
%
m-
%
d"
),
reverse
=
True
)
# retrieve exsiting lecture recorded videos
lec_video_meta
=
LecturerVideoMetaData
.
objects
.
all
()
lec_video_meta_ser
=
LecturerVideoMetaDataSerializer
(
lec_video_meta
,
many
=
True
)
lec_video_meta_data
=
lec_video_meta_ser
.
data
for
videoPath
in
videoPaths
:
video
=
LecturerVideo
()
video
=
{}
cap
=
cv2
.
VideoCapture
(
videoPath
)
fps
=
cap
.
get
(
cv2
.
CAP_PROP_FPS
)
# OpenCV2 version 2 used "CV_CAP_PROP_FPS"
frame_count
=
int
(
cap
.
get
(
cv2
.
CAP_PROP_FRAME_COUNT
))
duration
=
int
(
frame_count
/
fps
)
durations
.
append
(
duration
)
videoName
=
os
.
path
.
basename
(
videoPath
)
# videoName = videos.append(os.path.basename(videoPath))
durationObj
=
datetime
.
timedelta
(
seconds
=
duration
)
video
[
'path'
]
=
videoPath
video
[
'name'
]
=
videoName
video
[
'duration'
]
=
str
(
durationObj
)
video
[
'video_id'
]
=
None
# checking whether this video already exists
for
recorded_lecture
in
lec_video_meta_data
:
print
(
'recorded lecture: '
,
recorded_lecture
)
if
videoName
==
recorded_lecture
[
'lecturer_video_id'
][
'lecture_video_name'
]:
video
[
'isAvailable'
]
=
True
video
[
'video_id'
]
=
recorded_lecture
[
'lecturer_video_id'
][
'id'
]
videos
.
append
(
video
)
print
(
'Video Name: '
,
video
[
'name'
])
context
=
{
'object'
:
obj
,
'Videos'
:
videos
,
'durations'
:
durations
,
'template_name'
:
'MonitorLecturerApp/template.html'
,
'lec_list'
:
lec_list
}
return
render
(
request
,
'MonitorLecturerApp/index.html'
,
context
)
# in case the 'admin' session is not there
except
KeyError
as
exc
:
return
redirect
(
'/401'
)
# in case of general exceptions
except
Exception
as
exc
:
print
(
'exception: '
,
exc
)
return
redirect
(
'/500'
)
def
view404
(
request
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment