#ifndef CHOICEQUESITON_H
#define CHOICEQUESITON_H

#include <QWidget>

#include "paperDef.h"
#include "json/json.h"
#include "CBaseWidget.h"
#include "CHttpBll.h"

namespace Ui {
class choiceQuesiton;
}

class choiceQuesiton : public CQuestionBaseWidget
{
    Q_OBJECT

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

    int setUI(const int nWidth);

    void handinPaper();
    int widgetType();
    void audioPlayCountChange();
signals:
    void markedItem(bool bMarked, int nIndex);
    void questionAnswered(bool bAnswered, int nIndex);
    void uploadAnswer(int nIndex, __int64 timeStamp, QString sAnswer);
private slots:
    void onAnswerChanged(int nOrderIndex);
    void onAnswered();
    void onCancelAnswered();
    void onMutiAnswerChanged();
    void on_btn_mark_clicked();

private:
    void initBody(Json::Value jBody, int nOrderIndex);
    void initJudgeOptions();
    void initOptions(std::vector<int> voptionPermutation, std::vector<COption> vOptions, QString sQuestionType);
    void answerChange();
    void updateAnswer(QString sAnsStr, QString sAudioPalyedInfo);
    void setAnswer(QString sAnswer);
    void setMarkStyle();
    Ui::choiceQuesiton *ui;

    CSubQuestionStruct &m_sqs;
    int m_nListHeight;
    bool b_isPressed;
    QString m_sAnswerStr;
};

#endif // CHOICEQUESITON_H
