|
|
@ -2,7 +2,7 @@ from rest_framework import serializers |
|
|
|
|
|
|
|
|
# from dj_filer.admin import get_thumbs |
|
|
# from dj_filer.admin import get_thumbs |
|
|
from utils import get_thumbs |
|
|
from utils import get_thumbs |
|
|
from apps.course.models import Course, CourseCategory, Attachment, Glossary, LessonCompletion, Participant, Lesson, CourseAttachment, CourseGlossary |
|
|
|
|
|
|
|
|
from apps.course.models import Course, CourseCategory, Attachment, Glossary, LessonCompletion, Participant, Lesson, CourseAttachment, CourseGlossary, CourseLesson |
|
|
from apps.chat.models import RoomMessage |
|
|
from apps.chat.models import RoomMessage |
|
|
from apps.account.serializers import UserProfileSerializer |
|
|
from apps.account.serializers import UserProfileSerializer |
|
|
|
|
|
|
|
|
@ -132,18 +132,18 @@ class CourseDetailSerializer(serializers.ModelSerializer): |
|
|
# آخرین درس تکمیلشده توسط کاربر |
|
|
# آخرین درس تکمیلشده توسط کاربر |
|
|
last_completed_lesson = LessonCompletion.objects.filter( |
|
|
last_completed_lesson = LessonCompletion.objects.filter( |
|
|
student=user, |
|
|
student=user, |
|
|
lesson__course=obj |
|
|
|
|
|
|
|
|
course_lesson__course=obj |
|
|
).order_by('-completed_at').first() |
|
|
).order_by('-completed_at').first() |
|
|
|
|
|
|
|
|
if last_completed_lesson: |
|
|
if last_completed_lesson: |
|
|
# پیدا کردن درس بعدی بر اساس priority |
|
|
# پیدا کردن درس بعدی بر اساس priority |
|
|
next_lesson = Lesson.objects.filter( |
|
|
|
|
|
|
|
|
next_lesson = CourseLesson.objects.filter( |
|
|
course=obj, |
|
|
course=obj, |
|
|
priority__gt=last_completed_lesson.lesson.priority, |
|
|
|
|
|
|
|
|
priority__gt=last_completed_lesson.course_lesson.priority, |
|
|
is_active=True |
|
|
is_active=True |
|
|
).order_by('priority').first() |
|
|
).order_by('priority').first() |
|
|
if not next_lesson: |
|
|
if not next_lesson: |
|
|
next_lesson = Lesson.objects.filter( |
|
|
|
|
|
|
|
|
next_lesson = CourseLesson.objects.filter( |
|
|
course=obj, |
|
|
course=obj, |
|
|
is_active=True |
|
|
is_active=True |
|
|
).order_by('priority').first() |
|
|
).order_by('priority').first() |
|
|
@ -190,7 +190,7 @@ class CourseDetailSerializer(serializers.ModelSerializer): |
|
|
"""Helper method to count completed lessons for the student in the given course.""" |
|
|
"""Helper method to count completed lessons for the student in the given course.""" |
|
|
return LessonCompletion.objects.filter( |
|
|
return LessonCompletion.objects.filter( |
|
|
student=student, |
|
|
student=student, |
|
|
lesson__course=course |
|
|
|
|
|
|
|
|
course_lesson__course=course |
|
|
).count() |
|
|
).count() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -244,7 +244,7 @@ class MyCourseListSerializer(serializers.ModelSerializer): |
|
|
"""Helper method to count completed lessons for the student in the given course.""" |
|
|
"""Helper method to count completed lessons for the student in the given course.""" |
|
|
return LessonCompletion.objects.filter( |
|
|
return LessonCompletion.objects.filter( |
|
|
student=student, |
|
|
student=student, |
|
|
lesson__course=course |
|
|
|
|
|
|
|
|
course_lesson__course=course |
|
|
).count() |
|
|
).count() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|