20 lines
669 B
Python
20 lines
669 B
Python
from rest_framework.decorators import api_view
|
|
from rest_framework.response import Response
|
|
|
|
from vbv_lernwelt.completion.models import LearningContentCompletion
|
|
from vbv_lernwelt.learnpath.models import LearningContent
|
|
|
|
|
|
@api_view(['POST'])
|
|
def complete_learning_content(request):
|
|
learning_content_key = request.data.get('learning_content_key')
|
|
learning_content = LearningContent.objects.get(translation_key=learning_content_key)
|
|
|
|
LearningContentCompletion.objects.create(
|
|
user=request.user,
|
|
learning_content_key=learning_content_key,
|
|
circle_key=learning_content.get_parent().translation_key,
|
|
)
|
|
|
|
return Response(status=201)
|