Commit befed521 authored by LiniEisha's avatar LiniEisha

Merge branch 'QA_RELEASE' into IT17100908_Lecture_Summarizing

parents 7344a4b5 508f6c16
......@@ -1570,3 +1570,80 @@ class TestRandom(APIView):
"response": random
})
# this API will display the upcoming lectures for the lecturer (temporary API)
class DisplayUpcomingLecturesAPI(APIView):
def get(self, request):
lecturer = request.query_params.get('lecturer')
lecturer = int(lecturer)
cur_date = datetime.datetime.now().date()
cur_time = datetime.datetime.now().time()
eligible_start_time = ''
eligible_end_time = ''
subject_id = 0
subject_name = ''
subject_code = ''
# retrieve the faculty timetable
faculty_timetable = FacultyTimetable.objects.all()
# serialize the timetable
faculty_timetable_serialized = FacultyTimetableSerializer(faculty_timetable, many=True)
# get the serialized timetable data
faculty_timetable_serialized_data = faculty_timetable_serialized.data
# iterate through the serialized timetable data
for timetable in faculty_timetable_serialized_data:
# get the 'timetable' field
daily_timetable = timetable['timetable']
# iterate through the 'timetable' field
for day_timetable in daily_timetable:
# get the 'time_slots' field for a given day
time_slots = day_timetable['time_slots']
# iterate through the time slots
for time_slot in time_slots:
# if the lecturer is the currently logged in lecturer
if lecturer == time_slot['lecturer']['id']:
# find the upcoming lecture for the logged-in lecturer
if cur_date == day_timetable['date']:
# get the start and end times
start_time = time_slot['start_time']
end_time = time_slot['end_time']
start_time_list = str(start_time).split(":")
start_time_date = datetime.datetime.now().replace(hour=int(start_time_list[0]), minute=int(start_time_list[1]), second=int(start_time_list[2]))
end_time_list = str(end_time).split(":")
end_time_date = datetime.datetime.now().replace(hour=int(end_time_list[0]), minute=int(end_time_list[1]), second=int(end_time_list[2]))
# check for the upcoming time slot
if (start_time_date.time() > cur_time):
eligible_start_time = start_time_date.time()
eligible_end_time = end_time_date.time()
subject_id = time_slot['subject']['id']
subject_name = time_slot['subject']['name']
subject_code = time_slot['subject']['subject_code']
return Response({
"start_time": eligible_start_time,
"end_time": eligible_end_time,
"subject_id": subject_id,
"subject_name": subject_name,
"subject_code": subject_code,
})
import requests
import json
def batch_process(video_id, video_name):
def student_behavior_batch_process(video_id, video_name):
is_all_processed = False
# call the activity process
activity_resp = requests.get('http://127.0.0.1:8000/process-lecture-activity/?lecture_video_name=' + video_name + '&lecture_video_id=' + video_id)
activity_resp = requests.get('http://127.0.0.1:8000/process-lecture-activity/', params={'lecture_video_name': video_name, 'lecture_video_id': video_id})
# if the activity process is success
if activity_resp.json()['response']:
# call the emotion process
emotion_resp = requests.get('http://127.0.0.1:8000/process-lecture-emotion/?lecture_video_name=', params={'lecture_video_name': video_name, 'lecture_video_id': video_id})
# call the emotion process
emotion_resp = requests.get('http://127.0.0.1:8000/process-lecture-emotion/?lecture_video_name=' + video_name + '&lecture_video_id=' + video_id)
# if the emotion process is success
if emotion_resp.json()['response']:
# call the gaze process
gaze_resp = requests.get('http://127.0.0.1:8000/process-lecture-gaze-estimation/?lecture_video_name=' + video_name + '&lecture_video_id=' + video_id)
# call the gaze process
gaze_resp = requests.get('http://127.0.0.1:8000/process-lecture-gaze-estimation/?lecture_video_name=', params={'lecture_video_name': video_name, 'lecture_video_id': video_id})
# if the gaze estimation process is successful
if gaze_resp.json()['response']:
is_all_processed = True
pass
return is_all_processed
# 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)
\ No newline at end of file
# 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]
if __name__ == '__main__':
# content = {
# "lecturer": 1,
# "subject": 16,
# "date": "2020-12-09",
# "video_name": "Video_test_19.mp4",
# "video_length": "00:45:06"
# }
#
#
# data_dumps = json.dumps(content)
# data_json = json.loads(data_dumps)
#
#
# save_student_lecture_video(content)
student_behavior_batch_process(8, "Video_test_8.mp4")
......@@ -2687,7 +2687,7 @@
</button>
</div>
<div class="modal-body text-center">
<h3 class="font-weight-bold">Student Activity vs. Student Emotions</h3>
<h3 class="font-weight-bold">Student Activity vs. Student Gaze</h3>
<!-- ajax loader -->
<div class="text-center" id="student_activity_gaze_corr_loader" hidden>
......
......@@ -39,6 +39,7 @@
var lecturer_fps = 0;
var lecture_activity_frame_group_percentages = {};
var lecture_video_time_landmarks = [];
var CHART = '';
//jquery
......@@ -47,6 +48,10 @@
//disable the 'integrate_activity' button
$('#integrate_activity').hide();
//hide the 'Generate Report' button
{#$('#generate_report_before').hide();#}
$('#generate_report').hide();
//select a particular subject
$('input[type=radio]').click(function () {
let subject_id = $(this).attr('id');
......@@ -582,8 +587,6 @@
let comment_list = response.comments;
//render the chart onto the modal body
renderActivityChart(activity_labels);
}
......@@ -637,7 +640,7 @@
}
var chart = new CanvasJS.Chart("ActivityChartContainer", {
CHART = new CanvasJS.Chart("ActivityChartContainer", {
animationEnabled: true,
theme: "light2",
title: {
......@@ -671,7 +674,11 @@
},
data: data
});
chart.render();
{#chart.render();#}
CHART.render();
//show the 'generate report' button
$('#generate_report').show();
}
//this function will generate random colors
......@@ -695,6 +702,28 @@
}
//this method will handle the 'Generate Report' button
$('#generate_report').click(function () {
let script = "<script src='https://canvasjs.com/assets/script/canvasjs.min.js'><\/script>";
CHART.print();
{#var prtContent = document.getElementById("ActivityChartContainer");#}
{#var WinPrint = window.open('', '', 'left=0,top=0,width=800,height=900,toolbar=0,scrollbars=0,status=0');#}
{#var WinPrint = window.open('');#}
{#WinPrint.document.write(prtContent.innerHTML);#}
{#WinPrint.document.write(script);#}
{#WinPrint.document.write('<h1>This is Ishan</h1>');#}
{#WinPrint.document.close();#}
{#WinPrint.focus();#}
{#WinPrint.print();#}
{#WinPrint.close();#}
});
});
</script>
......@@ -719,8 +748,12 @@
<!-- Page Heading -->
<div class="d-sm-flex align-items-center justify-content-between mb-4">
<h1 class="h3 mb-0 text-gray-800">Student Activity Recognition</h1>
{# <button type="button" data-target="#generateReportModal" data-toggle="modal" class="d-none d-sm-inline-block btn btn-sm btn-primary shadow-sm" id="generate_report_before" disabled><i#}
{# class="fas fa-download fa-sm text-white-50"></i> Generate Report</button>#}
<button type="button" class="btn btn-primary" id="generate_report">Generate Report</button>
{# <button type="button"#}
{# class="d-none d-sm-inline-block btn btn-sm btn-primary shadow-sm"#}
{# id="generate_report_before"><i#}
{# class="fas fa-download fa-sm text-white-50"></i> Generate Report#}
{# </button>#}
</div>
......@@ -940,41 +973,41 @@
<!-- graph loader -->
<div class="text-center mt-3" id="graph_loader" hidden>
<img src="{% static 'FirstApp/images/ajax-loader.gif' %}"
alt="Loader">
alt="Loader">
</div>
<!-- end of graph loader -->
<!--card content -->
<div class="card shadow mb-4 p-3">
{# <!-- Card Header - Dropdown -->#}
{# <div class="card-header py-3 d-flex flex-row align-items-center justify-content-between">#}
{# <h6 class="m-0 font-weight-bold text-primary">Student#}
{# Activities</h6>#}
{# <div class="dropdown no-arrow">#}
{# <a class="dropdown-toggle" href="#" role="button"#}
{# id="dropdownMenuLink" data-toggle="dropdown"#}
{# aria-haspopup="true" aria-expanded="false">#}
{# <i class="fas fa-ellipsis-v fa-sm fa-fw text-gray-400"></i>#}
{# </a>#}
{# <div class="dropdown-menu dropdown-menu-right shadow animated--fade-in"#}
{# aria-labelledby="dropdownMenuLink">#}
{# <div class="dropdown-header">Dropdown Header:</div>#}
{# <a class="dropdown-item" href="#">Action</a>#}
{# <a class="dropdown-item" href="#">Another action</a>#}
{# <div class="dropdown-divider"></div>#}
{# <a class="dropdown-item" href="#">Something else here</a>#}
{# </div>#}
{# </div>#}
{# </div>#}
{# <!-- Card Header - Dropdown -->#}
{# <div class="card-header py-3 d-flex flex-row align-items-center justify-content-between">#}
{# <h6 class="m-0 font-weight-bold text-primary">Student#}
{# Activities</h6>#}
{# <div class="dropdown no-arrow">#}
{# <a class="dropdown-toggle" href="#" role="button"#}
{# id="dropdownMenuLink" data-toggle="dropdown"#}
{# aria-haspopup="true" aria-expanded="false">#}
{# <i class="fas fa-ellipsis-v fa-sm fa-fw text-gray-400"></i>#}
{# </a>#}
{# <div class="dropdown-menu dropdown-menu-right shadow animated--fade-in"#}
{# aria-labelledby="dropdownMenuLink">#}
{# <div class="dropdown-header">Dropdown Header:</div>#}
{# <a class="dropdown-item" href="#">Action</a>#}
{# <a class="dropdown-item" href="#">Another action</a>#}
{# <div class="dropdown-divider"></div>#}
{# <a class="dropdown-item" href="#">Something else here</a>#}
{# </div>#}
{# </div>#}
{# </div>#}
<!-- Card Body -->
<div class="card-body">
<div id="ActivityChartContainer"
style="height: 370px; max-width: 920px; margin: 0px auto;"></div>
</div>
<!-- End of Card Body -->
</div>
<!-- End of Card Body -->
</div>
</div>
......
......@@ -192,6 +192,9 @@ urlpatterns = [
# perform random task (delete later)
url(r'^get-random-number/$', api.TestRandom.as_view()),
# perform random task (delete later)
url(r'^display-upcoming-lectures/$', api.DisplayUpcomingLecturesAPI.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