Unverified Commit b6d9dfb2 by sanfordstudent Committed by GitHub

Merge pull request #16652 from edx/add-persistent-grade-override-table-in-admin

Add `PersistentSubsectionGradeOverride` table in django admin
parents 139fa895 baa967ca
......@@ -3,13 +3,14 @@ Django admin page for grades models
"""
from config_models.admin import ConfigurationModelAdmin, KeyedConfigurationModelAdmin
from django.contrib import admin
from django.utils.translation import ugettext_lazy as _
from lms.djangoapps.grades.config.forms import CoursePersistentGradesAdminForm
from lms.djangoapps.grades.config.models import (
ComputeGradesSetting,
CoursePersistentGradesFlag,
PersistentGradesEnabledFlag
)
from lms.djangoapps.grades.models import PersistentSubsectionGradeOverride, PersistentSubsectionGrade
class CoursePersistentGradesAdmin(KeyedConfigurationModelAdmin):
......@@ -26,6 +27,49 @@ class CoursePersistentGradesAdmin(KeyedConfigurationModelAdmin):
}),
)
class PersistentSubsectionGradeOverrideAdmin(admin.ModelAdmin):
fieldsets = (
(None, {
'fields': (
'grade',
'earned_all_override',
'earned_graded_override',
'possible_all_override',
'possible_graded_override',
),
'description': 'Enter the ID of the subsection grade you want to override. You will probably need to '
'find this in the read replica in the grades_persistentsubsectiongrade table.'
}),
)
list_display = [
'get_course_id',
'get_usage_key',
'get_user_id',
'earned_all_override',
'earned_graded_override',
'created',
'modified',
]
list_filter = ('grade__course_id', 'grade__user_id',)
raw_id_fields = ('grade',)
search_fields = ['grade__course_id', 'grade__user_id', 'grade__usage_key']
def get_course_id(self, persistent_grade):
return persistent_grade.grade.course_id
def get_usage_key(self, persistent_grade):
return persistent_grade.grade.usage_key
def get_user_id(self, persistent_grade):
return persistent_grade.grade.user_id
get_course_id.short_description = _('Course Id')
get_usage_key.short_description = _('Usage Key')
get_user_id.short_description = _('User Id')
admin.site.register(CoursePersistentGradesFlag, CoursePersistentGradesAdmin)
admin.site.register(PersistentGradesEnabledFlag, ConfigurationModelAdmin)
admin.site.register(ComputeGradesSetting, ConfigurationModelAdmin)
admin.site.register(PersistentSubsectionGradeOverride, PersistentSubsectionGradeOverrideAdmin)
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