o
    mh                     @   s   d dl mZ ddlmZmZmZmZmZ G dd dejZ	G dd dejZ
G dd	 d	ejZG d
d dejZG dd dejZdS )    )serializers   )CountryCategoryQuestionAnswerUserQuizPerformanceFeedbackc                   @   s   e Zd ZG dd dZdS )CountrySerializerc                   @      e Zd ZeZg dZdS )zCountrySerializer.Meta)idname
created_atN)__name__
__module____qualname__r   modelfields r   r   )/var/www/spmcq_backend/app/serializers.pyMeta       r   N)r   r   r   r   r   r   r   r   r	      s    r	   c                   @   s<   e Zd Zejej dZe	 Z
G dd dZdd ZdS )CategorySerializer)querysetc                   @   r
   )zCategorySerializer.Meta)r   countryr   r   question_countN)r   r   r   r   r   r   r   r   r   r   r      r   r   c                 C   s
   |j  S )N)questionanswer_setcount)selfobjr   r   r   get_question_count   s   
z%CategorySerializer.get_question_countN)r   r   r   r   PrimaryKeyRelatedFieldr   objectsallr   SerializerMethodFieldr   r   r   r   r   r   r   r   
   s
    r   c                   @   s&   e Zd Ze Ze ZG dd dZdS )QuestionAnswerSerializerc                   @   r
   )zQuestionAnswerSerializer.Meta)r   r   categoryquestion_textoption_aoption_boption_coption_dcorrect_option
difficultylanguager   N)r   r   r   r   r   r   r   r   r   r   r      r   r   N)r   r   r   r	   r   r   r%   r   r   r   r   r   r$      s    r$   c                   @   s.   e Zd Ze Ze Ze Z	G dd dZ
dS )UserQuizPerformanceSerializerc                   @   s   e Zd ZeZdZg dZdS )z"UserQuizPerformanceSerializer.Meta__all__)r   quiz_attempted_at
best_score	best_timetotal_attemptsN)r   r   r   r   r   r   read_only_fieldsr   r   r   r   r   "   s    r   N)r   r   r   r   StringRelatedFielduserr	   r   r   r%   r   r   r   r   r   r.      s
    r.   c                       s*   e Zd ZG dd dZ fddZ  ZS )FeedbackSerializerc                   @   r
   )zFeedbackSerializer.Meta)r   r   r%   question
user_emaildescriptionr   N)r   r   r   r   r   r   r   r   r   r   r   (   r   r   c                    s@   t  |}t|jj|d< t|jj|d< t|jj|d< |S )Nr   r%   r8   )	superto_representationr	   r   datar   r%   r$   r8   )r   instancerepresentation	__class__r   r   r<   ,   s
   z$FeedbackSerializer.to_representation)r   r   r   r   r<   __classcell__r   r   r@   r   r7   '   s    r7   N)rest_frameworkr   modelsr   r   r   r   r   ModelSerializerr	   r   r$   r.   r7   r   r   r   r   <module>   s   
