courseList.cpp 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290
  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. }
  862. }
  863. void courseList::onAppDownLoadUrl(CAppDownLoadUrl appDownLoadUrl)
  864. {
  865. if (appDownLoadUrl.nCode == 200)
  866. {
  867. g_appInfoPtr->m_sAppDownLoadUrl = appDownLoadUrl.sUrl;
  868. }
  869. else
  870. {
  871. if(appDownLoadUrl.sMessage.isEmpty())
  872. {
  873. ShowMsg(QString::fromLocal8Bit("获取APP下载地址失败"), this, MSG_ICON_TYPE::mit_error);
  874. }
  875. else
  876. {
  877. ShowMsg(appDownLoadUrl.sMessage, this, MSG_ICON_TYPE::mit_error);
  878. }
  879. }
  880. }
  881. void courseList::onDownLoadFile(CDownLoadFileInfo downLoadFileInfo)
  882. {
  883. if(downLoadFileInfo.sModuleName == __FILE__)
  884. {
  885. if (downLoadFileInfo.nCode == 200)
  886. {
  887. // QString sFileName = g_appInfoPtr->m_sStudentPhotoPath.right(g_appInfoPtr->m_sStudentPhotoPath.length() - g_appInfoPtr->m_sStudentPhotoPath.lastIndexOf("/") - 1);
  888. // sFileName = g_appInfoPtr->m_sCacheFileDir + sFileName;
  889. if (downLoadFileInfo.sAdditionStr == "MenuLogoUrl")
  890. {
  891. QString sFileName = g_appInfoPtr->m_sMenuLogoUrl.right(g_appInfoPtr->m_sMenuLogoUrl.length() - g_appInfoPtr->m_sMenuLogoUrl.lastIndexOf("/") - 1);
  892. sFileName = g_appInfoPtr->m_sCacheFileDir + sFileName;
  893. ui->label_cl_org_icon->setPixmap(QPixmap(sFileName).scaled(ui->label_cl_org_icon->width(), ui->label_cl_org_icon->height(),
  894. Qt::KeepAspectRatio, Qt::SmoothTransformation));
  895. }
  896. }
  897. else
  898. {
  899. if(downLoadFileInfo.sMessage.isEmpty())
  900. {
  901. ShowMsg(QString::fromLocal8Bit("下载失败"), this, MSG_ICON_TYPE::mit_error);
  902. }
  903. else
  904. {
  905. ShowMsg(downLoadFileInfo.sMessage, this, MSG_ICON_TYPE::mit_error);
  906. }
  907. }
  908. }
  909. }
  910. void courseList::onSpecialtyNameList(CSpecialtyNameList specialtyNameList)
  911. {
  912. if (specialtyNameList.nCode == 200)
  913. {
  914. g_appInfoPtr->m_sSpecialtyName = specialtyNameList.sSpecialtyName;
  915. CHttpRequestPackage hrp;
  916. hrp.sUri = "/api/ecs_oe_student/client/exam/process/checkExamInProgress";
  917. hrp.nRequestType = RequestType::rtCheckExamInProgress;
  918. hrp.sCommonStr = EXAM_INPROGRESS_ENTER_TYPE::EIET_COURSE_LIST;
  919. g_httpBllPtr->post(hrp);
  920. }
  921. else
  922. {
  923. if(specialtyNameList.sMessage.isEmpty())
  924. {
  925. ShowMsg(QString::fromLocal8Bit("获取专业信息失败"), this, MSG_ICON_TYPE::mit_error);
  926. }
  927. else
  928. {
  929. ShowMsg(specialtyNameList.sMessage, this, MSG_ICON_TYPE::mit_error);
  930. }
  931. }
  932. }
  933. void courseList::onCheckExamInProgress(CCheckExamInProgress checkExamInProgress)
  934. {
  935. if (checkExamInProgress.nCode == 200)
  936. {
  937. if (checkExamInProgress.bHasExamInProgress)
  938. {
  939. if (checkExamInProgress.bIsExceed)
  940. {
  941. //超过断点时长交卷
  942. g_appInfoPtr->m_oExamInfo.nExamRecordDataId = checkExamInProgress.nExamRecordDataId;
  943. g_appInfoPtr->m_oExamInfo.nExamId = checkExamInProgress.nExamId;
  944. CHttpRequestPackage hrp;
  945. hrp.sUri = QString("/api/ecs_oe_student/client/exam/process/endExam");
  946. hrp.sCommonStr = __FILE__;
  947. hrp.nRequestType = RequestType::rtEndExam;
  948. g_httpBllPtr->post(hrp);
  949. }
  950. else
  951. {
  952. //进入断点
  953. g_appInfoPtr->m_oExamInfo.nExamId = checkExamInProgress.nExamId;
  954. g_appInfoPtr->m_oExamInfo.nExamRecordDataId = checkExamInProgress.nExamRecordDataId;
  955. g_appInfoPtr->m_oExamInfo.sExamType = checkExamInProgress.sExamType;
  956. g_appInfoPtr->m_oExamInfo.bIsExamInProgress = true;
  957. if (m_pResumeExam == nullptr)
  958. {
  959. m_pResumeExam = std::make_shared<awResumeExam>(this);
  960. }
  961. m_pResumeExam->show();
  962. //环境监测
  963. CHttpRequestPackage hrp;
  964. hrp.sUri = QString("/api/ecs_exam_work/exam/getExamPropertyFromCacheByStudentSession/%1/%2")
  965. .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");
  966. hrp.nRequestType = RequestType::rtGetExamProperty;
  967. hrp.sCommonStr = "CHECK_ENVIRONMENT,IS_FACE_CHECK,SNAPSHOT_INTERVAL,WARN_THRESHOLD,FACE_VERIFY_START_MINUTE,FACE_VERIFY_END_MINUTE,IS_STRANGER_ENABLE";
  968. g_httpBllPtr->get(hrp);
  969. }
  970. }
  971. else
  972. {
  973. g_appInfoPtr->m_oExamInfo.bIsExamInProgress = false;
  974. if (checkExamInProgress.sEnterType == EXAM_INPROGRESS_ENTER_TYPE::EIET_COURSE_LIST)
  975. {
  976. CHttpRequestPackage hrp;
  977. hrp.sUri = "/api/ecs_core/rolePrivilege/getStudentClientMenu";
  978. hrp.nRequestType = RequestType::rtGetStudentClientMenu;
  979. hrp.sParamList.push_back(QString::fromLocal8Bit("rootOrgId,%1").arg(g_appInfoPtr->m_sRootOrgId));
  980. g_httpBllPtr->get(hrp);
  981. if (m_pWelcomeWidget == nullptr)
  982. {
  983. m_pWelcomeWidget = std::make_shared<welcomeWidget>(g_appInfoPtr->m_sStudentName, g_appInfoPtr->m_sStudentCode, g_appInfoPtr->m_sSpecialtyName, this);
  984. connect(m_pWelcomeWidget.get(), &welcomeWidget::exitWelcomeWidget, this, [&]() {
  985. m_pWelcomeWidget.reset();
  986. });
  987. }
  988. m_pWelcomeWidget->show();
  989. }
  990. else
  991. {
  992. //环境监测
  993. CHttpRequestPackage hrp;
  994. hrp.sUri = QString("/api/ecs_exam_work/exam/getExamPropertyFromCacheByStudentSession/%1/%2")
  995. .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");
  996. hrp.nRequestType = RequestType::rtGetExamProperty;
  997. hrp.sCommonStr = "CHECK_ENVIRONMENT,IS_FACE_CHECK,SNAPSHOT_INTERVAL,WARN_THRESHOLD,FACE_VERIFY_START_MINUTE,FACE_VERIFY_END_MINUTE,IS_STRANGER_ENABLE";
  998. g_httpBllPtr->get(hrp);
  999. }
  1000. }
  1001. }
  1002. else
  1003. {
  1004. if(checkExamInProgress.sMessage.isEmpty())
  1005. {
  1006. ShowMsg(QString::fromLocal8Bit("获取断点信息失败"), this, MSG_ICON_TYPE::mit_error);
  1007. }
  1008. else
  1009. {
  1010. ShowMsg(checkExamInProgress.sMessage, this, MSG_ICON_TYPE::mit_error);
  1011. }
  1012. }
  1013. }
  1014. void courseList::onEndExam(CEndExam endExam)
  1015. {
  1016. if(endExam.sModuleName == __FILE__)
  1017. {
  1018. if (endExam.nCode == 200)
  1019. {
  1020. m_pRefreshMenuTimer->stop();
  1021. if(m_pBackground != nullptr)
  1022. {
  1023. m_pBackground.reset();
  1024. }
  1025. m_pBackground = std::make_shared<awBackground>(AW_WIDGET_TYPE::awwt_examScore, this);
  1026. connect(m_pBackground.get(), &awBackground::minisize, this, &courseList::minisize);
  1027. connect(m_pBackground.get(), &awBackground::closeWidget, this, [&](){
  1028. m_pBackground.reset();
  1029. m_pRefreshMenuTimer->start();
  1030. if(m_pOnlineExam)
  1031. {
  1032. m_pOnlineExam->refreshExam();
  1033. }
  1034. if(m_pOnlineHomework)
  1035. {
  1036. m_pOnlineHomework->refreshExam();
  1037. }
  1038. });
  1039. m_pBackground->show();
  1040. }
  1041. else
  1042. {
  1043. if(endExam.sMessage.isEmpty())
  1044. {
  1045. ShowMsg(QString::fromLocal8Bit("交卷失败"), g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
  1046. }
  1047. else
  1048. {
  1049. ShowMsg(endExam.sMessage, g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
  1050. }
  1051. }
  1052. }
  1053. }
  1054. void courseList::onGetStudentClientMenu(CGetStudentClientMenu getStudentClientMenu)
  1055. {
  1056. if (getStudentClientMenu.nCode == 200)
  1057. {
  1058. ui->btn_onlineExam->setVisible(false);
  1059. ui->btn_onlineHomework->setVisible(false);
  1060. ui->btn_onlinePractice->setVisible(false);
  1061. ui->btn_offlineExam->setVisible(false);
  1062. ui->btn_notice->setVisible(false);
  1063. ui->btn_editPassword->setVisible(false);
  1064. for (CStudentClientMenu scm : getStudentClientMenu.vMenus)
  1065. {
  1066. QString sMenuName = scm.sName;
  1067. sMenuName.insert(sMenuName.length()/2, '\n');
  1068. QString sMenuCode = scm.sCode.left(scm.sCode.lastIndexOf("_"));
  1069. if (sMenuCode == "stu_online_exam")
  1070. {
  1071. ui->btn_onlineExam->setVisible(true);
  1072. ui->btn_onlineExam->setText(sMenuName);
  1073. }
  1074. else if (sMenuCode == "stu_online_homework")
  1075. {
  1076. ui->btn_onlineHomework->setVisible(true);
  1077. ui->btn_onlineHomework->setText(sMenuName);
  1078. }
  1079. else if (sMenuCode == "stu_online_practice")
  1080. {
  1081. ui->btn_onlinePractice->setVisible(true);
  1082. ui->btn_onlinePractice->setText(sMenuName);
  1083. }
  1084. else if (sMenuCode == "stu_offline_exam")
  1085. {
  1086. ui->btn_offlineExam->setVisible(true);
  1087. ui->btn_offlineExam->setText(sMenuName);
  1088. }
  1089. else if (sMenuCode == "stu_notice")
  1090. {
  1091. ui->btn_notice->setVisible(true);
  1092. ui->btn_notice->setText(sMenuName);
  1093. CHttpRequestPackage hrp;
  1094. hrp.sUri = "/api/ecs_exam_work/notice/getUserNoticeList";
  1095. hrp.nRequestType = RequestType::rtGetUserNoticeList;
  1096. g_httpBllPtr->get(hrp);
  1097. }
  1098. else if (sMenuCode == "stu_modify_pwd")
  1099. {
  1100. ui->btn_editPassword->setVisible(true);
  1101. ui->btn_editPassword->setText(sMenuName);
  1102. }
  1103. }
  1104. menuBtnRePosistion();
  1105. }
  1106. else
  1107. {
  1108. if(getStudentClientMenu.sMessage.isEmpty())
  1109. {
  1110. ShowMsg(QString::fromLocal8Bit("获取菜单失败"), this, MSG_ICON_TYPE::mit_error);
  1111. }
  1112. else
  1113. {
  1114. ShowMsg(getStudentClientMenu.sMessage, this, MSG_ICON_TYPE::mit_error);
  1115. }
  1116. }
  1117. }
  1118. void courseList::onGetUserNoticeList(CGetUserNoticeList getUserNoticeList)
  1119. {
  1120. if (getUserNoticeList.nCode == 200)
  1121. {
  1122. if (m_pNoticeList == nullptr)
  1123. {
  1124. m_pNoticeList = std::make_shared<clNoticeList>(ui->stw_courseList);
  1125. m_pNoticeList->setUI(ui->stw_courseList->width(), ui->stw_courseList->height());
  1126. connect(m_pNoticeList.get(), &clNoticeList::unReadNoticeCount, this, [&](int nCount) {
  1127. ui->btn_noticeNum->setText(QString::number(nCount));
  1128. ui->btn_noticeNum->setVisible(nCount > 0);
  1129. });
  1130. connect(m_pNoticeList.get(), &clNoticeList::readNotice, this, [&](__int64 nId) {
  1131. m_pNoticePopWidget->setNoticeRead(nId);
  1132. });
  1133. }
  1134. m_pNoticeList->setNotice(getUserNoticeList.vNoticeList);
  1135. if (m_pNoticePopWidget == nullptr)
  1136. {
  1137. m_pNoticePopWidget = std::make_shared<clNoticePopWidget>(this);
  1138. m_pNoticePopWidget->setUI(g_appInfoPtr->m_fRate * 960, g_appInfoPtr->m_fRate * 558, g_appInfoPtr->m_fRate * 310, g_appInfoPtr->m_fRate * 200);
  1139. connect(m_pNoticePopWidget.get(), &clNoticePopWidget::showNoticeDetail, this, [&](__int64 nId){
  1140. setCheck(COURSE_MENU_BTN_TYPE::cmbt_notice);
  1141. m_pNoticeList->viewNotice(nId);
  1142. });
  1143. }
  1144. int nUnReadCount = 0;
  1145. for (CNoticeInfo ni : getUserNoticeList.vNoticeList)
  1146. {
  1147. if (!ni.bHasRead)
  1148. {
  1149. m_pNoticePopWidget->addNotice(ni);
  1150. ++nUnReadCount;
  1151. }
  1152. }
  1153. ui->btn_noticeNum->setText(QString::number(nUnReadCount));
  1154. ui->btn_noticeNum->setVisible(nUnReadCount > 0);
  1155. if(m_pNoticePopWidget->noticeCount() > 0)
  1156. {
  1157. m_pNoticePopWidget->show();
  1158. }
  1159. }
  1160. else
  1161. {
  1162. if(getUserNoticeList.sMessage.isEmpty())
  1163. {
  1164. ShowMsg(QString::fromLocal8Bit("获取通知信息失败"), this, MSG_ICON_TYPE::mit_error);
  1165. }
  1166. else
  1167. {
  1168. ShowMsg(getUserNoticeList.sMessage, this, MSG_ICON_TYPE::mit_error);
  1169. }
  1170. }
  1171. }