Commit 196d379c by Diana Huang

Rename MilestonesTransformer.

Add comment explaining why we can't have a separate transformer.
parent 0899ac56
......@@ -7,7 +7,7 @@ from lms.djangoapps.course_blocks.transformers.hidden_content import HiddenConte
from openedx.core.djangoapps.content.block_structure.transformers import BlockStructureTransformers
from .transformers.blocks_api import BlocksAPITransformer
from .transformers.milestones import MilestonesTransformer
from .transformers.milestones import MilestonesAndSpecialExamsTransformer
from .serializers import BlockSerializer, BlockDictSerializer
......@@ -56,7 +56,7 @@ def get_blocks(
include_special_exams = True
if user is not None:
transformers += COURSE_BLOCK_ACCESS_TRANSFORMERS
transformers += [MilestonesTransformer(include_special_exams), HiddenContentTransformer()]
transformers += [MilestonesAndSpecialExamsTransformer(include_special_exams), HiddenContentTransformer()]
transformers += [
BlocksAPITransformer(
block_counts,
......
......@@ -6,7 +6,7 @@ from lms.djangoapps.course_blocks.transformers.visibility import VisibilityTrans
from .student_view import StudentViewTransformer
from .block_counts import BlockCountsTransformer
from .navigation import BlockNavigationTransformer
from .milestones import MilestonesTransformer
from .milestones import MilestonesAndSpecialExamsTransformer
class SupportedFieldType(object):
......@@ -45,7 +45,7 @@ SUPPORTED_FIELDS = [
# 'student_view_multi_device'
SupportedFieldType(StudentViewTransformer.STUDENT_VIEW_MULTI_DEVICE, StudentViewTransformer),
SupportedFieldType('special_exam_info', MilestonesTransformer),
SupportedFieldType('special_exam_info', MilestonesAndSpecialExamsTransformer),
# set the block_field_name to None so the entire data for the transformer is serialized
SupportedFieldType(None, BlockCountsTransformer, BlockCountsTransformer.BLOCK_COUNTS),
......
......@@ -17,7 +17,7 @@ from util import milestones_helpers
log = logging.getLogger(__name__)
class MilestonesTransformer(BlockStructureTransformer):
class MilestonesAndSpecialExamsTransformer(BlockStructureTransformer):
"""
A transformer that handles both milestones and special (timed) exams.
......@@ -106,6 +106,8 @@ class MilestonesTransformer(BlockStructureTransformer):
usage_info.user.id
))
# TODO: As part of a cleanup effort, this transformer should be split into
# MilestonesTransformer and SpecialExamsTransformer, which are completely independent.
def add_special_exam_info(self, block_key, block_structure, usage_info):
"""
For special exams, add the special exam information to the course blocks.
......
......@@ -12,7 +12,7 @@ from openedx.core.lib.gating import api as gating_api
from openedx.core.djangoapps.content.block_structure.transformers import BlockStructureTransformers
from student.tests.factories import CourseEnrollmentFactory
from ..milestones import MilestonesTransformer
from ..milestones import MilestonesAndSpecialExamsTransformer
from ...api import get_course_blocks
......@@ -23,7 +23,7 @@ class MilestonesTransformerTestCase(CourseStructureTestCase, MilestonesTestCaseM
"""
Test behavior of ProctoredExamTransformer
"""
TRANSFORMER_CLASS_TO_TEST = MilestonesTransformer
TRANSFORMER_CLASS_TO_TEST = MilestonesAndSpecialExamsTransformer
def setUp(self):
"""
......
......@@ -52,7 +52,7 @@ setup(
"visibility = lms.djangoapps.course_blocks.transformers.visibility:VisibilityTransformer",
"hidden_content = lms.djangoapps.course_blocks.transformers.hidden_content:HiddenContentTransformer",
"course_blocks_api = lms.djangoapps.course_api.blocks.transformers.blocks_api:BlocksAPITransformer",
"milestones = lms.djangoapps.course_api.blocks.transformers.milestones:MilestonesTransformer",
"milestones = lms.djangoapps.course_api.blocks.transformers.milestones:MilestonesAndSpecialExamsTransformer",
"grades = lms.djangoapps.grades.transformer:GradesTransformer",
],
}
......
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