clObjectiveScore.cpp 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. #include "clObjectiveScore.h"
  2. #include "ui_clObjectiveScore.h"
  3. #include "CAppInfo.h"
  4. #include <QListWidgetItem>
  5. #include <QHBoxLayout>
  6. #include <QLabel>
  7. #include <QGraphicsDropShadowEffect>
  8. #include "logproc.h"
  9. #include "awMsgBox.h"
  10. clObjectiveScore::clObjectiveScore(int nRow, QString sExamStudentId, QWidget *parent) :
  11. QWidget(parent),
  12. ui(new Ui::clObjectiveScore), m_sExamStudentId(sExamStudentId), m_nRow(nRow)
  13. {
  14. ui->setupUi(this);
  15. setStyleSheet(g_appInfoPtr->m_sQssStr);
  16. qRegisterMetaType<CQueryObjectiveScoreList>("CQueryObjectiveScoreList");
  17. connect(g_httpBllPtr.get(), &CHttpBll::sgnQueryObjectiveScoreList, this, &clObjectiveScore::onQueryObjectiveScoreList);
  18. CHttpRequestPackage hrp;
  19. hrp.sUri = "/api/ecs_oe_admin/client/exam/process/queryObjectiveScoreList";
  20. hrp.nRequestType = RequestType::rtQueryObjectiveScoreList;
  21. hrp.eParamType = HttpParamType::hptUrl;
  22. hrp.sCommonStr = sExamStudentId;
  23. hrp.sParamList.push_back(QString("examStudentId,%1").arg(m_sExamStudentId));
  24. g_httpBllPtr->post(hrp);
  25. }
  26. clObjectiveScore::~clObjectiveScore()
  27. {
  28. awMsgBox::clear(this);
  29. delete ui;
  30. }
  31. void clObjectiveScore::setUI(const int nLeft, const int nTop, const int nWidth, const int nHeight)
  32. {
  33. setGeometry(nLeft, nTop, nWidth, nHeight);
  34. ui->widget_objevtiveScore->setGeometry(g_appInfoPtr->m_fRate*5, g_appInfoPtr->m_fRate*5, width()-g_appInfoPtr->m_fRate*10, height()-g_appInfoPtr->m_fRate*10);
  35. ui->lw_objectiveScore->setGeometry(g_appInfoPtr->m_fRate*20, g_appInfoPtr->m_fRate*10,
  36. ui->widget_objevtiveScore->width() - g_appInfoPtr->m_fRate*20,
  37. ui->widget_objevtiveScore->height() - g_appInfoPtr->m_fRate*10*2);
  38. /*
  39. QListWidgetItem *pItem = new QListWidgetItem;
  40. QSize size = pItem->sizeHint();
  41. size.setHeight(g_appInfoPtr->m_fRate*46);
  42. pItem->setSizeHint(size);
  43. ui->lw_objectiveScore->addItem(pItem);
  44. QWidget *w = new QWidget;
  45. w->setStyleSheet(QString("QWidget{background:rgba(19, 187, 138, 1); border-radius:%1px}").arg((int)(g_appInfoPtr->m_fRate*10)));
  46. QHBoxLayout *l = new QHBoxLayout;
  47. QString sLabelStyle = QString(R"(QLabel{
  48. font-size:%1px;
  49. font-family:"Microsoft YaHei";
  50. font-weight:400;
  51. color:rgba(255,255,255,1);})").arg((int)(g_appInfoPtr->m_fRate*12));
  52. QLabel *label_times = new QLabel;
  53. label_times->setText(QString::fromLocal8Bit("次数"));
  54. label_times->setStyleSheet(sLabelStyle);
  55. label_times->adjustSize();
  56. QLabel *label_startTime = new QLabel;
  57. label_startTime->setText(QString::fromLocal8Bit("开始时间"));
  58. label_startTime->setStyleSheet(sLabelStyle);
  59. label_startTime->adjustSize();
  60. QLabel *label_handinPaperTime = new QLabel;
  61. label_handinPaperTime->setText(QString::fromLocal8Bit("交卷时间"));
  62. label_handinPaperTime->setStyleSheet(sLabelStyle);
  63. label_handinPaperTime->adjustSize();
  64. QLabel *label_score = new QLabel;
  65. label_score->setText(QString::fromLocal8Bit("客观分"));
  66. label_score->setStyleSheet(sLabelStyle);
  67. label_score->adjustSize();
  68. l->addSpacing(g_appInfoPtr->m_fRate*20);
  69. l->addWidget(label_times);
  70. l->addStretch();
  71. l->addWidget(label_startTime);
  72. l->addStretch();
  73. l->addWidget(label_handinPaperTime);
  74. l->addStretch();
  75. l->addWidget(label_score);
  76. l->addSpacing(g_appInfoPtr->m_fRate*20);
  77. w->setLayout(l);
  78. ui->lw_objectiveScore->setItemWidget(pItem, w);
  79. */
  80. QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect;
  81. effect->setOffset(g_appInfoPtr->m_fRate*4,g_appInfoPtr->m_fRate*4);
  82. effect->setColor(QColor(0,0,0,30));
  83. effect->setBlurRadius(g_appInfoPtr->m_fRate*16);
  84. ui->widget_objevtiveScore->setGraphicsEffect(effect);
  85. }
  86. void clObjectiveScore::onQueryObjectiveScoreList(CQueryObjectiveScoreList queryObjectiveScoreList)
  87. {
  88. if (queryObjectiveScoreList.nCode == 200)
  89. {
  90. if(m_sExamStudentId == queryObjectiveScoreList.sExamStudentId)
  91. {
  92. ui->lw_objectiveScore->clear();
  93. QListWidgetItem *pItem = new QListWidgetItem;
  94. QSize size = pItem->sizeHint();
  95. size.setHeight(g_appInfoPtr->m_fRate * 46);
  96. pItem->setSizeHint(size);
  97. ui->lw_objectiveScore->addItem(pItem);
  98. QWidget *w = new QWidget;
  99. w->setStyleSheet(QString("QWidget{background:rgba(19, 187, 138, 1); border-radius:%1px}").arg((int)(g_appInfoPtr->m_fRate * 10)));
  100. QHBoxLayout *l = new QHBoxLayout;
  101. QString sLabelStyle = QString(R"(QLabel{
  102. font-size:%1px;
  103. font-family:"Microsoft YaHei";
  104. font-weight:400;
  105. color:rgba(255,255,255,1);})").arg((int)(g_appInfoPtr->m_fRate * 12));
  106. QLabel *label_times = new QLabel;
  107. label_times->setText(QString::fromLocal8Bit("次数"));
  108. label_times->setStyleSheet(sLabelStyle);
  109. label_times->adjustSize();
  110. QLabel *label_startTime = new QLabel;
  111. label_startTime->setText(QString::fromLocal8Bit("开始时间"));
  112. label_startTime->setStyleSheet(sLabelStyle);
  113. label_startTime->adjustSize();
  114. QLabel *label_handinPaperTime = new QLabel;
  115. label_handinPaperTime->setText(QString::fromLocal8Bit("交卷时间"));
  116. label_handinPaperTime->setStyleSheet(sLabelStyle);
  117. label_handinPaperTime->adjustSize();
  118. QLabel *label_score = new QLabel;
  119. label_score->setText(QString::fromLocal8Bit("客观分"));
  120. label_score->setStyleSheet(sLabelStyle);
  121. label_score->adjustSize();
  122. l->addSpacing(g_appInfoPtr->m_fRate * 20);
  123. l->addWidget(label_times);
  124. l->addStretch();
  125. l->addWidget(label_startTime);
  126. l->addStretch();
  127. l->addWidget(label_handinPaperTime);
  128. l->addStretch();
  129. l->addWidget(label_score);
  130. l->addSpacing(g_appInfoPtr->m_fRate * 20);
  131. w->setLayout(l);
  132. ui->lw_objectiveScore->setItemWidget(pItem, w);
  133. int nSzie = queryObjectiveScoreList.vObjectiveScore.size();
  134. for (int i = nSzie - 1; i >= 0; --i)
  135. {
  136. if(i == nSzie - 11)
  137. {
  138. break;
  139. }
  140. CObjectiveScore os = queryObjectiveScoreList.vObjectiveScore[i];
  141. QListWidgetItem *pItem = new QListWidgetItem;
  142. QSize size = pItem->sizeHint();
  143. size.setHeight(g_appInfoPtr->m_fRate * 46);
  144. pItem->setSizeHint(size);
  145. ui->lw_objectiveScore->addItem(pItem);
  146. QWidget *w = new QWidget;
  147. w->setStyleSheet(QString("QWidget{background:rgba(255, 255, 255, 1); border-radius:%1px}").arg((int)(g_appInfoPtr->m_fRate * 10)));
  148. QHBoxLayout *l = new QHBoxLayout;
  149. QString sLabelStyle = QString(R"(QLabel{
  150. font-size:%1px;
  151. font-family:"Microsoft YaHei";
  152. font-weight:400;
  153. color:rgba(51,51,51,1);})").arg((int)(g_appInfoPtr->m_fRate * 12));
  154. QString sLabelScoreStyle = QString(R"(QLabel{
  155. font-size:%1px;
  156. font-family:"Microsoft YaHei";
  157. font-weight:500;
  158. color:rgba(51,51,51,1);})").arg((int)(g_appInfoPtr->m_fRate * 12));
  159. QLabel *label_times = new QLabel;
  160. label_times->setText(QString::number(os.nExamOrder));
  161. label_times->setStyleSheet(sLabelStyle);
  162. label_times->adjustSize();
  163. QLabel *label_startTime = new QLabel;
  164. label_startTime->setText(os.sStartTime);
  165. label_startTime->setStyleSheet(sLabelStyle);
  166. label_startTime->adjustSize();
  167. QLabel *label_handinPaperTime = new QLabel;
  168. label_handinPaperTime->setText(os.sEndTime);
  169. label_handinPaperTime->setStyleSheet(sLabelStyle);
  170. label_handinPaperTime->adjustSize();
  171. if (label_handinPaperTime->width() < label_startTime->width())
  172. {
  173. label_handinPaperTime->setFixedWidth(label_startTime->width());
  174. }
  175. QLabel *label_score = new QLabel;
  176. QString sScoreText = QString::number(os.fObjectiveScore);
  177. if (os.bIsAuditing)
  178. {
  179. sScoreText = QString::fromLocal8Bit("审核中");
  180. }
  181. if (os.bIsIllegality)
  182. {
  183. sScoreText = QString::fromLocal8Bit("违纪");
  184. }
  185. label_score->setText(sScoreText);
  186. label_score->setStyleSheet(sLabelScoreStyle);
  187. label_score->adjustSize();
  188. l->addSpacing(g_appInfoPtr->m_fRate * 20);
  189. l->addWidget(label_times);
  190. l->addStretch();
  191. l->addWidget(label_startTime);
  192. l->addStretch();
  193. l->addWidget(label_handinPaperTime);
  194. l->addStretch();
  195. l->addWidget(label_score);
  196. l->addSpacing(g_appInfoPtr->m_fRate * 20);
  197. w->setLayout(l);
  198. ui->lw_objectiveScore->setItemWidget(pItem, w);
  199. }
  200. nSzie = nSzie > 10 ? 10 : nSzie;
  201. int nHeight = g_appInfoPtr->m_fRate * 46*(nSzie+1) + g_appInfoPtr->m_fRate * (10 + 5) + g_appInfoPtr->m_fRate * (20 + 5);
  202. emit objectiveScoreHeight(m_nRow, nHeight);
  203. }
  204. }
  205. else
  206. {
  207. if(queryObjectiveScoreList.sMessage.isEmpty())
  208. {
  209. ShowMsg(QString::fromLocal8Bit("获取客观题成绩失败"), (QWidget*)(this->parent()), MSG_ICON_TYPE::mit_error);
  210. }
  211. else
  212. {
  213. ShowMsg(queryObjectiveScoreList.sMessage, (QWidget*)(this->parent()), MSG_ICON_TYPE::mit_error);
  214. }
  215. }
  216. }