vault backup: 2025-12-26 02:09:22
All checks were successful
Deploy Quartz site to GitHub Pages / build (push) Successful in 2m29s
All checks were successful
Deploy Quartz site to GitHub Pages / build (push) Successful in 2m29s
This commit is contained in:
30
stroma/quiz/admin/option_admin.py
Normal file
30
stroma/quiz/admin/option_admin.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from django.contrib import admin
|
||||
from django.utils.html import format_html
|
||||
from quiz.models import Option
|
||||
|
||||
|
||||
@admin.register(Option)
|
||||
class OptionAdmin(admin.ModelAdmin):
|
||||
"""Admin interface for Options"""
|
||||
list_display = ['id', 'question_preview', 'letter', 'text_preview', 'is_correct']
|
||||
list_filter = ['letter']
|
||||
search_fields = ['text', 'question__text']
|
||||
readonly_fields = ['question']
|
||||
|
||||
def question_preview(self, obj):
|
||||
"""Show question preview"""
|
||||
return obj.question.text[:40] + '...'
|
||||
question_preview.short_description = 'Question'
|
||||
|
||||
def text_preview(self, obj):
|
||||
"""Show option text preview"""
|
||||
return obj.text[:50] + '...' if len(obj.text) > 50 else obj.text
|
||||
text_preview.short_description = 'Option Text'
|
||||
|
||||
def is_correct(self, obj):
|
||||
"""Highlight if this is the correct answer"""
|
||||
if obj.question.correct_answer and obj.letter in obj.question.correct_answer:
|
||||
return format_html('<span style="color: green; font-weight: bold;">✓ Correct</span>')
|
||||
return format_html('<span style="color: #999;">-</span>')
|
||||
is_correct.short_description = 'Status'
|
||||
|
||||
Reference in New Issue
Block a user