- raise Http404
-
- ## @@ move this out of the view
- f = file(os.path.dirname(__file__) + '/fixtures/exercises.json')
- exercises = simplejson.loads(f.read())
- f.close()
-
+ return render(request, 'wtem/key_not_found.html')
+ exercises_with_answers = deepcopy(exercises)
+ if submission.answers:
+ answers = json.loads(submission.answers)
+ else:
+ answers = {}
+ for exercise in exercises_with_answers:
+ exercise['saved_answer'] = answers.get(str(exercise['id']), '')
+ if exercise['type'] == 'open' and exercise.get('fields'):
+ field_answers = {field['id']: field['text'] for field in exercise['saved_answer']}
+ for field in exercise['fields']:
+ field['saved_answer'] = field_answers.get(field['id'], '')