P-259: admin testing result
This commit is contained in:
1 parent
5c02e0e0f9
commit
23c433a316
2 files changed
+14
-11
No files matched your search
+13
-10
@@ -1,5 +1,5 @@
|
||||
from django.contrib import admin
|
||||
from .models import Test, TestAnswer, TestQuestion, TestAttempt, DictEmployee
|
||||
from .models import Test, TestAnswer, TestQuestion, TestAttempt, DictEmployee, Testing
|
||||
import nested_admin
|
||||
|
||||
class TestAnswerInline(nested_admin.NestedStackedInline):
|
||||
@@ -14,20 +14,23 @@ class TestQuestionInline(nested_admin.NestedStackedInline):
|
||||
class TestAdmin(nested_admin.NestedModelAdmin):
|
||||
inlines = [TestQuestionInline]
|
||||
|
||||
@admin.register(TestAttempt)
|
||||
class TestAttemptAdmin(admin.ModelAdmin):
|
||||
@admin.register(Testing)
|
||||
class TestingAdmin(admin.ModelAdmin):
|
||||
# list_display = ('testing_user', 'testing_test', 'score', 'completion_date')
|
||||
list_display = ('get_user_fio', 'testing_test', 'score', 'completion_date')
|
||||
list_display = ('get_user_fio', 'test', 'get_score', 'test_passed', 'completion_date')
|
||||
|
||||
def get_user_fio(self, obj):
|
||||
return obj.testing.user.user.fio
|
||||
get_user_fio.admin_order_field = 'testing__user__user__fio'
|
||||
return obj.user.user.fio
|
||||
|
||||
def testing_test(self, obj):
|
||||
return obj.testing.test
|
||||
def get_score(self, obj):
|
||||
last_attempt = TestAttempt.objects.filter(testing=obj).order_by('-attempt_number').first()
|
||||
if last_attempt:
|
||||
return last_attempt.score
|
||||
else:
|
||||
return None
|
||||
|
||||
get_user_fio.admin_order_field = 'user__user__fio'
|
||||
get_user_fio.short_description = 'Пользователь'
|
||||
testing_test.short_description = 'Тест'
|
||||
testing_test.admin_order_field = 'testing__test'
|
||||
get_score.short_description = 'Результат'
|
||||
|
||||
admin.site.register(Test, TestAdmin)
|
||||
Reference in new issue
Block a user