Commit ad27aa6d authored by I.K Seneviratne's avatar I.K Seneviratne

Committing the implementations in generating student activity comments and...

Committing the implementations in generating student activity comments and inserting new lecturer activity records..
.
parent d28b5572
......@@ -761,6 +761,9 @@ class GetLectureActivitySummary(APIView):
def get(self, request):
video_name = request.query_params.get('video_name')
phone_perct = request.query_params.get('phone_perct')
listen_perct = request.query_params.get('listen_perct')
note_perct = request.query_params.get('note_perct')
# checking the existence of lecture activity frame grouping records in the db
isExist = LectureActivityFrameGroupings.objects.filter(lecture_activity_id__lecture_video_id__video_name=video_name).exists()
......@@ -796,10 +799,14 @@ class GetLectureActivitySummary(APIView):
class_labels = ['phone_perct', 'listen_perct', 'note_perct']
# get the comments list
comments = sbp.generate_student_behavior_comments("Activity", phone_perct=phone_perct, listen_perct=listen_perct, note_perct=note_perct)
return Response({
"frame_landmarks": frame_landmarks,
"frame_group_percentages": frame_group_percentages,
"activity_labels": class_labels
"activity_labels": class_labels,
"comments": comments
})
# else:
......
......@@ -380,3 +380,36 @@ def calculate_student_emotion_gaze_correlations(lec_emotions, lec_gaze):
# return the list
return correlations
# this method will provide comments on the student behavior
def generate_student_behavior_comments(category, **kwargs):
# declare the comments list
comments = []
if category == "Activity":
float_phone_perct = float(kwargs.get('phone_perct'))
float_listen_perct = float(kwargs.get('listen_perct'))
float_note_perct = float(kwargs.get('note_perct'))
# set the threshold value list
THRESHOLDS = [40, 20, 30]
if int(float_phone_perct) >= THRESHOLDS[0]:
comments.append("Special Attention needs to be given to reduce student phone checking")
if int(float_listen_perct) < THRESHOLDS[1]:
comments.append("Consider taking steps to increase student attention")
if int(float_note_perct) < THRESHOLDS[2]:
comments.append("Try to pursue students to take important notes during the lecture")
elif category == "Emotion":
print('Emotion')
elif category == "Gaze":
print('Gaze')
# return the comment list
return comments
......@@ -307,3 +307,8 @@ def get_frame_landmarks(video_name):
# now return the frame landmarks
return frame_landmarks
# this method will save leture video (student)
def save_lecture_student_video():
pass
\ No newline at end of file
......@@ -257,8 +257,13 @@
//change the innerHTML of the clicked button
e.target.innerHTML = "<span class='font-italic'>Processing</span>";
let phone_perct = $('#phone_perct').text().split("%")[0];
let listen_perct = $('#listening_perct').text().split("%")[0];
let note_perct = $('#writing_perct').text().split("%")[0];
//fetch the activity summary details
fetch('http://127.0.0.1:8000/get-lecture-activity-summary/?video_name=' + global_video_name)
fetch('http://127.0.0.1:8000/get-lecture-activity-summary/?video_name=' + global_video_name + '&phone_perct=' + phone_perct + '&note_perct=' + note_perct + '&listen_perct=' + listen_perct)
.then((res) => res.json())
.then((out) => activityFrameGroupPercentages(out, e))
.catch((err) => alert('error: ' + err));
......@@ -295,16 +300,30 @@
//this function will handle the retrieved activity frame group percentages
function activityFrameGroupPercentages(response, e) {
//remove the previous comments
$('#student_activity_comments').empty();
lecture_activity_frame_group_percentages = response.frame_group_percentages;
let frame_landmarks = response.frame_landmarks;
{#let frame_group_dict = response.frame_group_dict;#}
let activity_labels = response.activity_labels;
let comment_list = response.comments;
//define a html string
let htmlString = "";
for (let i = 0; i < comment_list.length; i++) {
htmlString += "<p class='font-italic font-weight-bold'>";
htmlString += comment_list[i];
htmlString += "</p>";
}
//change the button back to original
e.target.innerHTML = "Summary";
//append the html string to the comments list
$('#student_activity_comments').append(htmlString);
//open the modal
$('#ActivitySummaryModal').modal();
......@@ -2278,6 +2297,21 @@
</div>
<div class="modal-body">
<div id="ActivityChartContainer" style="height: 370px; max-width: 920px; margin: 0px auto;"></div>
<!-- Notes header -->
<div class="modal-header mt-4">
<h3>Notes</h3>
</div>
<!-- End of Notes header -->
<!-- Comments row -->
<div class="row mt-3">
<div class="col-lg-6" id="student_activity_comments">
</div>
</div>
<!-- End of Comments row -->
</div>
<div class="modal-footer">
<button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button>
......
......@@ -241,8 +241,13 @@
//to handle the 'integrate' modal
$('#integrate_activity').click(function () {
//define the student video src
{#let video_src = "{% static '' %}FirstApp/videos/" + global_video_name;#}
let video_src = "{% static '' %}FirstApp/activity/" + global_video_name;
{#global_video_name = "Video_test_9.mp4";#}
{#global_video_name = "Video_test_9_annotated.mp4";#}
let video_src = "{% static '' %}FirstApp/videos/" + global_video_name;
{#let video_src = "{% static '' %}FirstApp/video/" + global_video_name;#}
{#let video_src = "{% static '' %}/FirstApp/activity/" + global_video_name;#}
{#let video_src = "{% static '' %}FirstApp/emotion/" + global_video_name;#}
//assign the video src
$('#student_video').attr('src', video_src);
......@@ -1079,6 +1084,11 @@
type="video/mp4">
Your browser does not support the video tag.
</video>
{# <video width="500" height="300" id="student_video" controls>#}
{# <source src="{% static 'FirstApp/videos/Video_test_2.mp4' %}"#}
{# type="video/mp4">#}
{# Your browser does not support the video tag.#}
{# </video>#}
</div>
<!--end of student video section -->
......
......@@ -242,25 +242,33 @@
//define the student video src
let video_src = "{% static '' %}FirstApp/videos/" + global_video_name;
{#global_lecturer_video_name = "Test_1.mp4";#}
{#global_lecturer_video_name = "Test_2.mp4";#}
global_lecturer_video_name = "Test_3.mp4";
//define the lecturer video src
let lecturer_video_src = "{% static '' %}FirstApp/lecturer_videos/" + global_lecturer_video_name;
//assign the video src
$('#student_video').attr('src', video_src);
//assign the video src
$('#lecturer_video').attr('src', lecturer_video_src);
$('#integrate_modal').modal();
//fetch the lecture recorded video name
fetch('http://127.0.0.1:8000/get-lecture-recorded-video-name/?lecturer=' + global_lecturer + '&subject=' + global_subject + '&date=' + global_lecture_date)
.then((res) => res.json())
.then((out) => assignLecturerRecordedVideoName(out))
.catch((err) => alert('error: ' + err));
{#global_lecturer_video_name = "Test_1.mp4";#}
{#global_lecturer_video_name = "Test_2.mp4";#}
{#global_lecturer_video_name = "Test_3.mp4";#}
{##}
{#//define the lecturer video src#}
{#let lecturer_video_src = "{% static '' %}FirstApp/lecturer_videos/" + global_lecturer_video_name;#}
{##}
{##}
{##}
{#//assign the video src#}
{#$('#lecturer_video').attr('src', lecturer_video_src);#}
{##}
{#$('#integrate_modal').modal();#}
//fetch data from the API
//fetch data from the API
fetch('http://127.0.0.1:8000/get-lecture-emotion-for-frame?video_name=' + global_video_name)
.then((res) => res.json())
.then((out) => displayEmotionRecognitionForFrame(out.response))
......@@ -269,6 +277,21 @@
});
//assign the lecturer recorded video name
function assignLecturerRecordedVideoName(res) {
global_lecturer_video_name = res.video_name;
//define the lecturer video src
let lecturer_video_src = "{% static '' %}FirstApp/lecturer_videos/" + global_lecturer_video_name;
//assign the video src
$('#lecturer_video').attr('src', lecturer_video_src);
$('#integrate_modal').modal();
}
//this function will display the emotion percentages for each frame
function displayEmotionRecognitionForFrame(response) {
......
......@@ -240,21 +240,16 @@
//define the student video src
let video_src = "{% static '' %}FirstApp/videos/" + global_video_name;
{#global_lecturer_video_name = "Test_1.mp4";#}
{#global_lecturer_video_name = "Test_2.mp4";#}
global_lecturer_video_name = "Test_3.mp4";
//define the lecturer video src
let lecturer_video_src = "{% static '' %}FirstApp/lecturer_videos/" + global_lecturer_video_name;
//assign the video src
$('#student_video').attr('src', video_src);
//assign the video src
$('#lecturer_video').attr('src', lecturer_video_src);
//fetch the lecture recorded video name
fetch('http://127.0.0.1:8000/get-lecture-recorded-video-name/?lecturer=' + global_lecturer + '&subject=' + global_subject + '&date=' + global_lecture_date)
.then((res) => res.json())
.then((out) => assignLecturerRecordedVideoName(out))
.catch((err) => alert('error: ' + err));
$('#integrate_modal').modal();
//fetch data from the API
fetch('http://127.0.0.1:8000/get-lecture-gaze-estimation-for-frame/?video_name=' + global_video_name)
......@@ -265,6 +260,23 @@
});
//assign the lecturer recorded video name
function assignLecturerRecordedVideoName(res) {
global_lecturer_video_name = res.video_name;
//define the lecturer video src
let lecturer_video_src = "{% static '' %}FirstApp/lecturer_videos/" + global_lecturer_video_name;
alert('hello');
//assign the video src
$('#lecturer_video').attr('src', lecturer_video_src);
$('#integrate_modal').modal();
}
//this function will load the activity recognition for frames
function displayGazeEstimationForFrame(response) {
......
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