Commit fa3961d4 by Arthur Barrett

merged openended and advanced categories per discussion at today's standup

parent ef9f963f
...@@ -70,8 +70,7 @@ log = logging.getLogger(__name__) ...@@ -70,8 +70,7 @@ log = logging.getLogger(__name__)
COMPONENT_TYPES = ['customtag', 'discussion', 'html', 'problem', 'video'] COMPONENT_TYPES = ['customtag', 'discussion', 'html', 'problem', 'video']
ADVANCED_COMPONENT_TYPES = { ADVANCED_COMPONENT_TYPES = {
'openended' : ['combinedopenended', 'peergrading'], 'advanced' : ['annotatable','combinedopenended', 'peergrading']
'advanced' : ['annotatable'],
} }
ADVANCED_COMPONENT_POLICY_KEY = 'advanced_modules' ADVANCED_COMPONENT_POLICY_KEY = 'advanced_modules'
...@@ -293,18 +292,20 @@ def edit_unit(request, location): ...@@ -293,18 +292,20 @@ def edit_unit(request, location):
course_metadata = CourseMetadata.fetch(course.location) course_metadata = CourseMetadata.fetch(course.location)
course_advanced_keys = course_metadata.get(ADVANCED_COMPONENT_POLICY_KEY, []) course_advanced_keys = course_metadata.get(ADVANCED_COMPONENT_POLICY_KEY, [])
#First try to parse with json # check if the keys are in JSON format, or perhaps a literal python expression
try: if isinstance(course_advanced_keys, basestring):
course_advanced_keys = json.loads(course_advanced_keys) # Are you JSON?
except: try:
log.error("Cannot json decode course advanced policy: {0}".format(course_advanced_keys)) course_advanced_keys = json.loads(course_advanced_keys)
#It may be that it is not a json object, but can be evaluated as a python literal except:
try: log.error("Cannot JSON decode course advanced policy: {0}".format(course_advanced_keys))
#This is a safe evaluation. See docs for ast # Not JSON? How about Python?
course_advanced_keys = ast.literal_eval(course_advanced_keys) try:
except: #This is a safe evaluation. See docs for ast
log.error("Cannot parse course advanced policy at all: {0}".format(course_advanced_keys)) course_advanced_keys = ast.literal_eval(course_advanced_keys)
course_advanced_keys=[] except:
log.error("Cannot parse course advanced policy at all: {0}".format(course_advanced_keys))
course_advanced_keys=[]
#Set component types according to course policy file #Set component types according to course policy file
component_types = COMPONENT_TYPES component_types = COMPONENT_TYPES
......
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