Fix context
This commit is contained in:
parent
c1e1f38a27
commit
58908bc5c6
|
|
@ -1,5 +1,5 @@
|
|||
import math
|
||||
from typing import List
|
||||
from typing import List, Tuple
|
||||
|
||||
import graphene
|
||||
|
||||
|
|
@ -148,7 +148,7 @@ def create_record(
|
|||
user_selection_ids: List[str] | None,
|
||||
urql_id_postfix: str = "",
|
||||
context=None,
|
||||
) -> AssignmentStatisticsRecordType:
|
||||
) -> Tuple[AssignmentStatisticsRecordType, dict]:
|
||||
if not context:
|
||||
context = {}
|
||||
|
||||
|
|
@ -172,26 +172,29 @@ def create_record(
|
|||
|
||||
learning_content = course_session_assignment.learning_content
|
||||
|
||||
return AssignmentStatisticsRecordType(
|
||||
# make sure it's unique, across all types of assignments!
|
||||
_id=f"{course_session_assignment._meta.model_name}#{course_session_assignment.id}@{urql_id_postfix}",
|
||||
# noqa
|
||||
course_session_id=str(course_session_assignment.course_session.id), # noqa
|
||||
circle_id=circle_id, # noqa
|
||||
course_session_assignment_id=str(course_session_assignment.id), # noqa
|
||||
generation=course_session_assignment.course_session.generation, # noqa
|
||||
assignment_type_translation_key=due_date.assignment_type_translation_key,
|
||||
# noqa
|
||||
assignment_title=learning_content.content_assignment.title, # noqa
|
||||
metrics=get_assignment_completion_metrics( # noqa
|
||||
course_session=course_session_assignment.course_session, # noqa
|
||||
assignment=learning_content.content_assignment, # noqa
|
||||
user_selection_ids=user_selection_ids, # noqa
|
||||
urql_id_postfix=urql_id_postfix, # noqa
|
||||
context=context, # noqa
|
||||
return (
|
||||
AssignmentStatisticsRecordType(
|
||||
# make sure it's unique, across all types of assignments!
|
||||
_id=f"{course_session_assignment._meta.model_name}#{course_session_assignment.id}@{urql_id_postfix}",
|
||||
# noqa
|
||||
course_session_id=str(course_session_assignment.course_session.id), # noqa
|
||||
circle_id=circle_id, # noqa
|
||||
course_session_assignment_id=str(course_session_assignment.id), # noqa
|
||||
generation=course_session_assignment.course_session.generation, # noqa
|
||||
assignment_type_translation_key=due_date.assignment_type_translation_key,
|
||||
# noqa
|
||||
assignment_title=learning_content.content_assignment.title, # noqa
|
||||
metrics=get_assignment_completion_metrics( # noqa
|
||||
course_session=course_session_assignment.course_session, # noqa
|
||||
assignment=learning_content.content_assignment, # noqa
|
||||
user_selection_ids=user_selection_ids, # noqa
|
||||
urql_id_postfix=urql_id_postfix, # noqa
|
||||
context=context, # noqa
|
||||
),
|
||||
details_url=due_date.url_expert, # noqa
|
||||
deadline=due_date.start, # noqa
|
||||
),
|
||||
details_url=due_date.url_expert, # noqa
|
||||
deadline=due_date.start, # noqa
|
||||
context,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -204,7 +207,6 @@ def assignments(
|
|||
) -> AssignmentsStatisticsType:
|
||||
if urql_id is None:
|
||||
urql_id = str(course_id)
|
||||
|
||||
course_sessions = CourseSession.objects.filter(
|
||||
id__in=course_session_selection_ids,
|
||||
)
|
||||
|
|
@ -215,13 +217,13 @@ def assignments(
|
|||
csets = query_competence_course_session_edoniq_tests(course_sessions, circle_ids)
|
||||
|
||||
for csa in csas:
|
||||
record = create_record(
|
||||
record, context = create_record(
|
||||
csa, user_selection_ids, urql_id_postfix=urql_id, context=context
|
||||
)
|
||||
records.append(record)
|
||||
|
||||
for cset in csets:
|
||||
record = create_record(
|
||||
record, context = create_record(
|
||||
cset, user_selection_ids, urql_id_postfix=urql_id, context=context
|
||||
)
|
||||
records.append(record)
|
||||
|
|
|
|||
|
|
@ -1,13 +1,10 @@
|
|||
from typing import List, Tuple
|
||||
|
||||
import graphene
|
||||
import structlog
|
||||
from wagtail.models import Page
|
||||
|
||||
from vbv_lernwelt.course.models import CourseCompletion, CourseCompletionStatus
|
||||
|
||||
logger = structlog.get_logger(__name__)
|
||||
|
||||
|
||||
class CompetencePerformanceStatisticsSummaryType(graphene.ObjectType):
|
||||
_id = graphene.ID(required=True)
|
||||
|
|
|
|||
|
|
@ -311,8 +311,8 @@ def get_dashboard_due_dates(request):
|
|||
# Fetch future due dates in a single query using Q objects for complex filtering
|
||||
future_due_dates = DueDate.objects.filter(
|
||||
Q(course_session_id__in=course_session_ids),
|
||||
Q(end__gte=today) | Q(start__gte=today)
|
||||
).select_related('course_session')
|
||||
Q(end__gte=today) | Q(start__gte=today),
|
||||
).select_related("course_session")
|
||||
|
||||
result_due_dates = []
|
||||
course_session_map = {cs.id: cs for cs in course_sessions}
|
||||
|
|
@ -608,7 +608,7 @@ def _get_course_sessions_with_roles_for_user(
|
|||
csr
|
||||
for csr in get_course_sessions_with_roles_for_user(user)
|
||||
if any(role in allowed_roles for role in csr.roles)
|
||||
and csr.id in requested_cs_ids
|
||||
and csr.id in requested_cs_ids
|
||||
] # noqa
|
||||
|
||||
return all_cs_roles_for_user
|
||||
|
|
|
|||
Loading…
Reference in New Issue