12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886 |
- #include "answerWidget.h"
- #include "ui_answerWidget.h"
- #include <QScrollBar>
- #include "CAppInfo.h"
- #include "awMsgBox.h"
- #include "awQuestionNavigate.h"
- #include "CCommonTools.h"
- #include "logproc.h"
- #include "inprogressFace.h"
- #include "popMsgBox.h"
- #include "CWebsocketProc.h"
- answerWidget::answerWidget(QWidget *parent) :
- QWidget(parent),
- ui(new Ui::answerWidget)
- {
- ui->setupUi(this);
- setStyleSheet(g_appInfoPtr->m_sQssStr);
-
- m_sRemoteList
- << "teamviewer"
- << "lookmypc"
- //<< "xt"
- << "winaw32"
- << "pcaquickconnect"
- << "sessioncontroller"
- << "sunlogin";
- // << "sunloginremote";
- /* << "qq"
- <<"wechat"
- <<"wemeetapp";*/
- m_sRemoteTipList
- << "TeamViewer"
- << "LookMyPC"
- //<< QString::fromLocal8Bit("协通")
- << "Symantec PCAnywhere"
- << "Symantec PCAnywhere"
- << "Symantec PCAnywhere"
- << QString::fromLocal8Bit("向日葵");
- // << QString::fromLocal8Bit("向日葵");
- /*
- << "QQ"
- << QString::fromLocal8Bit("微信")
- << QString::fromLocal8Bit("腾讯会议");*/
- qRegisterMetaType<CGetExamById>("CGetExamById");
- connect(g_httpBllPtr.get(), &CHttpBll::sgnGetExamById, this, &answerWidget::onGetExamById);
- qRegisterMetaType<CGetExamRecordPaperStruct>("CGetExamRecordPaperStruct");
- connect(g_httpBllPtr.get(), &CHttpBll::sgnGetExamRecordPaperStruct, this, &answerWidget::onGetExamRecordPaperStruct);
- qRegisterMetaType<CGetExamProperty>("CGetExamProperty");
- connect(g_httpBllPtr.get(), &CHttpBll::sgnGetExamProperty, this, &answerWidget::onGetExamProperty);
- qRegisterMetaType<CWeiXinAnswerEnabled>("CWeiXinAnswerEnabled");
- connect(g_httpBllPtr.get(), &CHttpBll::sgnWeiXinAnswerEnabled, this, &answerWidget::onWeiXinAnswerEnabled);
- qRegisterMetaType<CGetQuestionContent>("CGetQuestionContent");
- connect(g_httpBllPtr.get(), &CHttpBll::sgnGetQuestionContent, this, &answerWidget::onGetQuestionContent);
- qRegisterMetaType<CFindExamQuestionList>("CFindExamQuestionList");
- connect(g_httpBllPtr.get(), &CHttpBll::sgnFindExamQuestionList, this, &answerWidget::onFindExamQuestionList);
- qRegisterMetaType<CStartAnswer>("CStartAnswer");
- connect(g_httpBllPtr.get(), &CHttpBll::sgnStartAnswer, this, &answerWidget::onStartAnswer);
- qRegisterMetaType<CExamHeartbeat>("CExamHeartbeat");
- connect(g_httpBllPtr.get(), &CHttpBll::sgnExamHeartbeat, this, &answerWidget::onExamHeartbeat);
- qRegisterMetaType<CSubmitQuestionAnswer>("CSubmitQuestionAnswer");
- connect(g_httpBllPtr.get(), &CHttpBll::sgnSubmitQuestionAnswer, this, &answerWidget::onSubmitQuestionAnswer);
- qRegisterMetaType<CEndExam>("CEndExam");
- connect(g_httpBllPtr.get(), &CHttpBll::sgnEndExam, this, &answerWidget::onEndExam);
- // qRegisterMetaType<CGetOrgPropertiesByGroupWithoutCache>("CGetOrgPropertiesByGroupWithoutCache");
- // connect(g_httpBllPtr.get(), &CHttpBll::sgnGetOrgPropertiesByGroupWithoutCache, this, &answerWidget::onGetOrgPropertiesByGroupWithoutCache);
- qRegisterMetaType<CStartFaceLiveVerify>("CStartFaceLiveVerify");
- connect(g_httpBllPtr.get(), &CHttpBll::sgnStartFaceLiveVerify, this, &answerWidget::onStartFaceLiveVerify);
- qRegisterMetaType<CBaseResponsePackage>("CBaseResponsePackage");
- connect(g_httpBllPtr.get(), &CHttpBll::sgnExamControlCheckTime, this, &answerWidget::onExamControlCheckTime);
-
- #ifdef _DEBUG
- //g_appInfoPtr->m_oExamInfo.bLivenessCheck = false;
- // g_appInfoPtr->m_oExamInfo.bFaceCheck = false;
- #endif // _DEBUG
- //m_MonitorEnumeratorPtr = std::make_shared<CMultiMonitorEnumerator>();
- m_nLeftSeconds = 0;
- m_nHeartBreatFailedCount = 0;
- bShowLeftHint = false;
- GetExamProperty();
- // CHttpRequestPackage hrp;
- // hrp.sUri = QString("/api/ecs_exam_work/exam/getExamPropertyFromCacheByStudentSession/%1/%2")
- // .arg(g_appInfoPtr->m_oExamInfo.nExamId).arg("SNAPSHOT_INTERVAL,PRACTICE_TYPE,FREEZE_TIME,PRACTICE_TYPE");
- // hrp.nRequestType = RequestType::rtGetExamProperty;
- // hrp.sCommonStr = "SNAPSHOT_INTERVAL,PRACTICE_TYPE,FREEZE_TIME";
- // g_httpBllPtr->get(hrp);
- // {
- // CHttpRequestPackage hrp;
- // hrp.sUri = QString("/api/ecs_exam_work/exam/%1").arg(g_appInfoPtr->m_oExamInfo.nExamId);
- // hrp.nRequestType = RequestType::rtGetExamById;
- // g_httpBllPtr->get(hrp);
- // }
- // CHttpRequestPackage hrp1;
- // hrp1.sUri = "/api/ecs_oe_student/client/exam/process/getExamRecordPaperStruct";
- // hrp1.sParamList.push_back(QString("examRecordDataId,%1").arg(g_appInfoPtr->m_oExamInfo.nExamRecordDataId));
- // hrp1.nRequestType = RequestType::rtGetExamRecordPaperStruct;
- // hrp1.eParamType = HttpParamType::hptUrl;
- // g_httpBllPtr->post(hrp1);
- // {
- // CHttpRequestPackage hrp;
- // hrp.sUri = "/api/ecs_oe_student/client/exam/process/findExamQuestionList";
- // hrp.nRequestType = RequestType::rtFindExamQuestionList;
-
- // g_httpBllPtr->post(hrp);
- // }
- // {
- // CHttpRequestPackage hrp;
- // hrp.sUri = QString("/api/ecs_exam_work/exam/weixinAnswerEnabled/%1")
- // .arg(g_appInfoPtr->m_oExamInfo.nExamId);
- // hrp.sParamList.push_back(QString::fromLocal8Bit("courseCode,%1").arg(g_appInfoPtr->m_oExamInfo.sCourseCode));
- // hrp.nRequestType = RequestType::rtWeiXinAnswerEnabled;
- // g_httpBllPtr->get(hrp);
- // }
- m_pCountDownTimer = std::make_shared<QTimer>();
- m_pCountDownTimer->setInterval(1000);
- connect(m_pCountDownTimer.get(), &QTimer::timeout, this, [&](){
- --m_nLeftSeconds;
- if(m_nLeftSeconds >= 0)
- {
- ui->label_lastTime->setText(QString("%1:%2:%3").arg(m_nLeftSeconds/60/60, 2, 10, QChar('0'))
- .arg(m_nLeftSeconds/60%60, 2, 10, QChar('0'))
- .arg(m_nLeftSeconds%60, 2, 10, QChar('0')));
- }
- if(m_nLeftSeconds <= 0)
- {
- // m_pCountDownTimer->stop();
- handinPaper();
- }
- if(m_nLeftSeconds <= 5*60 &&
- m_nLeftSeconds >= 5 * 60 - 5 &&
- !bShowLeftHint)
- {
- bShowLeftHint = true;
- if(m_ptimeLeftTips == nullptr)
- {
- m_ptimeLeftTips = std::make_shared<awTimeLeftTips>(MASK_POP_WIDGET_TYPE::wt_timeLeft, (QWidget*)(this->parent()));
- connect(m_ptimeLeftTips.get(), &awTimeLeftTips::timeLeftConfirm, this, [&](){
- m_ptimeLeftTips.reset();
- });
- }
- m_ptimeLeftTips->show();
- }
- if(g_appInfoPtr->m_oExamInfo.bLivenessCheck &&
- g_appInfoPtr->m_oExamInfo.nFaceLiveVerifyId > 0)
- {
- if(bShowLivenessTip && (m_nUsedExamSeconds + m_nEnterExamTime - m_nLeftSeconds + g_appInfoPtr->m_oExamInfo.nActionAlert) > g_appInfoPtr->m_oExamInfo.nFaceVerifyDoMinute*60)
- {
- bShowLivenessTip = false;
- m_nEnterLivenessFaceSeconds = m_nLeftSeconds - 20;
- ShowMsg(QString::fromLocal8Bit("%1秒后开始指定动作检测,请准备!").arg(g_appInfoPtr->m_oExamInfo.nActionAlert), g_appInfoPtr->m_pAnsBgWidget);
- }
- if((m_nUsedExamSeconds + m_nEnterExamTime - m_nLeftSeconds) > g_appInfoPtr->m_oExamInfo.nFaceVerifyDoMinute * 60
- && m_nEnterLivenessFaceSeconds > m_nLeftSeconds)
- {
- //活体检测
- if(m_pFaceLiveness == nullptr)
- {
- stopCapture();
- m_pFaceLiveness = std::make_shared<faceLiveness>(FACE_LIVENESS_TYPE::flt_inprogress, g_appInfoPtr->m_pAnsBgWidget);
- connect(m_pFaceLiveness.get(), &faceLiveness::faceLivenessFaild, this, [&](){
- g_appInfoPtr->m_oExamInfo.nFaceLiveVerifyId = 0;
- m_pFaceLiveness.reset();
- if(g_appInfoPtr->m_bInprogressFaceLivenessFailedForceExit)
- {
- if(g_appInfoPtr->m_oExamInfo.nFaceVerifyTimes < 2)
- {
- emit gobackLogin();
- }
- else
- {
- //交卷
- handinPaper(true);
- }
- }
- else if (g_appInfoPtr->m_oExamInfo.bFaceCheck)
- {
- startCapture();
- }
- });
- connect(m_pFaceLiveness.get(), &faceLiveness::faceLivenessSucceed, this, [&](){
- g_appInfoPtr->m_oExamInfo.nFaceLiveVerifyId = 0;
- m_pFaceLiveness.reset();
- if (g_appInfoPtr->m_oExamInfo.bFaceCheck)
- {
- startCapture();
- }
- });
- m_pFaceLiveness->show();
- }
- }
- }
- });
- if (g_appInfoPtr->m_bDisableRemoteAssistance)
- {
- qRegisterMetaType<CGetSoftwareConfig>("CGetSoftwareConfig");
- connect(g_httpBllPtr.get(), &CHttpBll::sgnGetSoftwareConfig, this, &answerWidget::onGetSoftwareConfig);
- CHttpRequestPackage hrp;
- hrp.sUri = QString("https://%1/oe_client/software.json").arg(g_appInfoPtr->m_sEscDomain);
- hrp.nRequestType = RequestType::rtGetSoftwareConfig;
- g_httpBllPtr->getUrl(hrp);
- }
- m_pHeartbeatTimer = std::make_shared<QTimer>();
- m_pHeartbeatTimer->setInterval(60*1000);
- connect(m_pHeartbeatTimer.get(), &QTimer::timeout, this, [&](){
- heartBreat();
- if(g_appInfoPtr->m_bDisableRemoteAssistance)
- {
- checkRemoteBreach();
- }
-
- });
- }
- answerWidget::~answerWidget()
- {
- if (g_websocketPtr != nullptr)
- {
- g_websocketPtr->close();
- }
- awMsgBox::clear(this);
- if (g_inProcessFace)
- {
- stopCapture();
- g_inProcessFace.reset();
- }
- delete ui;
- }
- void answerWidget::GetExamProperty()
- {
- CHttpRequestPackage hrp;
- hrp.sUri = QString("/api/ecs_exam_work/exam/getExamPropertyFromCacheByStudentSession/%1/%2")
- .arg(g_appInfoPtr->m_oExamInfo.nExamId).arg("SNAPSHOT_INTERVAL,PRACTICE_TYPE,FREEZE_TIME,SHOW_MULTIPLE_CHOICE_WARNING");
- hrp.nRequestType = RequestType::rtGetExamProperty;
- hrp.sCommonStr = "SNAPSHOT_INTERVAL,PRACTICE_TYPE,FREEZE_TIME,SHOW_MULTIPLE_CHOICE_WARNING";
- g_httpBllPtr->get(hrp);
- }
- void answerWidget::GetExamById()
- {
- CHttpRequestPackage hrp;
- hrp.sUri = QString("/api/ecs_exam_work/exam/%1").arg(g_appInfoPtr->m_oExamInfo.nExamId);
- hrp.nRequestType = RequestType::rtGetExamById;
- g_httpBllPtr->get(hrp);
- }
- void answerWidget::GetExamRecordPaperStruct()
- {
- CHttpRequestPackage hrp1;
- hrp1.sUri = "/api/ecs_oe_student/client/exam/process/getExamRecordPaperStruct";
- hrp1.sParamList.push_back(QString("examRecordDataId,%1").arg(g_appInfoPtr->m_oExamInfo.nExamRecordDataId));
- hrp1.nRequestType = RequestType::rtGetExamRecordPaperStruct;
- hrp1.eParamType = HttpParamType::hptUrl;
- g_httpBllPtr->post(hrp1);
- }
- void answerWidget::FindExamQuestionList()
- {
- CHttpRequestPackage hrp;
- hrp.sUri = "/api/ecs_oe_student/client/exam/process/findExamQuestionList";
- hrp.nRequestType = RequestType::rtFindExamQuestionList;
- g_httpBllPtr->post(hrp);
- }
- void answerWidget::WeiXinAnswerEnabled()
- {
- CHttpRequestPackage hrp;
- hrp.sUri = QString("/api/ecs_exam_work/exam/weixinAnswerEnabled/%1")
- .arg(g_appInfoPtr->m_oExamInfo.nExamId);
- hrp.sParamList.push_back(QString::fromLocal8Bit("courseCode,%1").arg(g_appInfoPtr->m_oExamInfo.sCourseCode));
- hrp.nRequestType = RequestType::rtWeiXinAnswerEnabled;
- g_httpBllPtr->get(hrp);
- }
- void answerWidget::onGetSoftwareConfig(CGetSoftwareConfig getSoftwareConfig)
- {
- if (getSoftwareConfig.nCode == 200)
- {
- QString sSoftwareConfig = QByteArray::fromBase64(getSoftwareConfig.sSoftwareConfig.toLocal8Bit());
- if(!sSoftwareConfig.isEmpty())
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (reader.parse(sSoftwareConfig.toStdString(), jsonRoot))
- {
- QString sCamera = jsonRoot["vCamList"].asString().c_str();
- QStringList cameraList = sCamera.split("\n", QString::SkipEmptyParts);
- QString sRemoteApp = jsonRoot["remoteApp"].asString().c_str();
- QStringList remoteAppList = sRemoteApp.split("\n", QString::SkipEmptyParts);
- // m_sRemoteList += remoteAppList;
- // m_sRemoteTipList += remoteAppList;
- for(QString remoteApp : remoteAppList)
- {
- QString remoteAppProcess = remoteApp.left(remoteApp.indexOf("@@@"));
- QString remoteAppName = remoteApp.right(remoteApp.length() - remoteApp.indexOf("@@@") - 3);
- m_sRemoteList<<remoteAppProcess;
- m_sRemoteTipList<<remoteAppName;
- }
- }
- }
- }
- }
- void answerWidget::checkRemoteBreach()
- {
-
- static int nIndex = 0;
- ++nIndex;
- if(nIndex % 3 == 0)
- {
- std::shared_ptr<CMultiMonitorEnumerator> m_MonitorEnumeratorPtr = std::make_shared<CMultiMonitorEnumerator>();
- bool bExit = false;
- QString sCheckStr = "";
- if (CCommonTools::isUseRDP())
- {
- sCheckStr = QString::fromLocal8Bit("检测是否开启远程桌面");
- qDebug() << QString::fromLocal8Bit("开启远程桌面");
- bExit = true;
- }
-
- if (m_MonitorEnumeratorPtr->getMontorNumber() > 1)
- {
- sCheckStr = QString::fromLocal8Bit("请检测是否开启分屏");
- qDebug() << QString::fromLocal8Bit("开启双屏");
- bExit = true;
- }
- if(g_appInfoPtr->m_bInprogressCheckRemoteAssistance)
- {
- QStringList appList;
- CCommonTools::getAllAppNameList(appList, m_sRemoteList, m_sRemoteTipList);
- if (appList.count() > 0)
- {
- bExit = true;
- for (int i = 0; i < appList.count(); i++)
- {
- if (sCheckStr.isEmpty())
- {
- sCheckStr = QString::fromLocal8Bit("请检测是否开启%1").arg(appList[i]);
- }
- else
- {
- sCheckStr += QString::fromLocal8Bit("、%1").arg(appList[i]);
- }
- }
- }
- }
- QApplication::processEvents();
- if (bExit)
- {
- //退出
- awTimeLeftTips *wExitExam = new awTimeLeftTips(MASK_POP_WIDGET_TYPE::wt_exitExam, (QWidget*)(this->parent()));
- wExitExam->setText(sCheckStr, QString::fromLocal8Bit("退出考试"));
- connect(wExitExam, &awTimeLeftTips::timeLeftConfirm, this, [this, wExitExam]() {
- if (m_pNetWorkErrorTimerPtr)
- {
- m_pNetWorkErrorTimerPtr->stop();
- }
- delete wExitExam;
- emit gobackLogin();
- });
- wExitExam->show();
- if (m_pNetWorkErrorTimerPtr == nullptr)
- {
- m_pNetWorkErrorTimerPtr = std::make_shared<QTimer>();
- m_pNetWorkErrorTimerPtr->setInterval(30 * 1000);
- connect(m_pNetWorkErrorTimerPtr.get(), &QTimer::timeout, [this, wExitExam]() {
- m_pNetWorkErrorTimerPtr->stop();
- delete wExitExam;
- emit gobackLogin();
- });
- }
- m_pNetWorkErrorTimerPtr->start();
- }
- }
- }
- void answerWidget::setUI(const int nLeft, const int nTop, const int nWidth, const int nHeight)
- {
- setGeometry(nLeft, nTop, nWidth, nHeight);
- ui->widget_aw_answerBG->setGeometry(0, 0, width()*970/(970+270), height());
- ui->widget_navigate->setGeometry(ui->widget_aw_answerBG->x() + ui->widget_aw_answerBG->width() + g_appInfoPtr->m_fRate*20, 0,
- width() - ui->widget_aw_answerBG->width() - g_appInfoPtr->m_fRate*20, height());
- ui->widget_aw_face->setGeometry(0, ui->widget_navigate->height() - g_appInfoPtr->m_fRate*140, ui->widget_navigate->width(), g_appInfoPtr->m_fRate*140);
- ui->widget_aw_top->setGeometry(0, 0, ui->widget_aw_answerBG->width(), g_appInfoPtr->m_fRate*56);
- ui->widget_ng_top->setGeometry(0, 0, ui->widget_navigate->width(), g_appInfoPtr->m_fRate*56);
- ui->label_answerProgress->adjustSize();
- ui->label_answerProgress->setGeometry(g_appInfoPtr->m_fRate*20, (ui->widget_aw_top->height() - ui->label_answerProgress->height())/2,
- ui->label_answerProgress->width(), ui->label_answerProgress->height());
- ui->pgb_answerProgress->setGeometry(ui->label_answerProgress->x() + ui->label_answerProgress->width() + g_appInfoPtr->m_fRate*8,
- (ui->widget_aw_top->height() - g_appInfoPtr->m_fRate*20)/2,
- g_appInfoPtr->m_fRate*200, g_appInfoPtr->m_fRate*20);
- ui->btn_handInPaper->setGeometry(ui->widget_aw_top->width() - g_appInfoPtr->m_fRate*(10 + 100), g_appInfoPtr->m_fRate*10,
- g_appInfoPtr->m_fRate*100, g_appInfoPtr->m_fRate*36);
- ui->label_lastTimeIcon->setGeometry(g_appInfoPtr->m_fRate*48, g_appInfoPtr->m_fRate*12, g_appInfoPtr->m_fRate*32, g_appInfoPtr->m_fRate*32);
- ui->label_lastTime->adjustSize();
- ui->label_lastTime->setGeometry(ui->label_lastTimeIcon->x() + ui->label_lastTimeIcon->width() + g_appInfoPtr->m_fRate*10,
- ui->label_lastTimeIcon->y() + (ui->label_lastTimeIcon->height() - ui->label_lastTime->height())/2,
- ui->label_lastTime->width(), ui->label_lastTime->height());
- ui->btn_all->setGeometry(g_appInfoPtr->m_fRate*30, ui->widget_ng_top->height() + g_appInfoPtr->m_fRate*20,
- g_appInfoPtr->m_fRate*90, g_appInfoPtr->m_fRate*28);
- ui->btn_allNum->setGeometry(ui->btn_all->x() + ui->btn_all->width() - g_appInfoPtr->m_fRate*(4 + 30), ui->btn_all->y() + (ui->btn_all->height() - g_appInfoPtr->m_fRate*20)/2,
- g_appInfoPtr->m_fRate*30, g_appInfoPtr->m_fRate*20);
- ui->btn_answered->setGeometry(ui->btn_all->x() + ui->btn_all->width() + g_appInfoPtr->m_fRate*10,
- ui->btn_all->y(), ui->btn_all->width(), ui->btn_all->height());
- ui->btn_answeredNum->setGeometry(ui->btn_answered->x() + ui->btn_answered->width() - g_appInfoPtr->m_fRate*(4 + 30), ui->btn_allNum->y(),
- ui->btn_allNum->width(), ui->btn_allNum->height());
- ui->btn_unanswered->setGeometry(ui->btn_all->x(), ui->btn_all->y() + ui->btn_all->height() + g_appInfoPtr->m_fRate*10,
- ui->btn_all->width(), ui->btn_all->height());
- ui->btn_unansweredNum->setGeometry(ui->btn_allNum->x(), ui->btn_unanswered->y() + (ui->btn_unanswered->height() - g_appInfoPtr->m_fRate*20)/2,
- ui->btn_allNum->width(), ui->btn_allNum->height());
- ui->btn_marked->setGeometry(ui->btn_answered->x(), ui->btn_unanswered->y(), ui->btn_all->width(), ui->btn_all->height());
- ui->btn_markedNum->setGeometry(ui->btn_answeredNum->x(), ui->btn_unansweredNum->y(), ui->btn_allNum->width(), ui->btn_allNum->height());
- ui->label_HLine->setGeometry(ui->btn_all->x(), ui->btn_unanswered->y() + ui->btn_unanswered->height() + g_appInfoPtr->m_fRate*20,
- ui->widget_navigate->width() - ui->btn_all->x()*2, g_appInfoPtr->m_fRate*1 < 1 ? 1 : g_appInfoPtr->m_fRate*1);
- ui->lw_aw_questionList->setGeometry(0, ui->label_HLine->y(), ui->widget_navigate->width(),
- ui->widget_aw_face->y() - ui->label_HLine->y() - ui->label_HLine->height());
- ui->lw_aw_questionList->setVerticalScrollMode(QListWidget::ScrollPerPixel);
- ui->lw_aw_questionList->verticalScrollBar()->setSingleStep(5);
- }
- void answerWidget::onGetExamById(CGetExamById getExamById)
- {
- if (getExamById.nCode == 200)
- {
- m_nRetryCount = 0;
- g_appInfoPtr->m_oExamInfo.nExamId = getExamById.nId;
- g_appInfoPtr->m_oExamInfo.sExamType = getExamById.sExamType;
- g_appInfoPtr->m_oExamInfo.nDuration = getExamById.nDuration;
- GetExamRecordPaperStruct();
- }
- else
- {
- // if(getExamById.sMessage.isEmpty())
- // {
- // ShowMsg(QString::fromLocal8Bit("获取考试信息出错"), g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
- // }
- // else
- // {
- // ShowMsg(getExamById.sMessage, g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
- // }
- if(++m_nRetryCount > 3)
- {
- //退出
- exitExamTip();
- }
- else
- {
- GetExamById();
- }
- }
- }
- void answerWidget::onGetExamRecordPaperStruct(CGetExamRecordPaperStruct getExamRecordPaperStruct)
- {
- if (getExamRecordPaperStruct.nCode == 200)
- {
- m_nRetryCount = 0;
- m_vPaperGroupStruct.swap(getExamRecordPaperStruct.vPaperGroupStruct);
- int nSize = m_vPaperGroupStruct.size();
- QString sQuestionId = "";
- for (int i = 0; i < nSize; ++i)
- {
- CPaperGroupStruct &pgs = m_vPaperGroupStruct[i];
- awQuestionNavigate *questionItem = new awQuestionNavigate(pgs);
- connect(questionItem, &awQuestionNavigate::showSubQuestion, this, [&](QString sQuestionId, int nOrder, bool bHasContent) {
- showQuestionByOrder(nOrder);
- /*if (bHasContent)
- {
- for (CQuestionStruct &qs : pgs.vQuestionStruct)
- {
- if (qs.sQuestionId == sQuestionId)
- {
- QString sGroupTitleText = QString::fromLocal8Bit("%1、%2 (共%3题)").arg(CCommonTools::Arab2Sinogram(pgs.nNumber)).arg(pgs.sGroupName).arg(pgs.nTotalSubquestion);
- QString sGroupProgressText = QString::fromLocal8Bit("完成进度(%1/%2)").arg(pgs.nAnsweredCount).arg(pgs.nTotalSubquestion);
- showSubQuestion(qs, nOrder, sGroupTitleText, sGroupProgressText);
- }
- }
- }
- else
- {
- getQuestionContent(sQuestionId, nOrder);
- }
- */
- });
- QListWidgetItem *pItem = new QListWidgetItem;
- ui->lw_aw_questionList->addItem(pItem);
- ui->lw_aw_questionList->setItemWidget(pItem, questionItem);
- int nHeight = questionItem->setUI(ui->lw_aw_questionList->width() - g_appInfoPtr->m_fRate*60);
- QSize size = pItem->sizeHint();
- size.setHeight(nHeight);
- pItem->setSizeHint(size);
- }
- WeiXinAnswerEnabled();
- }
- else
- {
- // if(getExamRecordPaperStruct.sMessage.isEmpty())
- // {
- // ShowMsg(QString::fromLocal8Bit("获取考试结构出错"), g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
- // }
- // else
- // {
- // ShowMsg(getExamRecordPaperStruct.sMessage, g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
- // }
- if(++m_nRetryCount > 3)
- {
- //退出
- exitExamTip();
- }
- else
- {
- GetExamRecordPaperStruct();
- }
- }
- }
- CAnsweredQuestion answerWidget::findQuestionByOrder(CFindExamQuestionList &feql, int nOrder)
- {
- for (int i = 0; i < feql.vAnsweredQuestion.size(); ++i)
- {
- if (feql.vAnsweredQuestion[i].nOrder == nOrder)
- {
- return feql.vAnsweredQuestion[i];
- }
- }
- }
- void answerWidget::onFindExamQuestionList(CFindExamQuestionList findExamQuestionList)
- {
- if (findExamQuestionList.nCode == 200)
- {
- m_nRetryCount = 0;
- int nTotal = 0;
- int nAnswered = 0;
- int nMarked = 0;
- int nSize = m_vPaperGroupStruct.size();
- for (int i = 0; i < nSize; ++i)
- {
- int nQuestionSize = m_vPaperGroupStruct[i].vQuestionStruct.size();
- for (int j = 0; j < nQuestionSize; ++j)
- {
- int nSubQuestionSize = m_vPaperGroupStruct[i].vQuestionStruct[j].vSubQuestionStruct.size();
- for (int k = 0; k < nSubQuestionSize; ++k)
- {
- nTotal++;
- int nOrder = m_vPaperGroupStruct[i].vQuestionStruct[j].vSubQuestionStruct[k].nOrder;
-
- CAnsweredQuestion aq= findQuestionByOrder(findExamQuestionList, nOrder);
- m_vPaperGroupStruct[i].vQuestionStruct[j].vSubQuestionStruct[k].bAnswered = aq.bIsAnswer;
- m_vPaperGroupStruct[i].vQuestionStruct[j].vSubQuestionStruct[k].bMarked = aq.bIsSign;
- m_vPaperGroupStruct[i].vQuestionStruct[j].vSubQuestionStruct[k].sStudentAnswer = aq.sStudentAnswer;
- if(!aq.sStudentAnswer.isEmpty() && (aq.sQuestionType == QUESTION_TYPE::SingleChoice ||
- aq.sQuestionType == QUESTION_TYPE::MultipleChoice ||
- aq.sQuestionType == QUESTION_TYPE::TrueOrFalse))
- {
- Json::Reader reader;
- Json::Value jAnswer = Json::Value::null;
- if (!reader.parse(aq.sStudentAnswer.toStdString(), jAnswer))
- {
- // ShowMsg(QString::fromLocal8Bit("解析题干出错!"), g_appInfoPtr->m_answerWidget);
- myDebug() << QString::fromLocal8Bit("解析答案出错!");
- }
- QString sAnswer = "";
- int nSize = jAnswer["sections"].size();
- for(int i = 0; i < nSize; ++i)
- {
- int bSize = jAnswer["sections"][i]["blocks"].size();
- for(int j = 0; j < bSize; ++j)
- {
- if(jAnswer["sections"][i]["blocks"][j]["type"] == "text")
- {
- sAnswer += jAnswer["sections"][i]["blocks"][j]["value"].asString().c_str();
- }
- }
- }
- m_vPaperGroupStruct[i].vQuestionStruct[j].vSubQuestionStruct[k].sStudentAnswer = sAnswer;
- }
- if (aq.bIsAnswer)
- {
- nAnswered++;
- }
- if (aq.bIsSign)
- {
- nMarked++;
- }
- if (!aq.sAudioPlayTimes.isEmpty())
- {
- Json::Reader reader;
- Json::Value jAudioPlayTimes = Json::Value::null;
- if (reader.parse(aq.sAudioPlayTimes.toStdString(), jAudioPlayTimes))
- {
- for (int ja = 0; ja < jAudioPlayTimes.size(); ++ja)
- {
- Json::Value jAudioPlayItem = jAudioPlayTimes[ja];
- g_appInfoPtr->m_jAudioPlayedCount[jAudioPlayItem["name"].asString()] = jAudioPlayItem["times"].asInt();
- }
- }
- }
- }
- }
- }
- showQuestionByOrder(1);
- on_btn_all_clicked();
- ui->btn_allNum->setText(QString::number(nTotal));
- ui->btn_answeredNum->setText(QString::number(nAnswered));
- ui->btn_markedNum->setText(QString::number(nMarked));
- ui->btn_unansweredNum->setText(QString::number(nTotal - nAnswered));
- ui->pgb_answerProgress->setMaximum(nTotal);
- ui->pgb_answerProgress->setValue(nAnswered);
- refreshStatus();
- //开始答题
- startAnwer();
- }
- else
- {
- // if(findExamQuestionList.sMessage.isEmpty())
- // {
- // ShowMsg(QString::fromLocal8Bit("获取题目信息出错"), g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
- // }
- // else
- // {
- // ShowMsg(findExamQuestionList.sMessage, g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
- // }
- if(++m_nRetryCount > 3)
- {
- //退出
- exitExamTip();
- }
- else
- {
- FindExamQuestionList();
- }
- }
- }
- void answerWidget::startAnwer()
- {
- CHttpRequestPackage hrp1;
- hrp1.sUri = "/api/ecs_oe_student/client/exam/process/startAnswer";
- hrp1.sParamList.push_back(QString("examRecordDataId,%1").arg(g_appInfoPtr->m_oExamInfo.nExamRecordDataId));
- hrp1.nRequestType = RequestType::rtStartAnswer;
- hrp1.eParamType = HttpParamType::hptUrl;
- g_httpBllPtr->post(hrp1);
- }
- void answerWidget::onGetExamProperty(CGetExamProperty getExamProperty)
- {
- if (getExamProperty.nCode == 200)
- {
- m_nRetryCount = 0;
- if (getExamProperty.sType == "SNAPSHOT_INTERVAL,PRACTICE_TYPE,FREEZE_TIME,SHOW_MULTIPLE_CHOICE_WARNING")
- {
- m_nSnapshotInterval = getExamProperty.nSnapshotInterval;
- g_appInfoPtr->m_oExamInfo.sPracticeType = getExamProperty.sPracticeType;
- m_nFreezeTime = getExamProperty.nFreezeTime;
- g_appInfoPtr->m_bMutipleAnserCountTips = getExamProperty.bMutipleAnserCountTips;
- }
- GetExamById();
- }
- else
- {
- // if(getExamProperty.sMessage.isEmpty())
- // {
- // ShowMsg(QString::fromLocal8Bit("获取考试信息出错"), g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
- // }
- // else
- // {
- // ShowMsg(getExamProperty.sMessage, g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
- // }
- if(++m_nRetryCount > 3)
- {
- //退出
- exitExamTip();
- }
- else
- {
- GetExamProperty();
- }
- }
- }
- void answerWidget::onWeiXinAnswerEnabled(CWeiXinAnswerEnabled weiXinAnswerEnabled)
- {
- if (weiXinAnswerEnabled.nCode == 200)
- {
- m_nRetryCount = 0;
- g_appInfoPtr->m_bWeiXinAnswerEnabled = weiXinAnswerEnabled.bEnabled;
- FindExamQuestionList();
- }
- else
- {
- // if(weiXinAnswerEnabled.sMessage.isEmpty())
- // {
- // ShowMsg(QString::fromLocal8Bit("获取考试信息失败"), g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
- // }
- // else
- // {
- // ShowMsg(weiXinAnswerEnabled.sMessage, g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
- // }
- if(++m_nRetryCount > 3)
- {
- //退出
- exitExamTip();
- }
- else
- {
- WeiXinAnswerEnabled();
- }
- }
- }
- void answerWidget::showSubQuestion(CQuestionStruct &qs, int nOrder, QString sTitle, QString sProgress)
- {
- if (qs.sBody.isEmpty())
- {
- if (m_pQuestion != nullptr)
- {
- m_pQuestion.reset();
- }
- if (m_pQuestionSet != nullptr)
- {
- m_pQuestionSet.reset();
- }
- m_pQuestion = std::make_shared<question>(qs, nOrder, ui->btn_allNum->text().toInt(), ui->widget_aw_answerBG);
- connect(m_pQuestion.get(), &question::uploadAnswer, this, [&](int nIndex, __int64 timeStamp, QString sAnswer){
- uploadAnswer(nIndex, sAnswer);
- });
- connect(m_pQuestion.get(), &question::questionAnswered, this, [&](bool bAnswered, int nIndex){
- refreshStatus();
- int nSize = m_vPaperGroupStruct.size();
- for (int i = 0; i < nSize; ++i)
- {
- int nQuestionSize = m_vPaperGroupStruct[i].vQuestionStruct.size();
- for (int j = 0; j < nQuestionSize; ++j)
- {
- int nSubQuestionSize = m_vPaperGroupStruct[i].vQuestionStruct[j].vSubQuestionStruct.size();
- for (int k = 0; k < nSubQuestionSize; ++k)
- {
- CSubQuestionStruct sqs = m_vPaperGroupStruct[i].vQuestionStruct[j].vSubQuestionStruct[k];
- if(sqs.nOrder == nIndex)
- {
- QString sGroupProgressText = QString::fromLocal8Bit("完成进度(%1/%2)").arg(m_vPaperGroupStruct[i].nAnsweredCount).arg(m_vPaperGroupStruct[i].nTotalSubquestion);
- m_pQuestion->setGroupInfo("", sGroupProgressText);
- break;
- }
- }
- }
- }
- });
- connect(m_pQuestion.get(), &question::markedItem, this, [&](bool bMarked, int nIndex){
- refreshStatus();
- });
- connect(m_pQuestion.get(), &question::previousQuestion, this, [&](int nOrder){
- if(nOrder > 1)
- {
- showQuestionByOrder(nOrder - 1);
- }
- });
- connect(m_pQuestion.get(), &question::nextQuestion, this, [&](int nOrder){
- showQuestionByOrder(nOrder + 1);
- });
- m_pQuestion->setGroupInfo(sTitle, sProgress);
- m_pQuestion->setUI(0, g_appInfoPtr->m_fRate * 86,
- ui->widget_aw_answerBG->width(), ui->widget_aw_answerBG->height() - g_appInfoPtr->m_fRate * (86 + 20));
- m_pQuestion->show();
- }
- else
- {
- if (m_pQuestion != nullptr)
- {
- m_pQuestion.reset();
- }
- if (m_pQuestionSet != nullptr)
- {
- m_pQuestionSet.reset();
- }
- m_pQuestionSet = std::make_shared<questionSet>(qs, nOrder, ui->btn_allNum->text().toInt(), ui->widget_aw_answerBG);
- connect(m_pQuestionSet.get(), &questionSet::uploadAnswer, this, [&](int nIndex, __int64 timeStamp, QString sAnswer){
- uploadAnswer(nIndex, sAnswer);
- });
- connect(m_pQuestionSet.get(), &questionSet::questionAnswered, this, [&](bool bAnswered, int nIndex){
- refreshStatus();
- int nSize = m_vPaperGroupStruct.size();
- for (int i = 0; i < nSize; ++i)
- {
- int nQuestionSize = m_vPaperGroupStruct[i].vQuestionStruct.size();
- for (int j = 0; j < nQuestionSize; ++j)
- {
- int nSubQuestionSize = m_vPaperGroupStruct[i].vQuestionStruct[j].vSubQuestionStruct.size();
- for (int k = 0; k < nSubQuestionSize; ++k)
- {
- CSubQuestionStruct sqs = m_vPaperGroupStruct[i].vQuestionStruct[j].vSubQuestionStruct[k];
- if(sqs.nOrder == nIndex)
- {
- QString sGroupProgressText = QString::fromLocal8Bit("完成进度(%1/%2)").arg(m_vPaperGroupStruct[i].nAnsweredCount).arg(m_vPaperGroupStruct[i].nTotalSubquestion);
- m_pQuestionSet->setGroupInfo("", sGroupProgressText);
- break;
- }
- }
- }
- }
- });
- connect(m_pQuestionSet.get(), &questionSet::markedItem, this, [&](bool bMarked, int nIndex){
- refreshStatus();
- });
- connect(m_pQuestionSet.get(), &questionSet::previousQuestion, this, [&](int nOrder){
- if(nOrder > 1)
- {
- showQuestionByOrder(nOrder - 1);
- }
- });
- connect(m_pQuestionSet.get(), &questionSet::nextQuestion, this, [&](int nOrder){
- showQuestionByOrder(nOrder + 1);
- });
- m_pQuestionSet->setGroupInfo(sTitle, sProgress);
- m_pQuestionSet->setUI(0, g_appInfoPtr->m_fRate * 86,
- ui->widget_aw_answerBG->width(), ui->widget_aw_answerBG->height() - g_appInfoPtr->m_fRate * (86 + 20));
- m_pQuestionSet->show();
- }
- }
- void answerWidget::refreshStatus()
- {
- int nCount = ui->lw_aw_questionList->count();
- for(int i = 0; i < nCount; ++i)
- {
- awQuestionNavigate *questionItem = dynamic_cast<awQuestionNavigate*>(ui->lw_aw_questionList->itemWidget(ui->lw_aw_questionList->item(i)));
- if(questionItem)
- {
- questionItem->refreshStatus();
- }
- }
- int nTotal = 0;
- int nAnswered = 0;
- int nMarked = 0;
- int nSize = m_vPaperGroupStruct.size();
- for (int i = 0; i < nSize; ++i)
- {
- int nQuestionSize = m_vPaperGroupStruct[i].vQuestionStruct.size();
- int nAnswerCount = 0;
- for (int j = 0; j < nQuestionSize; ++j)
- {
- int nSubQuestionSize = m_vPaperGroupStruct[i].vQuestionStruct[j].vSubQuestionStruct.size();
- for (int k = 0; k < nSubQuestionSize; ++k)
- {
- CSubQuestionStruct sqs = m_vPaperGroupStruct[i].vQuestionStruct[j].vSubQuestionStruct[k];
- nTotal++;
- if (sqs.bAnswered)
- {
- nAnswerCount++;
- nAnswered++;
- }
- if (sqs.bMarked)
- {
- nMarked++;
- }
- }
- }
- m_vPaperGroupStruct[i].nAnsweredCount = nAnswerCount;
- }
- ui->btn_allNum->setText(QString::number(nTotal));
- ui->btn_answeredNum->setText(QString::number(nAnswered));
- ui->btn_markedNum->setText(QString::number(nMarked));
- ui->btn_unansweredNum->setText(QString::number(nTotal - nAnswered));
- ui->pgb_answerProgress->setMaximum(nTotal);
- ui->pgb_answerProgress->setValue(nAnswered);
- }
- void answerWidget::showQuestionByOrder(int nOrder)
- {
- int nSize = m_vPaperGroupStruct.size();
- if(g_appInfoPtr->m_bMutipleAnserCountTips)
- {
- for (int i = 0; i < nSize; ++i)
- {
- int nQuestionSize = m_vPaperGroupStruct[i].vQuestionStruct.size();
- for (int j = 0; j < nQuestionSize; ++j)
- {
- int nSubQuestionSize = m_vPaperGroupStruct[i].vQuestionStruct[j].vSubQuestionStruct.size();
- for (int k = 0; k < nSubQuestionSize; ++k)
- {
- CSubQuestionStruct sqs = m_vPaperGroupStruct[i].vQuestionStruct[j].vSubQuestionStruct[k];
- int n = sqs.sStudentAnswer.length();
- if (sqs.bCurrent && sqs.sQuestionType == QUESTION_TYPE::MultipleChoice && sqs.sStudentAnswer.length() < 2 && sqs.sStudentAnswer.length() > 0)
- {
- if(popMsg(QString::fromLocal8Bit("当前多选题所选答案不足2个,是否确认跳过?"), QString::fromLocal8Bit("系统提示"), this,
- QString::fromLocal8Bit("跳过此题"), QString::fromLocal8Bit("继续作答")) != QDialog::Accepted)
- {
- QString sGroupTitleText = QString::fromLocal8Bit("%1、%2 (共%3题)").arg(CCommonTools::Arab2Sinogram(m_vPaperGroupStruct[i].nNumber)).arg(m_vPaperGroupStruct[i].sGroupName).arg(m_vPaperGroupStruct[i].nTotalSubquestion);
- QString sGroupProgressText = QString::fromLocal8Bit("完成进度(%1/%2)").arg(m_vPaperGroupStruct[i].nAnsweredCount).arg(m_vPaperGroupStruct[i].nTotalSubquestion);
- showSubQuestion(m_vPaperGroupStruct[i].vQuestionStruct[j], sqs.nOrder, sGroupTitleText, sGroupProgressText);
- refreshStatus();
- return;
- }
- }
- }
- }
- }
- }
- for (int i = 0; i < nSize; ++i)
- {
- int nQuestionSize = m_vPaperGroupStruct[i].vQuestionStruct.size();
- for (int j = 0; j < nQuestionSize; ++j)
- {
- int nSubQuestionSize = m_vPaperGroupStruct[i].vQuestionStruct[j].vSubQuestionStruct.size();
- bool bHasContent = m_vPaperGroupStruct[i].vQuestionStruct[j].bHasContent;
- for (int k = 0; k < nSubQuestionSize; ++k)
- {
- CSubQuestionStruct &sqs = m_vPaperGroupStruct[i].vQuestionStruct[j].vSubQuestionStruct[k];
- sqs.bCurrent = false;
- if(sqs.nOrder == nOrder)
- {
- sqs.bCurrent = true;
- if (bHasContent)
- {
- QString sGroupTitleText = QString::fromLocal8Bit("%1、%2 (共%3题)").arg(CCommonTools::Arab2Sinogram(m_vPaperGroupStruct[i].nNumber)).arg(m_vPaperGroupStruct[i].sGroupName).arg(m_vPaperGroupStruct[i].nTotalSubquestion);
- QString sGroupProgressText = QString::fromLocal8Bit("完成进度(%1/%2)").arg(m_vPaperGroupStruct[i].nAnsweredCount).arg(m_vPaperGroupStruct[i].nTotalSubquestion);
- showSubQuestion(m_vPaperGroupStruct[i].vQuestionStruct[j], nOrder, sGroupTitleText, sGroupProgressText);
- }
- else
- {
- getQuestionContent(m_vPaperGroupStruct[i].vQuestionStruct[j].sQuestionId, nOrder);
- }
- }
- }
- }
- }
- refreshStatus();
- }
- void answerWidget::uploadAnswer(int nIndex, QString sAnswer)
- {
- int nSize = m_vPaperGroupStruct.size();
- for (int i = 0; i < nSize; ++i)
- {
- int nQuestionSize = m_vPaperGroupStruct[i].vQuestionStruct.size();
- for (int j = 0; j < nQuestionSize; ++j)
- {
- int nSubQuestionSize = m_vPaperGroupStruct[i].vQuestionStruct[j].vSubQuestionStruct.size();
- for (int k = 0; k < nSubQuestionSize; ++k)
- {
- CSubQuestionStruct sqs = m_vPaperGroupStruct[i].vQuestionStruct[j].vSubQuestionStruct[k];
- if(!sqs.bUpload)
- {
- CHttpRequestPackage hrp;
- hrp.sUri = QString("/api/ecs_oe_student/client/exam/process/submitQuestionAnswer");
- hrp.nRequestType = RequestType::rtSubmitQuestionAnswer;
- hrp.eParamType = HttpParamType::hptCustomBody;
- hrp.sParamList.push_back(QString("CustomBody,%1").arg(sAnswer));
- hrp.sCommonStr = QString("%1,%2").arg(sqs.nOrder).arg(sqs.nVersion);
- g_httpBllPtr->post(hrp);
- }
- }
- }
- }
- }
- void answerWidget::onSubmitQuestionAnswer(CSubmitQuestionAnswer submitQuestionAnswer)
- {
- if(submitQuestionAnswer.nCode == 200)
- {
- int nSize = m_vPaperGroupStruct.size();
- for (int i = 0; i < nSize; ++i)
- {
- int nQuestionSize = m_vPaperGroupStruct[i].vQuestionStruct.size();
- for (int j = 0; j < nQuestionSize; ++j)
- {
- int nSubQuestionSize = m_vPaperGroupStruct[i].vQuestionStruct[j].vSubQuestionStruct.size();
- for (int k = 0; k < nSubQuestionSize; ++k)
- {
- CSubQuestionStruct &sqs = m_vPaperGroupStruct[i].vQuestionStruct[j].vSubQuestionStruct[k];
- if(sqs.nOrder == submitQuestionAnswer.nOrder &&
- submitQuestionAnswer.nVersion >= sqs.nVersion)
- {
- sqs.bUpload = true;
- break;
- }
- }
- }
- }
- }
- else
- {
- if(submitQuestionAnswer.sMessage.isEmpty())
- {
- ShowMsg(QString::fromLocal8Bit("提交答案失败"), g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
- }
- else
- {
- ShowMsg(submitQuestionAnswer.sMessage, g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
- }
- }
- }
- void answerWidget::getQuestionContent(QString sQuestionId, int nOrder)
- {
- CHttpRequestPackage hrp;
- hrp.sUri = QString("/api/ecs_oe_student/client/exam/process/getQuestionContent")
- .arg(g_appInfoPtr->m_oExamInfo.nExamId);
- hrp.nRequestType = RequestType::rtGetQuestionContent;
- hrp.eParamType = HttpParamType::hptUrl;
- hrp.sCommonStr = sQuestionId + "," + QString::number(nOrder);
- hrp.sParamList.push_back(QString("questionId,%1").arg(sQuestionId));
- g_httpBllPtr->post(hrp);
- }
- void answerWidget::onGetQuestionContent(CGetQuestionContent getQuestionContent)
- {
- if (getQuestionContent.nCode == 200)
- {
- for (CPaperGroupStruct &pgs : m_vPaperGroupStruct)
- {
- for (CQuestionStruct &qs : pgs.vQuestionStruct)
- {
- if (qs.sQuestionId == getQuestionContent.sQuestionId)
- {
- qs.sBody = getQuestionContent.sBody;
- qs.sVersion = getQuestionContent.sVersion;
- qs.bhasAudios = getQuestionContent.bhasAudios;
- for (int i = 0; i < getQuestionContent.vSubQuestion.size(); ++i)
- {
- CSubQuestion sq = getQuestionContent.vSubQuestion[i];
- qs.vSubQuestionStruct[i].sBody = sq.sBody;
- qs.vSubQuestionStruct[i].vRightAnswer.swap(sq.vRightAnswer);
- qs.vSubQuestionStruct[i].vOptions.swap(sq.vOptions);
- }
- QString sGroupTitleText = QString::fromLocal8Bit("%1、%2 (共%3题)").arg(CCommonTools::Arab2Sinogram(pgs.nNumber)).arg(pgs.sGroupName).arg(pgs.nTotalSubquestion);
- QString sGroupProgressText = QString::fromLocal8Bit("完成进度(%1/%2)").arg(pgs.nAnsweredCount).arg(pgs.nTotalSubquestion);
- showSubQuestion(qs, getQuestionContent.sOrder.toInt(), sGroupTitleText, sGroupProgressText);
- break;
- }
- }
- }
- }
- else
- {
- if(getQuestionContent.sMessage.isEmpty())
- {
- ShowMsg(QString::fromLocal8Bit("获取题目内容失败"), g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
- }
- else
- {
- ShowMsg(getQuestionContent.sMessage, g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
- }
- }
- }
- void answerWidget::onStartAnswer(CStartAnswer startAnswer)
- {
- if(startAnswer.nCode == 200)
- {
- m_nRetryCount = 0;
- m_nUsedExamSeconds = startAnswer.nUsedExamSeconds;
- m_pHeartbeatTimer->start();
- heartBreat();
- //获取活体参数
- if (g_appInfoPtr->m_oExamInfo.bLivenessCheck)
- {
- StartFaceLiveVerify();
- // GetOrgPropertiesByGroupWithoutCache();
- // CHttpRequestPackage hrp;
- // hrp.sUri = QString("/api/ecs_core/org/getOrgPropertiesByGroupWithoutCache/%1/config4Edit1")
- // .arg(g_appInfoPtr->m_sRootOrgId);
- // hrp.nRequestType = RequestType::rtGetOrgPropertiesByGroupWithoutCache;
- // g_httpBllPtr->get(hrp);
- {
- // CHttpRequestPackage hrp;
- // hrp.sUri = QString("/api/ecs_oe_student/client/exam/process/startFaceLiveVerify")
- // .arg(g_appInfoPtr->m_sRootOrgId);
- // hrp.nRequestType = RequestType::rtStartFaceLiveVerify;
- // hrp.sParamList.push_back(QString("examRecordDataId,%1").arg(g_appInfoPtr->m_oExamInfo.nExamRecordDataId));
- // hrp.eParamType = HttpParamType::hptUrl;
- // g_httpBllPtr->post(hrp);
- }
- }
- }
- else
- {
- // if(startAnswer.sMessage.isEmpty())
- // {
- // ShowMsg(QString::fromLocal8Bit("开始作答失败"), g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
- // }
- // else
- // {
- // ShowMsg(startAnswer.sMessage, g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
- // }
- if(++m_nRetryCount > 3)
- {
- //退出
- exitExamTip();
- }
- else
- {
- startAnwer();
- }
- }
- }
- void answerWidget::GetOrgPropertiesByGroupWithoutCache()
- {
- CHttpRequestPackage hrp;
- hrp.sUri = QString("/api/ecs_core/org/getOrgPropertiesByGroupWithoutCache/%1/config4Edit1")
- .arg(g_appInfoPtr->m_sRootOrgId);
- hrp.nRequestType = RequestType::rtGetOrgPropertiesByGroupWithoutCache;
- g_httpBllPtr->get(hrp);
- }
- void answerWidget::onGetOrgPropertiesByGroupWithoutCache(CGetOrgPropertiesByGroupWithoutCache orgProperties)
- {
- if(orgProperties.nCode == 200)
- {
- m_nRetryCount = 0;
- g_appInfoPtr->m_oExamInfo.nActionNum = orgProperties.nActionNum;
- g_appInfoPtr->m_oExamInfo.sActionOptions = orgProperties.sActionOptions;
- g_appInfoPtr->m_oExamInfo.sActionOrder = orgProperties.sActionOrder;
- g_appInfoPtr->m_oExamInfo.nActionDuration = orgProperties.nActionDuration;
- g_appInfoPtr->m_oExamInfo.nActionAlert = orgProperties.nActionAlert;
- g_appInfoPtr->m_oExamInfo.nFaceThreshold = orgProperties.nFaceThreshold;
- StartFaceLiveVerify();
- }
- else
- {
- // if(orgProperties.sMessage.isEmpty())
- // {
- // ShowMsg(QString::fromLocal8Bit("获取考试信息失败"), g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
- // }
- // else
- // {
- // ShowMsg(orgProperties.sMessage, g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
- // }
- if(++m_nRetryCount > 3)
- {
- //退出
- exitExamTip();
- }
- else
- {
- GetOrgPropertiesByGroupWithoutCache();
- }
- }
- }
- void answerWidget::StartFaceLiveVerify()
- {
- CHttpRequestPackage hrp;
- hrp.sUri = QString("/api/ecs_oe_student/client/exam/process/startFaceLiveVerify")
- .arg(g_appInfoPtr->m_sRootOrgId);
- hrp.nRequestType = RequestType::rtStartFaceLiveVerify;
- hrp.sParamList.push_back(QString("examRecordDataId,%1").arg(g_appInfoPtr->m_oExamInfo.nExamRecordDataId));
- hrp.eParamType = HttpParamType::hptUrl;
- g_httpBllPtr->post(hrp);
- }
- void answerWidget::onStartFaceLiveVerify(CStartFaceLiveVerify startFaceLiveVerify)
- {
- if(startFaceLiveVerify.nCode == 200)
- {
- m_nRetryCount = 0;
- g_appInfoPtr->m_oExamInfo.nFaceLiveVerifyId = startFaceLiveVerify.nFaceLiveVerifyId;
- g_appInfoPtr->m_oExamInfo.nFaceVerifyTimes = startFaceLiveVerify.nTimes;
- g_appInfoPtr->m_oExamInfo.nFaceVerifyDoMinute = startFaceLiveVerify.nStartMinute;
- bShowLivenessTip = true;
- }
- else
- {
- // if(startFaceLiveVerify.sMessage.isEmpty())
- // {
- // ShowMsg(QString::fromLocal8Bit("开启活体验证失败"), g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
- // }
- // else
- // {
- // ShowMsg(startFaceLiveVerify.sMessage, g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
- // }
- if(++m_nRetryCount > 3)
- {
- //退出
- exitExamTip();
- }
- else
- {
- StartFaceLiveVerify();
- }
- }
- }
- void answerWidget::heartBreat()
- {
- CHttpRequestPackage hrp;
- hrp.sUri = QString("/api/ecs_oe_student/client/exam/process/examHeartbeat");
- hrp.nRequestType = RequestType::rtExamHeartbeat;
- hrp.nRetryCount = 0;
- g_httpBllPtr->post(hrp);
- }
- void answerWidget::onExamHeartbeat(CExamHeartbeat examHeartbeat)
- {
- if (examHeartbeat.nCode == 200)
- {
- if(m_nHeartBreatFailedCount > 0)
- {
- //m_pHeartbeatTimer->stop();
- m_pHeartbeatTimer->setInterval(60 * 1000);
- //m_pHeartbeatTimer->start();
- m_nHeartBreatFailedCount = 0;
- }
-
- m_nLeftSeconds = examHeartbeat.nLeftTime/1000;
- if(m_nEnterExamTime == 0)
- {
- m_nEnterExamTime = m_nLeftSeconds;
- }
- m_pCountDownTimer->start();
-
- //过程中人脸识别
- if(g_appInfoPtr->m_oExamInfo.bFaceCheck)
- {
- if(g_inProcessFace == nullptr)
- {
- g_inProcessFace = std::make_shared<CInprogressFace>();
- connect(g_inProcessFace.get(), &CInprogressFace::compareFailed, this, [&](QString sErrorMsg){
- ShowMsg(sErrorMsg, g_appInfoPtr->m_pAnsBgWidget);
- });
- startCapture();
- }
- m_nNextFaceCountSecond = m_nLeftSeconds - CCommonTools::genRandomNumber(1, 10);
- }
- }
- else
- {
- if(m_nHeartBreatFailedCount == 0)
- {
- // m_pHeartbeatTimer->stop();
- m_pHeartbeatTimer->setInterval(10 * 1000);
- //m_pHeartbeatTimer->start();
- }
- ++m_nHeartBreatFailedCount;
-
- if (m_nHeartBreatFailedCount >= m_nHeartBreatFailedExitCount)
- {
- exitExamTip();
- //退出
- // awTimeLeftTips *wExitExam = new awTimeLeftTips(MASK_POP_WIDGET_TYPE::wt_exitExam, (QWidget*)(this->parent()));
- // connect(wExitExam, &awTimeLeftTips::timeLeftConfirm, this, [this, wExitExam]() {
- // if (m_pNetWorkErrorTimerPtr)
- // {
- // m_pNetWorkErrorTimerPtr->stop();
- // }
- // delete wExitExam;
- // emit gobackLogin();
- // });
- // wExitExam->show();
- // if (m_pNetWorkErrorTimerPtr == nullptr)
- // {
- // m_pNetWorkErrorTimerPtr = std::make_shared<QTimer>();
- // m_pNetWorkErrorTimerPtr->setInterval(30 * 1000);
- // connect(m_pNetWorkErrorTimerPtr.get(), &QTimer::timeout, [this, wExitExam]() {
- // m_pNetWorkErrorTimerPtr->stop();
- // delete wExitExam;
- // emit gobackLogin();
- // });
- // }
- // m_pNetWorkErrorTimerPtr->start();
-
- }
- if(examHeartbeat.sMessage.isEmpty())
- {
- ShowMsg(QString::fromLocal8Bit("网络连接异常,请检查网络设置"), g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
- }
- else
- {
- ShowMsg(examHeartbeat.sMessage, g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
- }
- }
- }
- void answerWidget::exitExamTip()
- {
- //退出
- awTimeLeftTips *wExitExam = new awTimeLeftTips(MASK_POP_WIDGET_TYPE::wt_exitExam, (QWidget*)(this->parent()));
- connect(wExitExam, &awTimeLeftTips::timeLeftConfirm, this, [this, wExitExam]() {
- if (m_pNetWorkErrorTimerPtr)
- {
- m_pNetWorkErrorTimerPtr->stop();
- }
- delete wExitExam;
- emit gobackLogin();
- });
- wExitExam->show();
- if (m_pNetWorkErrorTimerPtr == nullptr)
- {
- m_pNetWorkErrorTimerPtr = std::make_shared<QTimer>();
- m_pNetWorkErrorTimerPtr->setInterval(30 * 1000);
- connect(m_pNetWorkErrorTimerPtr.get(), &QTimer::timeout, [this, wExitExam]() {
- m_pNetWorkErrorTimerPtr->stop();
- delete wExitExam;
- emit gobackLogin();
- });
- }
- m_pNetWorkErrorTimerPtr->start();
- }
- bool answerWidget::allMutipleQuestionHas2Answers()
- {
- int nSize = m_vPaperGroupStruct.size();
- for (int i = 0; i < nSize; ++i)
- {
- int nQuestionSize = m_vPaperGroupStruct[i].vQuestionStruct.size();
- for (int j = 0; j < nQuestionSize; ++j)
- {
- int nSubQuestionSize = m_vPaperGroupStruct[i].vQuestionStruct[j].vSubQuestionStruct.size();
- for (int k = 0; k < nSubQuestionSize; ++k)
- {
- CSubQuestionStruct sqs = m_vPaperGroupStruct[i].vQuestionStruct[j].vSubQuestionStruct[k];
- if (sqs.sQuestionType == QUESTION_TYPE::MultipleChoice && sqs.sStudentAnswer.length() < 2)
- {
- return false;
- }
- }
- }
- }
- return true;
- }
- void answerWidget::onExamControlCheckTime(CBaseResponsePackage res)
- {
- if(res.nCode == 200)
- {
- if(m_pHandinPaper == nullptr)
- {
- m_pHandinPaper = std::make_shared<awHandinPaper>(ui->btn_answeredNum->text().toInt(),
- ui->btn_unansweredNum->text().toInt(),
- ui->btn_markedNum->text().toInt(), (QWidget*)(this->parent()));
- connect(m_pHandinPaper.get(), &awHandinPaper::handinPaper, this, [&](){
- m_pHandinPaper.reset();
- //交卷
- handinPaper();
- });
- connect(m_pHandinPaper.get(), &awHandinPaper::cancelHandinPaper, this, [&](){
- m_pHandinPaper.reset();
- });
- }
- if(g_appInfoPtr->m_bMutipleAnserCountTips)
- {
- if(!allMutipleQuestionHas2Answers())
- {
- m_pHandinPaper->showMutipleChoiceTip();
- }
- }
- m_pHandinPaper->show();
- }
- else
- {
- if(res.sMessage.isEmpty())
- {
- res.sMessage = QString::fromLocal8Bit("交卷时间检查失败");
- }
- ShowMsg(res.sMessage, this);
- }
- }
- void answerWidget::on_btn_handInPaper_clicked()
- {
- // if(m_nFreezeTime*60 > m_nUsedExamSeconds + m_nEnterExamTime - m_nLeftSeconds)
- // {
- // ShowMsg(QString::fromLocal8Bit("冻结时间内不允许交卷"), this, MSG_ICON_TYPE::mit_error);
- // return;
- // }
- ui->btn_handInPaper->setEnabled(false);
- CHttpRequestPackage hrp;
- hrp.sUri = QString("/api/ecs_oe_student/examControl/check/time");
- hrp.nRequestType = RequestType::rtExamControlCheckTime;
- g_httpBllPtr->post(hrp);
- QTimer::singleShot(3000, this, [&](){
- ui->btn_handInPaper->setEnabled(true);
- });
- }
- bool answerWidget::checkAnswer()
- {
- bool bRet = true;
- int nSize = m_vPaperGroupStruct.size();
- for (int i = 0; i < nSize; ++i)
- {
- int nQuestionSize = m_vPaperGroupStruct[i].vQuestionStruct.size();
- for (int j = 0; j < nQuestionSize; ++j)
- {
- int nSubQuestionSize = m_vPaperGroupStruct[i].vQuestionStruct[j].vSubQuestionStruct.size();
- for (int k = 0; k < nSubQuestionSize; ++k)
- {
- CSubQuestionStruct sqs = m_vPaperGroupStruct[i].vQuestionStruct[j].vSubQuestionStruct[k];
- if (!sqs.bUpload)
- {
- bRet = false;
- CHttpRequestPackage hrp;
- hrp.sUri = QString("/api/ecs_oe_student/client/exam/process/submitQuestionAnswer");
- hrp.nRequestType = RequestType::rtSubmitQuestionAnswer;
- hrp.eParamType = HttpParamType::hptCustomBody;
- hrp.sParamList.push_back(QString("CustomBody,%1").arg(sqs.sUploadAnswer));
- hrp.sCommonStr = QString("%1,%2").arg(sqs.nOrder).arg(sqs.nVersion);
- g_httpBllPtr->post(hrp);
- }
- }
- }
- }
- return bRet;
- }
- void answerWidget::handinPaper(bool bForce)
- {
- m_pCountDownTimer->stop();
- if(g_appInfoPtr->m_oExamInfo.bFaceCheck)
- {
- stopCapture();
- }
- if(g_inProcessFace != nullptr)
- {
- stopCapture();
- g_inProcessFace.reset();
- }
- if(m_pResumeExam == nullptr)
- {
- m_pResumeExam = std::make_shared<awResumeExam>((QWidget*)(this->parent()), QString::fromLocal8Bit("交卷中请稍候…"));
- }
- m_pResumeExam->show();
- if (checkAnswer())
- {
- // CHttpRequestPackage hrp;
- // hrp.sUri = QString("/api/ecs_oe_student/client/exam/process/endExam");
- // hrp.sCommonStr = __FILE__;
- // hrp.nRequestType = RequestType::rtEndExam;
- // g_httpBllPtr->post(hrp);
- doEndExam(bForce);
- }
- else
- {
- if (m_pHandinPaperTimer == nullptr)
- {
- m_pHandinPaperTimer = std::make_shared<QTimer>();
- m_pHandinPaperTimer->setInterval(10 * 1000);
- connect(m_pHandinPaperTimer.get(), &QTimer::timeout, this, [&]() {
- if (checkAnswer())
- {
- m_pHandinPaperTimer->stop();
- doEndExam(bForce);
- // CHttpRequestPackage hrp;
- // hrp.sUri = QString("/api/ecs_oe_student/client/exam/process/endExam");
- // hrp.sCommonStr = __FILE__;
- // hrp.nRequestType = RequestType::rtEndExam;
- // g_httpBllPtr->post(hrp);
- }
- });
- }
- }
- }
- void answerWidget::doEndExam(bool bForce)
- {
- CHttpRequestPackage hrp;
- hrp.sUri = QString("/api/ecs_oe_student/client/exam/process/endExam");
- if(bForce)
- {
- hrp.sParamList.push_back(QString("force,%1").arg(bForce));
- hrp.eParamType = HttpParamType::hptUrl;
- }
- hrp.sCommonStr = __FILE__;
- hrp.sAdditionStr = bForce ? "1" : "0";
- hrp.nRequestType = RequestType::rtEndExam;
- g_httpBllPtr->post(hrp);
- }
- void answerWidget::onEndExam(CEndExam endExam)
- {
- if(endExam.sModuleName == __FILE__)
- {
- if (endExam.nCode == 200)
- {
- m_pHeartbeatTimer->stop();
- m_pResumeExam.reset();
- if (g_appInfoPtr->m_oExamInfo.sExamType == EXAM_TYPES::PRACTICE)
- {
- if(g_appInfoPtr->m_oExamInfo.sPracticeType != "NO_ANSWER")
- {
- emit showPracticeInfo();
- }
- else
- {
- emit gobackCourseList();
- }
- }
- else
- {
- emit showExamScore();
- }
- }
- else
- {
- QTimer::singleShot(5*1000, this, [&](){
- // CHttpRequestPackage hrp;
- // hrp.sUri = QString("/api/ecs_oe_student/client/exam/process/endExam");
- // hrp.sCommonStr = __FILE__;
- // hrp.nRequestType = RequestType::rtEndExam;
- // g_httpBllPtr->post(hrp);
- doEndExam(endExam.bForce);
- });
- }
- }
- }
- void answerWidget::on_btn_all_clicked()
- {
- int nCount = ui->lw_aw_questionList->count();
- for(int i = 0; i < nCount; ++i)
- {
- awQuestionNavigate *questionItem = dynamic_cast<awQuestionNavigate*>(ui->lw_aw_questionList->itemWidget(ui->lw_aw_questionList->item(i)));
- if(questionItem)
- {
- int nHeight = questionItem->setShowType(ITEM_SHOW_TYPE::ist_showAll);
- QListWidgetItem *listItem = ui->lw_aw_questionList->item(i);
- if(listItem)
- {
- QSize size = listItem->sizeHint();
- size.setHeight(nHeight);
- listItem->setSizeHint(size);
- }
- }
- }
- setChecked(ui->btn_all, true);
- setChecked(ui->btn_marked, false);
- setChecked(ui->btn_answered, false);
- setChecked(ui->btn_unanswered, false);
- }
- void answerWidget::setChecked(QPushButton *btn, bool bChecked)
- {
- QString sNormal = QString(R"(QPushButton
- {
- outline:none;
- background:rgba(242,243,247,1);
- border-radius:%1px;
- border:1px solid rgba(240,244,249,1);
- font-size:%2px;
- font-family:"Microsoft YaHei";
- font-weight:500;
- color:rgba(153,153,153,1);
- padding-left:%3px;
- text-align:left;
- })").arg((int)(g_appInfoPtr->m_fRate*14))
- .arg((int)(g_appInfoPtr->m_fRate*12))
- .arg((int)(g_appInfoPtr->m_fRate*15));
- QString sChecked = QString(R"(QPushButton
- {
- outline:none;
- background:rgba(242,243,247,1);
- border-radius:%1px;
- border:1px solid rgba(189,200,217,1);
- font-size:%2px;
- font-family:"Microsoft YaHei";
- font-weight:500;
- color:rgba(153,153,153,1);
- padding-left:%3px;
- text-align:left;
- })").arg((int)(g_appInfoPtr->m_fRate*14))
- .arg((int)(g_appInfoPtr->m_fRate*12))
- .arg((int)(g_appInfoPtr->m_fRate*15));
- btn->setStyleSheet(bChecked ? sChecked : sNormal);
- }
- void answerWidget::on_btn_answered_clicked()
- {
- int nCount = ui->lw_aw_questionList->count();
- for(int i = 0; i < nCount; ++i)
- {
- awQuestionNavigate *questionItem = dynamic_cast<awQuestionNavigate*>(ui->lw_aw_questionList->itemWidget(ui->lw_aw_questionList->item(i)));
- if(questionItem)
- {
- int nHeight = questionItem->setShowType(ITEM_SHOW_TYPE::ist_showAnswered);
- QListWidgetItem *listItem = ui->lw_aw_questionList->item(i);
- if(listItem)
- {
- QSize size = listItem->sizeHint();
- size.setHeight(nHeight);
- listItem->setSizeHint(size);
- }
- }
- }
- setChecked(ui->btn_all, false);
- setChecked(ui->btn_marked, false);
- setChecked(ui->btn_answered, true);
- setChecked(ui->btn_unanswered, false);
- }
- void answerWidget::on_btn_unanswered_clicked()
- {
- int nCount = ui->lw_aw_questionList->count();
- for(int i = 0; i < nCount; ++i)
- {
- awQuestionNavigate *questionItem = dynamic_cast<awQuestionNavigate*>(ui->lw_aw_questionList->itemWidget(ui->lw_aw_questionList->item(i)));
- if(questionItem)
- {
- int nHeight = questionItem->setShowType(ITEM_SHOW_TYPE::ist_showUnanswered);
- QListWidgetItem *listItem = ui->lw_aw_questionList->item(i);
- if(listItem)
- {
- QSize size = listItem->sizeHint();
- size.setHeight(nHeight);
- listItem->setSizeHint(size);
- }
- }
- }
- setChecked(ui->btn_all, false);
- setChecked(ui->btn_marked, false);
- setChecked(ui->btn_answered, false);
- setChecked(ui->btn_unanswered, true);
- }
- void answerWidget::on_btn_marked_clicked()
- {
- int nCount = ui->lw_aw_questionList->count();
- for(int i = 0; i < nCount; ++i)
- {
- awQuestionNavigate *questionItem = dynamic_cast<awQuestionNavigate*>(ui->lw_aw_questionList->itemWidget(ui->lw_aw_questionList->item(i)));
- if(questionItem)
- {
- int nHeight = questionItem->setShowType(ITEM_SHOW_TYPE::ist_showMarked);
- QListWidgetItem *listItem = ui->lw_aw_questionList->item(i);
- if(listItem)
- {
- QSize size = listItem->sizeHint();
- size.setHeight(nHeight);
- listItem->setSizeHint(size);
- }
- }
- }
- setChecked(ui->btn_all, false);
- setChecked(ui->btn_marked, true);
- setChecked(ui->btn_answered, false);
- setChecked(ui->btn_unanswered, false);
- }
- void answerWidget::on_btn_allNum_clicked()
- {
- on_btn_all_clicked();
- }
- void answerWidget::on_btn_answeredNum_clicked()
- {
- on_btn_answered_clicked();
- }
- void answerWidget::on_btn_unansweredNum_clicked()
- {
- on_btn_unanswered_clicked();
- }
- void answerWidget::on_btn_markedNum_clicked()
- {
- on_btn_marked_clicked();
- }
- void answerWidget::onRenderVideoFrame(const char* userId, TRTCVideoStreamType streamType, TRTCVideoFrame* frame)
- {
- if(g_clientVideoProcPtr->isCameraTest())
- {
- __int64 nServerTime = g_appInfoPtr->serverMTime();
- if(nServerTime - m_lastFaceTime >= 100)
- {
- m_lastFaceTime = nServerTime;
- cv::Mat matImg;
- cv::cvtColor(cv::Mat(frame->height, frame->width, CV_8UC4, frame->data), matImg, CV_RGBA2RGB);
- if(matImg.empty())
- {
- qDebug()<<"widgetCameraTest frame is empty";
- return;
- }
- std::scoped_lock lock(m_imageMutex);
- m_nCurImage = matImg;
- }
- }
- }
- void answerWidget::startCapture()
- {
- // if(m_pinitTimer == nullptr)
- // {
- // m_pinitTimer = std::make_shared<QTimer>();
- // m_pinitTimer->setInterval(1000);
- // connect(m_pinitTimer.get(), &QTimer::timeout, this, [&](){
- // m_pinitTimer->stop();
- // if(!m_cam.open(0))
- // {
- // ShowMsg(QString::fromLocal8Bit("打开摄像头失败"), this, MSG_ICON_TYPE::mit_error);
- // return;
- // }
- // int inWidth = ui->widget_aw_face->width();
- // m_cam.set(CV_CAP_PROP_FRAME_WIDTH, inWidth*3);
- // int inHeight = ui->widget_aw_face->height();
- // m_cam.set(CV_CAP_PROP_FRAME_HEIGHT, inHeight*3);
- // m_cam.set(CV_CAP_PROP_FPS, 5);
- // m_pVideoTimer->start();
- // });
- // }
- g_clientVideoProcPtr->startTest(this);
- g_inProcessFace->startFaceVerify(true);
- if(m_pVideoTimer == nullptr)
- {
- m_pVideoTimer = std::make_shared<QTimer>();
- m_pVideoTimer->setInterval(200);
- m_nLastCaptureSecond = m_nLeftSeconds;
- connect(m_pVideoTimer.get(), &QTimer::timeout, this, [&](){
- cv::Mat frame;
- {
- std::scoped_lock lock(m_imageMutex);
- frame = m_nCurImage;
- }
- if(frame.empty())
- {
- qDebug()<<"widgetCameraTest frame is empty";
- return;
- }
- if (g_inProcessFace != nullptr &&
- g_appInfoPtr->m_oExamInfo.bIsExamInProgress &&
- !m_bExamInpressFaceCaptured)
- {
- m_bExamInpressFaceCaptured = true;
- g_inProcessFace->addImage(frame);
- }
- if (g_inProcessFace != nullptr &&
- m_nLastCaptureSecond - m_nLeftSeconds > g_appInfoPtr->m_oExamInfo.nSnapshotInterval*60)
- {
- m_nLastCaptureSecond = m_nLeftSeconds;
- g_inProcessFace->addImage(frame);
- }
- if(g_inProcessFace != nullptr &&
- m_nNextFaceCountSecond > m_nLeftSeconds)
- {
- m_nNextFaceCountSecond = m_nLeftSeconds - CCommonTools::genRandomNumber(1, 10);
- g_inProcessFace->addFaceCountImage(frame);
- }
- QImage img = CCommonTools::Mat2QImage(frame);
- ui->widget_aw_face->setAutoFillBackground(true);
- QPalette palette;
- palette.setBrush(QPalette::Window, QBrush(img.scaled(ui->widget_aw_face->width(), ui->widget_aw_face->height())));
- ui->widget_aw_face->setPalette(palette);
- });
- }
- m_pVideoTimer->start();
- }
- void answerWidget::stopCapture()
- {
- m_pVideoTimer->stop();
- g_inProcessFace->startFaceVerify(false);
- g_clientVideoProcPtr->stopTest();
- // m_pVideoTimer->stop();
- // if(m_cam.isOpened())
- // {
- // m_cam.release();
- // }
- }
|