Commit 5b1ec409 authored by SohanDanushka's avatar SohanDanushka Committed by I.K Seneviratne

db changes verifying in lecturer video

parent 006dc258
...@@ -17,14 +17,6 @@ class LecturerVideoSerializer(serializers.ModelSerializer): ...@@ -17,14 +17,6 @@ class LecturerVideoSerializer(serializers.ModelSerializer):
model = LecturerVideo model = LecturerVideo
fields = '__all__' fields = '__all__'
class LecturerVideoMetaDataSerializer(serializers.ModelSerializer):
lecturer_video_id = LectureRecordedVideo()
class Meta:
model = LecturerVideoMetaData
fields = '__all__'
class LecturerAudioTextSerializer(serializers.ModelSerializer): class LecturerAudioTextSerializer(serializers.ModelSerializer):
...@@ -43,3 +35,12 @@ class LectureRecordedVideoSerializer(serializers.ModelSerializer): ...@@ -43,3 +35,12 @@ class LectureRecordedVideoSerializer(serializers.ModelSerializer):
class Meta: class Meta:
model = LectureRecordedVideo model = LectureRecordedVideo
fields = '__all__' fields = '__all__'
class LecturerVideoMetaDataSerializer(serializers.ModelSerializer):
lecturer_video_id = LectureRecordedVideoSerializer()
class Meta:
model = LecturerVideoMetaData
fields = '__all__'
\ No newline at end of file
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
var lecture_audio_text_summary = {}; var lecture_audio_text_summary = {};
$(document).ready(function () { $(document).ready(function () {
$('.calc').click(function () { $('.calc').click(function (e) {
let video_name = $(this).attr('data-name'); let video_name = $(this).attr('data-name');
$('#no_content_message').attr('hidden', true); $('#no_content_message').attr('hidden', true);
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
//fetching data from the API //fetching data from the API
fetch('http://127.0.0.1:8000/lecturer/activities/?video_name=' + video_name) fetch('http://127.0.0.1:8000/lecturer/activities/?video_name=' + video_name)
.then((res) => res.json()) .then((res) => res.json())
.then((out) => assignPerct(out.response)) .then((out) => assignPerct(out.response, e))
.catch((error) => alert('error ' + error)); .catch((error) => alert('error ' + error));
...@@ -62,10 +62,9 @@ ...@@ -62,10 +62,9 @@
//this function will handle the lecturer video results button //this function will handle the lecturer video results button
$('.results').click(function () { $('.results').click(function (e) {
let video_id = $(this).attr('data-id'); let video_id = $(this).attr('data-id');
$('#no_content_message').attr('hidden', true); $('#no_content_message').attr('hidden', true);
$('#video_loader').attr('hidden', false); $('#video_loader').attr('hidden', false);
...@@ -73,7 +72,7 @@ ...@@ -73,7 +72,7 @@
//fetch the results //fetch the results
fetch('http://127.0.0.1:8000/lecturer/get-lecturer-video-results/?video_id=' + video_id) fetch('http://127.0.0.1:8000/lecturer/get-lecturer-video-results/?video_id=' + video_id)
.then((res) => res.json()) .then((res) => res.json())
.then((out) => assignPerct(out.response)) .then((out) => assignPerct(out.response, e))
.catch((err) => alert('error: ' + err)) .catch((err) => alert('error: ' + err))
}); });
...@@ -81,11 +80,16 @@ ...@@ -81,11 +80,16 @@
//to assign percentage values //to assign percentage values
function assignPerct(percentages) { function assignPerct(percentages, e) {
$('#no_content_message').attr('hidden', true); $('#no_content_message').attr('hidden', true);
$('#progress_bars').attr('hidden', false); $('#progress_bars').attr('hidden', false);
$('#loader').attr('hidden', true); $('#loader').attr('hidden', true);
//display the 'results' button
{#e.target.parentNode.innerHTML = "<span class='font-italic bg-success'>Processed</span>";#}
{#alert("Result button error");#}
{#let sitting = Math.round(percentages.sitting_perct);#} {#let sitting = Math.round(percentages.sitting_perct);#}
let sitting = Math.round(percentages.sitting_perct); let sitting = Math.round(percentages.sitting_perct);
......
...@@ -71,9 +71,9 @@ def hello(request): ...@@ -71,9 +71,9 @@ def hello(request):
lec_list.sort(key=lambda date: dt.strptime(str(date['date']), "%Y-%m-%d"), reverse=True) lec_list.sort(key=lambda date: dt.strptime(str(date['date']), "%Y-%m-%d"), reverse=True)
# retrieve exsiting lecture recorded videos # retrieve exsiting lecture recorded videos
lec_recorded_video = LectureRecordedVideo.objects.all() lec_video_meta = LecturerVideoMetaData.objects.all()
lec_recorded_video_ser = LectureRecordedVideoSerializer(lec_recorded_video, many=True) lec_video_meta_ser = LecturerVideoMetaDataSerializer(lec_video_meta, many=True)
lec_recorded_video_data = lec_recorded_video_ser.data lec_video_meta_data = lec_video_meta_ser.data
for videoPath in videoPaths: for videoPath in videoPaths:
video = LecturerVideo() video = LecturerVideo()
...@@ -92,11 +92,13 @@ def hello(request): ...@@ -92,11 +92,13 @@ def hello(request):
video['video_id'] = None video['video_id'] = None
# checking whether this video already exists # checking whether this video already exists
for recorded_lecture in lec_recorded_video_data: for recorded_lecture in lec_video_meta_data:
if videoName == recorded_lecture['lecture_video_name']: print('recorded lecture: ', recorded_lecture)
if videoName == recorded_lecture['lecturer_video_id']['lecture_video_name']:
video['isAvailable'] = True video['isAvailable'] = True
video['video_id'] = recorded_lecture['id'] video['video_id'] = recorded_lecture['lecturer_video_id']['id']
videos.append(video) videos.append(video)
......
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