clopPaperDetail.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  1. #include "clopPaperDetail.h"
  2. #include "ui_clopPaperDetail.h"
  3. #include "CAppInfo.h"
  4. #include "questionBody.h"
  5. #include "audioPlay.h"
  6. #include "logproc.h"
  7. #include "CCommonTools.h"
  8. #include "awMsgBox.h"
  9. clopPaperDetail::clopPaperDetail(__int64 nExamRecordDataId, QString sCourseCode, bool bFromCache, QWidget *parent) :
  10. QWidget(parent),
  11. ui(new Ui::clopPaperDetail), m_sCourseCode(sCourseCode), m_nExamRecordDataId(nExamRecordDataId),m_bFromCache(bFromCache)
  12. {
  13. ui->setupUi(this);
  14. setStyleSheet(g_appInfoPtr->m_sQssStr);
  15. qRegisterMetaType<CFindExamRecordDataEntity>("CFindExamRecordDataEntity");
  16. connect(g_httpBllPtr.get(), &CHttpBll::sgnFindExamRecordDataEntity, this, &clopPaperDetail::onFindExamRecordDataEntity);
  17. qRegisterMetaType<CGetExamRecordPaperStruct>("CGetExamRecordPaperStruct");
  18. connect(g_httpBllPtr.get(), &CHttpBll::sgnGetExamRecordPaperStruct, this, &clopPaperDetail::onGetExamRecordPaperStruct);
  19. qRegisterMetaType<CGetExamRecordQuestions>("CGetExamRecordQuestions");
  20. connect(g_httpBllPtr.get(), &CHttpBll::sgnGetExamRecordQuestions, this, &clopPaperDetail::onGetExamRecordQuestions);
  21. qRegisterMetaType<CGetQuestion>("CGetQuestion");
  22. connect(g_httpBllPtr.get(), &CHttpBll::sgnGetQuestion, this, &clopPaperDetail::onGetQuestion);
  23. {
  24. CHttpRequestPackage hrp;
  25. hrp.sUri = "/api/ecs_oe_admin/client/exam/process/getExamRecordPaperStruct";
  26. hrp.sParamList.push_back(QString("examRecordDataId,%1").arg(nExamRecordDataId));
  27. if(bFromCache)
  28. {
  29. hrp.sParamList.push_back(QString("fromCache,%1").arg(true));
  30. }
  31. hrp.nRequestType = RequestType::rtGetExamRecordPaperStruct;
  32. hrp.eParamType = HttpParamType::hptUrl;
  33. g_httpBllPtr->post(hrp);
  34. }
  35. {
  36. CHttpRequestPackage hrp;
  37. hrp.sUri = QString("/api/ecs_oe_admin/client/exam/process/findExamRecordDataEntity");
  38. hrp.sParamList.push_back(QString("examRecordDataId,%1").arg(m_nExamRecordDataId));
  39. if(bFromCache)
  40. {
  41. hrp.sParamList.push_back(QString("fromCache,%1").arg(true));
  42. }
  43. hrp.nRequestType = RequestType::rtFindExamRecordDataEntity;
  44. hrp.eParamType = HttpParamType::hptUrl;
  45. g_httpBllPtr->post(hrp);
  46. }
  47. }
  48. clopPaperDetail::~clopPaperDetail()
  49. {
  50. delete ui;
  51. }
  52. int clopPaperDetail::setUI(const int nWidth)
  53. {
  54. ui->btn_expandPaper->setGeometry(g_appInfoPtr->m_fRate*30, 0, g_appInfoPtr->m_fRate*108, g_appInfoPtr->m_fRate*32);
  55. ui->btn_expandPaper->setIconSize(QSize(g_appInfoPtr->m_fRate*14, g_appInfoPtr->m_fRate*14));
  56. ui->btn_expandPaper->setIcon(QIcon(":/images/icon-expand-paper.png"));
  57. ui->lw_paperDetail->setGeometry(ui->btn_expandPaper->x(), ui->btn_expandPaper->y() + ui->btn_expandPaper->height() + g_appInfoPtr->m_fRate*19,
  58. nWidth - g_appInfoPtr->m_fRate*30*2, 200);
  59. ui->lw_paperDetail->setVisible(false);
  60. return ui->btn_expandPaper->y() + ui->btn_expandPaper->height() + g_appInfoPtr->m_fRate*20;
  61. }
  62. void clopPaperDetail::onFindExamRecordDataEntity(CFindExamRecordDataEntity findExamRecordDataEntity)
  63. {
  64. if (findExamRecordDataEntity.nCode == 200)
  65. {
  66. m_nExamId = findExamRecordDataEntity.nExamId;
  67. m_sPaperType = findExamRecordDataEntity.sPaperType;
  68. CHttpRequestPackage hrp;
  69. hrp.sUri = QString("/api/ecs_oe_admin/client/exam/process/getExamRecordQuestions");
  70. hrp.sParamList.push_back(QString("examRecordDataId,%1").arg(m_nExamRecordDataId));
  71. if(m_bFromCache)
  72. {
  73. hrp.sParamList.push_back(QString("fromCache,%1").arg(true));
  74. }
  75. hrp.nRequestType = RequestType::rtGetExamRecordQuestions;
  76. hrp.eParamType = HttpParamType::hptUrl;
  77. g_httpBllPtr->post(hrp);
  78. }
  79. else
  80. {
  81. if(findExamRecordDataEntity.sMessage.isEmpty())
  82. {
  83. ShowMsg(QString::fromLocal8Bit("获取考试记录失败"), (QWidget*)(this->parent()), MSG_ICON_TYPE::mit_error);
  84. }
  85. else
  86. {
  87. ShowMsg(findExamRecordDataEntity.sMessage, (QWidget*)(this->parent()), MSG_ICON_TYPE::mit_error);
  88. }
  89. }
  90. }
  91. void clopPaperDetail::onGetExamRecordQuestions(CGetExamRecordQuestions getExamRecordQuestions)
  92. {
  93. if (getExamRecordQuestions.nCode == 200)
  94. {
  95. int nSize = getExamRecordQuestions.vExamRecordQuestions.size();
  96. for (int i = 0; i < nSize; ++i)
  97. {
  98. CAnsweredQuestion aq = getExamRecordQuestions.vExamRecordQuestions[i];
  99. setStudentAnswer(aq.nOrder, aq.sStudentAnswer);
  100. CHttpRequestPackage hrp;
  101. hrp.sUri = QString("/api/branch_ecs_ques/default_question/question/for/client");
  102. hrp.sParamList.push_back(QString("questionId,%1").arg(aq.sQuestionId));
  103. hrp.sParamList.push_back(QString("examId,%1").arg(m_nExamId));
  104. hrp.sParamList.push_back(QString("courseCode,%1").arg(m_sCourseCode));
  105. hrp.sParamList.push_back(QString("groupCode,%1").arg(m_sPaperType));
  106. hrp.nRequestType = RequestType::rtGetQuestion;
  107. hrp.eParamType = HttpParamType::hptBody;
  108. g_httpBllPtr->post(hrp);
  109. }
  110. }
  111. else
  112. {
  113. if(getExamRecordQuestions.sMessage.isEmpty())
  114. {
  115. ShowMsg(QString::fromLocal8Bit("获取题目信息失败"), (QWidget*)(this->parent()), MSG_ICON_TYPE::mit_error);
  116. }
  117. else
  118. {
  119. ShowMsg(getExamRecordQuestions.sMessage, (QWidget*)(this->parent()), MSG_ICON_TYPE::mit_error);
  120. }
  121. }
  122. }
  123. void clopPaperDetail::setStudentAnswer(int nOrder, QString sStudentAnswer)
  124. {
  125. for (CPaperGroupStruct &pgs : m_vPaperGroupStruct)
  126. {
  127. for (CQuestionStruct &qs : pgs.vQuestionStruct)
  128. {
  129. for (CSubQuestionStruct &sqs : qs.vSubQuestionStruct)
  130. {
  131. if (sqs.nOrder == nOrder)
  132. {
  133. sqs.sStudentAnswer = sStudentAnswer;
  134. break;
  135. }
  136. }
  137. }
  138. }
  139. }
  140. void clopPaperDetail::onGetExamRecordPaperStruct(CGetExamRecordPaperStruct getExamRecordPaperStruct)
  141. {
  142. if (getExamRecordPaperStruct.nCode == 200)
  143. {
  144. m_vPaperGroupStruct.swap(getExamRecordPaperStruct.vPaperGroupStruct);
  145. }
  146. else
  147. {
  148. if(getExamRecordPaperStruct.sMessage.isEmpty())
  149. {
  150. ShowMsg(QString::fromLocal8Bit("获取试卷结构失败"), (QWidget*)(this->parent()), MSG_ICON_TYPE::mit_error);
  151. }
  152. else
  153. {
  154. ShowMsg(getExamRecordPaperStruct.sMessage, (QWidget*)(this->parent()), MSG_ICON_TYPE::mit_error);
  155. }
  156. }
  157. }
  158. void clopPaperDetail::onGetQuestion(CGetQuestion getQuestion)
  159. {
  160. if (getQuestion.nCode == 200)
  161. {
  162. for (CPaperGroupStruct &pgs : m_vPaperGroupStruct)
  163. {
  164. for (CQuestionStruct &qs : pgs.vQuestionStruct)
  165. {
  166. if (qs.sQuestionId == getQuestion.sId)
  167. {
  168. qs.bHasContent = true;
  169. qs.sBody = getQuestion.sBody;
  170. qs.sVersion = getQuestion.sVersion;
  171. qs.bhasAudios = getQuestion.bhasAudios;
  172. for (int i = 0; i < getQuestion.vSubQuestion.size(); ++i)
  173. {
  174. CSubQuestion sq = getQuestion.vSubQuestion[i];
  175. qs.vSubQuestionStruct[i].sBody = sq.sBody;
  176. qs.vSubQuestionStruct[i].vRightAnswer.swap(sq.vRightAnswer);
  177. qs.vSubQuestionStruct[i].vOptions.swap(sq.vOptions);
  178. }
  179. break;
  180. }
  181. }
  182. }
  183. }
  184. else
  185. {
  186. if(getQuestion.sMessage.isEmpty())
  187. {
  188. ShowMsg(QString::fromLocal8Bit("获取试题失败"), (QWidget*)(this->parent()), MSG_ICON_TYPE::mit_error);
  189. }
  190. else
  191. {
  192. ShowMsg(getQuestion.sMessage, (QWidget*)(this->parent()), MSG_ICON_TYPE::mit_error);
  193. }
  194. }
  195. }
  196. void clopPaperDetail::on_btn_expandPaper_clicked()
  197. {
  198. bool bShow = true;
  199. for(CPaperGroupStruct &pgs : m_vPaperGroupStruct)
  200. {
  201. for (CQuestionStruct &qs : pgs.vQuestionStruct)
  202. {
  203. if (!qs.bHasContent)
  204. {
  205. CHttpRequestPackage hrp;
  206. hrp.sUri = QString("/api/branch_ecs_ques/default_question/question/for/client");
  207. hrp.sParamList.push_back(QString("questionId,%1").arg(qs.sQuestionId));
  208. hrp.sParamList.push_back(QString("examId,%1").arg(m_nExamId));
  209. hrp.sParamList.push_back(QString("courseCode,%1").arg(m_sCourseCode));
  210. hrp.sParamList.push_back(QString("groupCode,%1").arg(m_sPaperType));
  211. hrp.nRequestType = RequestType::rtGetQuestion;
  212. hrp.eParamType = HttpParamType::hptBody;
  213. g_httpBllPtr->post(hrp);
  214. bShow = false;
  215. }
  216. }
  217. }
  218. if (bShow)
  219. {
  220. int nIndex = 1;
  221. Json::Value jBody = Json::Value::null;
  222. for (int i = 0; i < m_vPaperGroupStruct.size(); ++i)
  223. {
  224. CPaperGroupStruct pgs = m_vPaperGroupStruct[i];
  225. QString sGroupBody = QString::fromLocal8Bit(R"({"sections":[{"blocks":[{"type":"text","value":"%1、%2"}]}]})")
  226. .arg(CCommonTools::Arab2Sinogram(pgs.nNumber)).arg(pgs.sGroupName);
  227. Json::Value blockItem = Json::Value::null;
  228. blockItem["type"] = "text";
  229. blockItem["value"] = (QString::fromLocal8Bit("%1、%2").arg(CCommonTools::Arab2Sinogram(pgs.nNumber)).arg(pgs.sGroupName)).toStdString();
  230. Json::Value block = Json::Value::null;
  231. block["blocks"].append(blockItem);
  232. jBody["sections"].append(block);
  233. for (CQuestionStruct &qs : pgs.vQuestionStruct)
  234. {
  235. if (!qs.sBody.isEmpty())
  236. {
  237. Json::Reader reader;
  238. Json::Value jQuestion = Json::Value::null;
  239. if (!reader.parse(qs.sBody.toStdString(), jQuestion))
  240. {
  241. // ShowMsg(QString::fromLocal8Bit("解析题干出错!"), g_appInfoPtr->m_answerWidget);
  242. myDebug() << QString::fromLocal8Bit("解析题干出错!");
  243. }
  244. for (int iq = 0; iq < jQuestion["sections"].size(); ++iq)
  245. {
  246. jBody["sections"].append(jQuestion["sections"][iq]);
  247. }
  248. }
  249. for (CSubQuestionStruct &sqs : qs.vSubQuestionStruct)
  250. {
  251. if (!sqs.sBody.isEmpty())
  252. {
  253. Json::Reader reader;
  254. Json::Value jSubQuestion = Json::Value::null;
  255. if (!reader.parse(sqs.sBody.toStdString(), jSubQuestion))
  256. {
  257. // ShowMsg(QString::fromLocal8Bit("解析题干出错!"), g_appInfoPtr->m_answerWidget);
  258. myDebug() << QString::fromLocal8Bit("解析题干出错!");
  259. }
  260. if (jSubQuestion["sections"][0]["blocks"][0]["type"] == "text")
  261. {
  262. QString sValue = jSubQuestion["sections"][0]["blocks"][0]["value"].asString().c_str();
  263. jSubQuestion["sections"][0]["blocks"][0]["value"] = (QString::fromLocal8Bit("%1、%2").arg(nIndex).arg(sValue)).toStdString();
  264. }
  265. else
  266. {
  267. Json::Value blockItem = Json::Value::null;
  268. blockItem["type"] = "text";
  269. blockItem["value"] = QString::fromLocal8Bit("% 1、").arg(nIndex).toStdString();
  270. Json::Value block = Json::Value::null;
  271. block["blocks"].append(blockItem);
  272. jBody["sections"].append(block);
  273. }
  274. for (int isq = 0; isq < jSubQuestion["sections"].size(); ++isq)
  275. {
  276. jBody["sections"].append(jSubQuestion["sections"][isq]);
  277. }
  278. }
  279. else
  280. {
  281. Json::Value blockItem = Json::Value::null;
  282. blockItem["type"] = "text";
  283. blockItem["value"] = QString::fromLocal8Bit("% 1、").arg(nIndex).toStdString();
  284. Json::Value block = Json::Value::null;
  285. block["blocks"].append(blockItem);
  286. jBody["sections"].append(block);
  287. }
  288. nIndex++;
  289. for (int io = 0; io < sqs.vOptions.size(); ++io)
  290. {
  291. QString sOption = sqs.vOptions[io].sBody;
  292. Json::Reader reader;
  293. Json::Value jOption = Json::Value::null;
  294. if (!reader.parse(sOption.toStdString(), jOption))
  295. {
  296. // ShowMsg(QString::fromLocal8Bit("解析题干出错!"), g_appInfoPtr->m_answerWidget);
  297. myDebug() << QString::fromLocal8Bit("解析题干出错!");
  298. }
  299. if (jOption["sections"][0]["blocks"][0]["type"] == "text")
  300. {
  301. QString sValue = jOption["sections"][0]["blocks"][0]["value"].asString().c_str();
  302. jOption["sections"][0]["blocks"][0]["value"] = (QString::fromLocal8Bit("%1、%2").arg(QChar('A' + io)).arg(sValue)).toStdString();
  303. }
  304. else
  305. {
  306. Json::Value blockItem = Json::Value::null;
  307. blockItem["type"] = "text";
  308. blockItem["value"] = QString::fromLocal8Bit("% 1、").arg(nIndex).toStdString();
  309. Json::Value block = Json::Value::null;
  310. block["blocks"].append(blockItem);
  311. jBody["sections"].append(block);
  312. }
  313. for (int iop = 0; iop < jOption["sections"].size(); ++iop)
  314. {
  315. jBody["sections"].append(jOption["sections"][iop]);
  316. }
  317. }
  318. int nRA = sqs.vRightAnswer.size();
  319. QString sRightAnswer = "";
  320. for (int ira = 0; ira < nRA; ++ira)
  321. {
  322. if(sqs.sQuestionType == QUESTION_TYPE::SingleChoice ||
  323. sqs.sQuestionType == QUESTION_TYPE::MultipleChoice ||
  324. sqs.sQuestionType == QUESTION_TYPE::TrueOrFalse)
  325. {
  326. Json::Reader reader;
  327. Json::Value jRightAnswer = Json::Value::null;
  328. if (!reader.parse(sqs.vRightAnswer[ira].toStdString(), jRightAnswer))
  329. {
  330. // ShowMsg(QString::fromLocal8Bit("解析题干出错!"), g_appInfoPtr->m_answerWidget);
  331. myDebug() << QString::fromLocal8Bit("解析题干出错!");
  332. }
  333. for(int nrai = 0; nrai < jRightAnswer["sections"].size(); ++nrai)
  334. {
  335. Json::Value jBlocks = jRightAnswer["sections"][nrai];
  336. for(int nb = 0; nb < jBlocks["blocks"].size(); nb++)
  337. {
  338. if(jBlocks["blocks"][nb]["type"] == "text")
  339. {
  340. if(sqs.sQuestionType != QUESTION_TYPE::TrueOrFalse)
  341. {
  342. sRightAnswer += 'A' + QString(jBlocks["blocks"][nb]["value"].asString().c_str()).toInt();
  343. }
  344. else
  345. {
  346. QString sAns = jBlocks["blocks"][nb]["value"].asString().c_str();
  347. sRightAnswer += jBlocks["blocks"][nb]["value"].asString() == "true" ? QString::fromLocal8Bit("正确") : QString::fromLocal8Bit("错误");
  348. }
  349. }
  350. }
  351. }
  352. }
  353. else if (sqs.sQuestionType == QUESTION_TYPE::FillUp ||
  354. sqs.sQuestionType == QUESTION_TYPE::Essay)
  355. {
  356. sRightAnswer = sqs.vRightAnswer[ira];
  357. Json::Reader reader;
  358. Json::Value jRightAnswer = Json::Value::null;
  359. if (!reader.parse(sRightAnswer.toStdString(), jRightAnswer))
  360. {
  361. // ShowMsg(QString::fromLocal8Bit("解析题干出错!"), g_appInfoPtr->m_answerWidget);
  362. myDebug() << QString::fromLocal8Bit("解析题干出错!");
  363. }
  364. if(ira == 0)
  365. {
  366. Json::Value blockItemAns = Json::Value::null;
  367. blockItemAns["type"] = "text";
  368. blockItemAns["value"] = QString::fromLocal8Bit("正确答案:").toStdString();
  369. Json::Value blockAns = Json::Value::null;
  370. blockAns["blocks"].append(blockItemAns);
  371. jBody["sections"].append(blockAns);
  372. }
  373. for(int nrai = 0; nrai < jRightAnswer["sections"].size(); ++nrai)
  374. {
  375. jBody["sections"].append(jRightAnswer["sections"][nrai]);
  376. }
  377. }
  378. }
  379. if(sqs.sQuestionType == QUESTION_TYPE::SingleChoice ||
  380. sqs.sQuestionType == QUESTION_TYPE::MultipleChoice ||
  381. sqs.sQuestionType == QUESTION_TYPE::TrueOrFalse)
  382. {
  383. Json::Value blockItemAns = Json::Value::null;
  384. blockItemAns["type"] = "text";
  385. blockItemAns["value"] = (QString::fromLocal8Bit("正确答案:%1").arg(sRightAnswer)).toStdString();
  386. Json::Value blockAns = Json::Value::null;
  387. blockAns["blocks"].append(blockItemAns);
  388. jBody["sections"].append(blockAns);
  389. }
  390. QString sStudentAnswer = "";
  391. if (sqs.sQuestionType == QUESTION_TYPE::SingleChoice ||
  392. sqs.sQuestionType == QUESTION_TYPE::MultipleChoice ||
  393. sqs.sQuestionType == QUESTION_TYPE::TrueOrFalse)
  394. {
  395. if (sqs.sQuestionType != QUESTION_TYPE::TrueOrFalse)
  396. {
  397. for (int isal = 0; isal < sqs.sStudentAnswer.length(); ++isal)
  398. {
  399. sStudentAnswer += 'A' + QString(sqs.sStudentAnswer[isal]).toInt();
  400. }
  401. }
  402. else
  403. {
  404. QString sAns = sqs.sStudentAnswer;
  405. sStudentAnswer = sqs.sStudentAnswer == "true" ? QString::fromLocal8Bit("正确") : sqs.sStudentAnswer == "false" ? QString::fromLocal8Bit("错误") : "";
  406. }
  407. }
  408. else if (sqs.sQuestionType == QUESTION_TYPE::FillUp ||
  409. sqs.sQuestionType == QUESTION_TYPE::Essay)
  410. {
  411. sStudentAnswer += sqs.sStudentAnswer;
  412. }
  413. Json::Value blockItemStuAns = Json::Value::null;
  414. blockItemStuAns["type"] = "text";
  415. blockItemStuAns["value"] = (QString::fromLocal8Bit("考生答案:%1").arg(sStudentAnswer)).toStdString();
  416. Json::Value blockStuAns = Json::Value::null;
  417. blockStuAns["blocks"].append(blockItemStuAns);
  418. jBody["sections"].append(blockStuAns);
  419. Json::Value blockItem = Json::Value::null;
  420. blockItem["type"] = "text";
  421. blockItem["value"] = "";
  422. Json::Value block = Json::Value::null;
  423. block["blocks"].append(blockItem);
  424. jBody["sections"].append(block);
  425. }
  426. }
  427. }
  428. initQuestion(jBody);
  429. }
  430. }
  431. void clopPaperDetail::initQuestion(Json::Value jBody)
  432. {
  433. int nListHeight = 0;
  434. int nIndex = 1;
  435. int nSectionSize = jBody["sections"].size();
  436. Json::Value jSections = Json::Value::null;
  437. for (int i = 0; i < nSectionSize; i++)
  438. {
  439. Json::Value jblocks = Json::Value::null;
  440. int nBlockSize = jBody["sections"][i]["blocks"].size();
  441. for (int j = 0; j < nBlockSize; j++)
  442. {
  443. if (jBody["sections"][i]["blocks"][j]["type"].asString() == "audio")
  444. {
  445. if (jblocks != Json::Value::null ||
  446. jSections != Json::Value::null)
  447. {
  448. if (jblocks != Json::Value::null)
  449. {
  450. Json::Value jBlockItem = Json::Value::null;
  451. jBlockItem["blocks"] = jblocks;
  452. jblocks = Json::Value::null;
  453. jSections.append(jBlockItem);
  454. }
  455. Json::Value jQuestionBody = Json::Value::null;
  456. jQuestionBody["sections"] = jSections;
  457. jSections = Json::Value::null;
  458. jblocks = Json::Value::null;
  459. questionBody *wQB = new questionBody(jQuestionBody);
  460. QListWidgetItem *listItem = new QListWidgetItem;
  461. int nQBHeight = wQB->setUI(ui->lw_paperDetail->width() - 40, nIndex);
  462. listItem->setSizeHint(QSize(ui->lw_paperDetail->width() - 40, nQBHeight));
  463. ui->lw_paperDetail->addItem(listItem);
  464. ui->lw_paperDetail->setItemWidget(listItem, wQB);
  465. nListHeight += nQBHeight;
  466. }
  467. nIndex++;
  468. QString sAudioName = jBody["sections"][i]["blocks"][j]["ext2"].asString().c_str();
  469. QString sAudioUrl = jBody["sections"][i]["blocks"][j]["value"].asString().c_str();
  470. audioPlay *wAP = new audioPlay(sAudioName, sAudioUrl, 10);
  471. QListWidgetItem *listItem = new QListWidgetItem;
  472. int nAPHeight = wAP->setUI(ui->lw_paperDetail->width() - 40);
  473. listItem->setSizeHint(QSize(ui->lw_paperDetail->width() - 40, nAPHeight));
  474. ui->lw_paperDetail->addItem(listItem);
  475. ui->lw_paperDetail->setItemWidget(listItem, wAP);
  476. nListHeight += nAPHeight;
  477. }
  478. else
  479. {
  480. jblocks.append(jBody["sections"][i]["blocks"][j]);
  481. }
  482. }
  483. if (jblocks != Json::Value::null)
  484. {
  485. Json::Value jBlockItem = Json::Value::null;
  486. jBlockItem["blocks"] = jblocks;
  487. jblocks = Json::Value::null;
  488. jSections.append(jBlockItem);
  489. }
  490. }
  491. if (jSections != Json::Value::null)
  492. {
  493. Json::Value jQuestionBody = Json::Value::null;
  494. jQuestionBody["sections"] = jSections;
  495. jSections = Json::Value::null;
  496. questionBody *wQB = new questionBody(jQuestionBody);
  497. QListWidgetItem *listItem = new QListWidgetItem;
  498. int nQBHeight = wQB->setUI(ui->lw_paperDetail->width() - 40, nIndex);
  499. listItem->setSizeHint(QSize(ui->lw_paperDetail->width() - 40, nQBHeight));
  500. ui->lw_paperDetail->addItem(listItem);
  501. ui->lw_paperDetail->setItemWidget(listItem, wQB);
  502. nListHeight += nQBHeight;
  503. }
  504. ui->lw_paperDetail->setGeometry(ui->btn_expandPaper->x(), ui->btn_expandPaper->y() + ui->btn_expandPaper->height() + g_appInfoPtr->m_fRate * 19,
  505. width() - g_appInfoPtr->m_fRate * 30 * 2, nListHeight);
  506. ui->lw_paperDetail->setVisible(true);
  507. emit heightChange(ui->lw_paperDetail->y() + ui->lw_paperDetail->height() + g_appInfoPtr->m_fRate * 20);
  508. }