courseList.cpp 52 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397
  1. #include "courseList.h"
  2. #include "ui_courseList.h"
  3. #include "awMsgBox.h"
  4. #include <QDesktopWidget>
  5. #include <QMouseEvent>
  6. #include "CAppInfo.h"
  7. #include "CSqlite3DBProc.h"
  8. courseList::courseList(QWidget *parent) :
  9. QWidget(parent),
  10. ui(new Ui::courseList)
  11. {
  12. ui->setupUi(this);
  13. setWindowFlags(Qt::FramelessWindowHint);
  14. setStyleSheet(g_appInfoPtr->m_sQssStr);
  15. qRegisterMetaType<CGetStudentInfoBySession>("CGetStudentInfoBySession");
  16. connect(g_httpBllPtr.get(), &CHttpBll::sgnGetStudentInfoBySession, this, &courseList::onGetStudentInfoBySession);
  17. qRegisterMetaType<CSpecialtyNameList>("CSpecialtyNameList");
  18. connect(g_httpBllPtr.get(), &CHttpBll::sgnSpecialtyNameList, this, &courseList::onSpecialtyNameList);
  19. qRegisterMetaType<CCheckExamInProgress>("CCheckExamInProgress");
  20. connect(g_httpBllPtr.get(), &CHttpBll::sgnCheckExamInProgress, this, &courseList::onCheckExamInProgress);
  21. qRegisterMetaType<CGetStudentClientMenu>("CGetStudentClientMenu");
  22. connect(g_httpBllPtr.get(), &CHttpBll::sgnGetStudentClientMenu, this, &courseList::onGetStudentClientMenu);
  23. qRegisterMetaType<CGetUserNoticeList>("CGetUserNoticeList");
  24. connect(g_httpBllPtr.get(), &CHttpBll::sgnGetUserNoticeList, this, &courseList::onGetUserNoticeList);
  25. qRegisterMetaType<CDownLoadFileInfo>("CDownLoadFileInfo");
  26. connect(g_httpBllPtr.get(), &CHttpBll::sgnDownLoadFile, this, &courseList::onDownLoadFile);
  27. qRegisterMetaType<CAppDownLoadUrl>("CAppDownLoadUrl");
  28. connect(g_httpBllPtr.get(), &CHttpBll::sgnAppDownLoadUrl, this, &courseList::onAppDownLoadUrl);
  29. qRegisterMetaType<CStartExamLimit>("CStartExamLimit");
  30. connect(g_httpBllPtr.get(), &CHttpBll::sgnStartExamLimit, this, &courseList::onStartExamLimit);
  31. qRegisterMetaType<CIpLimit>("CIpLimit");
  32. connect(g_httpBllPtr.get(), &CHttpBll::sgnIpLimit, this, &courseList::onIpLimit);
  33. qRegisterMetaType<CGetExamProperty>("CGetExamProperty");
  34. connect(g_httpBllPtr.get(), &CHttpBll::sgnGetExamProperty, this, &courseList::onGetExamProperty);
  35. qRegisterMetaType<CFaceCheckEnabled>("CFaceCheckEnabled");
  36. connect(g_httpBllPtr.get(), &CHttpBll::sgnFaceCheckEnabled, this, &courseList::onFaceCheckEnabled);
  37. qRegisterMetaType<CLivenessEnabled>("CLivenessEnabled");
  38. connect(g_httpBllPtr.get(), &CHttpBll::sgnLivenessEnabled, this, &courseList::onLivenessEnabled);
  39. qRegisterMetaType<CEndExam>("CEndExam");
  40. connect(g_httpBllPtr.get(), &CHttpBll::sgnEndExam, this, &courseList::onEndExam);
  41. qRegisterMetaType<CGetOrgPropertiesByGroupWithoutCache>("CGetOrgPropertiesByGroupWithoutCache");
  42. connect(g_httpBllPtr.get(), &CHttpBll::sgnGetOrgPropertiesByGroupWithoutCache, this, &courseList::onGetOrgPropertiesByGroupWithoutCache);
  43. sqlite3_stmt *stmt;
  44. QString sSql = QString("select agreement from t_agreement where student_id=%1")
  45. .arg(g_appInfoPtr->m_nStudentId);
  46. if (!g_sysDBProcPtr->QuerySql(sSql.toStdString(), &stmt))
  47. {
  48. ShowMsg(QString::fromLocal8Bit("加载隐私协议信息失败!"), this, MSG_ICON_TYPE::mit_error);
  49. }
  50. bool bAgreement = false;
  51. int nField = 0;
  52. g_sysDBProcPtr->BeginGetFields(stmt);
  53. if (!g_sysDBProcPtr->Eof())
  54. {
  55. if (g_sysDBProcPtr->GetFields(0, nField, stmt) == 1)
  56. {
  57. bAgreement = true;
  58. }
  59. }
  60. g_sysDBProcPtr->EndGetFields(stmt);
  61. if (!bAgreement)
  62. {
  63. if (m_pPrivacyWidget == nullptr)
  64. {
  65. m_pPrivacyWidget = std::make_shared<privacyWidget>(this);
  66. connect(m_pPrivacyWidget.get(), &privacyWidget::agreement, this, [&]() {
  67. m_pPrivacyWidget.reset();
  68. getStudentInfoBySession();
  69. });
  70. connect(m_pPrivacyWidget.get(), &privacyWidget::disAgreement, this, [&]() {
  71. on_btn_exit_clicked();
  72. });
  73. }
  74. m_pPrivacyWidget->show();
  75. }
  76. else
  77. {
  78. getStudentInfoBySession();
  79. }
  80. initUI();
  81. m_pMobileLogin = nullptr;
  82. m_pStudentInfo = nullptr;
  83. m_pMobileLoginBtnTimer = std::make_shared<QTimer>();
  84. m_pMobileLoginBtnTimer->setInterval(500);
  85. connect(m_pMobileLoginBtnTimer.get(), &QTimer::timeout, this, &courseList::hideMobileLoginBtn);
  86. m_pStudentInfoBtnTimer = std::make_shared<QTimer>();
  87. m_pStudentInfoBtnTimer->setInterval(500);
  88. connect(m_pStudentInfoBtnTimer.get(), &QTimer::timeout, this, &courseList::hideStudentInfoBtn);
  89. m_pServerTime = std::make_shared<QTimer>();
  90. m_pServerTime->setInterval(1000);
  91. connect(m_pServerTime.get(), &QTimer::timeout, this, [&]() {
  92. ui->label_serverTime->adjustSize();
  93. ui->label_serverTime->setText(QString::fromLocal8Bit("服务器时间:%1")
  94. .arg(QDateTime::fromMSecsSinceEpoch(g_appInfoPtr->serverMTime()).toString("yyyy-MM-dd hh:mm:ss")));
  95. });
  96. m_pServerTime->start();
  97. m_pRefreshMenuTimer = std::make_shared<QTimer>();
  98. m_pRefreshMenuTimer->setInterval(1000 * 60 * 3);
  99. connect(m_pRefreshMenuTimer.get(), &QTimer::timeout, this, []() {
  100. CHttpRequestPackage hrp;
  101. hrp.sUri = "/api/ecs_core/rolePrivilege/getStudentClientMenu";
  102. hrp.nRequestType = RequestType::rtGetStudentClientMenu;
  103. hrp.sParamList.push_back(QString::fromLocal8Bit("rootOrgId,%1").arg(g_appInfoPtr->m_sRootOrgId));
  104. g_httpBllPtr->get(hrp);
  105. });
  106. m_pOnlineTimer = std::make_shared<QTimer>();
  107. m_pOnlineTimer->setInterval(1000*60*3);
  108. connect(m_pOnlineTimer.get(), &QTimer::timeout, this, []() {
  109. CHttpRequestPackage hrp1;
  110. hrp1.sUri = "/api/ecs_core/student/online_signal/" + QString::number(g_appInfoPtr->m_nStudentId);
  111. hrp1.nRequestType = RequestType::rtOnlineSignal;
  112. g_httpBllPtr->get(hrp1);
  113. });
  114. ui->btn_mobileLogin->installEventFilter(this);
  115. ui->btn_studentInfo->installEventFilter(this);
  116. m_pOnlineTimer->start();
  117. m_pRefreshMenuTimer->start();
  118. if (!g_appInfoPtr->m_sMenuLogoUrl.isEmpty())
  119. {
  120. QString sFileName = g_appInfoPtr->m_sMenuLogoUrl.right(g_appInfoPtr->m_sMenuLogoUrl.length() - g_appInfoPtr->m_sMenuLogoUrl.lastIndexOf("/") - 1);
  121. sFileName = g_appInfoPtr->m_sCacheFileDir + sFileName;
  122. CHttpRequestPackage hrp;
  123. hrp.sUri = g_appInfoPtr->m_sMenuLogoUrl;
  124. hrp.sCommonStr = sFileName;
  125. hrp.sCommonStr1 = __FILE__;
  126. hrp.sAdditionStr = "MenuLogoUrl";
  127. hrp.nRequestType = RequestType::rtDownLoadFile;
  128. hrp.nRetryCount = 3;
  129. g_httpBllPtr->downLoad(hrp);
  130. }
  131. else
  132. {
  133. ui->label_cl_org_icon->setPixmap(QPixmap(":/images/qm-logo.png").scaled(ui->label_cl_org_icon->width(), ui->label_cl_org_icon->height(),
  134. Qt::KeepAspectRatio, Qt::SmoothTransformation));
  135. }
  136. }
  137. courseList::~courseList()
  138. {
  139. awMsgBox::clear(this);
  140. delete ui;
  141. }
  142. void courseList::initUI()
  143. {
  144. QDesktopWidget *dekwiget = QApplication::desktop();
  145. setGeometry(0, 0, dekwiget->width(), dekwiget->height());
  146. ui->widget_cl_BG->setGeometry(0, 0, dekwiget->width(), dekwiget->height());
  147. ui->widget_menu->setGeometry(0, 0, g_appInfoPtr->m_fRate*96, height());
  148. ui->widget_top->setGeometry(ui->widget_menu->width(), 0, width() - ui->widget_menu->width(), g_appInfoPtr->m_fRate*56);
  149. ui->widget_bottom->setGeometry(ui->widget_top->x(), height() - g_appInfoPtr->m_fRate*38, ui->widget_top->width(), g_appInfoPtr->m_fRate*38);
  150. ui->stw_courseList->setGeometry(ui->widget_top->x(), ui->widget_top->y() + ui->widget_top->height(),
  151. ui->widget_top->width(), height() - ui->widget_top->height() - ui->widget_bottom->height());
  152. /*
  153. clOnlineExam *cloe = new clOnlineExam;
  154. cloe->setUI(ui->stw_courseList->width(), ui->stw_courseList->height());
  155. ui->stw_courseList->addWidget(cloe);
  156. clOnlineHomework *clow = new clOnlineHomework;
  157. clow->setUI(ui->stw_courseList->width(), ui->stw_courseList->height());
  158. ui->stw_courseList->addWidget(clow);
  159. clOnlinePractice *clop = new clOnlinePractice;
  160. clop->setUI(ui->stw_courseList->width(), ui->stw_courseList->height());
  161. ui->stw_courseList->addWidget(clop);
  162. clOfflineExam *cloffe = new clOfflineExam;
  163. cloffe->setUI(ui->stw_courseList->width(), ui->stw_courseList->height());
  164. ui->stw_courseList->addWidget(cloffe);
  165. clNoticeList *clnl = new clNoticeList;
  166. clnl->setUI(ui->stw_courseList->width(), ui->stw_courseList->height());
  167. ui->stw_courseList->addWidget(clnl);
  168. clEditPassword *clep = new clEditPassword;
  169. clep->setUI(ui->stw_courseList->width(), ui->stw_courseList->height());
  170. ui->stw_courseList->addWidget(clep);
  171. ui->stw_courseList->setCurrentIndex(0);
  172. */
  173. ui->label_cl_org_icon->setGeometry(g_appInfoPtr->m_fRate*15, g_appInfoPtr->m_fRate*15, g_appInfoPtr->m_fRate*66, g_appInfoPtr->m_fRate*66);
  174. ui->btn_onlineExam->setGeometry(g_appInfoPtr->m_fRate*20, g_appInfoPtr->m_fRate*103, g_appInfoPtr->m_fRate*56, g_appInfoPtr->m_fRate*66);
  175. ui->btn_onlineHomework->setGeometry(ui->btn_onlineExam->x(), ui->btn_onlineExam->y() + ui->btn_onlineExam->height() + g_appInfoPtr->m_fRate*17,
  176. ui->btn_onlineExam->width(), ui->btn_onlineExam->height());
  177. ui->btn_onlinePractice->setGeometry(ui->btn_onlineExam->x(), ui->btn_onlineHomework->y() + ui->btn_onlineHomework->height() + g_appInfoPtr->m_fRate*17,
  178. ui->btn_onlineExam->width(), ui->btn_onlineExam->height());
  179. ui->btn_offlineExam->setGeometry(ui->btn_onlineExam->x(), ui->btn_onlinePractice->y() + ui->btn_onlinePractice->height() + g_appInfoPtr->m_fRate*17,
  180. ui->btn_onlineExam->width(), ui->btn_onlineExam->height());
  181. ui->btn_notice->setGeometry(ui->btn_onlineExam->x(), ui->btn_offlineExam->y() + ui->btn_offlineExam->height() + g_appInfoPtr->m_fRate*17,
  182. ui->btn_onlineExam->width(), ui->btn_onlineExam->height());
  183. ui->btn_noticeNum->setGeometry(ui->btn_notice->x() + ui->btn_notice->width() - g_appInfoPtr->m_fRate*16, ui->btn_notice->y(),
  184. g_appInfoPtr->m_fRate*16, g_appInfoPtr->m_fRate*16);
  185. ui->btn_noticeNum->setVisible(false);
  186. ui->btn_editPassword->setGeometry(ui->btn_onlineExam->x(), ui->btn_notice->y() + ui->btn_notice->height() + g_appInfoPtr->m_fRate*17,
  187. ui->btn_onlineExam->width(), ui->btn_onlineExam->height());
  188. ui->label_currentPlaceIcon->setGeometry(g_appInfoPtr->m_fRate*30, (ui->widget_top->height() - g_appInfoPtr->m_fRate*10)/2,
  189. g_appInfoPtr->m_fRate*10, g_appInfoPtr->m_fRate*10);
  190. ui->label_currrentPlace->adjustSize();
  191. ui->label_currrentPlace->setGeometry(ui->label_currentPlaceIcon->x() + ui->label_currentPlaceIcon->width() + g_appInfoPtr->m_fRate*10,
  192. (ui->widget_top->height() - ui->label_currrentPlace->height())/2, g_appInfoPtr->m_fRate*400, ui->label_currrentPlace->height());
  193. ui->btn_cl_close->setGeometry(ui->widget_top->width() - g_appInfoPtr->m_fRate*10 - g_appInfoPtr->m_fRate*24, g_appInfoPtr->m_fRate*16,
  194. g_appInfoPtr->m_fRate*24, g_appInfoPtr->m_fRate*24);
  195. ui->btn_minisize->setGeometry(ui->btn_cl_close->x() - g_appInfoPtr->m_fRate*6 - ui->btn_cl_close->width(), ui->btn_cl_close->y(),
  196. ui->btn_cl_close->width(), ui->btn_cl_close->height());
  197. ui->label_VLine->setGeometry(ui->btn_minisize->x() - g_appInfoPtr->m_fRate*21, ui->btn_cl_close->y(),
  198. g_appInfoPtr->m_fRate*1 < 1 ? 1 : g_appInfoPtr->m_fRate*1, g_appInfoPtr->m_fRate*24);
  199. ui->btn_exit->setGeometry(ui->label_VLine->x() - g_appInfoPtr->m_fRate*(20+24), ui->btn_cl_close->y(),
  200. ui->btn_cl_close->width(), ui->btn_cl_close->height());
  201. ui->btn_studentInfo->setGeometry(ui->btn_exit->x() - g_appInfoPtr->m_fRate*(10+90), ui->btn_cl_close->y(),
  202. g_appInfoPtr->m_fRate*90, g_appInfoPtr->m_fRate*24);
  203. ui->btn_studentInfo->setIconSize(QSize(g_appInfoPtr->m_fRate*8, g_appInfoPtr->m_fRate*8));
  204. ui->btn_studentInfo->setIcon(QIcon(":/images/icon-student-info.png"));
  205. ui->label_arrow->setGeometry(ui->btn_studentInfo->x() + (ui->btn_studentInfo->width() - g_appInfoPtr->m_fRate*12)/2,
  206. ui->btn_studentInfo->y() + ui->btn_studentInfo->height(),
  207. g_appInfoPtr->m_fRate*12, g_appInfoPtr->m_fRate*3);
  208. ui->label_arrow->setVisible(false);
  209. ui->btn_mobileLogin->setGeometry(ui->btn_studentInfo->x() - g_appInfoPtr->m_fRate*(10+167), ui->btn_cl_close->y(),
  210. g_appInfoPtr->m_fRate*167, g_appInfoPtr->m_fRate*24);
  211. ui->btn_mobileLogin->setIconSize(QSize(g_appInfoPtr->m_fRate*8, g_appInfoPtr->m_fRate*8));
  212. ui->btn_mobileLogin->setIcon(QIcon(":/images/icon-mobile-login.png"));
  213. ui->label_cl_company->adjustSize();
  214. ui->label_cl_company->setGeometry(g_appInfoPtr->m_fRate*30, (ui->widget_bottom->height() - ui->label_cl_company->height())/2,
  215. ui->label_cl_company->width(), ui->label_cl_company->height());
  216. ui->label_cl_version->adjustSize();
  217. ui->label_cl_version->setGeometry(ui->widget_bottom->width() - g_appInfoPtr->m_fRate*30 - ui->label_cl_version->width(),
  218. ui->label_cl_company->y(), ui->label_cl_version->width(), ui->label_cl_version->height());
  219. ui->label_serverTime->setText(QString::fromLocal8Bit("服务器时间:%1")
  220. .arg(QDateTime::fromMSecsSinceEpoch(g_appInfoPtr->serverMTime()).toString("yyyy-MM-dd hh:mm:ss")));
  221. ui->label_serverTime->adjustSize();
  222. ui->label_serverTime->setGeometry(ui->label_cl_version->x() - g_appInfoPtr->m_fRate*20 - ui->label_serverTime->width(), ui->label_cl_company->y(),
  223. ui->label_serverTime->width(), ui->label_serverTime->height());
  224. setCheck(COURSE_MENU_BTN_TYPE::cmbt_online_exam);
  225. }
  226. void courseList::menuBtnRePosistion()
  227. {
  228. int nTop = g_appInfoPtr->m_fRate * 103;
  229. if(ui->btn_onlineExam->isVisible())
  230. {
  231. ui->btn_onlineExam->setGeometry(g_appInfoPtr->m_fRate * 20, nTop, g_appInfoPtr->m_fRate * 56, g_appInfoPtr->m_fRate * 66);
  232. nTop = nTop + ui->btn_onlineExam->height() + g_appInfoPtr->m_fRate * 17;
  233. }
  234. if(ui->btn_onlineHomework->isVisible())
  235. {
  236. ui->btn_onlineHomework->setGeometry(ui->btn_onlineExam->x(), nTop,
  237. ui->btn_onlineExam->width(), ui->btn_onlineExam->height());
  238. nTop = nTop + ui->btn_onlineExam->height() + g_appInfoPtr->m_fRate * 17;
  239. }
  240. if (ui->btn_onlinePractice->isVisible())
  241. {
  242. ui->btn_onlinePractice->setGeometry(ui->btn_onlineExam->x(), nTop,
  243. ui->btn_onlineExam->width(), ui->btn_onlineExam->height());
  244. nTop = nTop + ui->btn_onlineExam->height() + g_appInfoPtr->m_fRate * 17;
  245. }
  246. if (ui->btn_offlineExam->isVisible())
  247. {
  248. ui->btn_offlineExam->setGeometry(ui->btn_onlineExam->x(), nTop,
  249. ui->btn_onlineExam->width(), ui->btn_onlineExam->height());
  250. nTop = nTop + ui->btn_onlineExam->height() + g_appInfoPtr->m_fRate * 17;
  251. }
  252. if (ui->btn_notice->isVisible())
  253. {
  254. ui->btn_notice->setGeometry(ui->btn_onlineExam->x(), nTop,
  255. ui->btn_onlineExam->width(), ui->btn_onlineExam->height());
  256. ui->btn_noticeNum->setGeometry(ui->btn_notice->x() + ui->btn_notice->width() - g_appInfoPtr->m_fRate * 16, ui->btn_notice->y(),
  257. g_appInfoPtr->m_fRate * 16, g_appInfoPtr->m_fRate * 16);
  258. nTop = nTop + ui->btn_onlineExam->height() + g_appInfoPtr->m_fRate * 17;
  259. }
  260. if (ui->btn_editPassword->isVisible())
  261. {
  262. ui->btn_editPassword->setGeometry(ui->btn_onlineExam->x(), ui->btn_notice->y() + ui->btn_notice->height() + g_appInfoPtr->m_fRate * 17,
  263. ui->btn_onlineExam->width(), ui->btn_onlineExam->height());
  264. }
  265. }
  266. void courseList::on_btn_minisize_clicked()
  267. {
  268. emit minisize();
  269. }
  270. void courseList::on_btn_cl_close_clicked()
  271. {
  272. // logout();
  273. // close();
  274. QCoreApplication::quit();
  275. }
  276. void courseList::setCheck(COURSE_MENU_BTN_TYPE cmbt)
  277. {
  278. QString sNormalSheet = QString(R"(outline:none;
  279. font-size:%1px;
  280. font-family:"Microsoft YaHei";
  281. font-weight:400;
  282. color:rgba(255,255,255,0.4);
  283. background:rgba(255,255,255,0);
  284. border-radius:%2;)").arg((int)(g_appInfoPtr->m_fRate*12)).arg(g_appInfoPtr->m_fRate*12);
  285. QString sCheckSheet = QString(R"(QPushButton
  286. {
  287. outline:none;
  288. font-size:%1px;
  289. font-family:"Microsoft YaHei";
  290. font-weight:400;
  291. color:rgba(255,255,255,1);
  292. border-radius:%2px;
  293. background:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(16, 195, 182, 1), stop:1 rgba(39, 217, 146, 1));
  294. })").arg((int)(g_appInfoPtr->m_fRate*12)).arg(g_appInfoPtr->m_fRate*12);
  295. ui->btn_onlineExam->setStyleSheet(sNormalSheet);
  296. ui->btn_onlineHomework->setStyleSheet(sNormalSheet);
  297. ui->btn_onlinePractice->setStyleSheet(sNormalSheet);
  298. ui->btn_offlineExam->setStyleSheet(sNormalSheet);
  299. ui->btn_notice->setStyleSheet(sNormalSheet);
  300. ui->btn_editPassword->setStyleSheet(sNormalSheet);
  301. if (m_pOnlineExam != nullptr)
  302. {
  303. m_pOnlineExam->hide();
  304. }
  305. if (m_pOnlineHomework != nullptr)
  306. {
  307. m_pOnlineHomework->hide();
  308. }
  309. if (m_pOnlinePractice != nullptr)
  310. {
  311. m_pOnlinePractice->hide();
  312. m_pOnlinePractice->releaseClopResult();
  313. }
  314. if (m_pClopReport != nullptr)
  315. {
  316. m_pClopReport->hide();
  317. }
  318. if (m_pOfflineExam != nullptr)
  319. {
  320. m_pOfflineExam->hide();
  321. }
  322. if (m_pNoticeList != nullptr)
  323. {
  324. m_pNoticeList->hide();
  325. }
  326. if (m_pEditPassword != nullptr)
  327. {
  328. m_pEditPassword->hide();
  329. }
  330. QString sCurrentPlace = "";
  331. if (cmbt == COURSE_MENU_BTN_TYPE::cmbt_online_exam)
  332. {
  333. if (m_pOnlineExam == nullptr)
  334. {
  335. m_pOnlineExam = std::make_shared<clOnlineExam>(ui->stw_courseList);
  336. m_pOnlineExam->setUI(ui->stw_courseList->width(), ui->stw_courseList->height());
  337. connect(m_pOnlineExam.get(), &clOnlineExam::enterExam, this, &courseList::onEnterExam);
  338. }
  339. m_pOnlineExam->show();
  340. ui->btn_onlineExam->setStyleSheet(sCheckSheet);
  341. sCurrentPlace = QString::fromLocal8Bit("当前所在位置:在线考试");
  342. }
  343. else if(cmbt == COURSE_MENU_BTN_TYPE::cmbt_online_homework)
  344. {
  345. if (m_pOnlineHomework == nullptr)
  346. {
  347. m_pOnlineHomework = std::make_shared<clOnlineHomework>(ui->stw_courseList);
  348. m_pOnlineHomework->setUI(ui->stw_courseList->width(), ui->stw_courseList->height());
  349. connect(m_pOnlineHomework.get(), &clOnlineHomework::enterExam, this, &courseList::onEnterExam);
  350. }
  351. m_pOnlineHomework->show();
  352. ui->btn_onlineHomework->setStyleSheet(sCheckSheet);
  353. sCurrentPlace = QString::fromLocal8Bit("当前所在位置:在线作业");
  354. }
  355. else if(cmbt == COURSE_MENU_BTN_TYPE::cmbt_online_practice)
  356. {
  357. if (m_pOnlinePractice == nullptr)
  358. {
  359. m_pOnlinePractice = std::make_shared<clOnlinePractice>(ui->stw_courseList);
  360. m_pOnlinePractice->setUI(ui->stw_courseList->width(), ui->stw_courseList->height());
  361. connect(m_pOnlinePractice.get(), &clOnlinePractice::enterExam, this, &courseList::onEnterExam);
  362. }
  363. m_pOnlinePractice->show();
  364. ui->btn_onlinePractice->setStyleSheet(sCheckSheet);
  365. sCurrentPlace = QString::fromLocal8Bit("当前所在位置:在线练习");
  366. }
  367. else if(cmbt == COURSE_MENU_BTN_TYPE::cmbt_offline_exam)
  368. {
  369. if (m_pOfflineExam == nullptr)
  370. {
  371. m_pOfflineExam = std::make_shared<clOfflineExam>(ui->stw_courseList);
  372. m_pOfflineExam->setUI(ui->stw_courseList->width(), ui->stw_courseList->height());
  373. }
  374. m_pOfflineExam->show();
  375. ui->btn_offlineExam->setStyleSheet(sCheckSheet);
  376. sCurrentPlace = QString::fromLocal8Bit("当前所在位置:离线考试");
  377. }
  378. else if(cmbt == COURSE_MENU_BTN_TYPE::cmbt_notice)
  379. {
  380. if (m_pNoticeList == nullptr)
  381. {
  382. m_pNoticeList = std::make_shared<clNoticeList>(ui->stw_courseList);
  383. m_pNoticeList->setUI(ui->stw_courseList->width(), ui->stw_courseList->height());
  384. }
  385. m_pNoticeList->show();
  386. ui->btn_notice->setStyleSheet(sCheckSheet);
  387. sCurrentPlace = QString::fromLocal8Bit("当前所在位置:公告通知");
  388. }
  389. else if(cmbt == COURSE_MENU_BTN_TYPE::cmbt_edit_password)
  390. {
  391. if (m_pEditPassword == nullptr)
  392. {
  393. m_pEditPassword = std::make_shared<clEditPassword>(ui->stw_courseList);
  394. m_pEditPassword->setUI(ui->stw_courseList->width(), ui->stw_courseList->height());
  395. }
  396. m_pEditPassword->show();
  397. ui->btn_editPassword->setStyleSheet(sCheckSheet);
  398. sCurrentPlace = QString::fromLocal8Bit("当前所在位置:修改密码");
  399. }
  400. ui->label_currrentPlace->setText(sCurrentPlace);
  401. }
  402. void courseList::onEnterExam(CL_OPERATION_TYPE cot, __int64 nExamId, __int64 nExamStudentId, QString sCourseCode, QString sCourseName)
  403. {
  404. if(cot == CL_OPERATION_TYPE::cot_online_exam)
  405. {
  406. g_appInfoPtr->m_oExamInfo.sExamType = EXAM_TYPES::ONLINE;
  407. }
  408. g_appInfoPtr->m_oExamInfo.nExamId = nExamId;
  409. g_appInfoPtr->m_oExamInfo.nExamStudentId = nExamStudentId;
  410. g_appInfoPtr->m_oExamInfo.sCourseCode = sCourseCode;
  411. g_appInfoPtr->m_oExamInfo.sCourseName = sCourseName;
  412. //开考限流
  413. m_nRetryCount = 0;
  414. CHttpRequestPackage hrp;
  415. hrp.sUri = QString("https://tcc.qmth.com.cn/rate_limit/prod/startExam/%1").arg(100);
  416. hrp.nRequestType = RequestType::rtStartExamLimit;
  417. g_httpBllPtr->getUrl(hrp);
  418. }
  419. void courseList::onStartExamLimit(CStartExamLimit startExamLimit)
  420. {
  421. if (startExamLimit.nCode == 200)
  422. {
  423. ++m_nRetryCount;
  424. if (startExamLimit.bPass)
  425. {
  426. CHttpRequestPackage hrp;
  427. hrp.sUri = QString("/api/ecs_exam_work/exam/ipLimit/%1").arg(g_appInfoPtr->m_oExamInfo.nExamId);
  428. hrp.nRequestType = RequestType::rtIpLimit;
  429. g_httpBllPtr->get(hrp);
  430. }
  431. else
  432. {
  433. //重试
  434. if(m_nRetryCount >= 3)
  435. {
  436. ShowMsg(QString::fromLocal8Bit("系统繁忙,请稍后重试"), this, MSG_ICON_TYPE::mit_error);
  437. }
  438. else
  439. {
  440. QTimer::singleShot(3*1000, this, [](){
  441. CHttpRequestPackage hrp;
  442. hrp.sUri = QString("https://tcc.qmth.com.cn/rate_limit/prod/startExam/%1").arg(100);
  443. hrp.nRequestType = RequestType::rtStartExamLimit;
  444. g_httpBllPtr->getUrl(hrp);
  445. });
  446. }
  447. }
  448. }
  449. else
  450. {
  451. ShowMsg(QString::fromLocal8Bit("开考失败"), this, MSG_ICON_TYPE::mit_error);
  452. }
  453. }
  454. void courseList::onIpLimit(CIpLimit ipLimit)
  455. {
  456. if (ipLimit.nCode == 200)
  457. {
  458. if (!ipLimit.bLimited)
  459. {
  460. //断点
  461. CHttpRequestPackage hrp;
  462. hrp.sUri = "/api/ecs_oe_student/client/exam/process/checkExamInProgress";
  463. hrp.nRequestType = RequestType::rtCheckExamInProgress;
  464. hrp.sCommonStr = EXAM_INPROGRESS_ENTER_TYPE::EIET_ENTER_EXAM;
  465. g_httpBllPtr->post(hrp);
  466. }
  467. else
  468. {
  469. ShowMsg(QString::fromLocal8Bit("当前ip限制参加考试"), this, MSG_ICON_TYPE::mit_error);
  470. }
  471. }
  472. else
  473. {
  474. ShowMsg(QString::fromLocal8Bit("开考失败"), this, MSG_ICON_TYPE::mit_error);
  475. }
  476. }
  477. void courseList::onGetExamProperty(CGetExamProperty getExamProperty)
  478. {
  479. if (getExamProperty.nCode == 200)
  480. {
  481. if (getExamProperty.sType == "CHECK_ENVIRONMENT,IS_FACE_CHECK,SNAPSHOT_INTERVAL,WARN_THRESHOLD,FACE_VERIFY_START_MINUTE,FACE_VERIFY_END_MINUTE,IS_STRANGER_ENABLE,IS_FACE_VERIFY_BEFORE")
  482. {
  483. g_appInfoPtr->m_oExamInfo.bIsFaceCheck = getExamProperty.bIsFaceCheck;
  484. g_appInfoPtr->m_oExamInfo.nWarnThreshold = getExamProperty.nWarnThreshold;
  485. g_appInfoPtr->m_oExamInfo.nSnapshotInterval = getExamProperty.nSnapshotInterval;
  486. g_appInfoPtr->m_oExamInfo.nFaceVerifyStartMinute = getExamProperty.nFaceVerifyStartMinute;
  487. g_appInfoPtr->m_oExamInfo.nFaceVerifyEndMinute = getExamProperty.nFaceVerifyEndMinute;
  488. g_appInfoPtr->m_oExamInfo.bIsStrangerEnable = getExamProperty.bIsStrangerEnable;
  489. g_appInfoPtr->m_oExamInfo.bIsLivenessBefore = getExamProperty.bIsLivenessBefore;
  490. if (getExamProperty.bCheckEnvironment && !g_appInfoPtr->m_oExamInfo.bIsExamInProgress)
  491. {
  492. if(m_pWhetherEnvTest == nullptr)
  493. {
  494. m_pWhetherEnvTest = std::make_shared<etWhetherEnvTest>(this);
  495. connect(m_pWhetherEnvTest.get(), &etWhetherEnvTest::envTest, this, [&](){
  496. m_pWhetherEnvTest.reset();
  497. //环境检测
  498. if (m_pEnvironmentalTest == nullptr)
  499. {
  500. m_pEnvironmentalTest = std::make_shared<environmentalTest>(this);
  501. connect(m_pEnvironmentalTest.get(), &environmentalTest::enterExam, this, [&](){
  502. m_pEnvironmentalTest.reset();
  503. //人脸识别
  504. CHttpRequestPackage hrp;
  505. hrp.sUri = QString("/api/ecs_exam_work/exam/faceCheckEnabled/%1")
  506. .arg(g_appInfoPtr->m_oExamInfo.nExamId);
  507. hrp.nRequestType = RequestType::rtFaceCheckEnabled;
  508. g_httpBllPtr->get(hrp);
  509. });
  510. }
  511. m_pEnvironmentalTest->show();
  512. });
  513. connect(m_pWhetherEnvTest.get(), &etWhetherEnvTest::skipEnvTest, this, [&](){
  514. m_pWhetherEnvTest.reset();
  515. //人脸识别
  516. CHttpRequestPackage hrp;
  517. hrp.sUri = QString("/api/ecs_exam_work/exam/faceCheckEnabled/%1")
  518. .arg(g_appInfoPtr->m_oExamInfo.nExamId);
  519. hrp.nRequestType = RequestType::rtFaceCheckEnabled;
  520. g_httpBllPtr->get(hrp);
  521. });
  522. }
  523. m_pWhetherEnvTest->show();
  524. }
  525. else
  526. {
  527. //人脸识别
  528. CHttpRequestPackage hrp;
  529. hrp.sUri = QString("/api/ecs_exam_work/exam/faceCheckEnabled/%1")
  530. .arg(g_appInfoPtr->m_oExamInfo.nExamId);
  531. hrp.nRequestType = RequestType::rtFaceCheckEnabled;
  532. g_httpBllPtr->get(hrp);
  533. }
  534. }
  535. }
  536. else
  537. {
  538. if(getExamProperty.sMessage.isEmpty())
  539. {
  540. ShowMsg(QString::fromLocal8Bit("获取考试信息失败"), this, MSG_ICON_TYPE::mit_error);
  541. }
  542. else
  543. {
  544. ShowMsg(getExamProperty.sMessage, this);
  545. }
  546. }
  547. }
  548. void courseList::onFaceCheckEnabled(CFaceCheckEnabled faceCheckEnabled)
  549. {
  550. if (faceCheckEnabled.nCode == 200)
  551. {
  552. //人脸检测
  553. g_appInfoPtr->m_oExamInfo.bFaceCheck = faceCheckEnabled.bEnabled;
  554. // if (faceCheckEnabled.bEnabled && !g_appInfoPtr->m_oExamInfo.bIsExamInProgress)
  555. // {
  556. // if (g_appInfoPtr->m_sStudentPhotoPath.isEmpty())
  557. // {
  558. // ShowMsg(QString::fromLocal8Bit("本场考试需要进行人脸检测,但是您没有上传底照,请联系老师"), this, MSG_ICON_TYPE::mit_error);
  559. // return;
  560. // }
  561. // if (m_pFaceCompare == nullptr)
  562. // {
  563. // m_pFaceCompare = std::make_shared<faceCompare>(this);
  564. // connect(m_pFaceCompare.get(), &faceCompare::exitFaceCompare, this, [&]() {
  565. // m_pFaceCompare.reset();
  566. // });
  567. // connect(m_pFaceCompare.get(), &faceCompare::faceComparePass, this, [&]() {
  568. // m_pFaceCompare.reset();
  569. // //活体检测
  570. // CHttpRequestPackage hrp;
  571. // hrp.sUri = QString("/api/ecs_exam_work/exam/identificationOfLivingEnabled/%1")
  572. // .arg(g_appInfoPtr->m_oExamInfo.nExamId);
  573. // hrp.nRequestType = RequestType::rtLivenessEnabled;
  574. // g_httpBllPtr->get(hrp);
  575. // });
  576. // }
  577. // m_pFaceCompare->show();
  578. // }
  579. // else
  580. {
  581. //活体检测
  582. CHttpRequestPackage hrp;
  583. hrp.sUri = QString("/api/ecs_exam_work/exam/identificationOfLivingEnabled/%1")
  584. .arg(g_appInfoPtr->m_oExamInfo.nExamId);
  585. hrp.nRequestType = RequestType::rtLivenessEnabled;
  586. g_httpBllPtr->get(hrp);
  587. }
  588. }
  589. else
  590. {
  591. if(faceCheckEnabled.sMessage.isEmpty())
  592. {
  593. ShowMsg(QString::fromLocal8Bit("获取人脸识别信息失败"), this, MSG_ICON_TYPE::mit_error);
  594. }
  595. else
  596. {
  597. ShowMsg(faceCheckEnabled.sMessage, this, MSG_ICON_TYPE::mit_error);
  598. }
  599. }
  600. }
  601. void courseList::doFaceCompare()
  602. {
  603. if (g_appInfoPtr->m_sStudentPhotoPath.isEmpty())
  604. {
  605. ShowMsg(QString::fromLocal8Bit("本场考试需要进行人脸检测,但是您没有上传底照,请联系老师"), this, MSG_ICON_TYPE::mit_error);
  606. return;
  607. }
  608. if (m_pFaceCompare == nullptr)
  609. {
  610. m_pFaceCompare = std::make_shared<faceCompare>(this);
  611. connect(m_pFaceCompare.get(), &faceCompare::exitFaceCompare, this, [&]() {
  612. m_pFaceCompare.reset();
  613. });
  614. connect(m_pFaceCompare.get(), &faceCompare::faceComparePass, this, [&]() {
  615. m_pFaceCompare.reset();
  616. //进入待考
  617. enterWaitExam();
  618. });
  619. }
  620. m_pFaceCompare->show();
  621. }
  622. void courseList::onLivenessEnabled(CLivenessEnabled livenessEnabled)
  623. {
  624. if (livenessEnabled.nCode == 200)
  625. {
  626. g_appInfoPtr->m_oExamInfo.bLivenessCheck = livenessEnabled.bEnabled;
  627. GetOrgPropertiesByGroupWithoutCache();
  628. //进入待考
  629. // enterWaitExam();
  630. }
  631. else
  632. {
  633. if(livenessEnabled.sMessage.isEmpty())
  634. {
  635. ShowMsg(QString::fromLocal8Bit("获取活体信息失败"), this, MSG_ICON_TYPE::mit_error);
  636. }
  637. else
  638. {
  639. ShowMsg(livenessEnabled.sMessage, this, MSG_ICON_TYPE::mit_error);
  640. }
  641. }
  642. }
  643. void courseList::doLiveness()
  644. {
  645. //活体检测
  646. if(m_pFaceLiveness == nullptr)
  647. {
  648. m_pFaceLiveness = std::make_shared<faceLiveness>(FACE_LIVENESS_TYPE::flt_entry_exam, this);
  649. connect(m_pFaceLiveness.get(), &faceLiveness::faceLivenessFaild, this, [&](){
  650. g_appInfoPtr->m_oExamInfo.nFaceLiveVerifyId = 0;
  651. m_pFaceLiveness.reset();
  652. });
  653. connect(m_pFaceLiveness.get(), &faceLiveness::faceLivenessSucceed, this, [&](){
  654. g_appInfoPtr->m_oExamInfo.nFaceLiveVerifyId = 0;
  655. m_pFaceLiveness.reset();
  656. //进入待考
  657. enterWaitExam();
  658. });
  659. m_pFaceLiveness->show();
  660. }
  661. }
  662. void courseList::GetOrgPropertiesByGroupWithoutCache()
  663. {
  664. CHttpRequestPackage hrp;
  665. hrp.sUri = QString("/api/ecs_core/org/getOrgPropertiesByGroupWithoutCache/%1/config4Edit1")
  666. .arg(g_appInfoPtr->m_sRootOrgId);
  667. hrp.nRequestType = RequestType::rtGetOrgPropertiesByGroupWithoutCache;
  668. g_httpBllPtr->get(hrp);
  669. }
  670. void courseList::onGetOrgPropertiesByGroupWithoutCache(CGetOrgPropertiesByGroupWithoutCache orgProperties)
  671. {
  672. if(orgProperties.nCode == 200)
  673. {
  674. m_nRetryCount = 0;
  675. g_appInfoPtr->m_oExamInfo.nActionNum = orgProperties.nActionNum;
  676. g_appInfoPtr->m_oExamInfo.sActionOptions = orgProperties.sActionOptions;
  677. g_appInfoPtr->m_oExamInfo.sActionOrder = orgProperties.sActionOrder;
  678. g_appInfoPtr->m_oExamInfo.nActionDuration = orgProperties.nActionDuration;
  679. g_appInfoPtr->m_oExamInfo.nActionAlert = orgProperties.nActionAlert;
  680. g_appInfoPtr->m_oExamInfo.nAllActionDuration = orgProperties.nAllActionDuration;
  681. if(!g_appInfoPtr->m_oExamInfo.bIsExamInProgress)
  682. {
  683. if(g_appInfoPtr->m_oExamInfo.bIsLivenessBefore)
  684. {
  685. doLiveness();
  686. }
  687. else if(g_appInfoPtr->m_oExamInfo.bFaceCheck)
  688. {
  689. doFaceCompare();
  690. }
  691. }
  692. else
  693. {
  694. enterWaitExam();
  695. }
  696. }
  697. else
  698. {
  699. if(orgProperties.sMessage.isEmpty())
  700. {
  701. ShowMsg(QString::fromLocal8Bit("获取活体信息失败"), this, MSG_ICON_TYPE::mit_error);
  702. }
  703. else
  704. {
  705. ShowMsg(orgProperties.sMessage, this, MSG_ICON_TYPE::mit_error);
  706. }
  707. }
  708. }
  709. void courseList::enterWaitExam()
  710. {
  711. //进入待考
  712. if (m_pBackground == nullptr)
  713. {
  714. if (g_appInfoPtr->m_oExamInfo.bIsExamInProgress)
  715. {
  716. m_pBackground = std::make_shared<awBackground>(AW_WIDGET_TYPE::awwt_answerWidget, this);
  717. m_pResumeExam.reset();
  718. }
  719. else
  720. {
  721. m_pBackground = std::make_shared<awBackground>(AW_WIDGET_TYPE::awwt_waitExam, this);
  722. }
  723. connect(m_pBackground.get(), &awBackground::minisize, this, &courseList::minisize);
  724. connect(m_pBackground.get(), &awBackground::closeWidget, this, [&](){
  725. m_pBackground.reset();
  726. m_pRefreshMenuTimer->start();
  727. if(m_pOnlineExam)
  728. {
  729. m_pOnlineExam->refreshExam();
  730. }
  731. if(m_pOnlineHomework)
  732. {
  733. m_pOnlineHomework->refreshExam();
  734. }
  735. });
  736. connect(m_pBackground.get(), &awBackground::gobackLogin, this, [&](){
  737. m_pBackground.reset();
  738. logout();
  739. close();
  740. });
  741. connect(m_pBackground.get(), &awBackground::showPracticeInfo, this, [&](){
  742. m_pBackground.reset();
  743. CPracticeRecord pr;
  744. pr.nId = g_appInfoPtr->m_oExamInfo.nExamRecordDataId;
  745. pr.sCourseCode = g_appInfoPtr->m_oExamInfo.sCourseCode;
  746. pr.sCourseName = g_appInfoPtr->m_oExamInfo.sCourseName;
  747. if(m_pClopReport == nullptr)
  748. {
  749. m_pClopReport = std::make_shared<clopReport>(pr, true, ui->stw_courseList);
  750. connect(m_pClopReport.get(), &clopReport::goback, this, [&](){
  751. m_pClopReport.reset();
  752. if(m_pOnlinePractice)
  753. {
  754. m_pOnlinePractice->refreshExamInfo();
  755. }
  756. });
  757. m_pClopReport->setUI(0, 0, ui->stw_courseList->width(), ui->stw_courseList->height());
  758. }
  759. m_pClopReport->show();
  760. m_pRefreshMenuTimer->start();
  761. });
  762. }
  763. m_pBackground->show();
  764. m_pRefreshMenuTimer->stop();
  765. }
  766. void courseList::on_btn_onlineExam_clicked()
  767. {
  768. ui->stw_courseList->setCurrentIndex(0);
  769. setCheck(COURSE_MENU_BTN_TYPE::cmbt_online_exam);
  770. }
  771. void courseList::on_btn_onlineHomework_clicked()
  772. {
  773. ui->stw_courseList->setCurrentIndex(1);
  774. setCheck(COURSE_MENU_BTN_TYPE::cmbt_online_homework);
  775. }
  776. void courseList::on_btn_onlinePractice_clicked()
  777. {
  778. ui->stw_courseList->setCurrentIndex(2);
  779. setCheck(COURSE_MENU_BTN_TYPE::cmbt_online_practice);
  780. }
  781. void courseList::on_btn_offlineExam_clicked()
  782. {
  783. ui->stw_courseList->setCurrentIndex(3);
  784. setCheck(COURSE_MENU_BTN_TYPE::cmbt_offline_exam);
  785. }
  786. void courseList::on_btn_notice_clicked()
  787. {
  788. ui->stw_courseList->setCurrentIndex(4);
  789. setCheck(COURSE_MENU_BTN_TYPE::cmbt_notice);
  790. }
  791. void courseList::on_btn_editPassword_clicked()
  792. {
  793. ui->stw_courseList->setCurrentIndex(5);
  794. setCheck(COURSE_MENU_BTN_TYPE::cmbt_edit_password);
  795. }
  796. void courseList::on_btn_exit_clicked()
  797. {
  798. logout();
  799. close();
  800. }
  801. void courseList::logout()
  802. {
  803. CHttpRequestPackage hrp;
  804. hrp.sUri = "/api/ecs_core/auth/logout";
  805. hrp.nRequestType = RequestType::rtLogout;
  806. g_httpBllPtr->get(hrp);
  807. }
  808. bool courseList::eventFilter(QObject *obj, QEvent *ev)
  809. {
  810. if(ev->type() == QEvent::Enter)
  811. {
  812. if(obj == ui->btn_mobileLogin)
  813. {
  814. m_pMobileLoginBtnTimer->stop();
  815. if(m_pStudentInfo != nullptr)
  816. {
  817. m_pStudentInfo.reset();
  818. m_pStudentInfo = nullptr;
  819. }
  820. if(m_pMobileLogin == nullptr)
  821. {
  822. m_pMobileLogin = std::make_shared<clMobileLogin>(this);
  823. m_pMobileLogin->setUI(g_appInfoPtr->m_fRate*838, g_appInfoPtr->m_fRate*53, g_appInfoPtr->m_fRate*240, g_appInfoPtr->m_fRate*290);
  824. m_pMobileLogin->show();
  825. m_pMobileLogin->installEventFilter(this);
  826. }
  827. ui->btn_mobileLogin->setIcon(QIcon(":/images/icon-mobile-login-hover.png"));
  828. }
  829. else if(obj == ui->btn_studentInfo)
  830. {
  831. m_pStudentInfoBtnTimer->stop();
  832. if(m_pMobileLogin != nullptr)
  833. {
  834. m_pMobileLogin.reset();
  835. m_pMobileLogin = nullptr;
  836. }
  837. if(m_pStudentInfo == nullptr)
  838. {
  839. m_pStudentInfo = std::make_shared<clStudentInfo>(this);
  840. connect(m_pStudentInfo.get(), &clStudentInfo::sgnStudentLogout, this, [&]() {
  841. on_btn_exit_clicked();
  842. });
  843. connect(m_pStudentInfo.get(), &clStudentInfo::sgnStudentEditPassword, this, [&]() {
  844. if (m_pStudentInfo != nullptr)
  845. {
  846. m_pStudentInfo.reset();
  847. }
  848. on_btn_editPassword_clicked();
  849. });
  850. m_pStudentInfo->setUI(g_appInfoPtr->m_fRate*838, g_appInfoPtr->m_fRate*53, g_appInfoPtr->m_fRate*330, g_appInfoPtr->m_fRate*240);
  851. m_pStudentInfo->show();
  852. m_pStudentInfo->installEventFilter(this);
  853. }
  854. ui->btn_studentInfo->setIcon(QIcon(":/images/icon-student-info-hover.png"));
  855. }
  856. else if(obj == m_pMobileLogin.get())
  857. {
  858. m_pMobileLoginBtnTimer->stop();
  859. }
  860. else if(obj == m_pStudentInfo.get())
  861. {
  862. m_pStudentInfoBtnTimer->stop();
  863. }
  864. }
  865. else if(ev->type() == QEvent::Leave)
  866. {
  867. if(obj == ui->btn_mobileLogin || obj == m_pMobileLogin.get())
  868. {
  869. ui->btn_mobileLogin->setIcon(QIcon(":/images/icon-mobile-login.png"));
  870. m_pMobileLoginBtnTimer->start();
  871. }
  872. if(obj == ui->btn_studentInfo || obj == m_pStudentInfo.get())
  873. {
  874. ui->btn_studentInfo->setIcon(QIcon(":/images/icon-student-info.png"));
  875. m_pStudentInfoBtnTimer->start();
  876. }
  877. }
  878. return QWidget::eventFilter(obj, ev);
  879. }
  880. void courseList::hideStudentInfoBtn()
  881. {
  882. if(m_pStudentInfo != nullptr)
  883. {
  884. m_pStudentInfo.reset();
  885. }
  886. }
  887. void courseList::hideMobileLoginBtn()
  888. {
  889. if(m_pMobileLogin != nullptr)
  890. {
  891. m_pMobileLogin.reset();
  892. }
  893. }
  894. void courseList::getStudentInfoBySession()
  895. {
  896. CHttpRequestPackage hrp;
  897. hrp.sUri = "/api/ecs_core/student/getStudentInfoBySession";
  898. hrp.nRequestType = RequestType::rtGetStudentInfoBySession;
  899. g_httpBllPtr->get(hrp);
  900. }
  901. void courseList::onGetStudentInfoBySession(CGetStudentInfoBySession getStudentInfoBySession)
  902. {
  903. if (getStudentInfoBySession.nCode == 200)
  904. {
  905. g_appInfoPtr->m_nStudentId = getStudentInfoBySession.nId;
  906. g_appInfoPtr->m_sStudentName = getStudentInfoBySession.sName;
  907. g_appInfoPtr->m_nOrgId = getStudentInfoBySession.nOrgId;
  908. g_appInfoPtr->m_sOrgCode = getStudentInfoBySession.sOrgCode;
  909. g_appInfoPtr->m_sOrgName = getStudentInfoBySession.sOrgName;
  910. g_appInfoPtr->m_sStudentCode = getStudentInfoBySession.sStudentCode;
  911. g_appInfoPtr->m_sStudentIdentityNumber = getStudentInfoBySession.sIdentityNumber;
  912. g_appInfoPtr->m_sStudentPhotoPath = getStudentInfoBySession.sPhotoPath;
  913. g_appInfoPtr->m_bStudentEnable = getStudentInfoBySession.bEnable;
  914. ui->btn_studentInfo->setText(g_appInfoPtr->m_sStudentName);
  915. ui->btn_studentInfo->setVisible(g_appInfoPtr->m_bStudentEnable);
  916. ui->btn_mobileLogin->setVisible(g_appInfoPtr->m_bShowStudentClientAppQrcode);
  917. CHttpRequestPackage hrp;
  918. hrp.sUri = "/api/ecs_exam_work/exam_student/specialtyNameList";
  919. hrp.nRequestType = RequestType::rtSpecialtyNameList;
  920. g_httpBllPtr->get(hrp);
  921. if (!g_appInfoPtr->m_sStudentPhotoPath.isEmpty())
  922. {
  923. QString sFileName = g_appInfoPtr->m_sStudentPhotoPath.right(g_appInfoPtr->m_sStudentPhotoPath.length() - g_appInfoPtr->m_sStudentPhotoPath.lastIndexOf("/") - 1);
  924. sFileName = g_appInfoPtr->m_sCacheFileDir + sFileName;
  925. CHttpRequestPackage hrp;
  926. hrp.sUri = g_appInfoPtr->m_sStudentPhotoPath;
  927. hrp.sCommonStr = sFileName;
  928. hrp.sCommonStr1 = __FILE__;
  929. hrp.sAdditionStr = "StudentPhotoPath";
  930. hrp.nRequestType = RequestType::rtDownLoadFile;
  931. hrp.nRetryCount = 3;
  932. g_httpBllPtr->downLoad(hrp);
  933. }
  934. if (g_appInfoPtr->m_bShowStudentClientAppQrcode)
  935. {
  936. CHttpRequestPackage hrp;
  937. hrp.sUri = "/api/ecs_core/systemProperty/APP_DOWNLOAD_URL";
  938. hrp.nRequestType = RequestType::rtAppDownLoadUrl;
  939. g_httpBllPtr->get(hrp);
  940. }
  941. }
  942. else
  943. {
  944. if(getStudentInfoBySession.sMessage.isEmpty())
  945. {
  946. ShowMsg(QString::fromLocal8Bit("获取考生信息失败"), this, MSG_ICON_TYPE::mit_error);
  947. }
  948. else
  949. {
  950. ShowMsg(getStudentInfoBySession.sMessage, this, MSG_ICON_TYPE::mit_error);
  951. }
  952. courseList::getStudentInfoBySession();
  953. }
  954. }
  955. void courseList::onAppDownLoadUrl(CAppDownLoadUrl appDownLoadUrl)
  956. {
  957. if (appDownLoadUrl.nCode == 200)
  958. {
  959. g_appInfoPtr->m_sAppDownLoadUrl = appDownLoadUrl.sUrl;
  960. }
  961. else
  962. {
  963. if(appDownLoadUrl.sMessage.isEmpty())
  964. {
  965. ShowMsg(QString::fromLocal8Bit("获取APP下载地址失败"), this, MSG_ICON_TYPE::mit_error);
  966. }
  967. else
  968. {
  969. ShowMsg(appDownLoadUrl.sMessage, this, MSG_ICON_TYPE::mit_error);
  970. }
  971. }
  972. }
  973. void courseList::onDownLoadFile(CDownLoadFileInfo downLoadFileInfo)
  974. {
  975. if(downLoadFileInfo.sModuleName == __FILE__)
  976. {
  977. if (downLoadFileInfo.nCode == 200)
  978. {
  979. // QString sFileName = g_appInfoPtr->m_sStudentPhotoPath.right(g_appInfoPtr->m_sStudentPhotoPath.length() - g_appInfoPtr->m_sStudentPhotoPath.lastIndexOf("/") - 1);
  980. // sFileName = g_appInfoPtr->m_sCacheFileDir + sFileName;
  981. if (downLoadFileInfo.sAdditionStr == "MenuLogoUrl")
  982. {
  983. QString sFileName = g_appInfoPtr->m_sMenuLogoUrl.right(g_appInfoPtr->m_sMenuLogoUrl.length() - g_appInfoPtr->m_sMenuLogoUrl.lastIndexOf("/") - 1);
  984. sFileName = g_appInfoPtr->m_sCacheFileDir + sFileName;
  985. ui->label_cl_org_icon->setPixmap(QPixmap(sFileName).scaled(ui->label_cl_org_icon->width(), ui->label_cl_org_icon->height(),
  986. Qt::KeepAspectRatio, Qt::SmoothTransformation));
  987. }
  988. }
  989. else
  990. {
  991. if(downLoadFileInfo.sMessage.isEmpty())
  992. {
  993. ShowMsg(QString::fromLocal8Bit("下载失败"), this, MSG_ICON_TYPE::mit_error);
  994. }
  995. else
  996. {
  997. ShowMsg(downLoadFileInfo.sMessage, this, MSG_ICON_TYPE::mit_error);
  998. }
  999. }
  1000. }
  1001. }
  1002. void courseList::onSpecialtyNameList(CSpecialtyNameList specialtyNameList)
  1003. {
  1004. if (specialtyNameList.nCode == 200)
  1005. {
  1006. g_appInfoPtr->m_sSpecialtyName = specialtyNameList.sSpecialtyName;
  1007. CHttpRequestPackage hrp;
  1008. hrp.sUri = "/api/ecs_oe_student/client/exam/process/checkExamInProgress";
  1009. hrp.nRequestType = RequestType::rtCheckExamInProgress;
  1010. hrp.sCommonStr = EXAM_INPROGRESS_ENTER_TYPE::EIET_COURSE_LIST;
  1011. g_httpBllPtr->post(hrp);
  1012. }
  1013. else
  1014. {
  1015. if(specialtyNameList.sMessage.isEmpty())
  1016. {
  1017. ShowMsg(QString::fromLocal8Bit("获取专业信息失败"), this, MSG_ICON_TYPE::mit_error);
  1018. }
  1019. else
  1020. {
  1021. ShowMsg(specialtyNameList.sMessage, this, MSG_ICON_TYPE::mit_error);
  1022. }
  1023. }
  1024. }
  1025. void courseList::onCheckExamInProgress(CCheckExamInProgress checkExamInProgress)
  1026. {
  1027. if (checkExamInProgress.nCode == 200)
  1028. {
  1029. if (checkExamInProgress.bHasExamInProgress)
  1030. {
  1031. if (checkExamInProgress.bIsExceed)
  1032. {
  1033. //超过断点时长交卷
  1034. g_appInfoPtr->m_oExamInfo.nExamRecordDataId = checkExamInProgress.nExamRecordDataId;
  1035. g_appInfoPtr->m_oExamInfo.nExamId = checkExamInProgress.nExamId;
  1036. CHttpRequestPackage hrp;
  1037. hrp.sUri = QString("/api/ecs_oe_student/client/exam/process/endExam");
  1038. hrp.sCommonStr = __FILE__;
  1039. hrp.nRequestType = RequestType::rtEndExam;
  1040. g_httpBllPtr->post(hrp);
  1041. }
  1042. else
  1043. {
  1044. //进入断点
  1045. g_appInfoPtr->m_oExamInfo.nExamId = checkExamInProgress.nExamId;
  1046. g_appInfoPtr->m_oExamInfo.nExamRecordDataId = checkExamInProgress.nExamRecordDataId;
  1047. g_appInfoPtr->m_oExamInfo.sExamType = checkExamInProgress.sExamType;
  1048. g_appInfoPtr->m_oExamInfo.bIsExamInProgress = true;
  1049. if (m_pResumeExam == nullptr)
  1050. {
  1051. m_pResumeExam = std::make_shared<awResumeExam>(this);
  1052. }
  1053. m_pResumeExam->show();
  1054. //环境监测
  1055. CHttpRequestPackage hrp;
  1056. hrp.sUri = QString("/api/ecs_exam_work/exam/getExamPropertyFromCacheByStudentSession/%1/%2")
  1057. .arg(g_appInfoPtr->m_oExamInfo.nExamId).arg("CHECK_ENVIRONMENT,IS_FACE_CHECK,SNAPSHOT_INTERVAL,WARN_THRESHOLD,FACE_VERIFY_START_MINUTE,FACE_VERIFY_END_MINUTE,IS_STRANGER_ENABLE,IS_FACE_VERIFY_BEFORE");
  1058. hrp.nRequestType = RequestType::rtGetExamProperty;
  1059. hrp.sCommonStr = "CHECK_ENVIRONMENT,IS_FACE_CHECK,SNAPSHOT_INTERVAL,WARN_THRESHOLD,FACE_VERIFY_START_MINUTE,FACE_VERIFY_END_MINUTE,IS_STRANGER_ENABLE,IS_FACE_VERIFY_BEFORE";
  1060. g_httpBllPtr->get(hrp);
  1061. }
  1062. }
  1063. else
  1064. {
  1065. g_appInfoPtr->m_oExamInfo.bIsExamInProgress = false;
  1066. if (checkExamInProgress.sEnterType == EXAM_INPROGRESS_ENTER_TYPE::EIET_COURSE_LIST)
  1067. {
  1068. CHttpRequestPackage hrp;
  1069. hrp.sUri = "/api/ecs_core/rolePrivilege/getStudentClientMenu";
  1070. hrp.nRequestType = RequestType::rtGetStudentClientMenu;
  1071. hrp.sParamList.push_back(QString::fromLocal8Bit("rootOrgId,%1").arg(g_appInfoPtr->m_sRootOrgId));
  1072. g_httpBllPtr->get(hrp);
  1073. if (m_pWelcomeWidget == nullptr)
  1074. {
  1075. m_pWelcomeWidget = std::make_shared<welcomeWidget>(g_appInfoPtr->m_sStudentName, g_appInfoPtr->m_sStudentCode, g_appInfoPtr->m_sSpecialtyName, this);
  1076. connect(m_pWelcomeWidget.get(), &welcomeWidget::exitWelcomeWidget, this, [&]() {
  1077. m_pWelcomeWidget.reset();
  1078. });
  1079. }
  1080. m_pWelcomeWidget->show();
  1081. }
  1082. else
  1083. {
  1084. //环境监测
  1085. CHttpRequestPackage hrp;
  1086. hrp.sUri = QString("/api/ecs_exam_work/exam/getExamPropertyFromCacheByStudentSession/%1/%2")
  1087. .arg(g_appInfoPtr->m_oExamInfo.nExamId).arg("CHECK_ENVIRONMENT,IS_FACE_CHECK,SNAPSHOT_INTERVAL,WARN_THRESHOLD,FACE_VERIFY_START_MINUTE,FACE_VERIFY_END_MINUTE,IS_STRANGER_ENABLE,IS_FACE_VERIFY_BEFORE");
  1088. hrp.nRequestType = RequestType::rtGetExamProperty;
  1089. hrp.sCommonStr = "CHECK_ENVIRONMENT,IS_FACE_CHECK,SNAPSHOT_INTERVAL,WARN_THRESHOLD,FACE_VERIFY_START_MINUTE,FACE_VERIFY_END_MINUTE,IS_STRANGER_ENABLE,IS_FACE_VERIFY_BEFORE";
  1090. g_httpBllPtr->get(hrp);
  1091. }
  1092. }
  1093. }
  1094. else
  1095. {
  1096. if(checkExamInProgress.sMessage.isEmpty())
  1097. {
  1098. ShowMsg(QString::fromLocal8Bit("获取断点信息失败"), this, MSG_ICON_TYPE::mit_error);
  1099. }
  1100. else
  1101. {
  1102. ShowMsg(checkExamInProgress.sMessage, this, MSG_ICON_TYPE::mit_error);
  1103. }
  1104. }
  1105. }
  1106. void courseList::onEndExam(CEndExam endExam)
  1107. {
  1108. if(endExam.sModuleName == __FILE__)
  1109. {
  1110. if (endExam.nCode == 200)
  1111. {
  1112. m_pRefreshMenuTimer->stop();
  1113. if(m_pBackground != nullptr)
  1114. {
  1115. m_pBackground.reset();
  1116. }
  1117. m_pBackground = std::make_shared<awBackground>(AW_WIDGET_TYPE::awwt_examScore, this);
  1118. connect(m_pBackground.get(), &awBackground::minisize, this, &courseList::minisize);
  1119. connect(m_pBackground.get(), &awBackground::closeWidget, this, [&](){
  1120. m_pBackground.reset();
  1121. m_pRefreshMenuTimer->start();
  1122. if(m_pOnlineExam)
  1123. {
  1124. m_pOnlineExam->refreshExam();
  1125. }
  1126. if(m_pOnlineHomework)
  1127. {
  1128. m_pOnlineHomework->refreshExam();
  1129. }
  1130. });
  1131. m_pBackground->show();
  1132. }
  1133. else
  1134. {
  1135. if(endExam.sMessage.isEmpty())
  1136. {
  1137. ShowMsg(QString::fromLocal8Bit("交卷失败"), g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
  1138. }
  1139. else
  1140. {
  1141. ShowMsg(endExam.sMessage, g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
  1142. }
  1143. }
  1144. }
  1145. }
  1146. void courseList::onGetStudentClientMenu(CGetStudentClientMenu getStudentClientMenu)
  1147. {
  1148. if (getStudentClientMenu.nCode == 200)
  1149. {
  1150. ui->btn_onlineExam->setVisible(false);
  1151. ui->btn_onlineHomework->setVisible(false);
  1152. ui->btn_onlinePractice->setVisible(false);
  1153. ui->btn_offlineExam->setVisible(false);
  1154. ui->btn_notice->setVisible(false);
  1155. ui->btn_editPassword->setVisible(false);
  1156. for (CStudentClientMenu scm : getStudentClientMenu.vMenus)
  1157. {
  1158. QString sMenuName = scm.sName;
  1159. sMenuName.insert(sMenuName.length()/2, '\n');
  1160. QString sMenuCode = scm.sCode.left(scm.sCode.lastIndexOf("_"));
  1161. if (sMenuCode == "stu_online_exam")
  1162. {
  1163. ui->btn_onlineExam->setVisible(true);
  1164. ui->btn_onlineExam->setText(sMenuName);
  1165. }
  1166. else if (sMenuCode == "stu_online_homework")
  1167. {
  1168. ui->btn_onlineHomework->setVisible(true);
  1169. ui->btn_onlineHomework->setText(sMenuName);
  1170. }
  1171. else if (sMenuCode == "stu_online_practice")
  1172. {
  1173. ui->btn_onlinePractice->setVisible(true);
  1174. ui->btn_onlinePractice->setText(sMenuName);
  1175. }
  1176. else if (sMenuCode == "stu_offline_exam")
  1177. {
  1178. ui->btn_offlineExam->setVisible(true);
  1179. ui->btn_offlineExam->setText(sMenuName);
  1180. }
  1181. else if (sMenuCode == "stu_notice")
  1182. {
  1183. ui->btn_notice->setVisible(true);
  1184. ui->btn_notice->setText(sMenuName);
  1185. CHttpRequestPackage hrp;
  1186. hrp.sUri = "/api/ecs_exam_work/notice/getUserNoticeList";
  1187. hrp.nRequestType = RequestType::rtGetUserNoticeList;
  1188. g_httpBllPtr->get(hrp);
  1189. }
  1190. else if (sMenuCode == "stu_modify_pwd")
  1191. {
  1192. ui->btn_editPassword->setVisible(true);
  1193. ui->btn_editPassword->setText(sMenuName);
  1194. }
  1195. }
  1196. menuBtnRePosistion();
  1197. }
  1198. else
  1199. {
  1200. if(getStudentClientMenu.sMessage.isEmpty())
  1201. {
  1202. ShowMsg(QString::fromLocal8Bit("获取菜单失败"), this, MSG_ICON_TYPE::mit_error);
  1203. }
  1204. else
  1205. {
  1206. ShowMsg(getStudentClientMenu.sMessage, this, MSG_ICON_TYPE::mit_error);
  1207. }
  1208. }
  1209. }
  1210. void courseList::onGetUserNoticeList(CGetUserNoticeList getUserNoticeList)
  1211. {
  1212. if (getUserNoticeList.nCode == 200)
  1213. {
  1214. if (m_pNoticeList == nullptr)
  1215. {
  1216. m_pNoticeList = std::make_shared<clNoticeList>(ui->stw_courseList);
  1217. m_pNoticeList->setUI(ui->stw_courseList->width(), ui->stw_courseList->height());
  1218. connect(m_pNoticeList.get(), &clNoticeList::unReadNoticeCount, this, [&](int nCount) {
  1219. ui->btn_noticeNum->setText(QString::number(nCount));
  1220. ui->btn_noticeNum->setVisible(nCount > 0);
  1221. });
  1222. connect(m_pNoticeList.get(), &clNoticeList::readNotice, this, [&](__int64 nId) {
  1223. m_pNoticePopWidget->setNoticeRead(nId);
  1224. });
  1225. }
  1226. m_pNoticeList->setNotice(getUserNoticeList.vNoticeList);
  1227. if (m_pNoticePopWidget == nullptr)
  1228. {
  1229. m_pNoticePopWidget = std::make_shared<clNoticePopWidget>(this);
  1230. m_pNoticePopWidget->setUI(g_appInfoPtr->m_fRate * 960, g_appInfoPtr->m_fRate * 558, g_appInfoPtr->m_fRate * 310, g_appInfoPtr->m_fRate * 200);
  1231. connect(m_pNoticePopWidget.get(), &clNoticePopWidget::showNoticeDetail, this, [&](__int64 nId){
  1232. setCheck(COURSE_MENU_BTN_TYPE::cmbt_notice);
  1233. m_pNoticeList->viewNotice(nId);
  1234. });
  1235. }
  1236. int nUnReadCount = 0;
  1237. for (CNoticeInfo ni : getUserNoticeList.vNoticeList)
  1238. {
  1239. if (!ni.bHasRead)
  1240. {
  1241. m_pNoticePopWidget->addNotice(ni);
  1242. ++nUnReadCount;
  1243. }
  1244. }
  1245. ui->btn_noticeNum->setText(QString::number(nUnReadCount));
  1246. ui->btn_noticeNum->setVisible(nUnReadCount > 0);
  1247. if(m_pNoticePopWidget->noticeCount() > 0)
  1248. {
  1249. m_pNoticePopWidget->show();
  1250. }
  1251. }
  1252. else
  1253. {
  1254. if(getUserNoticeList.sMessage.isEmpty())
  1255. {
  1256. ShowMsg(QString::fromLocal8Bit("获取通知信息失败"), this, MSG_ICON_TYPE::mit_error);
  1257. }
  1258. else
  1259. {
  1260. ShowMsg(getUserNoticeList.sMessage, this, MSG_ICON_TYPE::mit_error);
  1261. }
  1262. }
  1263. }