Files
edx-platform/courseware/capa/util.py
Piotr Mitros 18dc8cc5cb Major refactor of infrastructure for grading problems
--HG--
rename : courseware/calc.py => courseware/capa/calc.py
2012-01-10 22:04:24 -05: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