{{ question.explanation }}
diff --git a/tkupek_elearning/elearning/views.py b/tkupek_elearning/elearning/views.py index 708f045..bdffe0e 100644 --- a/tkupek_elearning/elearning/views.py +++ b/tkupek_elearning/elearning/views.py @@ -1,8 +1,9 @@ +from django.http import HttpResponse from django.shortcuts import render_to_response -from tkupek_elearning.elearning.models import Setting, Question, Option +from tkupek_elearning.elearning.models import Setting, Question, Option, UserAnswer, User -#import pdb +import pdb def home(request): @@ -17,3 +18,29 @@ def home(request): questions_options[question] = options return render_to_response('index.html', {'settings': settings, 'questions_options': questions_options}) + + +def getAnswer(request): + + # if request.method == 'GET': + # pdb.set_trace() + # request_questionId = request.GET.get('id') + # request_answers = request.GET.get('answers') + # request_userToken = request.GET.get('user') + # + # question = Question.objects.filter(questionId=request_questionId) + # user = User.objects.filter(token=request_userToken) + # + # userAnswer = UserAnswer.objects.filter(questionId=question.id, user=user.token) + # if not userAnswer: + # userAnswer = UserAnswer() + # userAnswer.questionId = question + # userAnswer.user = user + # userAnswer.answers = "" + # userAnswer.save() + # else: + # return HttpResponse('error:alreadyAnswered'); + # + # options = Option.objects.filter(question=question.id) + # + # return HttpResponse(options) diff --git a/tkupek_elearning/urls.py b/tkupek_elearning/urls.py index ac08c56..5fd377c 100644 --- a/tkupek_elearning/urls.py +++ b/tkupek_elearning/urls.py @@ -20,5 +20,6 @@ import tkupek_elearning.elearning.views urlpatterns = [ url(r'^admin/', admin.site.urls), - url(r'start', tkupek_elearning.elearning.views.home) -] \ No newline at end of file + url(r'start', tkupek_elearning.elearning.views.home), + url(r'api', tkupek_elearning.elearning.views.getAnswer) +]