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

Merge branch 'monitoring_student_behavior_IT17138000' into 'QA_RELEASE'

Monitoring student behavior it17138000

See merge request !34
parents a48f6270 c465c70a
...@@ -761,6 +761,9 @@ class GetLectureActivitySummary(APIView): ...@@ -761,6 +761,9 @@ class GetLectureActivitySummary(APIView):
def get(self, request): def get(self, request):
video_name = request.query_params.get('video_name') 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 # 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() isExist = LectureActivityFrameGroupings.objects.filter(lecture_activity_id__lecture_video_id__video_name=video_name).exists()
...@@ -796,10 +799,14 @@ class GetLectureActivitySummary(APIView): ...@@ -796,10 +799,14 @@ class GetLectureActivitySummary(APIView):
class_labels = ['phone_perct', 'listen_perct', 'note_perct'] 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({ return Response({
"frame_landmarks": frame_landmarks, "frame_landmarks": frame_landmarks,
"frame_group_percentages": frame_group_percentages, "frame_group_percentages": frame_group_percentages,
"activity_labels": class_labels "activity_labels": class_labels,
"comments": comments
}) })
# else: # else:
...@@ -1167,6 +1174,7 @@ class GetLectureActivityCorrelations(APIView): ...@@ -1167,6 +1174,7 @@ class GetLectureActivityCorrelations(APIView):
activity_correlations = ar.get_activity_correlations(individual_lec_activities, lec_recorded_activity_data) activity_correlations = ar.get_activity_correlations(individual_lec_activities, lec_recorded_activity_data)
return Response({ return Response({
"correlations": activity_correlations "correlations": activity_correlations
}) })
......
...@@ -670,10 +670,14 @@ def get_emotion_correlations(individual_lec_emotions, lec_recorded_activity_data ...@@ -670,10 +670,14 @@ def get_emotion_correlations(individual_lec_emotions, lec_recorded_activity_data
# this variable will be used to store the correlations # this variable will be used to store the correlations
correlations = [] correlations = []
limit = 10 # limit = 10
limit = len(individual_lec_emotions)
data_index = ['lecture-{}'.format(i + 1) for i in range(len(individual_lec_emotions))] data_index = ['lecture-{}'.format(i + 1) for i in range(len(individual_lec_emotions))]
# declare the correlation data dictionary
corr_data = {}
# student activity labels # student activity labels
student_emotion_labels = ['Happy', 'Sad', 'Angry', 'Surprise', 'Neutral'] student_emotion_labels = ['Happy', 'Sad', 'Angry', 'Surprise', 'Neutral']
lecturer_activity_labels = ['seated', 'standing', 'walking'] lecturer_activity_labels = ['seated', 'standing', 'walking']
...@@ -693,31 +697,72 @@ def get_emotion_correlations(individual_lec_emotions, lec_recorded_activity_data ...@@ -693,31 +697,72 @@ def get_emotion_correlations(individual_lec_emotions, lec_recorded_activity_data
# loop through the lecturer recorded data (lecturer) # loop through the lecturer recorded data (lecturer)
for data in lec_recorded_activity_data: for data in lec_recorded_activity_data:
sitting_perct_list.append(int(data['seated_count'])) value = int(data['seated_count'])
standing_perct_list.append(int(data['standing_count'])) value1 = int(data['standing_count'])
walking_perct_list.append(int(data['walking_count'])) value2 = int(data['walking_count'])
if value != 0:
sitting_perct_list.append(int(data['seated_count']))
if value1 != 0:
standing_perct_list.append(int(data['standing_count']))
if value2 != 0:
walking_perct_list.append(int(data['walking_count']))
# loop through the lecturer recorded data (student) # loop through the lecturer recorded data (student)
for data in individual_lec_emotions: for data in individual_lec_emotions:
happy_perct_list.append(int(data['happy_perct'])) value = int(data['happy_perct'])
sad_perct_list.append(int(data['sad_perct'])) value1 = int(data['sad_perct'])
angry_perct_list.append(int(data['angry_perct'])) value2 = int(data['angry_perct'])
surprise_perct_list.append(int(data['surprise_perct'])) value3 = int(data['surprise_perct'])
neutral_perct_list.append(int(data['neutral_perct'])) value4 = int(data['neutral_perct'])
if value != 0:
corr_data = {'Happy': happy_perct_list, 'Sad': sad_perct_list, 'Angry': angry_perct_list, 'Surprise': surprise_perct_list, 'Neutral': neutral_perct_list, happy_perct_list.append(int(data['happy_perct']))
'seated': sitting_perct_list, 'standing': standing_perct_list, 'walking': walking_perct_list} if value1 != 0:
sad_perct_list.append(int(data['sad_perct']))
if value2 != 0:
angry_perct_list.append(int(data['angry_perct']))
if value3 != 0:
surprise_perct_list.append(int(data['surprise_perct']))
if value4 != 0:
neutral_perct_list.append(int(data['neutral_perct']))
if len(happy_perct_list) == len(individual_lec_emotions):
corr_data[student_emotion_labels[0]] = happy_perct_list
if len(sad_perct_list) == len(individual_lec_emotions):
corr_data[student_emotion_labels[1]] = sad_perct_list
if len(angry_perct_list) == len(individual_lec_emotions):
corr_data[student_emotion_labels[2]] = angry_perct_list
if len(surprise_perct_list) == len(individual_lec_emotions):
corr_data[student_emotion_labels[3]] = surprise_perct_list
if len(neutral_perct_list) == len(individual_lec_emotions):
corr_data[student_emotion_labels[4]] = neutral_perct_list
if (len(sitting_perct_list)) == len(individual_lec_emotions):
corr_data[lecturer_activity_labels[0]] = sitting_perct_list
if (len(standing_perct_list)) == len(individual_lec_emotions):
corr_data[lecturer_activity_labels[1]] = standing_perct_list
if (len(walking_perct_list)) == len(individual_lec_emotions):
corr_data[lecturer_activity_labels[2]] = walking_perct_list
# corr_data = {'Happy': happy_perct_list, 'Sad': sad_perct_list, 'Angry': angry_perct_list, 'Surprise': surprise_perct_list, 'Neutral': neutral_perct_list,
# 'seated': sitting_perct_list, 'standing': standing_perct_list, 'walking': walking_perct_list}
# create the dataframe # create the dataframe
df = pd.DataFrame(corr_data, index=data_index) df = pd.DataFrame(corr_data, index=data_index)
print(df)
# calculate the correlation # calculate the correlation
pd_series = ut.get_top_abs_correlations(df, limit) pd_series = ut.get_top_abs_correlations(df, limit)
print('====correlated variables=====') print('====correlated variables=====')
print(pd_series) print(pd_series)
# assign a new value to the 'limit' variable
limit = len(pd_series) if len(pd_series) < limit else limit
for i in range(limit): for i in range(limit):
# this dictionary will get the pandas.Series object's indices and values separately # this dictionary will get the pandas.Series object's indices and values separately
corr_dict = {} corr_dict = {}
......
...@@ -752,10 +752,14 @@ def get_activity_correlations(individual_lec_activities, lec_recorded_activity_d ...@@ -752,10 +752,14 @@ def get_activity_correlations(individual_lec_activities, lec_recorded_activity_d
# this variable will be used to store the correlations # this variable will be used to store the correlations
correlations = [] correlations = []
limit = 10 # limit = 10
limit = len(individual_lec_activities)
data_index = ['lecture-{}'.format(i+1) for i in range(len(individual_lec_activities))] data_index = ['lecture-{}'.format(i+1) for i in range(len(individual_lec_activities))]
# declare the correlation data dictionary
corr_data = {}
# student activity labels # student activity labels
student_activity_labels = ['phone checking', 'listening', 'note taking'] student_activity_labels = ['phone checking', 'listening', 'note taking']
lecturer_activity_labels = ['seated', 'standing', 'walking'] lecturer_activity_labels = ['seated', 'standing', 'walking']
...@@ -772,29 +776,63 @@ def get_activity_correlations(individual_lec_activities, lec_recorded_activity_d ...@@ -772,29 +776,63 @@ def get_activity_correlations(individual_lec_activities, lec_recorded_activity_d
# loop through the lecturer recorded data (lecturer) # loop through the lecturer recorded data (lecturer)
for data in lec_recorded_activity_data: for data in lec_recorded_activity_data:
sitting_perct_list.append(int(data['seated_count'])) value = int(data['seated_count'])
standing_perct_list.append(int(data['standing_count'])) value1 = int(data['standing_count'])
walking_perct_list.append(int(data['walking_count'])) value2 = int(data['walking_count'])
if value != 0:
sitting_perct_list.append(int(data['seated_count']))
if value1 != 0:
standing_perct_list.append(int(data['standing_count']))
if value2 != 0:
walking_perct_list.append(int(data['walking_count']))
# loop through the lecturer recorded data (student) # loop through the lecturer recorded data (student)
for data in individual_lec_activities: for data in individual_lec_activities:
phone_perct_list.append(int(data['phone_perct'])) value = int(data['phone_perct'])
listen_perct_list.append(int(data['listening_perct'])) value1 = int(data['listening_perct'])
note_perct_list.append(int(data['writing_perct'])) value2 = int(data['writing_perct'])
if value != 0:
phone_perct_list.append(int(data['phone_perct']))
if value1 != 0:
listen_perct_list.append(int(data['listening_perct']))
if value2 != 0:
note_perct_list.append(int(data['writing_perct']))
if (len(phone_perct_list)) == len(individual_lec_activities):
corr_data[student_activity_labels[0]] = phone_perct_list
if (len(listen_perct_list)) == len(individual_lec_activities):
corr_data[student_activity_labels[1]] = listen_perct_list
if (len(note_perct_list)) == len(individual_lec_activities):
corr_data[student_activity_labels[2]] = note_perct_list
if (len(sitting_perct_list)) == len(individual_lec_activities):
corr_data[lecturer_activity_labels[0]] = sitting_perct_list
if (len(standing_perct_list)) == len(individual_lec_activities):
corr_data[lecturer_activity_labels[1]] = standing_perct_list
if (len(walking_perct_list)) == len(individual_lec_activities):
corr_data[lecturer_activity_labels[2]] = walking_perct_list
corr_data = {'phone checking': phone_perct_list, 'listening': listen_perct_list, 'note taking': note_perct_list,
'seated': sitting_perct_list, 'standing': standing_perct_list, 'walking': walking_perct_list}
# corr_data = {'phone checking': phone_perct_list, 'listening': listen_perct_list, 'note taking': note_perct_list,
# 'seated': sitting_perct_list, 'standing': standing_perct_list, 'walking': walking_perct_list}
# create the dataframe # create the dataframe
df = pd.DataFrame(corr_data, index=data_index) df = pd.DataFrame(corr_data, index=data_index)
print(df)
# calculate the correlation # calculate the correlation
pd_series = ut.get_top_abs_correlations(df, limit) pd_series = ut.get_top_abs_correlations(df, limit)
print('====correlated variables=====') print('====correlated variables=====')
print(pd_series) print(pd_series)
# assign a new value to the 'limit' variable
limit = len(pd_series) if len(pd_series) < limit else limit
for i in range(limit): for i in range(limit):
# this dictionary will get the pandas.Series object's indices and values separately # this dictionary will get the pandas.Series object's indices and values separately
corr_dict = {} corr_dict = {}
......
...@@ -14,4 +14,11 @@ def batch_process(video_id, video_name): ...@@ -14,4 +14,11 @@ def batch_process(video_id, video_name):
gaze_resp = requests.get('http://127.0.0.1:8000/process-lecture-gaze-estimation/?lecture_video_name=' + video_name + '&lecture_video_id=' + video_id) gaze_resp = requests.get('http://127.0.0.1:8000/process-lecture-gaze-estimation/?lecture_video_name=' + video_name + '&lecture_video_id=' + video_id)
pass pass
\ No newline at end of file
# this method will save the lecture video
def save_student_lecture_video(student_video):
# 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
...@@ -1007,10 +1007,14 @@ def get_gaze_correlations(individual_lec_gaze, lec_recorded_activity_data): ...@@ -1007,10 +1007,14 @@ def get_gaze_correlations(individual_lec_gaze, lec_recorded_activity_data):
# this variable will be used to store the correlations # this variable will be used to store the correlations
correlations = [] correlations = []
limit = 10 # limit = 10
limit = len(individual_lec_gaze)
data_index = ['lecture-{}'.format(i + 1) for i in range(len(individual_lec_gaze))] data_index = ['lecture-{}'.format(i + 1) for i in range(len(individual_lec_gaze))]
# declare the correlation data dictionary
corr_data = {}
# student gaze labels # student gaze labels
student_gaze_labels = ['Up and Right', 'Up and Left', 'Down and Right', 'Down and Left', 'Front'] student_gaze_labels = ['Up and Right', 'Up and Left', 'Down and Right', 'Down and Left', 'Front']
lecturer_activity_labels = ['seated', 'standing', 'walking'] lecturer_activity_labels = ['seated', 'standing', 'walking']
...@@ -1029,28 +1033,72 @@ def get_gaze_correlations(individual_lec_gaze, lec_recorded_activity_data): ...@@ -1029,28 +1033,72 @@ def get_gaze_correlations(individual_lec_gaze, lec_recorded_activity_data):
# loop through the lecturer recorded data (lecturer) # loop through the lecturer recorded data (lecturer)
for data in lec_recorded_activity_data: for data in lec_recorded_activity_data:
sitting_perct_list.append(int(data['seated_count'])) value = int(data['seated_count'])
standing_perct_list.append(int(data['standing_count'])) value1 = int(data['standing_count'])
walking_perct_list.append(int(data['walking_count'])) value2 = int(data['walking_count'])
if value != 0:
sitting_perct_list.append(int(data['seated_count']))
if value1 != 0:
standing_perct_list.append(int(data['standing_count']))
if value2 != 0:
walking_perct_list.append(int(data['walking_count']))
# loop through the lecturer recorded data (student) # loop through the lecturer recorded data (student)
for data in individual_lec_gaze: for data in individual_lec_gaze:
upright_perct_list.append(int(data['looking_up_and_right_perct'])) value = int(data['looking_up_and_right_perct'])
upleft_perct_list.append(int(data['looking_up_and_left_perct'])) value1 = int(data['looking_up_and_left_perct'])
downright_perct_list.append(int(data['looking_down_and_right_perct'])) value2 = int(data['looking_down_and_right_perct'])
downleft_perct_list.append(int(data['looking_down_and_left_perct'])) value3 = int(data['looking_down_and_left_perct'])
front_perct_list.append(int(data['looking_front_perct'])) value4 = int(data['looking_front_perct'])
corr_data = {'Up and Right': upright_perct_list, 'Up and Left': upleft_perct_list, 'Down and Right': downright_perct_list, if value != 0:
'Down and Left': downleft_perct_list, 'Front': front_perct_list, upright_perct_list.append(int(data['looking_up_and_right_perct']))
'seated': sitting_perct_list, 'standing': standing_perct_list, 'walking': walking_perct_list} if value1 != 0:
upleft_perct_list.append(int(data['looking_up_and_left_perct']))
if value2 != 0:
downright_perct_list.append(int(data['looking_down_and_right_perct']))
if value3 != 0:
downleft_perct_list.append(int(data['looking_down_and_left_perct']))
if value4 != 0:
front_perct_list.append(int(data['looking_front_perct']))
if (len(upright_perct_list)) == len(individual_lec_gaze):
corr_data[student_gaze_labels[0]] = upright_perct_list
if (len(upleft_perct_list)) == len(individual_lec_gaze):
corr_data[student_gaze_labels[1]] = upleft_perct_list
if (len(downright_perct_list)) == len(individual_lec_gaze):
corr_data[student_gaze_labels[2]] = downright_perct_list
if (len(downleft_perct_list)) == len(individual_lec_gaze):
corr_data[student_gaze_labels[3]] = downleft_perct_list
if (len(front_perct_list)) == len(individual_lec_gaze):
corr_data[student_gaze_labels[4]] = front_perct_list
if (len(sitting_perct_list)) == len(individual_lec_gaze):
corr_data[lecturer_activity_labels[0]] = sitting_perct_list
if (len(standing_perct_list)) == len(individual_lec_gaze):
corr_data[lecturer_activity_labels[1]] = standing_perct_list
if (len(walking_perct_list)) == len(individual_lec_gaze):
corr_data[lecturer_activity_labels[2]] = walking_perct_list
# corr_data = {'Up and Right': upright_perct_list, 'Up and Left': upleft_perct_list, 'Down and Right': downright_perct_list,
# 'Down and Left': downleft_perct_list, 'Front': front_perct_list,
# 'seated': sitting_perct_list, 'standing': standing_perct_list, 'walking': walking_perct_list}
# create the dataframe # create the dataframe
df = pd.DataFrame(corr_data, index=data_index) df = pd.DataFrame(corr_data, index=data_index)
print(df)
# calculate the correlation # calculate the correlation
pd_series = ut.get_top_abs_correlations(df, limit) pd_series = ut.get_top_abs_correlations(df, limit)
print('====correlated variables=====')
print(pd_series)
# assign a new value to the 'limit' variable
limit = len(pd_series) if len(pd_series) < limit else limit
for i in range(limit): for i in range(limit):
# this dictionary will get the pandas.Series object's indices and values separately # this dictionary will get the pandas.Series object's indices and values separately
......
This diff is collapsed.
# this method will remove the redundant pairs in pandas dataframe
def get_redundant_pairs(df): def get_redundant_pairs(df):
'''Get diagonal and lower triangular pairs of correlation matrix''' '''Get diagonal and lower triangular pairs of correlation matrix'''
pairs_to_drop = set() pairs_to_drop = set()
...@@ -8,6 +9,7 @@ def get_redundant_pairs(df): ...@@ -8,6 +9,7 @@ def get_redundant_pairs(df):
pairs_to_drop.add((cols[i], cols[j])) pairs_to_drop.add((cols[i], cols[j]))
return pairs_to_drop return pairs_to_drop
# this method will return the top specified correlations
def get_top_abs_correlations(df, n): def get_top_abs_correlations(df, n):
au_corr = df.corr().abs().unstack() au_corr = df.corr().abs().unstack()
labels_to_drop = get_redundant_pairs(df) labels_to_drop = get_redundant_pairs(df)
......
...@@ -306,4 +306,9 @@ def get_frame_landmarks(video_name): ...@@ -306,4 +306,9 @@ def get_frame_landmarks(video_name):
# now return the frame landmarks # now return the frame landmarks
return frame_landmarks return frame_landmarks
\ No newline at end of file
# this method will save leture video (student)
def save_lecture_student_video():
pass
\ No newline at end of file
This diff is collapsed.
...@@ -241,8 +241,13 @@ ...@@ -241,8 +241,13 @@
//to handle the 'integrate' modal //to handle the 'integrate' modal
$('#integrate_activity').click(function () { $('#integrate_activity').click(function () {
//define the student video src //define the student video src
{#let video_src = "{% static '' %}FirstApp/videos/" + global_video_name;#} {#global_video_name = "Video_test_9.mp4";#}
let video_src = "{% static '' %}FirstApp/activity/" + global_video_name; {#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 //assign the video src
$('#student_video').attr('src', video_src); $('#student_video').attr('src', video_src);
...@@ -1079,6 +1084,11 @@ ...@@ -1079,6 +1084,11 @@
type="video/mp4"> type="video/mp4">
Your browser does not support the video tag. Your browser does not support the video tag.
</video> </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> </div>
<!--end of student video section --> <!--end of student video section -->
......
...@@ -74,6 +74,8 @@ ...@@ -74,6 +74,8 @@
real_class = '.' + real_class; real_class = '.' + real_class;
let date = e.target.parentNode.parentNode.firstChild.innerHTML; let date = e.target.parentNode.parentNode.firstChild.innerHTML;
//assign the date
global_lecture_date = date;
fetch('http://127.0.0.1:8000/get-lecture-emotion-availability/?lecturer=' + global_lecturer + '&date=' + date + '&index=' + global_lecturer_subject_index) fetch('http://127.0.0.1:8000/get-lecture-emotion-availability/?lecturer=' + global_lecturer + '&date=' + date + '&index=' + global_lecturer_subject_index)
.then((res) => res.json()) .then((res) => res.json())
...@@ -242,32 +244,67 @@ ...@@ -242,32 +244,67 @@
//define the student video src //define the student video src
let video_src = "{% static '' %}FirstApp/videos/" + global_video_name; let video_src = "{% static '' %}FirstApp/videos/" + global_video_name;
//assign the video src
$('#student_video').attr('src', video_src);
{#fetch('http://127.0.0.1:8000/get-random-number')#}
{#.then((res) => res.json())#}
{#.then((out) => alert(out.response))#}
{#.catch((err) => alert('err: ' + err));#}
//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_1.mp4";#}
{#global_lecturer_video_name = "Test_2.mp4";#} {#global_lecturer_video_name = "Test_2.mp4";#}
global_lecturer_video_name = "Test_3.mp4"; {#global_lecturer_video_name = "Test_3.mp4";#}
{#global_lecturer_video_name = "Lecturer_Video_4.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('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))#}
{# .catch((err) => alert('error: ' + err));#}
});
//assign the lecturer recorded video name
function assignLecturerRecordedVideoName(res) {
global_lecturer_video_name = res.video_name;
//define the lecturer video src //define the lecturer video src
let lecturer_video_src = "{% static '' %}FirstApp/lecturer_videos/" + global_lecturer_video_name; 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 //assign the video src
$('#lecturer_video').attr('src', lecturer_video_src); $('#lecturer_video').attr('src', lecturer_video_src);
$('#integrate_modal').modal(); $('#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) fetch('http://127.0.0.1:8000/get-lecture-emotion-for-frame?video_name=' + global_video_name)
.then((res) => res.json()) .then((res) => res.json())
.then((out) => displayEmotionRecognitionForFrame(out.response)) .then((out) => displayEmotionRecognitionForFrame(out.response))
.catch((err) => alert('error: ' + err)); .catch((err) => alert('error: ' + err));
}
});
//this function will display the emotion percentages for each frame //this function will display the emotion percentages for each frame
...@@ -339,7 +376,7 @@ ...@@ -339,7 +376,7 @@
fetch('http://127.0.0.1:8000/lecturer/get-lecturer-video-frame-recognitions/?video_name=' + global_lecturer_video_name) fetch('http://127.0.0.1:8000/lecturer/get-lecturer-video-frame-recognitions/?video_name=' + global_lecturer_video_name)
.then((res) => res.json()) .then((res) => res.json())
.then((out) => displayLecturerEmotionRecognitionForFrame(out)) .then((out) => displayLecturerEmotionRecognitionForFrame(out))
.catch((err) => alert('error: ' + err)) .catch((err) => alert('error: ' + err));
} }
......
...@@ -74,6 +74,8 @@ ...@@ -74,6 +74,8 @@
real_class = '.' + real_class; real_class = '.' + real_class;
let date = e.target.parentNode.parentNode.firstChild.innerHTML; let date = e.target.parentNode.parentNode.firstChild.innerHTML;
//assign the date
global_lecture_date = date;
fetch('http://127.0.0.1:8000/get-lecture-video-gaze-estimation-availability/?lecturer=' + global_lecturer + '&date=' + date + '&index=' + global_lecturer_subject_index) fetch('http://127.0.0.1:8000/get-lecture-video-gaze-estimation-availability/?lecturer=' + global_lecturer + '&date=' + date + '&index=' + global_lecturer_subject_index)
.then((res) => res.json()) .then((res) => res.json())
...@@ -240,21 +242,28 @@ ...@@ -240,21 +242,28 @@
//define the student video src //define the student video src
let video_src = "{% static '' %}FirstApp/videos/" + global_video_name; 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 //assign the video src
$('#student_video').attr('src', video_src); $('#student_video').attr('src', video_src);
//assign the video src //fetch the lecture recorded video name
$('#lecturer_video').attr('src', lecturer_video_src); 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";#}
{#global_lecturer_video_name = "Lecturer_Video_4.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();#}
$('#integrate_modal').modal();
//fetch data from the API //fetch data from the API
fetch('http://127.0.0.1:8000/get-lecture-gaze-estimation-for-frame/?video_name=' + global_video_name) fetch('http://127.0.0.1:8000/get-lecture-gaze-estimation-for-frame/?video_name=' + global_video_name)
...@@ -265,6 +274,23 @@ ...@@ -265,6 +274,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 //this function will load the activity recognition for frames
function displayGazeEstimationForFrame(response) { function displayGazeEstimationForFrame(response) {
......
This diff is collapsed.
...@@ -301,7 +301,8 @@ ...@@ -301,7 +301,8 @@
/* /*
let interval = setInterval(() => { let interval = setInterval(() => {
{#let url = 'http://127.0.0.1:8000/get-random_number';#}
{#let url = 'http://127.0.0.1:8000/get-random_number';#}
let url = 'http://127.0.0.1:8000/check-availability'; let url = 'http://127.0.0.1:8000/check-availability';
fetch(url) fetch(url)
...@@ -401,7 +402,7 @@ ...@@ -401,7 +402,7 @@
<div class="card-body"> <div class="card-body">
<!--loading gif --> <!--loading gif -->
{% if due_lectures.count == 0 %} {% if due_lectures|length == 0 %}
<div class="text-center" id="no_subject_selected"> <div class="text-center" id="no_subject_selected">
<span class="font-italic">No lecture is to be processed</span> <span class="font-italic">No lecture is to be processed</span>
</div> </div>
...@@ -414,38 +415,43 @@ ...@@ -414,38 +415,43 @@
<div class="text-center" id="no_timetable_content" hidden> <div class="text-center" id="no_timetable_content" hidden>
<span class="font-italic">Not included in the timetable</span> <span class="font-italic">Not included in the timetable</span>
</div> </div>
<!--displaying the timetable -->
<table class="table table-striped" id="timetable"> <!-- if there are due lectures, display the table -->
{# <caption id="timetable_caption"></caption>#} {% if due_lectures %}
<thead>
<tr> <!--displaying the timetable -->
<th>Date</th> <table class="table table-striped" id="timetable">
<th>Subject</th> {# <caption id="timetable_caption"></caption>#}
<th>start time</th> <thead>
<th>end time</th>
<th></th>
</tr>
</thead>
<tbody id="timetable_body">
{% for lecture in due_lectures %}
<tr> <tr>
<td class="font-weight-bolder">{{ lecture.date }}</td> <th>Date</th>
{# <td>{{ lecture.subject }}</td>#} <th>Subject</th>
<td class="font-weight-bolder">{{ lecture.subject_name }}</td> <th>start time</th>
<td class="font-weight-bolder">{{ lecture.start_time }}</td> <th>end time</th>
<td class="font-weight-bolder">{{ lecture.end_time }}</td> <th></th>
<td>
<button type="button" class="btn btn-success batch_process"
data-video-id="{{ lecture.video_id }}"
data-video-name="{{ lecture.video_name }}"
id="{{ lecture.subject }}">Process
</button>
{# <span class="font-italic font-weight-bolder text-success">Processing</span>#}
</td>
</tr> </tr>
{% endfor %} </thead>
</tbody> <tbody id="timetable_body">
</table> {% for lecture in due_lectures %}
<tr>
<td class="font-weight-bolder">{{ lecture.date }}</td>
{# <td>{{ lecture.subject }}</td>#}
<td class="font-weight-bolder">{{ lecture.subject_name }}</td>
<td class="font-weight-bolder">{{ lecture.start_time }}</td>
<td class="font-weight-bolder">{{ lecture.end_time }}</td>
<td>
<button type="button" class="btn btn-success batch_process"
data-video-id="{{ lecture.video_id }}"
data-video-name="{{ lecture.video_name }}"
id="{{ lecture.subject }}">Process
</button>
{# <span class="font-italic font-weight-bolder text-success">Processing</span>#}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
</div> </div>
...@@ -528,7 +534,6 @@ ...@@ -528,7 +534,6 @@
<!-- end of progress row --> <!-- end of progress row -->
</div> </div>
<!-- end of container --> <!-- end of container -->
...@@ -541,9 +546,9 @@ ...@@ -541,9 +546,9 @@
</div> </div>
<!-- end of progress row --> <!-- end of progress row -->
<!-- snackbar --> <!-- snackbar -->
<div id="snackbar">The lecture is completely processed..</div> <div id="snackbar">The lecture is completely processed..</div>
<!-- end of snackbar --> <!-- end of snackbar -->
</div> </div>
{% endblock %} {% endblock %}
......
...@@ -190,7 +190,7 @@ urlpatterns = [ ...@@ -190,7 +190,7 @@ urlpatterns = [
url(r'^check-availability/$', api.CheckStudentBehaviorAvailability.as_view()), url(r'^check-availability/$', api.CheckStudentBehaviorAvailability.as_view()),
# perform random task (delete later) # perform random task (delete later)
url(r'^get-random_number/$', api.TestRandom.as_view()), url(r'^get-random-number/$', api.TestRandom.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