rockviewer/three_d_viewer/ajax.py

21 lines
519 B
Python
Raw Permalink Normal View History

2013-08-25 20:16:20 +10:00
"""
Handle asynchronous calls from the web pages
"""
from django.utils import simplejson
from dajaxice.decorators import dajaxice_register
2013-09-11 23:59:23 +10:00
from three_d_viewer.models import Question
2013-08-25 19:43:19 +10:00
2013-08-25 19:43:19 +10:00
@dajaxice_register
def check_answer(request, answerid, questionid):
2013-08-25 20:16:20 +10:00
"""
Check whether answerid is the correct answer for questionid.
Returns a boolean in 'result'
"""
question = Question.objects.get(id=int(questionid))
2013-08-25 21:10:22 +10:00
result = question.check_answer(answerid)
2013-08-25 20:16:20 +10:00
return simplejson.dumps({'result': result})