courseList.cpp 48 KB

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