2013-08-17 21:12:21 +10:00
|
|
|
from django.utils import simplejson
|
|
|
|
|
from dajaxice.decorators import dajaxice_register
|
|
|
|
|
|
2013-08-24 22:12:41 +10:00
|
|
|
from three_d_viewer.models import Question
|
2013-08-17 21:12:21 +10:00
|
|
|
|
2013-08-24 22:12:41 +10:00
|
|
|
@dajaxice_register
|
2013-08-17 21:12:21 +10:00
|
|
|
def dajaxice_example(request):
|
2013-08-24 22:12:41 +10:00
|
|
|
test = check_answer(request, 3, 1)
|
|
|
|
|
print test
|
2013-08-17 21:12:21 +10:00
|
|
|
return simplejson.dumps({'message':'Hello from Python!'})
|
2013-08-24 22:12:41 +10:00
|
|
|
|
|
|
|
|
@dajaxice_register
|
|
|
|
|
def check_answer(request, answerid, questionid):
|
|
|
|
|
question = Question.objects.get(id=int(questionid))
|
|
|
|
|
|
|
|
|
|
result = False
|
|
|
|
|
for answer in question.correct_answers():
|
|
|
|
|
print type(answer.id)
|
|
|
|
|
if answer.id == int(answerid):
|
|
|
|
|
result = True
|
|
|
|
|
print simplejson.dumps({'result': result})
|
|
|
|
|
return simplejson.dumps({'result': result})
|
2013-08-17 21:12:21 +10:00
|
|
|
|