Commit 20fd8ccb authored by I.K Seneviratne's avatar I.K Seneviratne

Committing considerable changes in Home page for displaying student behavior...

Committing considerable changes in Home page for displaying student behavior summary for given time period .
parent 90df2c29
......@@ -669,6 +669,11 @@ class GetStudentBehaviorSummaryForPeriod(APIView):
isRecordFound = False
activity_percentages = {}
emotion_percentages = {}
individual_lec_activties = []
individual_lec_emotions = []
activity_labels = []
emotion_labels = []
current_date = datetime.datetime.now().date()
option_date = datetime.timedelta(days=int_option)
......@@ -686,7 +691,7 @@ class GetStudentBehaviorSummaryForPeriod(APIView):
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)
activity_percentages, individual_lec_activties, activity_labels = ar.get_student_activity_summary_for_period(activity_data)
# retrieving lecture emotions
lec_emotion = LectureEmotionReport.objects.filter(
......@@ -698,12 +703,16 @@ class GetStudentBehaviorSummaryForPeriod(APIView):
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)
emotion_percentages, individual_lec_emotions, emotion_labels = ed.get_student_emotion_summary_for_period(emotion_data)
return Response({
"activity_response": activity_percentages,
"emotion_response": emotion_percentages,
"individual_activities": individual_lec_activties,
"individual_emotions": individual_lec_emotions,
"activity_labels": activity_labels,
"emotion_labels": emotion_labels,
"isRecordFound": isRecordFound
})
......@@ -356,9 +356,21 @@ def get_student_emotion_summary_for_period(emotions):
# get the number of activties to calculate average
no_of_emotions = len(emotions)
individual_lec_emotions = []
emotion_labels = ["happy_perct", "sad_perct", "angry_perct", "disgust_perct", "surprise_perct", "neutral_perct"]
# iterate through the activities
for emotion in emotions:
individual_emotion = {}
individual_emotion["happy_perct"] = float(emotion['happy_perct'])
individual_emotion["sad_perct"] = float(emotion['sad_perct'])
individual_emotion["angry_perct"] = float(emotion['angry_perct'])
individual_emotion["disgust_perct"] = float(emotion['disgust_perct'])
individual_emotion["surprise_perct"] = float(emotion['surprise_perct'])
individual_emotion["neutral_perct"] = float(emotion['neutral_perct'])
happy_perct_combined += float(emotion['happy_perct'])
sad_perct_combined += float(emotion['sad_perct'])
angry_perct_combined += float(emotion['angry_perct'])
......@@ -366,6 +378,8 @@ def get_student_emotion_summary_for_period(emotions):
surprise_perct_combined += float(emotion['surprise_perct'])
neutral_perct_combined += float(emotion['neutral_perct'])
# append to the list
individual_lec_emotions.append(individual_emotion)
# calculate the average percentages
......@@ -384,4 +398,4 @@ def get_student_emotion_summary_for_period(emotions):
percentages["surprise_perct"] = surprise_average_perct
percentages["neutral_perct"] = neutral_average_perct
return percentages
\ No newline at end of file
return percentages, individual_lec_emotions, emotion_labels
\ No newline at end of file
......@@ -584,12 +584,24 @@ def get_student_activity_summary_for_period(activities):
# get the number of activties to calculate average
no_of_activities = len(activities)
individual_lec_activities = []
activity_labels = ["phone_perct", "listening_perct", "writing_perct"]
# iterate through the activities
for activity in activities:
individual_activity = {}
individual_activity["phone_perct"] = float(activity['phone_perct'])
individual_activity["listening_perct"] = float(activity['listening_perct'])
individual_activity["writing_perct"] = float(activity['writing_perct'])
phone_checking_perct_combined += float(activity['phone_perct'])
listening_perct_combined += float(activity['listening_perct'])
note_taking_perct_combined += float(activity['writing_perct'])
# append to the list
individual_lec_activities.append(individual_activity)
# calculate the average percentages
......@@ -602,4 +614,4 @@ def get_student_activity_summary_for_period(activities):
percentages["listening_perct"] = listening_average_perct
percentages["writing_perct"] = note_taking_average_perct
return percentages
\ No newline at end of file
return percentages, individual_lec_activities, activity_labels
\ No newline at end of file
This diff is collapsed.
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