Files
edx-platform/djangoapps/courseware/capa/util.py
2012-03-19 11:10:44 -04:00

7 lines
298 B
Python

def contextualize_text(text, context): # private
''' Takes a string with variables. E.g. $a+$b.
Does a substitution of those variables from the context '''
for key in sorted(context, lambda x,y:cmp(len(y),len(x))):
text=text.replace('$'+key, str(context[key]))
return text