Commit bcdeadae authored by SohanDanushka's avatar SohanDanushka

Merge remote-tracking branch 'origin/QA_RELEASE' into db_and_monitoring_IT17097284

parents 03720152 df06d2d8
...@@ -17,7 +17,7 @@ from MonitorLecturerApp.models import LectureRecordedVideo, LecturerVideoMetaDat ...@@ -17,7 +17,7 @@ from MonitorLecturerApp.models import LectureRecordedVideo, LecturerVideoMetaDat
from MonitorLecturerApp.serializers import LectureRecordedVideoSerializer, LecturerVideoMetaDataSerializer from MonitorLecturerApp.serializers import LectureRecordedVideoSerializer, LecturerVideoMetaDataSerializer
from rest_framework.views import * from rest_framework.views import *
from .logic import activity_recognition as ar from .logic import activity_recognition as ar
from . import emotion_detector as ed from . import emotion_detector as ed, automation_process as ap
from .logic import id_generator as ig from .logic import id_generator as ig
from .logic import pdf_file_generator as pdf from .logic import pdf_file_generator as pdf
from .logic import head_gaze_estimation as hge from .logic import head_gaze_estimation as hge
...@@ -1647,3 +1647,23 @@ class DisplayUpcomingLecturesAPI(APIView): ...@@ -1647,3 +1647,23 @@ class DisplayUpcomingLecturesAPI(APIView):
"subject_code": subject_code, "subject_code": subject_code,
}) })
# this API will handle all the batch processes and video/audio saving to the system
class AutomationProcess(APIView):
def get(self, request):
return Response({
"response": "This API will be used for Automation process"
})
def post(self, request):
lecturer = request.data['lecturer']
subject = request.data['subject']
subject_code = request.data['subject_code']
video_length = request.data['video_length']
processed = ap.automation_process(lecturer=lecturer, subject=subject, subject_code=subject_code, video_length=video_length)
return Response({
"is_processed": processed
})
\ No newline at end of file
import requests
import json
from . logic import batch_process as bp
from MonitorLecturerApp.logic import lecturer_batch_process as lbp
import datetime
# this method will save the lecture video
#
# def save_student_lecture_video(student_video):
#
# data_dumps = json.dumps(student_video)
#
# headers = {
# 'Content-Type': 'application/json'
# }
#
# # call the API
# # student_video_save_resp = requests.post('http://127.0.0.1:8000/lecture-video', student_video)
# student_video_save_resp = requests.post(url='http://127.0.0.1:8000/lecture-video', data=data_dumps, headers=headers)
#
# data = student_video_save_resp.json()
#
# return data[0]
#
#
# # this method will save the lecturer video details
# def save_lecturer_video_details(video):
#
#
# headers = {
# "Content-Type": "application/json"
# }
#
# # convert the data into JSON string
# video_json_str = json.dumps(video)
#
# lecturer_video_resp = requests.post(url='http://127.0.0.1:8000/lecturer/lecturer-video/', data=video_json_str, headers=headers)
#
# response = lecturer_video_resp.json()
#
# return response[0]
# this method will handle the batch processing and video/audio saving pf the system
def automation_process(lecturer, subject, subject_code, video_length="00:20:00"):
current_date = datetime.datetime.now().date()
# this variable will be returned
is_all_processed = False
# define the video/audio names to be saved
student_video_name = str(current_date) + "_{}_student_video.mp4".format(subject_code)
lecturer_video_name = str(current_date) + "_{}_lecturer_video.mp4".format(subject_code)
lecturer_audio_name = str(current_date) + "_{}_lecturer_audio.wav".format(subject_code)
# this variable will be passed in the individual batch process
student_video_id = 0
# create the student video content
student_video_content = {
"lecturer": lecturer,
"subject": subject,
"date": str(current_date),
"video_name": student_video_name,
"video_length": video_length
}
# create the student video content
lecturer_video_content = {
"lecturer": lecturer,
"subject": subject,
"lecturer_date": str(current_date),
"lecture_video_name": lecturer_video_name,
"lecture_video_length": video_length
}
# create the lecturer audio
lecturer_audio_content = {}
# save the student video
student_video_response = bp.save_student_lecture_video(student_video_content)
# student_video_response = save_student_lecture_video(student_video_content)
student_video_id = student_video_response['id']
# save the lecturer video
lecturer_video_response = lbp.save_lecturer_video_details(lecturer_video_content)
# lecturer_video_response = save_lecturer_video_details(lecturer_video_content)
print('lecturer video response: ', lecturer_video_response)
# save the lecturer audio
# start the batch processing for lecture summarization component
# lecture_summary_batch_process = lecture_summarization_batch_process(audio_name)
lecture_summary_batch_process = True
# if the lecture summarization process is successful
# if lecture_summary_batch_process:
#
# # start the batch processing for monitoring lecturer performance component
# lecturer_batch_process_response = lecturer_batch_process(lecturer_video_name, lecturer_audio_name)
#
# # if the lecturer performance process is successful
# if lecturer_batch_process_response:
#
# # start the batch processing for monitoring student behavior component
# student_batch_process_response = student_behavior_batch_process(student_video_id, student_video_name)
#
# # if the student behavior process is successful
# if student_batch_process_response:
# is_all_processed = True
# return the status
return is_all_processed
# test the above method using 'main' method
# if __name__ == '__main__':
#
# lecturer = 1
# subject = 16
# subject_code = "IT1120"
#
# # call the method
# automation_process(lecturer, subject, subject_code)
...@@ -29,10 +29,11 @@ def student_behavior_batch_process(video_id, video_name): ...@@ -29,10 +29,11 @@ def student_behavior_batch_process(video_id, video_name):
return is_all_processed return is_all_processed
# this method will save the lecture video # this method will save the student lecture video
def save_student_lecture_video(student_video): def save_student_lecture_video(student_video):
data_dumps = json.dumps(student_video) data_dumps = json.dumps(student_video)
response = None
headers = { headers = {
'Content-Type': 'application/json' 'Content-Type': 'application/json'
...@@ -43,11 +44,12 @@ def save_student_lecture_video(student_video): ...@@ -43,11 +44,12 @@ def save_student_lecture_video(student_video):
student_video_save_resp = requests.post(url='http://127.0.0.1:8000/lecture-video', data=data_dumps, headers=headers) student_video_save_resp = requests.post(url='http://127.0.0.1:8000/lecture-video', data=data_dumps, headers=headers)
data = student_video_save_resp.json() data = student_video_save_resp.json()
response = data[0]
return data[0] return response
if __name__ == '__main__': # if __name__ == '__main__':
# content = { # content = {
# "lecturer": 1, # "lecturer": 1,
# "subject": 16, # "subject": 16,
...@@ -63,5 +65,5 @@ if __name__ == '__main__': ...@@ -63,5 +65,5 @@ if __name__ == '__main__':
# #
# save_student_lecture_video(content) # save_student_lecture_video(content)
student_behavior_batch_process(8, "Video_test_8.mp4") # student_behavior_batch_process(8, "Video_test_8.mp4")
...@@ -1144,6 +1144,12 @@ ...@@ -1144,6 +1144,12 @@
//hide the loader //hide the loader
$('#activity_corr_loader').hide(); $('#activity_corr_loader').hide();
//show the color palettes
$('#advanced_activity_color_palette_heading').attr('hidden', false);
$('#advanced_activity_color_palette_1').attr('hidden', false);
$('#advanced_activity_color_palette_2').attr('hidden', false);
//show the table //show the table
$('#activity_corr_table').attr('hidden', false); $('#activity_corr_table').attr('hidden', false);
...@@ -1196,6 +1202,11 @@ ...@@ -1196,6 +1202,11 @@
//hide the loader //hide the loader
$('#emotion_corr_loader').hide(); $('#emotion_corr_loader').hide();
//show the color palettes
$('#advanced_emotion_color_palette_heading').attr('hidden', false);
$('#advanced_emotion_color_palette_1').attr('hidden', false);
$('#advanced_emotion_color_palette_2').attr('hidden', false);
//show the table //show the table
$('#emotion_corr_table').attr('hidden', false); $('#emotion_corr_table').attr('hidden', false);
...@@ -1249,6 +1260,12 @@ ...@@ -1249,6 +1260,12 @@
//hide the loader //hide the loader
$('#gaze_corr_loader').hide(); $('#gaze_corr_loader').hide();
//show the color palettes
$('#advanced_gaze_color_palette_heading').attr('hidden', false);
$('#advanced_gaze_color_palette_1').attr('hidden', false);
$('#advanced_gaze_color_palette_2').attr('hidden', false);
//show the table //show the table
$('#gaze_corr_table').attr('hidden', false); $('#gaze_corr_table').attr('hidden', false);
...@@ -1310,6 +1327,12 @@ ...@@ -1310,6 +1327,12 @@
//hide the loader //hide the loader
$('#student_activity_emotion_corr_loader').hide(); $('#student_activity_emotion_corr_loader').hide();
//show the color palettes
$('#student_activity_emotion_color_palette_heading').attr('hidden', false);
$('#student_activity_emotion_color_palette_1').attr('hidden', false);
$('#student_activity_emotion_color_palette_2').attr('hidden', false);
//show the table //show the table
$('#student_activity_emotion_corr_table').attr('hidden', false); $('#student_activity_emotion_corr_table').attr('hidden', false);
...@@ -1370,6 +1393,12 @@ ...@@ -1370,6 +1393,12 @@
//hide the loader //hide the loader
$('#student_activity_gaze_corr_loader').hide(); $('#student_activity_gaze_corr_loader').hide();
//show the color palettes
$('#student_activity_gaze_color_palette_heading').attr('hidden', false);
$('#student_activity_gaze_color_palette_1').attr('hidden', false);
$('#student_activity_gaze_color_palette_2').attr('hidden', false);
//show the table //show the table
$('#student_activity_gaze_corr_table').attr('hidden', false); $('#student_activity_gaze_corr_table').attr('hidden', false);
...@@ -1432,6 +1461,12 @@ ...@@ -1432,6 +1461,12 @@
//hide the loader //hide the loader
$('#student_emotion_gaze_corr_loader').hide(); $('#student_emotion_gaze_corr_loader').hide();
//show the color palettes
$('#student_emotion_gaze_color_palette_heading').attr('hidden', false);
$('#student_emotion_gaze_color_palette_1').attr('hidden', false);
$('#student_emotion_gaze_color_palette_2').attr('hidden', false);
//show the table //show the table
$('#student_emotion_gaze_corr_table').attr('hidden', false); $('#student_emotion_gaze_corr_table').attr('hidden', false);
...@@ -2510,13 +2545,14 @@ ...@@ -2510,13 +2545,14 @@
<div class="modal-body text-center"> <div class="modal-body text-center">
<h3 class="font-weight-bold">Student Activity VS. Lecturer Activity</h3> <h3 class="font-weight-bold">Student Activity VS. Lecturer Activity</h3>
<!-- ajax loader --> <!-- ajax loader -->
<div class="text-center" id="activity_corr_loader" hidden> <div class="text-center" id="activity_corr_loader" hidden>
<img src="{% static 'FirstApp/images/ajax-loader.gif' %}" alt="Loader"> <img src="{% static 'FirstApp/images/ajax-loader.gif' %}" alt="Loader">
</div> </div>
<!-- correlation table --> <!-- correlation table -->
<table class="table table-striped" id="activity_corr_table" hidden> <table class="table table-striped mt-4" id="activity_corr_table" hidden>
<thead> <thead>
<tr> <tr>
<th>Student Activity</th> <th>Student Activity</th>
...@@ -2531,6 +2567,53 @@ ...@@ -2531,6 +2567,53 @@
</table> </table>
<!-- end of correlation table --> <!-- end of correlation table -->
<!-- Heading row -->
<div class="row mt-3 ml-1" id="advanced_activity_color_palette_heading" hidden>
<h5 class="float-left font-italic">Correlation color palette</h5>
</div>
<!-- End of Heading row -->
<!-- Color palette (row 1) -->
<div class="row mt-2 border-top" id="advanced_activity_color_palette_1" hidden>
<div class="col-lg-4">
<p class="text-center">Very High (81-100)%</p>
<div class="d-flex justify-content-center">
<div class="bg-success rounded" style="height: 10px; width: 100px"></div>
</div>
</div>
<div class="col-lg-4">
<p class="text-center">High (61-80)%</p>
<div class="d-flex justify-content-center">
<div class="bg-primary rounded" style="height: 10px; width: 100px"></div>
</div>
</div>
<div class="col-lg-4">
<p class="text-center">Moderate (41-60)%</p>
<div class="d-flex justify-content-center">
<div class="bg-warning rounded" style="height: 10px; width: 100px"></div>
</div>
</div>
</div>
<!-- End of Color palette (row 1) -->
<!-- Color palette (row 2) -->
<div class="row mt-4 mb-4 border-top" id="advanced_activity_color_palette_2" hidden>
<div class="col-lg-6">
<p class="text-center">Low (21-40)%</p>
<div class="d-flex justify-content-center">
<div class="bg-danger rounded" style="height: 10px; width: 100px"></div>
</div>
</div>
<div class="col-lg-6">
<p class="text-center">Weak (0-20)%</p>
<div class="d-flex justify-content-center">
<div class="bg-dark rounded" style="height: 10px; width: 100px"></div>
</div>
</div>
</div>
<!-- End of Color palette (row 2) -->
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button> <button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button>
...@@ -2575,6 +2658,54 @@ ...@@ -2575,6 +2658,54 @@
</table> </table>
<!-- end of correlation table --> <!-- end of correlation table -->
<!-- Heading row -->
<div class="row mt-3 ml-1" id="advanced_emotion_color_palette_heading" hidden>
<h5 class="float-left font-italic">Correlation color palette</h5>
</div>
<!-- End of Heading row -->
<!-- Color palette (row 1) -->
<div class="row mt-2 border-top" id="advanced_emotion_color_palette_1" hidden>
<div class="col-lg-4">
<p class="text-center">Very High (81-100)%</p>
<div class="d-flex justify-content-center">
<div class="bg-success rounded" style="height: 10px; width: 100px"></div>
</div>
</div>
<div class="col-lg-4">
<p class="text-center">High (61-80)%</p>
<div class="d-flex justify-content-center">
<div class="bg-primary rounded" style="height: 10px; width: 100px"></div>
</div>
</div>
<div class="col-lg-4">
<p class="text-center">Moderate (41-60)%</p>
<div class="d-flex justify-content-center">
<div class="bg-warning rounded" style="height: 10px; width: 100px"></div>
</div>
</div>
</div>
<!-- End of Color palette (row 1) -->
<!-- Color palette (row 2) -->
<div class="row mt-4 mb-4 border-top" id="advanced_emotion_color_palette_2" hidden>
<div class="col-lg-6">
<p class="text-center">Low (21-40)%</p>
<div class="d-flex justify-content-center">
<div class="bg-danger rounded" style="height: 10px; width: 100px"></div>
</div>
</div>
<div class="col-lg-6">
<p class="text-center">Weak (0-20)%</p>
<div class="d-flex justify-content-center">
<div class="bg-dark rounded" style="height: 10px; width: 100px"></div>
</div>
</div>
</div>
<!-- End of Color palette (row 2) -->
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button> <button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button>
...@@ -2619,6 +2750,54 @@ ...@@ -2619,6 +2750,54 @@
</table> </table>
<!-- end of correlation table --> <!-- end of correlation table -->
<!-- Heading row -->
<div class="row mt-3 ml-1" id="advanced_gaze_color_palette_heading" hidden>
<h5 class="float-left font-italic">Correlation color palette</h5>
</div>
<!-- End of Heading row -->
<!-- Color palette (row 1) -->
<div class="row mt-2 border-top" id="advanced_gaze_color_palette_1" hidden>
<div class="col-lg-4">
<p class="text-center">Very High (81-100)%</p>
<div class="d-flex justify-content-center">
<div class="bg-success rounded" style="height: 10px; width: 100px"></div>
</div>
</div>
<div class="col-lg-4">
<p class="text-center">High (61-80)%</p>
<div class="d-flex justify-content-center">
<div class="bg-primary rounded" style="height: 10px; width: 100px"></div>
</div>
</div>
<div class="col-lg-4">
<p class="text-center">Moderate (41-60)%</p>
<div class="d-flex justify-content-center">
<div class="bg-warning rounded" style="height: 10px; width: 100px"></div>
</div>
</div>
</div>
<!-- End of Color palette (row 1) -->
<!-- Color palette (row 2) -->
<div class="row mt-4 mb-4 border-top" id="advanced_gaze_color_palette_2" hidden>
<div class="col-lg-6">
<p class="text-center">Low (21-40)%</p>
<div class="d-flex justify-content-center">
<div class="bg-danger rounded" style="height: 10px; width: 100px"></div>
</div>
</div>
<div class="col-lg-6">
<p class="text-center">Weak (0-20)%</p>
<div class="d-flex justify-content-center">
<div class="bg-dark rounded" style="height: 10px; width: 100px"></div>
</div>
</div>
</div>
<!-- End of Color palette (row 2) -->
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button> <button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button>
...@@ -2665,10 +2844,58 @@ ...@@ -2665,10 +2844,58 @@
</table> </table>
<!-- end of correlation table --> <!-- end of correlation table -->
<!-- Heading row -->
<div class="row mt-3 ml-1" id="student_activity_emotion_color_palette_heading" hidden>
<h5 class="float-left font-italic">Correlation color palette</h5>
</div>
<!-- End of Heading row -->
<!-- Color palette (row 1) -->
<div class="row mt-2 border-top" id="student_activity_emotion_color_palette_1" hidden>
<div class="col-lg-4">
<p class="text-center">Very High (81-100)%</p>
<div class="d-flex justify-content-center">
<div class="bg-success rounded" style="height: 10px; width: 100px"></div>
</div>
</div>
<div class="col-lg-4">
<p class="text-center">High (61-80)%</p>
<div class="d-flex justify-content-center">
<div class="bg-primary rounded" style="height: 10px; width: 100px"></div>
</div>
</div>
<div class="col-lg-4">
<p class="text-center">Moderate (41-60)%</p>
<div class="d-flex justify-content-center">
<div class="bg-warning rounded" style="height: 10px; width: 100px"></div>
</div>
</div>
</div>
<!-- End of Color palette (row 1) -->
<!-- Color palette (row 2) -->
<div class="row mt-4 mb-4 border-top" id="student_activity_emotion_color_palette_2" hidden>
<div class="col-lg-6">
<p class="text-center">Low (21-40)%</p>
<div class="d-flex justify-content-center">
<div class="bg-danger rounded" style="height: 10px; width: 100px"></div>
</div>
</div>
<div class="col-lg-6">
<p class="text-center">Weak (0-20)%</p>
<div class="d-flex justify-content-center">
<div class="bg-dark rounded" style="height: 10px; width: 100px"></div>
</div>
</div>
</div>
<!-- End of Color palette (row 2) -->
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button> <button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
...@@ -2710,10 +2937,60 @@ ...@@ -2710,10 +2937,60 @@
</table> </table>
<!-- end of correlation table --> <!-- end of correlation table -->
<!-- Heading row -->
<div class="row mt-3 ml-1" id="student_activity_gaze_color_palette_heading" hidden>
<h5 class="float-left font-italic">Correlation color palette</h5>
</div>
<!-- End of Heading row -->
<!-- Color palette (row 1) -->
<div class="row mt-2 border-top" id="student_activity_gaze_color_palette_1" hidden>
<div class="col-lg-4">
<p class="text-center">Very High (81-100)%</p>
<div class="d-flex justify-content-center">
<div class="bg-success rounded" style="height: 10px; width: 100px"></div>
</div>
</div>
<div class="col-lg-4">
<p class="text-center">High (61-80)%</p>
<div class="d-flex justify-content-center">
<div class="bg-primary rounded" style="height: 10px; width: 100px"></div>
</div>
</div>
<div class="col-lg-4">
<p class="text-center">Moderate (41-60)%</p>
<div class="d-flex justify-content-center">
<div class="bg-warning rounded" style="height: 10px; width: 100px"></div>
</div>
</div>
</div>
<!-- End of Color palette (row 1) -->
<!-- Color palette (row 2) -->
<div class="row mt-4 mb-4 border-top" id="student_activity_gaze_color_palette_2" hidden>
<div class="col-lg-6">
<p class="text-center">Low (21-40)%</p>
<div class="d-flex justify-content-center">
<div class="bg-danger rounded" style="height: 10px; width: 100px"></div>
</div>
</div>
<div class="col-lg-6">
<p class="text-center">Weak (0-20)%</p>
<div class="d-flex justify-content-center">
<div class="bg-dark rounded" style="height: 10px; width: 100px"></div>
</div>
</div>
</div> </div>
<!-- End of Color palette (row 2) -->
</div>
<div class="modal-footer"> <div class="modal-footer">
<button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button> <button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
...@@ -2755,6 +3032,53 @@ ...@@ -2755,6 +3032,53 @@
</table> </table>
<!-- end of correlation table --> <!-- end of correlation table -->
<!-- Heading row -->
<div class="row mt-3 ml-1" id="student_emotion_gaze_color_palette_heading" hidden>
<h5 class="float-left font-italic">Correlation color palette</h5>
</div>
<!-- End of Heading row -->
<!-- Color palette (row 1) -->
<div class="row mt-2 border-top" id="student_emotion_gaze_color_palette_1" hidden>
<div class="col-lg-4">
<p class="text-center">Very High (81-100)%</p>
<div class="d-flex justify-content-center">
<div class="bg-success rounded" style="height: 10px; width: 100px"></div>
</div>
</div>
<div class="col-lg-4">
<p class="text-center">High (61-80)%</p>
<div class="d-flex justify-content-center">
<div class="bg-primary rounded" style="height: 10px; width: 100px"></div>
</div>
</div>
<div class="col-lg-4">
<p class="text-center">Moderate (41-60)%</p>
<div class="d-flex justify-content-center">
<div class="bg-warning rounded" style="height: 10px; width: 100px"></div>
</div>
</div>
</div>
<!-- End of Color palette (row 1) -->
<!-- Color palette (row 2) -->
<div class="row mt-4 mb-4 border-top" id="student_emotion_gaze_color_palette_2" hidden>
<div class="col-lg-6">
<p class="text-center">Low (21-40)%</p>
<div class="d-flex justify-content-center">
<div class="bg-danger rounded" style="height: 10px; width: 100px"></div>
</div>
</div>
<div class="col-lg-6">
<p class="text-center">Weak (0-20)%</p>
<div class="d-flex justify-content-center">
<div class="bg-dark rounded" style="height: 10px; width: 100px"></div>
</div>
</div>
</div>
<!-- End of Color palette (row 2) -->
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button> <button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button>
......
...@@ -195,6 +195,9 @@ urlpatterns = [ ...@@ -195,6 +195,9 @@ urlpatterns = [
# perform random task (delete later) # perform random task (delete later)
url(r'^display-upcoming-lectures/$', api.DisplayUpcomingLecturesAPI.as_view()), url(r'^display-upcoming-lectures/$', api.DisplayUpcomingLecturesAPI.as_view()),
# perform random task (delete later)
url(r'^automation-process/', api.AutomationProcess.as_view()),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment