From eeaa1e04400eddbcbf881089f67e9d40ea973322 Mon Sep 17 00:00:00 2001 From: kimth Date: Fri, 3 Aug 2012 13:54:33 -0400 Subject: [PATCH] Capa util function to turn File objects in dict to filename (string) --- common/lib/capa/capa/util.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/common/lib/capa/capa/util.py b/common/lib/capa/capa/util.py index 63a5f43c03..1de69cd032 100644 --- a/common/lib/capa/capa/util.py +++ b/common/lib/capa/capa/util.py @@ -30,3 +30,14 @@ def contextualize_text(text, context): # private for key in sorted(context, lambda x, y: cmp(len(y), len(x))): text = text.replace('$' + key, str(context[key])) return text + + +def convert_files_to_filenames(answers): + ''' + Check for File objects in the dict of submitted answers, + convert File objects to their filename (string) + ''' + new_answers = dict() + for answer_id in answers.keys(): + new_answers[answer_id] = str(answers[answer_id]) + return new_answers