Commit e874de12 by cahrens

Some cleanup TODOs.

parent 57427f9a
......@@ -34,6 +34,7 @@ class StringyInteger(Integer):
return None
# TODO: move to fields.py and remove duplicated code.
class StringyFloat(Float):
"""
A model type that converts from string to floats when reading from json
......@@ -95,7 +96,7 @@ class CapaFields(object):
input_state = Object(help="Dictionary for maintaining the state of inputtypes", scope=Scope.user_state)
student_answers = Object(help="Dictionary with the current student responses", scope=Scope.user_state)
done = Boolean(help="Whether the student has answered the problem", scope=Scope.user_state)
display_name = String(help="Display name for this module", scope=Scope.settings)
display_name = XModule.display_name
seed = StringyInteger(help="Random seed for this student", scope=Scope.user_state)
weight = StringyFloat(help="How much to weight this problem by", scope=Scope.settings)
markdown = String(help="Markdown source of this module", scope=Scope.settings)
......
from .x_module import XModuleDescriptor, DescriptorSystem
from .modulestore.inheritance import own_metadata
from xblock.core import Scope
class MakoDescriptorSystem(DescriptorSystem):
......@@ -44,10 +46,26 @@ class MakoModuleDescriptor(XModuleDescriptor):
# cdodge: encapsulate a means to expose "editable" metadata fields (i.e. not internal system metadata)
@property
def editable_metadata_fields(self):
fields = {}
for field, value in own_metadata(self).items():
if field in self.system_metadata_fields:
# fields = {}
# for field, value in own_metadata(self).items():
# if field in self.system_metadata_fields:
# continue
#
# fields[field] = value
# return fields
inherited_metadata = getattr(self, '_inherited_metadata', {})
metadata = {}
for field in self.fields:
# Only save metadata that wasn't inherited
if field.scope != Scope.settings or field.name in self.system_metadata_fields:
continue
fields[field] = value
return fields
if field.name in self._model_data:
metadata[field.name] = self._model_data[field.name]
if field.name in inherited_metadata and self._model_data.get(field.name) == inherited_metadata.get(
field.name):
metadata[field.name] = str(metadata[field.name]) + ' INHERITED'
else:
metadata[field.name] = str(getattr(self, field.name)) + ' DEFAULT'
return metadata
......@@ -155,6 +155,7 @@ class XmlDescriptor(XModuleDescriptor):
Remove any attribute named in cls.metadata_attributes from the supplied
xml_object
"""
# TODO: change to use Fields definitions
for attr in cls.metadata_attributes:
if xml_object.get(attr) is not None:
del xml_object.attrib[attr]
......
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