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
2020-101
2020-101
Commits
90df2c29
Commit
90df2c29
authored
Sep 13, 2020
by
I.K Seneviratne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Committing the inclusion of viewing student behavior summary in Home page .
parent
0da62040
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
211 additions
and
9 deletions
+211
-9
FirstApp/api.py
FirstApp/api.py
+34
-3
FirstApp/emotion_detector.py
FirstApp/emotion_detector.py
+46
-1
FirstApp/logic/activity_recognition.py
FirstApp/logic/activity_recognition.py
+28
-2
FirstApp/templates/FirstApp/Home.html
FirstApp/templates/FirstApp/Home.html
+102
-2
FirstApp/views.py
FirstApp/views.py
+1
-1
No files found.
FirstApp/api.py
View file @
90df2c29
...
...
@@ -662,17 +662,48 @@ class GetStudentBehaviorSummaryForPeriod(APIView):
def
get
(
self
,
request
):
option
=
request
.
query_params
.
get
(
'option'
)
lecturer
=
request
.
query_params
.
get
(
'lecturer'
)
int_lecturer
=
int
(
lecturer
)
int_option
=
int
(
option
)
int_option
=
150
isRecordFound
=
False
activity_percentages
=
{}
emotion_percentages
=
{}
current_date
=
datetime
.
datetime
.
now
()
.
date
()
option_date
=
datetime
.
timedelta
(
days
=
int_option
)
previous_date
=
current_date
-
option_date
# print('current time: ',
# retrieving lecture activities
lec_activity
=
LectureActivity
.
objects
.
filter
(
lecture_video_id__date__gte
=
previous_date
,
lecture_video_id__date__lte
=
current_date
,
lecture_video_id__lecturer
=
lecturer
)
if
len
(
lec_activity
)
>
0
:
isRecordFound
=
True
activity_serializer
=
LectureActivitySerializer
(
lec_activity
,
many
=
True
)
activity_data
=
activity_serializer
.
data
activity_percentages
=
ar
.
get_student_activity_summary_for_period
(
activity_data
)
# retrieving lecture emotions
lec_emotion
=
LectureEmotionReport
.
objects
.
filter
(
lecture_video_id__date__gte
=
previous_date
,
lecture_video_id__date__lte
=
current_date
,
lecture_video_id__lecturer
=
lecturer
)
if
len
(
lec_emotion
)
>
0
:
emotion_serializer
=
LectureEmotionSerializer
(
lec_emotion
,
many
=
True
)
emotion_data
=
emotion_serializer
.
data
emotion_percentages
=
ed
.
get_student_emotion_summary_for_period
(
emotion_data
)
lec_activity
=
LectureActivity
.
objects
.
filter
()
return
Response
({
"response"
:
option
"activity_response"
:
activity_percentages
,
"emotion_response"
:
emotion_percentages
,
"isRecordFound"
:
isRecordFound
})
FirstApp/emotion_detector.py
View file @
90df2c29
...
...
@@ -339,4 +339,49 @@ def get_frame_emotion_recognition(video_name):
sorted_activity_frame_recognitions
=
cs
.
custom_object_sorter
(
frame_emotion_recognitions
)
# return the detected frame percentages
return
sorted_activity_frame_recognitions
\ No newline at end of file
return
sorted_activity_frame_recognitions
# this method will retrieve student activity summary for given time period
def
get_student_emotion_summary_for_period
(
emotions
):
# declare variables to add percentage values
happy_perct_combined
=
0.0
sad_perct_combined
=
0.0
angry_perct_combined
=
0.0
disgust_perct_combined
=
0.0
surprise_perct_combined
=
0.0
neutral_perct_combined
=
0.0
# get the number of activties to calculate average
no_of_emotions
=
len
(
emotions
)
# iterate through the activities
for
emotion
in
emotions
:
happy_perct_combined
+=
float
(
emotion
[
'happy_perct'
])
sad_perct_combined
+=
float
(
emotion
[
'sad_perct'
])
angry_perct_combined
+=
float
(
emotion
[
'angry_perct'
])
disgust_perct_combined
+=
float
(
emotion
[
'disgust_perct'
])
surprise_perct_combined
+=
float
(
emotion
[
'surprise_perct'
])
neutral_perct_combined
+=
float
(
emotion
[
'neutral_perct'
])
# calculate the average percentages
happy_average_perct
=
round
((
happy_perct_combined
/
no_of_emotions
),
1
)
sad_average_perct
=
round
((
sad_perct_combined
/
no_of_emotions
),
1
)
angry_average_perct
=
round
((
angry_perct_combined
/
no_of_emotions
),
1
)
disgust_average_perct
=
round
((
disgust_perct_combined
/
no_of_emotions
),
1
)
surprise_average_perct
=
round
((
surprise_perct_combined
/
no_of_emotions
),
1
)
neutral_average_perct
=
round
((
neutral_perct_combined
/
no_of_emotions
),
1
)
percentages
=
{}
percentages
[
"happy_perct"
]
=
happy_average_perct
percentages
[
"sad_perct"
]
=
sad_average_perct
percentages
[
"angry_perct"
]
=
angry_average_perct
percentages
[
"disgust_perct"
]
=
disgust_average_perct
percentages
[
"surprise_perct"
]
=
surprise_average_perct
percentages
[
"neutral_perct"
]
=
neutral_average_perct
return
percentages
\ No newline at end of file
FirstApp/logic/activity_recognition.py
View file @
90df2c29
...
...
@@ -574,6 +574,32 @@ def get_individual_student_evaluation(video_name, student_name):
# this method will retrieve student activity summary for given time period
def
get_student_activity_summary_for_period
():
def
get_student_activity_summary_for_period
(
activities
):
return
None
\ No newline at end of file
# declare variables to add percentage values
phone_checking_perct_combined
=
0.0
listening_perct_combined
=
0.0
note_taking_perct_combined
=
0.0
# get the number of activties to calculate average
no_of_activities
=
len
(
activities
)
# iterate through the activities
for
activity
in
activities
:
phone_checking_perct_combined
+=
float
(
activity
[
'phone_perct'
])
listening_perct_combined
+=
float
(
activity
[
'listening_perct'
])
note_taking_perct_combined
+=
float
(
activity
[
'writing_perct'
])
# calculate the average percentages
phone_checking_average_perct
=
round
((
phone_checking_perct_combined
/
no_of_activities
),
1
)
listening_average_perct
=
round
((
listening_perct_combined
/
no_of_activities
),
1
)
note_taking_average_perct
=
round
((
note_taking_perct_combined
/
no_of_activities
),
1
)
percentages
=
{}
percentages
[
"phone_perct"
]
=
phone_checking_average_perct
percentages
[
"listening_perct"
]
=
listening_average_perct
percentages
[
"writing_perct"
]
=
note_taking_average_perct
return
percentages
\ No newline at end of file
FirstApp/templates/FirstApp/Home.html
View file @
90df2c29
...
...
@@ -42,6 +42,11 @@
//hide the previously displayed progress areas
$
(
'
#progress_areas
'
).
attr
(
'
hidden
'
,
true
);
//hide the summary button
$
(
'
#student_behavior_OR_text
'
).
attr
(
'
hidden
'
,
true
);
//hide the summart button
$
(
'
#student_behavior_view_summary
'
).
attr
(
'
hidden
'
,
true
);
global_lecturer_subject_index
=
$
(
this
).
attr
(
'
data-index
'
);
global_lecturer
=
$
(
this
).
attr
(
'
data-lecturer
'
);
...
...
@@ -320,16 +325,51 @@
$
(
'
#view_summary_option_form
'
).
submit
(
function
(
e
)
{
let
option
=
$
(
"
input[name='option']:checked
"
).
val
();
let
lecturer
=
"
{{ lecturer }}
"
;
e
.
preventDefault
();
//send the data using fetch API
fetch
(
'
http://127.0.0.1:8000/get-student-behavior-summary-for-period/?option=
'
+
option
)
fetch
(
'
http://127.0.0.1:8000/get-student-behavior-summary-for-period/?option=
'
+
option
+
"
&lecturer=
"
+
lecturer
)
.
then
((
res
)
=>
res
.
json
())
.
then
((
out
)
=>
alert
(
'
response:
'
+
out
.
response
))
.
then
((
out
)
=>
displayPeriodStudentActivitySummary
(
out
))
.
catch
((
err
)
=>
alert
(
'
error:
'
+
err
))
});
//this function will display the percentages
function
displayPeriodStudentActivitySummary
(
out
)
{
if
(
out
.
isRecordFound
)
{
//show the summary tables
$
(
'
#student_behavior_summary_for_period
'
).
attr
(
'
hidden
'
,
false
);
//assign the activity values
$
(
'
#phone_perct_for_period
'
).
text
(
out
.
activity_response
.
phone_perct
);
$
(
'
#listening_perct_for_period
'
).
text
(
out
.
activity_response
.
listening_perct
);
$
(
'
#writing_perct_for_period
'
).
text
(
out
.
activity_response
.
writing_perct
);
//assign the emotion values
$
(
'
#happy_perct_for_period
'
).
text
(
out
.
emotion_response
.
happy_perct
);
$
(
'
#sad_perct_for_period
'
).
text
(
out
.
emotion_response
.
sad_perct
);
$
(
'
#angry_perct_for_period
'
).
text
(
out
.
emotion_response
.
angry_perct
);
$
(
'
#disgust_perct_for_period
'
).
text
(
out
.
emotion_response
.
disgust_perct
);
$
(
'
#surprise_perct_for_period
'
).
text
(
out
.
emotion_response
.
surprise_perct
);
$
(
'
#neutral_perct_for_period
'
).
text
(
out
.
emotion_response
.
neutral_perct
);
}
else
{
$
(
'
#student_summary_not_found_message
'
).
attr
(
'
hidden
'
,
false
);
}
//hide the modal
$
(
'
#student_behavior_view_summary_modal
'
).
modal
(
"
hide
"
);
}
});
</script>
...
...
@@ -492,6 +532,66 @@
<img
src=
"{% static 'FirstApp/images/ajax-loader.gif' %}"
alt=
"Loader"
>
</div>
<!-- student summary not found message -->
<div
class=
"text-center mt-4"
id=
"student_summary_not_found_message"
hidden
>
<span
class=
"font-italic"
>
No student summary was found
</span>
</div>
<!-- to display student behavior summary for period -->
<div
class=
"text-center"
id=
"student_behavior_summary_for_period"
hidden
>
<!-- activity table -->
<table
class=
"table table-borderless"
>
<tbody>
<tr>
<td>
Phone percentage
</td>
<td
id=
"phone_perct_for_period"
></td>
</tr>
<tr>
<td>
Listening percentage
</td>
<td
id=
"listening_perct_for_period"
></td>
</tr>
<tr>
<td>
Note taking percentage
</td>
<td
id=
"writing_perct_for_period"
></td>
</tr>
</tbody>
</table>
<!-- end of activity table -->
<!-- emotion table -->
<table
class=
"table table-borderless"
>
<tbody>
<tr>
<td>
Happy percentage
</td>
<td
id=
"happy_perct_for_period"
></td>
</tr>
<tr>
<td>
Sad percentage
</td>
<td
id=
"sad_perct_for_period"
></td>
</tr>
<tr>
<td>
Angry percentage
</td>
<td
id=
"angry_perct_for_period"
></td>
</tr>
<tr>
<td>
Disgust percentage
</td>
<td
id=
"disgust_perct_for_period"
></td>
</tr>
<tr>
<td>
Surprise percentage
</td>
<td
id=
"surprise_perct_for_period"
></td>
</tr>
<tr>
<td>
Neutral percentage
</td>
<td
id=
"neutral_perct_for_period"
></td>
</tr>
</tbody>
</table>
<!-- end of emotion table -->
</div>
<!-- end of student behavior summary -->
<!-- a vertical list displaying the student engagement categories -->
<ul
class=
"list-group"
id=
"progress_areas"
hidden
>
...
...
FirstApp/views.py
View file @
90df2c29
...
...
@@ -190,7 +190,7 @@ def hello(request):
# video.name = videoName
# video.duration = str(durationObj)
# videos.append(video)
context
=
{
'object'
:
obj
,
'Videos'
:
videos
,
'durations'
:
durations
,
'template_name'
:
'FirstApp/template.html'
,
'lecturer_details'
:
lecturer_details
}
context
=
{
'object'
:
obj
,
'Videos'
:
videos
,
'durations'
:
durations
,
'template_name'
:
'FirstApp/template.html'
,
'lecturer_details'
:
lecturer_details
,
"lecturer"
:
lecturer
}
return
render
(
request
,
'FirstApp/Home.html'
,
context
)
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