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

Committing the partial implementation of saving lecture activity frame...

Committing the partial implementation of saving lecture activity frame recognitions in the database.
parent 3a6e7948
......@@ -185,6 +185,29 @@ class LectureActivityFrameGroupings(models.Model):
return self.lecture_activity_frame_groupings_id
# this abstract class will contain lecture activity frame recognition details
class LectureActivityFrameRecognitionDetails(models.Model):
frame_name = models.CharField(max_length=15)
phone_perct = models.DecimalField(default=0.0, max_digits=3, decimal_places=1)
listen_perct = models.DecimalField(default=0.0, max_digits=3, decimal_places=1)
note_perct = models.DecimalField(default=0.0, max_digits=3, decimal_places=1)
class Meta:
abstract = True
# this class will contain lecture activity frame recognitions
class LectureActivityFrameRecognitions(models.Model):
lecture_activity_frame_recognition_id = models.CharField(max_length=15)
lecture_activity_id = models.ForeignKey(LectureActivity, on_delete=models.CASCADE)
frame_recognition_details = models.ArrayField(LectureActivityFrameRecognitionDetails)
def __str__(self):
return self.lecture_activity_frame_recognition_id
# EMOTIONS section
# Lecture emotion report
class LectureEmotionReport(models.Model):
......
# Generated by Django 2.2.11 on 2020-10-16 17:07
import FirstApp.MongoModels
from django.db import migrations, models
import django.db.models.deletion
import djongo.models.fields
class Migration(migrations.Migration):
dependencies = [
('FirstApp', '0011_lectureemotionframegroupings_lecturegazeframegroupings'),
]
operations = [
migrations.CreateModel(
name='LectureActivityFrameRecognitions',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('lecture_activity_frame_recognition_id', models.CharField(max_length=15)),
('frame_recognition_details', djongo.models.fields.ArrayField(model_container=FirstApp.MongoModels.LectureActivityFrameRecognitionDetails)),
('lecture_activity_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='FirstApp.LectureActivity')),
],
),
]
......@@ -283,6 +283,31 @@ class LectureActivityFrameGroupingsSerializer(serializers.ModelSerializer):
fields = '__all__'
# lecture activity frame recognition serializer
class LectureActivityFrameRecognitionsSerializer(serializers.ModelSerializer):
lecture_activity_id = LectureActivitySerializer()
frame_recognition_details = serializers.SerializerMethodField()
def get_frame_recognition_details(self, obj):
return_data = []
for frame_recognition in obj.frame_recognition_details:
recognition = {}
recognition["frame_name"] = frame_recognition.frame_name
recognition["phone_perct"] = frame_recognition.frame_name
recognition["listen_perct"] = frame_recognition.frame_name
recognition["note_perct"] = frame_recognition.frame_name
return_data.append(recognition)
# return the data
return return_data
# EMOTIONS section
# lecture emotions serailzier
class LectureEmotionSerializer(serializers.ModelSerializer):
......
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