clOfflineExam.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  1. #include "clOfflineExam.h"
  2. #include "ui_clOfflineExam.h"
  3. #include "CAppInfo.h"
  4. #include "clOperation.h"
  5. #include "awMsgBox.h"
  6. #include <QScrollBar>
  7. #include <QFileDialog>
  8. clOfflineExam::clOfflineExam(QWidget *parent) :
  9. QWidget(parent),
  10. ui(new Ui::clOfflineExam)
  11. {
  12. ui->setupUi(this);
  13. setStyleSheet(g_appInfoPtr->m_sQssStr);
  14. qRegisterMetaType<CGetOfflineCourse>("CGetOfflineCourse");
  15. connect(g_httpBllPtr.get(), &CHttpBll::sgnGetOfflineCourse, this, &clOfflineExam::onGetOfflineCourse);
  16. qRegisterMetaType<CGetOffLineExamAnswerSheet>("CGetOffLineExamAnswerSheet");
  17. connect(g_httpBllPtr.get(), &CHttpBll::sgnGetOffLineExamAnswerSheet, this, &clOfflineExam::onGetOffLineExamAnswerSheet);
  18. qRegisterMetaType<CStartOfflineExam>("CStartOfflineExam");
  19. connect(g_httpBllPtr.get(), &CHttpBll::sgnStartOfflineExam, this, &clOfflineExam::onStartOfflineExam);
  20. qRegisterMetaType<CGetOffLineExamPaper>("CGetOffLineExamPaper");
  21. connect(g_httpBllPtr.get(), &CHttpBll::sgnGetOffLineExamPaper, this, &clOfflineExam::onGetOffLineExamPaper);
  22. qRegisterMetaType<CPreviewOffLineExamPaper>("CPreviewOffLineExamPaper");
  23. connect(g_httpBllPtr.get(), &CHttpBll::sgnPreviewOffLineExamPaper, this, &clOfflineExam::onPreviewOffLineExamPaper);
  24. qRegisterMetaType<CGetExamProperty>("CGetExamProperty");
  25. connect(g_httpBllPtr.get(), &CHttpBll::sgnGetExamProperty, this, &clOfflineExam::onGetExamProperty);
  26. qRegisterMetaType<CDownLoadFileInfo>("CDownLoadFileInfo");
  27. connect(g_httpBllPtr.get(), &CHttpBll::sgnDownLoadFile, this, &clOfflineExam::onDownLoadFile);
  28. }
  29. clOfflineExam::~clOfflineExam()
  30. {
  31. delete ui;
  32. }
  33. void clOfflineExam::setUI(const int nWidth, const int nHeight)
  34. {
  35. setGeometry(0, 0, nWidth, nHeight);
  36. ui->widget_offlineExam->setGeometry(0, 0, width(), height());
  37. ui->widget_op_top->setGeometry(0, 0, width(), g_appInfoPtr->m_fRate*72);
  38. ui->btn_downloadAnswerSheet->setGeometry(ui->widget_op_top->width() - g_appInfoPtr->m_fRate*30 - g_appInfoPtr->m_fRate*144,
  39. (ui->widget_op_top->height() - g_appInfoPtr->m_fRate*32)/2,
  40. g_appInfoPtr->m_fRate*144, g_appInfoPtr->m_fRate*32);
  41. ui->btn_downloadAnswerSheet->setVisible(false);
  42. ui->btn_downloadAnswerSheet->setIconSize(QSize(g_appInfoPtr->m_fRate*14, g_appInfoPtr->m_fRate*14));
  43. ui->btn_downloadAnswerSheet->setIcon(QIcon(":/images/icon-download-answer-sheet.png"));
  44. ui->tablewt_examList->setGeometry(g_appInfoPtr->m_fRate*30, ui->widget_op_top->height() + g_appInfoPtr->m_fRate*10,
  45. ui->widget_offlineExam->width() - g_appInfoPtr->m_fRate*30*2,
  46. ui->widget_offlineExam->height() - ui->widget_op_top->height() - g_appInfoPtr->m_fRate*(10 + 62));
  47. ui->tablewt_examList->setEditTriggers(QAbstractItemView::NoEditTriggers);
  48. //整行选中的方式
  49. ui->tablewt_examList->setSelectionBehavior(QAbstractItemView::SelectRows);
  50. //设置为只能选中一行
  51. ui->tablewt_examList->setSelectionMode(QAbstractItemView::SingleSelection);
  52. //隐藏列表头
  53. ui->tablewt_examList->verticalHeader()->setVisible(false);
  54. //隐藏边框
  55. ui->tablewt_examList->setShowGrid(false);
  56. //表头不高亮显示
  57. ui->tablewt_examList->horizontalHeader()->setHighlightSections(false);
  58. //设置行数
  59. ui->tablewt_examList->setRowCount(10);
  60. //设置列数
  61. ui->tablewt_examList->setColumnCount(5);
  62. ui->tablewt_examList->setHorizontalScrollMode(QTableWidget::ScrollPerPixel);
  63. ui->tablewt_examList->horizontalScrollBar()->setSingleStep(g_appInfoPtr->m_fRate*5);
  64. QStringList sHeadStr;
  65. sHeadStr << QString::fromLocal8Bit("课程") <<
  66. QString::fromLocal8Bit("专业") <<
  67. QString::fromLocal8Bit("进入考试时间") <<
  68. QString::fromLocal8Bit("状态") <<
  69. QString::fromLocal8Bit("操作");
  70. ui->tablewt_examList->setHorizontalHeaderLabels(sHeadStr);
  71. ui->tablewt_examList->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft | Qt::AlignVCenter);
  72. ui->tablewt_examList->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed);
  73. ui->tablewt_examList->verticalHeader()->setDefaultSectionSize(g_appInfoPtr->m_fRate*48);
  74. ui->tablewt_examList->setColumnWidth(0, g_appInfoPtr->m_fRate*240);
  75. ui->tablewt_examList->setColumnWidth(1, g_appInfoPtr->m_fRate*220);
  76. ui->tablewt_examList->setColumnWidth(2, g_appInfoPtr->m_fRate*340);
  77. ui->tablewt_examList->setColumnWidth(3, g_appInfoPtr->m_fRate*90);
  78. ui->tablewt_examList->setColumnWidth(4, g_appInfoPtr->m_fRate*232);
  79. ui->tablewt_examList->horizontalHeader()->setStretchLastSection(true);
  80. }
  81. void clOfflineExam::showEvent(QShowEvent *)
  82. {
  83. refreshCourse();
  84. }
  85. void clOfflineExam::refreshCourse()
  86. {
  87. CHttpRequestPackage hrp1;
  88. hrp1.sUri = "/api/ecs_core/org/getAnswersUrl/" + g_appInfoPtr->m_sRootOrgId;
  89. hrp1.nRequestType = RequestType::rtGetOffLineExamAnswerSheet;
  90. g_httpBllPtr->get(hrp1);
  91. CHttpRequestPackage hrp;
  92. hrp.sUri = "/api/ecs_oe_admin/client/exam/process/getOfflineCourse";
  93. hrp.nRequestType = RequestType::rtGetOfflineCourse;
  94. g_httpBllPtr->post(hrp);
  95. }
  96. void clOfflineExam::onGetOfflineCourse(CGetOfflineCourse getOfflineCourse)
  97. {
  98. if (getOfflineCourse.nCode == 200)
  99. {
  100. int nSize = getOfflineCourse.vOfflineCourseInfo.size();
  101. ui->tablewt_examList->setRowCount(nSize);
  102. for (int i = 0; i < nSize; ++i)
  103. {
  104. COfflineCourseInfo oci = getOfflineCourse.vOfflineCourseInfo[i];
  105. ui->tablewt_examList->setItem(i, 0, new QTableWidgetItem(oci.sCourseName));
  106. ui->tablewt_examList->setItem(i, 1, new QTableWidgetItem(oci.sSpecialtyName));
  107. ui->tablewt_examList->setItem(i, 2, new QTableWidgetItem(QString::fromLocal8Bit("%1 ~ %2").arg(oci.sStartTime).arg(oci.sEndTime)));
  108. CL_OPERATION_TYPE sAnswerStatus = CL_OPERATION_TYPE::cot_offline_status_null;
  109. CL_OPERATION_TYPE otStatus = CL_OPERATION_TYPE::cot_offline_init_exam;
  110. if (!oci.sStatus.isEmpty())
  111. {
  112. otStatus = CL_OPERATION_TYPE::cot_offline_exam;
  113. if (oci.vOfflineFileInfo.size() > 0)
  114. {
  115. sAnswerStatus = CL_OPERATION_TYPE::cot_offline_status_download;
  116. }
  117. }
  118. clOperation *cloStatus = new clOperation(i, ui->tablewt_examList);
  119. connect(cloStatus, &clOperation::downloadOfflineAnswer, this, [&](int nRow){
  120. QString sExportDir = QFileDialog::getExistingDirectory(
  121. this, QString::fromLocal8Bit("选择导出目录"),
  122. "/");
  123. if (sExportDir.isEmpty())
  124. {
  125. return;
  126. }
  127. //导出
  128. if (sExportDir.right(1) != "/")
  129. {
  130. sExportDir += "/";
  131. }
  132. COfflineCourseInfo &oci = m_vOfflineCourseInfo[nRow];
  133. for (COfflineFileInfo &fileInfo : oci.vOfflineFileInfo)
  134. {
  135. QString sFileName = fileInfo.sOfflineFileUrl.right(fileInfo.sOfflineFileUrl.length() - fileInfo.sOfflineFileUrl.lastIndexOf("/") - 1);
  136. QString sAnswerFile = sExportDir + sFileName;
  137. fileInfo.sLocalFileName = sAnswerFile;
  138. CHttpRequestPackage hrp;
  139. hrp.sUri = fileInfo.sOfflineFileUrl;
  140. hrp.sCommonStr = sAnswerFile;
  141. hrp.sAdditionStr = QString::number(nRow);
  142. hrp.sCommonStr1 = __FILE__;
  143. hrp.nRequestType = RequestType::rtDownLoadFile;
  144. hrp.nRetryCount = 3;
  145. g_httpBllPtr->downLoad(hrp);
  146. }
  147. });
  148. cloStatus->setUI(ui->tablewt_examList->columnWidth(4), ui->tablewt_examList->rowHeight(i), sAnswerStatus);
  149. ui->tablewt_examList->setCellWidget(i, 3, cloStatus);
  150. clOperation *clo = new clOperation(i, ui->tablewt_examList);
  151. connect(clo, &clOperation::offlineExamStart, this, [&](int nRow){
  152. COfflineCourseInfo oci = m_vOfflineCourseInfo[nRow];
  153. CHttpRequestPackage hrp;
  154. hrp.sUri = "/api/ecs_oe_admin/client/exam/process/startOfflineExam";
  155. hrp.sParamList.push_back(QString("examStudentId,%1").arg(oci.nExamStudentId));
  156. hrp.nRequestType = RequestType::rtStartOfflineExam;
  157. hrp.eParamType = HttpParamType::hptUrl;
  158. hrp.sCommonStr = QString::number(nRow);
  159. g_httpBllPtr->post(hrp);
  160. });
  161. connect(clo, &clOperation::viewOfflinePaper, this, [&](int nRow){
  162. COfflineCourseInfo oci = m_vOfflineCourseInfo[nRow];
  163. CHttpRequestPackage hrp;
  164. hrp.sUri = QString("/api/branch_ecs_ques/paper/%1").arg(oci.sPaperId);
  165. hrp.nRequestType = RequestType::rtPreviewOffLineExamPaper;
  166. hrp.sCommonStr = QString::number(nRow);
  167. g_httpBllPtr->get(hrp);
  168. });
  169. connect(clo, &clOperation::downloadOfflinePaper, this, [&](int nRow){
  170. COfflineCourseInfo oci = m_vOfflineCourseInfo[nRow];
  171. // QString sExportDir = QFileDialog::getExistingDirectory(
  172. // this, QString::fromLocal8Bit("选择下载目录"),
  173. // "/");
  174. // if (sExportDir.isEmpty())
  175. // {
  176. // return;
  177. // }
  178. // //导出
  179. // if (sExportDir.right(1) != "/")
  180. // {
  181. // sExportDir += "/";
  182. // }
  183. QString sPaperFile = oci.sCourseCode + "_" + oci.sCourseName + ".zip";
  184. sPaperFile = QFileDialog::getSaveFileName(
  185. this, oci.sPaperId, sPaperFile,
  186. "All Files(*.*)");
  187. if(sPaperFile.isEmpty())
  188. {
  189. return;
  190. }
  191. if (!QFile::exists(sPaperFile))
  192. {
  193. CHttpRequestPackage hrp;
  194. hrp.sUri = QString("/api/branch_ecs_ques/paper/export/%1/PAPER/offLine").arg(oci.sPaperId);
  195. hrp.nRequestType = RequestType::rtGetOffLineExamPaper;
  196. hrp.sCommonStr = sPaperFile;
  197. g_httpBllPtr->get(hrp);
  198. }
  199. });
  200. connect(clo, &clOperation::uploadOfflineAnswer, this, [&](int nRow){
  201. COfflineCourseInfo oci = m_vOfflineCourseInfo[nRow];
  202. CHttpRequestPackage hrp;
  203. hrp.sUri = QString("/api/ecs_exam_work/exam/getExamPropertyFromCacheByStudentSession/%1/%2")
  204. .arg(oci.nExamId).arg("OFFLINE_UPLOAD_FILE_TYPE");
  205. hrp.nRequestType = RequestType::rtGetExamProperty;
  206. hrp.sCommonStr = "OFFLINE_UPLOAD_FILE_TYPE;" + QString::number(oci.nExamRecordDataId);
  207. g_httpBllPtr->get(hrp);
  208. });
  209. clo->setUI(ui->tablewt_examList->columnWidth(4), ui->tablewt_examList->rowHeight(i), otStatus);
  210. ui->tablewt_examList->setCellWidget(i, 4, clo);
  211. }
  212. m_vOfflineCourseInfo.swap(getOfflineCourse.vOfflineCourseInfo);
  213. }
  214. else
  215. {
  216. if(getOfflineCourse.sMessage.isEmpty())
  217. {
  218. ShowMsg(QString::fromLocal8Bit("获取离线考试信息失败"), g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
  219. }
  220. else
  221. {
  222. ShowMsg(getOfflineCourse.sMessage, g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
  223. }
  224. }
  225. }
  226. void clOfflineExam::onDownLoadFile(CDownLoadFileInfo downLoadFileInfo)
  227. {
  228. if (downLoadFileInfo.sModuleName == __FILE__)
  229. {
  230. if(downLoadFileInfo.nCode == 200)
  231. {
  232. if(downLoadFileInfo.sAdditionStr == "downloadAnswerSheet")
  233. {
  234. ShowMsg(QString::fromLocal8Bit("下载完成"), g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_succeed);
  235. }
  236. else
  237. {
  238. int nRow = downLoadFileInfo.sAdditionStr.toInt();
  239. COfflineCourseInfo oci = m_vOfflineCourseInfo[nRow];
  240. QString sLocalFileName = oci.vOfflineFileInfo[oci.vOfflineFileInfo.size() - 1].sLocalFileName;
  241. if(sLocalFileName == downLoadFileInfo.sFileName)
  242. {
  243. ShowMsg(QString::fromLocal8Bit("下载完成"), g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_succeed);
  244. }
  245. }
  246. }
  247. else
  248. {
  249. if(downLoadFileInfo.sMessage.isEmpty())
  250. {
  251. ShowMsg(QString::fromLocal8Bit("下载失败"), g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
  252. }
  253. else
  254. {
  255. ShowMsg(downLoadFileInfo.sMessage, g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
  256. }
  257. }
  258. }
  259. // downLoadFileInfo
  260. // QString sFileName = g_appInfoPtr->m_sStudentPhotoPath.right(g_appInfoPtr->m_sStudentPhotoPath.length() - g_appInfoPtr->m_sStudentPhotoPath.lastIndexOf("/") - 1);
  261. // QString sAudioFile = g_appInfoPtr->m_sCacheFileDir + "cache/" + sFileName;
  262. // if (downLoadFileInfo.sFileName == sAudioFile)
  263. // {
  264. // if (downLoadFileInfo.nCode == 200)
  265. // {
  266. // int nSecord = g_audioPalyerPtr->GetMediaDuration(sAudioFile);
  267. // m_nMaxTestSecord = nSecord;
  268. // QString sText = QString("00:00 / %1:%2")
  269. // .arg((int)(nSecord/60), 2, 10, QChar('0'))
  270. // .arg((int)(nSecord%60), 2, 10, QChar('0'));
  271. // ui->label_ap_time->setText(sText);
  272. // }
  273. // else
  274. // {
  275. // }
  276. // }
  277. }
  278. void clOfflineExam::onGetOffLineExamAnswerSheet(CGetOffLineExamAnswerSheet getOffLineExamAnswerSheet)
  279. {
  280. if (getOffLineExamAnswerSheet.nCode == 200)
  281. {
  282. if (!getOffLineExamAnswerSheet.sAnswerSheetUrl.isEmpty())
  283. {
  284. m_sAnswerSheetUrl = getOffLineExamAnswerSheet.sAnswerSheetUrl;
  285. ui->btn_downloadAnswerSheet->setVisible(true);
  286. }
  287. }
  288. else
  289. {
  290. if(getOffLineExamAnswerSheet.sMessage.isEmpty())
  291. {
  292. ShowMsg(QString::fromLocal8Bit("获取离线考试信息失败"), g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
  293. }
  294. else
  295. {
  296. ShowMsg(getOffLineExamAnswerSheet.sMessage, g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
  297. }
  298. }
  299. }
  300. void clOfflineExam::onStartOfflineExam(CStartOfflineExam startOfflineExam)
  301. {
  302. if (startOfflineExam.nCode == 200)
  303. {
  304. refreshCourse();
  305. // int nRow = startOfflineExam.nRow;
  306. // COfflineCourseInfo &oci = m_vOfflineCourseInfo[nRow];
  307. // oci.sStatus = "EXAM_ING";
  308. // clOperation *op = dynamic_cast<clOperation*>(ui->tablewt_examList->cellWidget(nRow, 4));
  309. // if (op)
  310. // {
  311. // op->setOperationType(CL_OPERATION_TYPE::cot_offline_exam);
  312. // }
  313. // CHttpRequestPackage hrp;
  314. // hrp.sUri = QString("/api/branch_ecs_ques/paper/export/%1/PAPER/offLine").arg(oci.sPaperId);
  315. // hrp.nRequestType = RequestType::rtGetOffLineExamPaper;
  316. // hrp.sCommonStr = QString::number(nRow);
  317. // g_httpBllPtr->get(hrp);
  318. }
  319. else
  320. {
  321. if(startOfflineExam.sMessage.isEmpty())
  322. {
  323. ShowMsg(QString::fromLocal8Bit("离线考试开考失败"), g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
  324. }
  325. else
  326. {
  327. ShowMsg(startOfflineExam.sMessage, g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
  328. }
  329. }
  330. }
  331. void clOfflineExam::onGetOffLineExamPaper(CGetOffLineExamPaper getOffLineExamPaper)
  332. {
  333. if (getOffLineExamPaper.nCode == 200)
  334. {
  335. ShowMsg(QString::fromLocal8Bit("下载试卷完成"), g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_succeed);
  336. }
  337. else
  338. {
  339. if(getOffLineExamPaper.sMessage.isEmpty())
  340. {
  341. ShowMsg(QString::fromLocal8Bit("离线考试下载试卷失败"), g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
  342. }
  343. else
  344. {
  345. ShowMsg(getOffLineExamPaper.sMessage, g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
  346. }
  347. }
  348. }
  349. void clOfflineExam::onPreviewOffLineExamPaper(CPreviewOffLineExamPaper previewOffLineExamPaper)
  350. {
  351. if (previewOffLineExamPaper.nCode == 200)
  352. {
  353. int nRow = previewOffLineExamPaper.nRow;
  354. if (m_pViewPaper == nullptr)
  355. {
  356. m_pViewPaper = std::make_shared<cloeViewPaper>(previewOffLineExamPaper.sUrl, (QWidget*)this->parent()->parent());
  357. connect(m_pViewPaper.get(), &cloeViewPaper::goback, this, [&](){
  358. m_pViewPaper.reset();
  359. });
  360. }
  361. if(nRow >= 0 && nRow < m_vOfflineCourseInfo.size())
  362. {
  363. COfflineCourseInfo oci = m_vOfflineCourseInfo[nRow];
  364. m_pViewPaper->setCourseCodeAndName(oci.sCourseCode, oci.sCourseName);
  365. }
  366. m_pViewPaper->show();
  367. }
  368. else
  369. {
  370. if(previewOffLineExamPaper.sMessage.isEmpty())
  371. {
  372. ShowMsg(QString::fromLocal8Bit("离线考试下载试卷失败"), g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
  373. }
  374. else
  375. {
  376. ShowMsg(previewOffLineExamPaper.sMessage, g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
  377. }
  378. }
  379. }
  380. void clOfflineExam::onGetExamProperty(CGetExamProperty getExamProperty)
  381. {
  382. if (getExamProperty.nCode == 200)
  383. {
  384. QStringList sList = getExamProperty.sType.split(";");
  385. if (sList.count() != 2)
  386. {
  387. return;
  388. }
  389. if (sList[0] == "OFFLINE_UPLOAD_FILE_TYPE")
  390. {
  391. if(m_pUploadFile == nullptr)
  392. {
  393. m_pUploadFile = std::make_shared<cloeUploadFile>(sList[1].toLongLong(), getExamProperty.vOfflineUploadFileType, (QWidget*)this->parent()->parent());
  394. connect(m_pUploadFile.get(), &cloeUploadFile::cancel, this, [&](){
  395. m_pUploadFile.reset();
  396. });
  397. connect(m_pUploadFile.get(), &cloeUploadFile::uploadSucceed, this, [&]() {
  398. m_pUploadFile.reset();
  399. CHttpRequestPackage hrp;
  400. hrp.sUri = "/api/ecs_oe_admin/client/exam/process/getOfflineCourse";
  401. hrp.nRequestType = RequestType::rtGetOfflineCourse;
  402. g_httpBllPtr->post(hrp);
  403. });
  404. }
  405. m_pUploadFile->show();
  406. }
  407. }
  408. else
  409. {
  410. if(getExamProperty.sMessage.isEmpty())
  411. {
  412. ShowMsg(QString::fromLocal8Bit("获取离线考试信息失败"), g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
  413. }
  414. else
  415. {
  416. ShowMsg(getExamProperty.sMessage, g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
  417. }
  418. }
  419. }
  420. void clOfflineExam::on_btn_downloadAnswerSheet_clicked()
  421. {
  422. // QString sExportDir = QFileDialog::getExistingDirectory(
  423. // this, QString::fromLocal8Bit("选择下载目录"),
  424. // "/");
  425. // if (sExportDir.isEmpty())
  426. // {
  427. // return;
  428. // }
  429. // //导出
  430. // if (sExportDir.right(1) != "/")
  431. // {
  432. // sExportDir += "/";
  433. // }
  434. QString sFileName = m_sAnswerSheetUrl.right(m_sAnswerSheetUrl.length() - m_sAnswerSheetUrl.lastIndexOf("/") - 1);
  435. // QString sAnswerFile = sExportDir + sFileName;
  436. QString sAnswerFile = QFileDialog::getSaveFileName(
  437. this, m_sAnswerSheetUrl, QFileInfo(sFileName).fileName(),
  438. "All Files(*.*)");
  439. if(sAnswerFile.isEmpty())
  440. {
  441. return;
  442. }
  443. CHttpRequestPackage hrp;
  444. hrp.sUri = m_sAnswerSheetUrl;
  445. hrp.sCommonStr = sAnswerFile;
  446. hrp.sAdditionStr = "downloadAnswerSheet";
  447. hrp.sCommonStr1 = __FILE__;
  448. hrp.nRequestType = RequestType::rtDownLoadFile;
  449. hrp.nRetryCount = 3;
  450. g_httpBllPtr->downLoad(hrp);
  451. }