Commit 7bea9382 by Piotr Mitros

Handling case of response not in cache explicitly

--HG--
branch : profile-cache
parent 88adbc95
......@@ -38,30 +38,28 @@ def get_grade(request, problem, cache):
## HACK: assumes max score is fixed per problem
id = problem.get('id')
correct = 0
print ",",
if id in cache:
print "In cache"
response = cache[id]
if response.grade!=None:
correct=response.grade
if id in cache and response.max_grade != None:
total = response.max_grade
else: #if id in cache and response.max_grade == None:
elif id in cache and response.max_grade == None:
total=courseware.modules.capa_module.Module(etree.tostring(problem), "id").max_score()
# response.max_grade = total
# response.save()
# else: # if id not in cache
# total=courseware.modules.capa_module.Module(etree.tostring(problem), "id").max_score()
# module = StudentModule(module_type = 'problem',
# module_id = id,
# student = request.user,
# state = None,
# grade = 0,
# max_grade = total,
# done = 'i')
# total=courseware.modules.capa_module.Module(etree.tostring(problem), "id").max_score()
# module.save()
# cache[id] = module
response.max_grade = total
response.save()
else: # if id not in cache
total=courseware.modules.capa_module.Module(etree.tostring(problem), "id").max_score()
module = StudentModule(module_type = 'problem',
module_id = id,
student = request.user,
state = None,
grade = 0,
max_grade = total,
done = 'i')
total=courseware.modules.capa_module.Module(etree.tostring(problem), "id").max_score()
module.save()
cache[id] = module
return (correct, total)
......
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