feat: add assignment type count warning (#32068)
* feat: add assignment type count warning * style: quality
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
Common utility functions useful throughout the contentstore
|
||||
"""
|
||||
|
||||
from collections import defaultdict
|
||||
import logging
|
||||
from contextlib import contextmanager
|
||||
from datetime import datetime
|
||||
@@ -731,3 +732,24 @@ def translation_language(language):
|
||||
translation.activate(previous)
|
||||
else:
|
||||
yield
|
||||
|
||||
|
||||
def get_subsections_by_assignment_type(course_key):
|
||||
"""
|
||||
Construct a dictionary mapping each found assignment type in the course
|
||||
to a list of dictionaries with the display name of the subsection and
|
||||
the display name of the section they are in
|
||||
"""
|
||||
subsections_by_assignment_type = defaultdict(list)
|
||||
|
||||
with modulestore().bulk_operations(course_key):
|
||||
course = modulestore().get_course(course_key, depth=3)
|
||||
sections = course.get_children()
|
||||
for section in sections:
|
||||
subsections = section.get_children()
|
||||
for subsection in subsections:
|
||||
if subsection.format:
|
||||
subsections_by_assignment_type[subsection.format].append(
|
||||
f'{section.display_name} - {subsection.display_name}'
|
||||
)
|
||||
return subsections_by_assignment_type
|
||||
|
||||
@@ -100,6 +100,7 @@ from ..utils import (
|
||||
add_instructor,
|
||||
get_lms_link_for_item,
|
||||
get_proctored_exam_settings_url,
|
||||
get_subsections_by_assignment_type,
|
||||
initialize_permissions,
|
||||
remove_all_instructors,
|
||||
reverse_course_url,
|
||||
@@ -1343,6 +1344,7 @@ def grading_handler(request, course_key_string, grader_index=None):
|
||||
|
||||
if 'text/html' in request.META.get('HTTP_ACCEPT', '') and request.method == 'GET':
|
||||
course_details = CourseGradingModel.fetch(course_key)
|
||||
course_assignment_lists = get_subsections_by_assignment_type(course_key)
|
||||
return render_to_response('settings_graders.html', {
|
||||
'context_course': course_block,
|
||||
'course_locator': course_key,
|
||||
@@ -1350,6 +1352,7 @@ def grading_handler(request, course_key_string, grader_index=None):
|
||||
'grading_url': reverse_course_url('grading_handler', course_key),
|
||||
'is_credit_course': is_credit_course(course_key),
|
||||
'mfe_proctored_exam_settings_url': get_proctored_exam_settings_url(course_block.id),
|
||||
'course_assignment_lists': dict(course_assignment_lists)
|
||||
})
|
||||
elif 'application/json' in request.META.get('HTTP_ACCEPT', ''):
|
||||
if request.method == 'GET':
|
||||
|
||||
Reference in New Issue
Block a user