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

Committing the graphical implementation of the lecture activity frame...

Committing the graphical implementation of the lecture activity frame groupings in the lecturer Home page.
parent 229e02da
...@@ -110,6 +110,36 @@ class LectureVideo(models.Model): ...@@ -110,6 +110,36 @@ class LectureVideo(models.Model):
def __str__(self): def __str__(self):
return self.lecture_video_id return self.lecture_video_id
class Landmarks(models.Model):
landmark = models.CharField(max_length=15)
class Meta:
abstract = True
# lecture video time landmarks table
class LectureVideoTimeLandmarks(models.Model):
lecture_video_time_landmarks_id = models.CharField(max_length=15)
lecture_video_id = models.ForeignKey(LectureVideo, on_delete=models.CASCADE)
time_landmarks = models.ArrayField(Landmarks)
def __str__(self):
return self.lecture_video_time_landmarks_id
# lecture video frame landmarks table
class LectureVideoFrameLandmarks(models.Model):
lecture_video_frame_landmarks_id = models.CharField(max_length=15)
lecture_video_id = models.ForeignKey(LectureVideo, on_delete=models.CASCADE)
frame_landmarks = models.ArrayField(Landmarks)
def __str__(self):
return self.lecture_video_frame_landmarks_id
# ACTIVITY section # ACTIVITY section
# lecture activity table # lecture activity table
class LectureActivity(models.Model): class LectureActivity(models.Model):
......
This diff is collapsed.
...@@ -764,7 +764,6 @@ def activity_frame_groupings(video_name, frame_landmarks, frame_group_dict): ...@@ -764,7 +764,6 @@ def activity_frame_groupings(video_name, frame_landmarks, frame_group_dict):
# print('frame group dict: ', frame_group_dict) # print('frame group dict: ', frame_group_dict)
activity_labels = ['phone_perct', 'listen_perct', 'note_perct'] activity_labels = ['phone_perct', 'listen_perct', 'note_perct']
print('frame group percentages: ', frame_group_dict)
# return the dictionary # return the dictionary
return frame_group_dict, activity_labels return frame_group_dict, activity_labels
\ No newline at end of file
...@@ -201,6 +201,52 @@ class LectureVideoSerializer(serializers.ModelSerializer): ...@@ -201,6 +201,52 @@ class LectureVideoSerializer(serializers.ModelSerializer):
fields = '__all__' fields = '__all__'
# lecture video time landmarks serializer
class LectureVideoTimeLandmarksSerializer(serializers.ModelSerializer):
lecture_video_id = LectureVideoSerializer()
time_landmarks = serializers.SerializerMethodField()
def get_time_landmarks(self, obj):
return_data = []
for time_landmark in obj.time_landmarks:
landmark_details = {}
landmark_details["landmark"] = time_landmark.landmark
return_data.append(landmark_details)
return return_data
class Meta:
model = LectureVideoTimeLandmarks
fields = '__all__'
# lecture video frame landmarks serializer
class LectureVideoFrameLandmarksSerializer(serializers.ModelSerializer):
lecture_video_id = LectureVideoSerializer()
frame_landmarks = serializers.SerializerMethodField()
def get_frame_landmarks(self, obj):
return_data = []
for frame_landmark in obj.frame_landmarks:
landmark_details = {}
landmark_details["landmark"] = frame_landmark.landmark
return_data.append(landmark_details)
return return_data
class Meta:
model = LectureVideoFrameLandmarks
fields = '__all__'
class LectureActivitySerializer(serializers.ModelSerializer): class LectureActivitySerializer(serializers.ModelSerializer):
lecture_video_id = LectureVideoSerializer() lecture_video_id = LectureVideoSerializer()
...@@ -213,6 +259,23 @@ class LectureActivitySerializer(serializers.ModelSerializer): ...@@ -213,6 +259,23 @@ class LectureActivitySerializer(serializers.ModelSerializer):
class LectureActivityFrameGroupingsSerializer(serializers.ModelSerializer): class LectureActivityFrameGroupingsSerializer(serializers.ModelSerializer):
lecture_activity_id = LectureActivitySerializer() lecture_activity_id = LectureActivitySerializer()
frame_group_details = serializers.SerializerMethodField()
def get_frame_group_details(self, obj):
return_data = []
for frame_group in obj.frame_group_details:
group_details = {}
group_details["frame_group_percentages"] = {}
group_details["frame_group"] = frame_group.frame_group
group_details["frame_group_percentages"]["phone_perct"] = frame_group.frame_group_percentages.phone_perct
group_details["frame_group_percentages"]["listen_perct"] = frame_group.frame_group_percentages.listen_perct
group_details["frame_group_percentages"]["note_perct"] = frame_group.frame_group_percentages.note_perct
return_data.append(group_details)
return return_data
class Meta: class Meta:
model = LectureActivityFrameGroupings model = LectureActivityFrameGroupings
......
...@@ -291,7 +291,7 @@ ...@@ -291,7 +291,7 @@
lecture_activity_frame_group_percentages = response.frame_group_percentages; lecture_activity_frame_group_percentages = response.frame_group_percentages;
let frame_landmarks = response.frame_landmarks; let frame_landmarks = response.frame_landmarks;
let frame_group_dict = response.frame_group_dict; {#let frame_group_dict = response.frame_group_dict;#}
let activity_labels = response.activity_labels; let activity_labels = response.activity_labels;
......
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