clopPaperReport.cpp 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. #include "clopPaperReport.h"
  2. #include "ui_clopPaperReport.h"
  3. #include "CAppInfo.h"
  4. #include <QScrollBar>
  5. #include "awMsgBox.h"
  6. clopPaperReport::clopPaperReport(__int64 nExamRecordDataId, bool bFromCache, QWidget *parent) :
  7. QWidget(parent),
  8. ui(new Ui::clopPaperReport)
  9. {
  10. ui->setupUi(this);
  11. setStyleSheet(g_appInfoPtr->m_sQssStr);
  12. qRegisterMetaType<CGetPracticeDetailInfo>("CGetPracticeDetailInfo");
  13. connect(g_httpBllPtr.get(), &CHttpBll::sgnGetPracticeDetailInfo, this, &clopPaperReport::onGetPracticeDetailInfo);
  14. CHttpRequestPackage hrp;
  15. hrp.sUri = QString("/api/ecs_oe_admin/client/exam/process/getPracticeDetailInfo");
  16. hrp.sParamList.push_back(QString("examRecordDataId,%1").arg(nExamRecordDataId));
  17. if(bFromCache)
  18. {
  19. hrp.sParamList.push_back(QString("fromCache,%1").arg(true));
  20. }
  21. hrp.nRequestType = RequestType::rtGetPracticeDetailInfo;
  22. hrp.eParamType = HttpParamType::hptUrl;
  23. g_httpBllPtr->post(hrp);
  24. }
  25. clopPaperReport::~clopPaperReport()
  26. {
  27. delete ui;
  28. }
  29. int clopPaperReport::setUI(const int nWidth)
  30. {
  31. ui->label_clop_tips_title->adjustSize();
  32. ui->label_clop_tips_title->setGeometry(g_appInfoPtr->m_fRate*30, g_appInfoPtr->m_fRate*20,
  33. ui->label_clop_tips_title->width(), ui->label_clop_tips_title->height());
  34. ui->label_clop_tips->setFixedWidth(nWidth - g_appInfoPtr->m_fRate*30*2);
  35. ui->label_clop_tips->adjustSize();
  36. ui->label_clop_tips->setGeometry(ui->label_clop_tips_title->x(), ui->label_clop_tips_title->y() + ui->label_clop_tips_title->height() + g_appInfoPtr->m_fRate*5,
  37. ui->label_clop_tips->width(), ui->label_clop_tips->height());
  38. ui->tablewt_examList->setGeometry(g_appInfoPtr->m_fRate*30, ui->label_clop_tips->y() + ui->label_clop_tips->height() + g_appInfoPtr->m_fRate*20,
  39. nWidth - g_appInfoPtr->m_fRate*30*2,
  40. (ui->tablewt_examList->rowCount() + 1)*g_appInfoPtr->m_fRate * 48);
  41. ui->tablewt_examList->setEditTriggers(QAbstractItemView::NoEditTriggers);
  42. //整行选中的方式
  43. ui->tablewt_examList->setSelectionBehavior(QAbstractItemView::SelectRows);
  44. //设置为只能选中一行
  45. ui->tablewt_examList->setSelectionMode(QAbstractItemView::SingleSelection);
  46. //隐藏列表头
  47. ui->tablewt_examList->verticalHeader()->setVisible(false);
  48. //隐藏边框
  49. ui->tablewt_examList->setShowGrid(false);
  50. //表头不高亮显示
  51. ui->tablewt_examList->horizontalHeader()->setHighlightSections(false);
  52. //设置行数
  53. ui->tablewt_examList->setRowCount(10);
  54. //设置列数
  55. ui->tablewt_examList->setColumnCount(5);
  56. ui->tablewt_examList->setHorizontalScrollMode(QTableWidget::ScrollPerPixel);
  57. ui->tablewt_examList->horizontalScrollBar()->setSingleStep(g_appInfoPtr->m_fRate*5);
  58. QStringList sHeadStr;
  59. sHeadStr << QString::fromLocal8Bit("题型") <<
  60. QString::fromLocal8Bit("题量") <<
  61. QString::fromLocal8Bit("正确") <<
  62. QString::fromLocal8Bit("错误") <<
  63. QString::fromLocal8Bit("未答");
  64. ui->tablewt_examList->setHorizontalHeaderLabels(sHeadStr);
  65. ui->tablewt_examList->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft | Qt::AlignVCenter);
  66. ui->tablewt_examList->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed);
  67. ui->tablewt_examList->verticalHeader()->setDefaultSectionSize(g_appInfoPtr->m_fRate*48);
  68. int nColWidth = ui->tablewt_examList->width()/5;
  69. ui->tablewt_examList->setColumnWidth(0, nColWidth);
  70. ui->tablewt_examList->setColumnWidth(1, nColWidth);
  71. ui->tablewt_examList->setColumnWidth(2, nColWidth);
  72. ui->tablewt_examList->setColumnWidth(3, nColWidth);
  73. ui->tablewt_examList->setColumnWidth(4, nColWidth);
  74. ui->tablewt_examList->horizontalHeader()->setStretchLastSection(true);
  75. return ui->tablewt_examList->y() + ui->tablewt_examList->height() + g_appInfoPtr->m_fRate*20;
  76. }
  77. QString clopPaperReport::getQuestionName(QString questionType)
  78. {
  79. if(questionType == QUESTION_TYPE::SingleChoice)
  80. {
  81. return QString::fromLocal8Bit("单选题");
  82. }
  83. else if(questionType == QUESTION_TYPE::MultipleChoice)
  84. {
  85. return QString::fromLocal8Bit("多选题");
  86. }
  87. else if(questionType == QUESTION_TYPE::TrueOrFalse)
  88. {
  89. return QString::fromLocal8Bit("判断题");
  90. }
  91. else if(questionType == QUESTION_TYPE::FillUp)
  92. {
  93. return QString::fromLocal8Bit("填空题");
  94. }
  95. else if(questionType == QUESTION_TYPE::Essay)
  96. {
  97. return QString::fromLocal8Bit("问答题");
  98. }
  99. }
  100. void clopPaperReport::onGetPracticeDetailInfo(CGetPracticeDetailInfo getPracticeDetailInfo)
  101. {
  102. if(getPracticeDetailInfo.nCode == 200)
  103. {
  104. int nSize = getPracticeDetailInfo.vPracticePaperStructList.size();
  105. emit objectiveAccuracy(getPracticeDetailInfo.fObjectiveAccuracy);
  106. ui->tablewt_examList->setRowCount(nSize);
  107. for(int i = 0; i < nSize; i++)
  108. {
  109. CPracticePaperStructInfo pps = getPracticeDetailInfo.vPracticePaperStructList[i];
  110. ui->tablewt_examList->setItem(i, 0, new QTableWidgetItem(pps.sTitle));
  111. ui->tablewt_examList->setItem(i, 1, new QTableWidgetItem(QString::number(pps.nQuestionCount)));
  112. ui->tablewt_examList->setItem(i, 2, new QTableWidgetItem(QString::number(pps.nSuccQuestionNum)));
  113. ui->tablewt_examList->setItem(i, 3, new QTableWidgetItem(QString::number(pps.nFailQuestionNum)));
  114. ui->tablewt_examList->setItem(i, 4, new QTableWidgetItem(QString::number(pps.nNotAnsweredCount)));
  115. }
  116. int nHeight = ui->tablewt_examList->y() + (nSize+1)*g_appInfoPtr->m_fRate*48 + g_appInfoPtr->m_fRate*20;
  117. ui->tablewt_examList->setGeometry(g_appInfoPtr->m_fRate * 30, ui->label_clop_tips->y() + ui->label_clop_tips->height() + g_appInfoPtr->m_fRate * 20,
  118. width() - g_appInfoPtr->m_fRate * 30 * 2,
  119. (ui->tablewt_examList->rowCount()+1)*g_appInfoPtr->m_fRate * 48) ;
  120. emit heightChange(nHeight);
  121. }
  122. else
  123. {
  124. if(getPracticeDetailInfo.sMessage.isEmpty())
  125. {
  126. ShowMsg(QString::fromLocal8Bit("获取练习信息失败"), (QWidget*)(this->parent()), MSG_ICON_TYPE::mit_error);
  127. }
  128. else
  129. {
  130. ShowMsg(getPracticeDetailInfo.sMessage, (QWidget*)(this->parent()), MSG_ICON_TYPE::mit_error);
  131. }
  132. }
  133. }