#ifndef FILLBLANK_H
#define FILLBLANK_H

#include <QWidget>
#include <QTimer>
#include "paperDef.h"

#include "CBaseWidget.h"
#include "CHttpBll.h"

namespace Ui {
class fillBlank;
}

class fillBlank : public CQuestionBaseWidget
{
    Q_OBJECT

public:
    explicit fillBlank(CSubQuestionStruct &sqs, QWidget *parent = nullptr);
    ~fillBlank();

    int setUI(const int nWidth);
    void handinPaper();
    void audioPlayCountChange();
    int widgetType();
signals:
    void markedItem(bool bMarked, int nOrder);
    void questionAnswered(bool bAnswered, int nOrder);
    void uploadAnswer(int nOrder, __int64 timeStamp, QString sAnswer);
private slots:
    void on_btn_mark_clicked();
    void onAnswerChanged();

    void onTimeout();
private:
    void initBody(Json::Value jBody, int nOrderIndex);
    QString generateAnswer(bool &answered);
    void updateAnswer();
    bool eventFilter(QObject *obj, QEvent *ev);
    void setMarkStyle();
    Ui::fillBlank *ui;

    CSubQuestionStruct &m_sqs;
    int m_nListHeight;
    bool b_isPressed;       

    QTimer *m_pTimer;
    bool m_bAnswerChange;
    QString m_sAnswer;
    __int64 m_nTimeStap;   
};

#endif // FILLBLANK_H
