clopResultList.cpp 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. #include "clopResultList.h"
  2. #include "ui_clopResultList.h"
  3. #include "CAppInfo.h"
  4. #include "clOperation.h"
  5. #include <QScrollBar>
  6. #include "awMsgBox.h"
  7. clopResultList::clopResultList(CPracticeCourseInfo pci, QString sBatchName, QWidget *parent) :
  8. QWidget(parent),
  9. ui(new Ui::clopResultList)
  10. {
  11. ui->setupUi(this);
  12. setStyleSheet(g_appInfoPtr->m_sQssStr);
  13. qRegisterMetaType<CQueryPracticeRecordList>("CQueryPracticeRecordList");
  14. connect(g_httpBllPtr.get(), &CHttpBll::sgnQueryPracticeRecordList, this, &clopResultList::onQueryPracticeRecordList);
  15. ui->label_clop_batch->setText(QString::fromLocal8Bit("批次:%1").arg(sBatchName));
  16. ui->label_clop_course->setText(QString::fromLocal8Bit("科目:%1").arg(pci.sCourseName));
  17. ui->label_clop_avgCorrectRate->setText(QString::fromLocal8Bit("平均正确率:%1").arg(pci.fAveObjectiveAccuracy));
  18. ui->label_clop_maxCorrectRate->setText(QString::fromLocal8Bit("最高正确率:%1").arg(pci.fMaxObjectiveAccuracy));
  19. CHttpRequestPackage hrp;
  20. hrp.sUri = QString("/api/ecs_oe_admin/client/exam/process/queryPracticeRecordList");
  21. hrp.sParamList.push_back(QString("examStudentId,%1").arg(pci.nExamStudentId));
  22. hrp.nRequestType = RequestType::rtQueryPracticeRecordList;
  23. hrp.eParamType = HttpParamType::hptUrl;
  24. g_httpBllPtr->post(hrp);
  25. }
  26. clopResultList::~clopResultList()
  27. {
  28. delete ui;
  29. }
  30. void clopResultList::setUI(const int nLeft, const int nTop, const int nWidth, const int nHeight)
  31. {
  32. setGeometry(nLeft, nTop, nWidth, nHeight);
  33. ui->widget_clop_BG->setGeometry(0, 0, width(), height());
  34. ui->widget_clop_top->setGeometry(0, 0, width(), g_appInfoPtr->m_fRate*56);
  35. ui->btn_clop_goback->setGeometry(ui->widget_clop_top->width() - g_appInfoPtr->m_fRate*(108 + 30), (ui->widget_clop_top->height() - g_appInfoPtr->m_fRate*32)/2, g_appInfoPtr->m_fRate*108, g_appInfoPtr->m_fRate*32);
  36. ui->btn_clop_goback->setIconSize(QSize(g_appInfoPtr->m_fRate*14, g_appInfoPtr->m_fRate*14));
  37. ui->btn_clop_goback->setIcon(QIcon(":/images/icon-goback-list.png"));
  38. ui->label_clop_batch->adjustSize();
  39. ui->label_clop_batch->setGeometry(g_appInfoPtr->m_fRate*30, (ui->widget_clop_top->height() - ui->label_clop_batch->height())/2,
  40. ui->label_clop_batch->width(), ui->label_clop_batch->height());
  41. ui->label_clop_maxCorrectRate->adjustSize();
  42. ui->label_clop_maxCorrectRate->setGeometry(ui->btn_clop_goback->x() - g_appInfoPtr->m_fRate*30 - ui->label_clop_maxCorrectRate->width(),
  43. ui->label_clop_batch->y(), ui->label_clop_maxCorrectRate->width(), ui->label_clop_maxCorrectRate->height());
  44. ui->label_clop_course->adjustSize();
  45. ui->label_clop_avgCorrectRate->adjustSize();
  46. int nLabelSpace = (ui->label_clop_maxCorrectRate->x() - ui->label_clop_batch->x() - ui->label_clop_batch->width() - ui->label_clop_course->width() - ui->label_clop_avgCorrectRate->width())/3;
  47. ui->label_clop_course->setGeometry(ui->label_clop_batch->x() + ui->label_clop_batch->width() + nLabelSpace,
  48. ui->label_clop_batch->y(), ui->label_clop_course->width(), ui->label_clop_course->height());
  49. ui->label_clop_avgCorrectRate->setGeometry(ui->label_clop_course->x() + ui->label_clop_course->width() + nLabelSpace,
  50. ui->label_clop_batch->y(), ui->label_clop_avgCorrectRate->width(), ui->label_clop_avgCorrectRate->height());
  51. ui->tablewt_examList->setGeometry(g_appInfoPtr->m_fRate*30, ui->widget_clop_top->height() + g_appInfoPtr->m_fRate*10,
  52. ui->widget_clop_BG->width() - g_appInfoPtr->m_fRate*30*2,
  53. ui->widget_clop_BG->height() - ui->widget_clop_top->height() - g_appInfoPtr->m_fRate*(10+78));
  54. ui->tablewt_examList->setEditTriggers(QAbstractItemView::NoEditTriggers);
  55. //整行选中的方式
  56. ui->tablewt_examList->setSelectionBehavior(QAbstractItemView::SelectRows);
  57. //设置为只能选中一行
  58. ui->tablewt_examList->setSelectionMode(QAbstractItemView::SingleSelection);
  59. //隐藏列表头
  60. ui->tablewt_examList->verticalHeader()->setVisible(false);
  61. //隐藏边框
  62. ui->tablewt_examList->setShowGrid(false);
  63. //表头不高亮显示
  64. ui->tablewt_examList->horizontalHeader()->setHighlightSections(false);
  65. //设置行数
  66. ui->tablewt_examList->setRowCount(10);
  67. //设置列数
  68. ui->tablewt_examList->setColumnCount(10);
  69. ui->tablewt_examList->setHorizontalScrollMode(QTableWidget::ScrollPerPixel);
  70. ui->tablewt_examList->horizontalScrollBar()->setSingleStep(g_appInfoPtr->m_fRate*5);
  71. QStringList sHeadStr;
  72. sHeadStr << QString::fromLocal8Bit("练习编号") <<
  73. QString::fromLocal8Bit("开始日期") <<
  74. QString::fromLocal8Bit("结束日期") <<
  75. QString::fromLocal8Bit("练习时长") <<
  76. QString::fromLocal8Bit("总题量") <<
  77. QString::fromLocal8Bit("正确") <<
  78. QString::fromLocal8Bit("错误") <<
  79. QString::fromLocal8Bit("未答") <<
  80. QString::fromLocal8Bit("正确率") <<
  81. QString::fromLocal8Bit("操作");
  82. ui->tablewt_examList->setHorizontalHeaderLabels(sHeadStr);
  83. ui->tablewt_examList->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft | Qt::AlignVCenter);
  84. ui->tablewt_examList->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed);
  85. ui->tablewt_examList->verticalHeader()->setDefaultSectionSize(g_appInfoPtr->m_fRate*52);
  86. ui->tablewt_examList->setColumnWidth(0, g_appInfoPtr->m_fRate*92);
  87. ui->tablewt_examList->setColumnWidth(1, g_appInfoPtr->m_fRate*172);
  88. ui->tablewt_examList->setColumnWidth(2, g_appInfoPtr->m_fRate*172);
  89. ui->tablewt_examList->setColumnWidth(3, g_appInfoPtr->m_fRate*97);
  90. ui->tablewt_examList->setColumnWidth(4, g_appInfoPtr->m_fRate*90);
  91. ui->tablewt_examList->setColumnWidth(5, g_appInfoPtr->m_fRate*90);
  92. ui->tablewt_examList->setColumnWidth(6, g_appInfoPtr->m_fRate*90);
  93. ui->tablewt_examList->setColumnWidth(7, g_appInfoPtr->m_fRate*90);
  94. ui->tablewt_examList->setColumnWidth(8, g_appInfoPtr->m_fRate*90);
  95. ui->tablewt_examList->setColumnWidth(9, g_appInfoPtr->m_fRate*128);
  96. ui->tablewt_examList->horizontalHeader()->setStretchLastSection(true);
  97. }
  98. void clopResultList::onQueryPracticeRecordList(CQueryPracticeRecordList queryPracticeRecordList)
  99. {
  100. if(queryPracticeRecordList.nCode == 200)
  101. {
  102. int nSize = queryPracticeRecordList.vPracticeRecordList.size();
  103. ui->tablewt_examList->setRowCount(nSize);
  104. for(int i = 0; i < nSize; ++i)
  105. {
  106. CPracticeRecord pr = queryPracticeRecordList.vPracticeRecordList[i];
  107. ui->tablewt_examList->setItem(i, 0, new QTableWidgetItem(QString::number(pr.nId)));
  108. ui->tablewt_examList->setItem(i, 1, new QTableWidgetItem(pr.sStartTime));
  109. ui->tablewt_examList->setItem(i, 2, new QTableWidgetItem(pr.sEndTime));
  110. ui->tablewt_examList->setItem(i, 3, new QTableWidgetItem(QString("%1:%2:%3")
  111. .arg(pr.nUsedExamTime/1000/60/60, 2, 10, QChar('0'))
  112. .arg(pr.nUsedExamTime/1000/60%60, 2, 10, QChar('0'))
  113. .arg(pr.nUsedExamTime/1000%60, 2, 10, QChar('0'))));
  114. ui->tablewt_examList->setItem(i, 4, new QTableWidgetItem(QString::number(pr.nTotalQuestionCount)));
  115. ui->tablewt_examList->setItem(i, 5, new QTableWidgetItem(QString::number(pr.nSuccQuestionNum)));
  116. ui->tablewt_examList->setItem(i, 6, new QTableWidgetItem(QString::number(pr.nFailQuestionNum)));
  117. ui->tablewt_examList->setItem(i, 7, new QTableWidgetItem(QString::number(pr.nNotAnsweredCount)));
  118. ui->tablewt_examList->setItem(i, 8, new QTableWidgetItem(QString::fromLocal8Bit("%1%").arg(pr.fObjectiveAccuracy)));
  119. clOperation *clo = new clOperation(i, ui->tablewt_examList);
  120. connect(clo, &clOperation::viewPracticePaper, this, [&](int nRow){
  121. if(m_pReport == nullptr)
  122. {
  123. m_pReport = std::make_shared<clopReport>(m_vPracticeRecordList[nRow], false, this);
  124. connect(m_pReport.get(), &clopReport::goback, this, [&](){
  125. m_pReport.reset();
  126. });
  127. m_pReport->setUI(0, 0, width(), height());
  128. }
  129. m_pReport->show();
  130. });
  131. clo->setUI(ui->tablewt_examList->columnWidth(9), ui->tablewt_examList->rowHeight(i), CL_OPERATION_TYPE::cot_online_practice_result);
  132. ui->tablewt_examList->setCellWidget(i, 9, clo);
  133. }
  134. m_vPracticeRecordList.swap(queryPracticeRecordList.vPracticeRecordList);
  135. }
  136. else
  137. {
  138. if(queryPracticeRecordList.sMessage.isEmpty())
  139. {
  140. ShowMsg(QString::fromLocal8Bit("获取练习列表信息失败"), (QWidget*)(this->parent()), MSG_ICON_TYPE::mit_error);
  141. }
  142. else
  143. {
  144. ShowMsg(queryPracticeRecordList.sMessage, (QWidget*)(this->parent()), MSG_ICON_TYPE::mit_error);
  145. }
  146. }
  147. }
  148. void clopResultList::on_btn_clop_goback_clicked()
  149. {
  150. emit goback();
  151. }