implemented multiple choice question functionality
This commit is contained in:
parent
685287c0c2
commit
a4da2240d7
4 changed files with 34 additions and 5 deletions
|
|
@ -1,8 +1,23 @@
|
|||
from django.utils import simplejson
|
||||
from dajaxice.decorators import dajaxice_register
|
||||
|
||||
@dajaxice_register
|
||||
from three_d_viewer.models import Question
|
||||
|
||||
@dajaxice_register
|
||||
def dajaxice_example(request):
|
||||
test = check_answer(request, 3, 1)
|
||||
print test
|
||||
return simplejson.dumps({'message':'Hello from Python!'})
|
||||
|
||||
@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})
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue