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

Committing minor modifications in adjusting the functionality of lecture radio...

Committing minor modifications in adjusting the functionality of lecture radio buttons in the Lecturer Home Page
parent 1da1edbb
...@@ -215,14 +215,24 @@ class GetLectureVideoViewSetForHome(APIView): ...@@ -215,14 +215,24 @@ class GetLectureVideoViewSetForHome(APIView):
def get(self, request): def get(self, request):
lecturer = request.query_params.get('lecturer') lecturer = request.query_params.get('lecturer')
date = request.query_params.get('date') date = request.query_params.get('date')
counter = int(request.query_params.get('counter'))
lecturer_video = LectureVideo.objects.filter(lecturer_id=lecturer, date=date) lecturer_video = LectureVideo.objects.filter(lecturer_id=lecturer, date=date)
serializer = LectureVideoSerializer(lecturer_video, many=True) serializer = LectureVideoSerializer(lecturer_video, many=True)
response = {}
# to check whether there is only one lecture video for the query
if len(serializer.data) > 1:
lecture_video_id = serializer.data[counter]['lecture_video_id']
response = serializer.data[counter]
else:
lecture_video_id = serializer.data[0]['lecture_video_id'] lecture_video_id = serializer.data[0]['lecture_video_id']
print('lecture video id: ', lecture_video_id) response = serializer.data[0]
return Response({ return Response({
"response": serializer.data[0] "response": response
}) })
......
...@@ -54,6 +54,10 @@ ...@@ -54,6 +54,10 @@
global_lecturer = $(this).attr('data-lecturer'); global_lecturer = $(this).attr('data-lecturer');
global_lecture_date = $(this).attr('data-date'); global_lecture_date = $(this).attr('data-date');
let counter = $(this).attr('data-counter');
alert('counter: ' + counter);
let real_date = new Date(global_lecture_date); let real_date = new Date(global_lecture_date);
//extract the day //extract the day
let day = '' + real_date.getDate(); let day = '' + real_date.getDate();
...@@ -75,7 +79,7 @@ ...@@ -75,7 +79,7 @@
//display the video loading message //display the video loading message
$('#student_behavior_video_loading').attr('hidden', false); $('#student_behavior_video_loading').attr('hidden', false);
fetch('http://127.0.0.1:8000/get-lecture-video-for-home/?lecturer=' + global_lecturer + '&date=' + date_format) fetch('http://127.0.0.1:8000/get-lecture-video-for-home/?lecturer=' + global_lecturer + '&date=' + date_format + '&counter=' + counter)
.then((res) => res.json()) .then((res) => res.json())
.then((out) => retrieveLectureVideoDetails(out)) .then((out) => retrieveLectureVideoDetails(out))
.catch((error) => alert('an error occurred: ' + error)); .catch((error) => alert('an error occurred: ' + error));
...@@ -1279,7 +1283,8 @@ ...@@ -1279,7 +1283,8 @@
name="recent_recordings_radio" name="recent_recordings_radio"
data-lecturer="{{ lecturer_detail.lecturer }}" data-lecturer="{{ lecturer_detail.lecturer }}"
data-index="{{ lecturer_detail.index }}" data-index="{{ lecturer_detail.index }}"
data-date="{{ lecturer_detail.date }}"> data-date="{{ lecturer_detail.date }}"
data-counter="{{ forloop.counter0 }}">
</label> </label>
</div> </div>
</td> </td>
......
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