awExamScore.cpp 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. #include "awExamScore.h"
  2. #include "ui_awExamScore.h"
  3. #include "CAppInfo.h"
  4. #include "awMsgBox.h"
  5. awExamScore::awExamScore(QWidget *parent) :
  6. QWidget(parent),
  7. ui(new Ui::awExamScore)
  8. {
  9. ui->setupUi(this);
  10. setStyleSheet(g_appInfoPtr->m_sQssStr);
  11. qRegisterMetaType<CGetExamProperty>("CGetExamProperty");
  12. connect(g_httpBllPtr.get(), &CHttpBll::sgnGetExamProperty, this, &awExamScore::onGetExamProperty);
  13. qRegisterMetaType<CGetEndExamInfo>("CGetEndExamInfo");
  14. connect(g_httpBllPtr.get(), &CHttpBll::sgnGetEndExamInfo, this, &awExamScore::onGetEndExamInfo);
  15. CHttpRequestPackage hrp;
  16. hrp.sUri = QString("/api/ecs_exam_work/exam/getExamPropertyFromCacheByStudentSession/%1/%2")
  17. .arg(g_appInfoPtr->m_oExamInfo.nExamId).arg("AFTER_EXAM_REMARK,IS_OBJ_SCORE_VIEW,SHOW_CHEATING_REMARK,CHEATING_REMARK");
  18. hrp.nRequestType = RequestType::rtGetExamProperty;
  19. hrp.sCommonStr = "AFTER_EXAM_REMARK,IS_OBJ_SCORE_VIEW,SHOW_CHEATING_REMARK,CHEATING_REMARK";
  20. g_httpBllPtr->get(hrp);
  21. }
  22. awExamScore::~awExamScore()
  23. {
  24. awMsgBox::clear(this);
  25. delete ui;
  26. }
  27. void awExamScore::setUI(const int nLeft, const int nTop, const int nWidth, const int nHeight)
  28. {
  29. setGeometry(nLeft, nTop, nWidth, nHeight);
  30. ui->widget_awes_BG->setGeometry(0, 0, nWidth, nHeight);
  31. ui->label_awes_title->adjustSize();
  32. ui->label_awes_title->setGeometry((ui->widget_awes_BG->width() - ui->label_awes_title->width())/2, g_appInfoPtr->m_fRate*58,
  33. ui->label_awes_title->width(), ui->label_awes_title->height());
  34. ui->label_awes_ptoto->setGeometry((ui->widget_awes_BG->width() - g_appInfoPtr->m_fRate*90)/2,
  35. ui->label_awes_title->y() + ui->label_awes_title->height() + g_appInfoPtr->m_fRate*20,
  36. g_appInfoPtr->m_fRate*90, g_appInfoPtr->m_fRate*120);
  37. QString sFileName = g_appInfoPtr->m_sStudentPhotoPath.right(g_appInfoPtr->m_sStudentPhotoPath.length() - g_appInfoPtr->m_sStudentPhotoPath.lastIndexOf("/") - 1);
  38. sFileName = g_appInfoPtr->m_sCacheFileDir + sFileName;
  39. ui->label_awes_ptoto->setPixmap(QPixmap(sFileName).scaled(ui->label_awes_ptoto->width(), ui->label_awes_ptoto->height(),
  40. Qt::IgnoreAspectRatio));
  41. ui->label_awes_result->adjustSize();
  42. ui->label_awes_result->setGeometry((ui->widget_awes_BG->width() - ui->label_awes_result->width())/2, ui->label_awes_ptoto->y() + ui->label_awes_ptoto->height() + g_appInfoPtr->m_fRate*20,
  43. ui->label_awes_result->width(), ui->label_awes_result->height());
  44. ui->txtb_awes_postNotice->setGeometry(g_appInfoPtr->m_fRate*40, ui->label_awes_result->y() + ui->label_awes_result->height() + g_appInfoPtr->m_fRate*40,
  45. ui->widget_awes_BG->width() - g_appInfoPtr->m_fRate*40*2, g_appInfoPtr->m_fRate*164);
  46. ui->txtb_awes_breachNotice->setVisible(false);
  47. ui->txtb_awes_breachNotice->setGeometry(ui->txtb_awes_postNotice->x() + ui->txtb_awes_postNotice->width() + g_appInfoPtr->m_fRate*20,
  48. ui->txtb_awes_postNotice->y(), ui->txtb_awes_postNotice->width(), ui->txtb_awes_postNotice->height());
  49. ui->btn_awes_goback->setGeometry((ui->widget_awes_BG->width() - g_appInfoPtr->m_fRate*200)/2, ui->txtb_awes_postNotice->y() + ui->txtb_awes_postNotice->height() + g_appInfoPtr->m_fRate*30,
  50. g_appInfoPtr->m_fRate*200, g_appInfoPtr->m_fRate*40);
  51. }
  52. void awExamScore::onGetExamProperty(CGetExamProperty getExamProperty)
  53. {
  54. if (getExamProperty.nCode == 200)
  55. {
  56. if (getExamProperty.sType == "AFTER_EXAM_REMARK,IS_OBJ_SCORE_VIEW,SHOW_CHEATING_REMARK,CHEATING_REMARK")
  57. {
  58. if (getExamProperty.bShowCheatingRemark)
  59. {
  60. ui->txtb_awes_breachNotice->setVisible(true);
  61. ui->txtb_awes_postNotice->setGeometry(g_appInfoPtr->m_fRate * 40, ui->label_awes_result->y() + ui->label_awes_result->height() + g_appInfoPtr->m_fRate * 40,
  62. (ui->widget_awes_BG->width() - g_appInfoPtr->m_fRate * 40 * 2 - g_appInfoPtr->m_fRate*20)/2, g_appInfoPtr->m_fRate * 164);
  63. ui->txtb_awes_breachNotice->setGeometry(ui->txtb_awes_postNotice->x() + ui->txtb_awes_postNotice->width() + g_appInfoPtr->m_fRate * 20,
  64. ui->txtb_awes_postNotice->y(), ui->txtb_awes_postNotice->width(), ui->txtb_awes_postNotice->height());
  65. QTextCursor cursor = ui->txtb_awes_breachNotice->textCursor();
  66. QTextBlockFormat textStyleFormat = cursor.blockFormat();
  67. textStyleFormat.setLineHeight(g_appInfoPtr->m_fRate * 5, QTextBlockFormat::LineDistanceHeight);
  68. cursor.setBlockFormat(textStyleFormat);
  69. QTextCharFormat fmt;
  70. QFont font;
  71. font.setFamily("Microsoft YaHei");
  72. font.setPixelSize(g_appInfoPtr->m_fRate*16);
  73. font.setWeight(QFont::Bold);
  74. fmt.setFont(font);
  75. cursor.insertText(QString::fromLocal8Bit("违纪说明:\n"), fmt);
  76. cursor.insertHtml(getExamProperty.sCheatingRemark);
  77. ui->txtb_awes_breachNotice->setTextCursor(cursor);
  78. }
  79. {
  80. QTextCursor cursor = ui->txtb_awes_postNotice->textCursor();
  81. QTextBlockFormat textStyleFormat = cursor.blockFormat();
  82. textStyleFormat.setLineHeight(g_appInfoPtr->m_fRate * 5, QTextBlockFormat::LineDistanceHeight);
  83. cursor.setBlockFormat(textStyleFormat);
  84. QTextCharFormat fmt;
  85. QFont font;
  86. font.setFamily("Microsoft YaHei");
  87. font.setPixelSize(g_appInfoPtr->m_fRate * 16);
  88. font.setWeight(QFont::DemiBold);
  89. fmt.setFont(font);
  90. cursor.insertText(QString::fromLocal8Bit("考后说明:\n"), fmt);
  91. cursor.insertHtml(getExamProperty.sAfterExamRemark);
  92. ui->txtb_awes_postNotice->setTextCursor(cursor);
  93. }
  94. if (getExamProperty.bIsObjScoreView)
  95. {
  96. //获取客观分
  97. ui->label_awes_result->setText(QString::fromLocal8Bit("考试结果计算中..."));
  98. m_getScoreEndTime = g_appInfoPtr->serverMTime() + +2 * 60 * 1000;
  99. getObjectiveScore();
  100. }
  101. else
  102. {
  103. //显示交卷成功
  104. ui->label_awes_result->setText(QString::fromLocal8Bit("交卷完成"));
  105. }
  106. }
  107. }
  108. else
  109. {
  110. if(getExamProperty.sMessage.isEmpty())
  111. {
  112. ShowMsg(QString::fromLocal8Bit("获取考试信息失败"), g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
  113. }
  114. else
  115. {
  116. ShowMsg(getExamProperty.sMessage, g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
  117. }
  118. }
  119. }
  120. void awExamScore::getObjectiveScore()
  121. {
  122. CHttpRequestPackage hrp;
  123. hrp.sUri = QString("/api/ecs_oe_student/client/exam/process/getEndExamInfo");
  124. hrp.sParamList.push_back(QString("examRecordDataId,%1").arg(g_appInfoPtr->m_oExamInfo.nExamRecordDataId));
  125. hrp.nRequestType = RequestType::rtGetEndExamInfo;
  126. hrp.eParamType = HttpParamType::hptUrl;
  127. g_httpBllPtr->post(hrp);
  128. }
  129. void awExamScore::onGetEndExamInfo(CGetEndExamInfo getEndExamInfo)
  130. {
  131. if (getEndExamInfo.nCode == 200)
  132. {
  133. if (getEndExamInfo.bIsCalculate)
  134. {
  135. ui->label_awes_result->setText(QString::fromLocal8Bit("考试结果计算中…"));
  136. if (m_getScoreEndTime > g_appInfoPtr->serverMTime())
  137. {
  138. QTimer::singleShot(3 * 1000, [&]() {
  139. getObjectiveScore();
  140. });
  141. }
  142. else
  143. {
  144. }
  145. }
  146. else if (getEndExamInfo.bIsWarn)
  147. {
  148. ui->label_awes_result->setText(QString::fromLocal8Bit("成绩待审核"));
  149. }
  150. else
  151. {
  152. ui->label_awes_result->setText(QString::fromLocal8Bit("客观题得分:%1").arg(getEndExamInfo.fObjectiveScore));
  153. }
  154. }
  155. else
  156. {
  157. if(getEndExamInfo.sMessage.isEmpty())
  158. {
  159. ShowMsg(QString::fromLocal8Bit("获取考试信息失败"), g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
  160. }
  161. else
  162. {
  163. ShowMsg(getEndExamInfo.sMessage, g_appInfoPtr->m_pAnsBgWidget, MSG_ICON_TYPE::mit_error);
  164. }
  165. }
  166. }
  167. void awExamScore::on_btn_awes_goback_clicked()
  168. {
  169. emit goHomePage();
  170. }