You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
90 lines
3.2 KiB
90 lines
3.2 KiB
from django.contrib import admin
|
|
from unfold.admin import ModelAdmin, TabularInline, StackedInline
|
|
from apps.lms.models import (
|
|
Course,
|
|
CourseModule,
|
|
Lesson,
|
|
QuizQuestion,
|
|
CourseEnrollment,
|
|
LessonProgress,
|
|
DigitalCertificate,
|
|
)
|
|
|
|
|
|
class LessonInline(TabularInline):
|
|
model = Lesson
|
|
extra = 1
|
|
fields = ('order', 'title', 'lesson_type', 'duration_minutes', 'is_preview')
|
|
|
|
|
|
class CourseModuleInline(StackedInline):
|
|
model = CourseModule
|
|
extra = 1
|
|
fields = ('order', 'title', 'description')
|
|
|
|
|
|
class QuizQuestionInline(StackedInline):
|
|
model = QuizQuestion
|
|
extra = 1
|
|
fields = ('order', 'question_text', 'options', 'correct_option_index', 'explanation')
|
|
|
|
|
|
@admin.register(Course)
|
|
class CourseAdmin(ModelAdmin):
|
|
list_display = ('title', 'category', 'language', 'level', 'instructor_name', 'is_published', 'is_featured', 'created_at')
|
|
list_display_links = ('title', 'category', 'instructor_name')
|
|
list_filter = ('category', 'language', 'level', 'is_published', 'is_featured')
|
|
search_fields = ('title', 'description', 'instructor_name', 'organization_name')
|
|
prepopulated_fields = {'slug': ('title',)}
|
|
inlines = [CourseModuleInline]
|
|
|
|
|
|
@admin.register(CourseModule)
|
|
class CourseModuleAdmin(ModelAdmin):
|
|
list_display = ('title', 'course', 'order', 'created_at')
|
|
list_display_links = ('title', 'course')
|
|
list_filter = ('course',)
|
|
search_fields = ('title', 'description', 'course__title')
|
|
inlines = [LessonInline]
|
|
|
|
|
|
@admin.register(Lesson)
|
|
class LessonAdmin(ModelAdmin):
|
|
list_display = ('title', 'module', 'lesson_type', 'duration_minutes', 'order', 'is_preview')
|
|
list_display_links = ('title', 'module')
|
|
list_filter = ('lesson_type', 'is_preview', 'module__course')
|
|
search_fields = ('title', 'content', 'module__title', 'module__course__title')
|
|
inlines = [QuizQuestionInline]
|
|
|
|
|
|
@admin.register(QuizQuestion)
|
|
class QuizQuestionAdmin(ModelAdmin):
|
|
list_display = ('question_text', 'lesson', 'correct_option_index', 'order')
|
|
list_display_links = ('question_text', 'lesson')
|
|
list_filter = ('lesson__module__course',)
|
|
search_fields = ('question_text', 'explanation', 'lesson__title')
|
|
|
|
|
|
@admin.register(CourseEnrollment)
|
|
class CourseEnrollmentAdmin(ModelAdmin):
|
|
list_display = ('user', 'course', 'progress_percentage', 'enrolled_at', 'completed_at')
|
|
list_display_links = ('user', 'course')
|
|
list_filter = ('course', 'progress_percentage')
|
|
search_fields = ('user__email', 'user__fullname', 'course__title')
|
|
|
|
|
|
@admin.register(LessonProgress)
|
|
class LessonProgressAdmin(ModelAdmin):
|
|
list_display = ('user', 'lesson', 'is_completed', 'quiz_score', 'completed_at')
|
|
list_display_links = ('user', 'lesson')
|
|
list_filter = ('is_completed', 'lesson__module__course')
|
|
search_fields = ('user__email', 'user__fullname', 'lesson__title')
|
|
|
|
|
|
@admin.register(DigitalCertificate)
|
|
class DigitalCertificateAdmin(ModelAdmin):
|
|
list_display = ('certificate_code', 'user', 'course', 'issue_date', 'final_score', 'is_revoked')
|
|
list_display_links = ('certificate_code', 'user', 'course')
|
|
list_filter = ('is_revoked', 'issue_date', 'course')
|
|
search_fields = ('certificate_code', 'user__email', 'user__fullname', 'course__title')
|
|
readonly_fields = ('uuid', 'created_at')
|