from django.shortcuts import render
from rest_framework.decorators import detail_route
from rest_framework.response import Response
from rest_framework.viewsets import GenericViewSet
from rest_framework.generics import CreateAPIView

# Create your views here.
from api.serializers import ConceptSerializer
from quiz.models import *


class ConceptViewSet(GenericViewSet):

    queryset = Concept.objects.all()

    @detail_route(url_path="details")
    def details(self, request, pk):
        instance = self.get_queryset().get(pk=pk)
        return Response(ConceptSerializer(instance).data)

    @detail_route(url_path="related_quiz")
    def related_quiz(self, request, pk):
        instance = self.get_object()
        quizes = instance.questions.prefetc.all()
