mainwindow.cpp 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. #include "mainwindow.h"
  2. #include "ui_mainwindow.h"
  3. MainWindow::MainWindow(QWidget *parent)
  4. : QMainWindow(parent)
  5. , ui(new Ui::MainWindow)
  6. {
  7. ui->setupUi(this);
  8. _initialize_all(); // initialize all user controls
  9. }
  10. MainWindow::~MainWindow()
  11. {
  12. delete ui;
  13. }
  14. void MainWindow::_initialize_all()
  15. {
  16. ui->comboBox_thesis_spervisorEvaluation->activated(0);
  17. ui->comboBox_thesis_examinerEvaluation->activated(0);
  18. ui->comboBox_thesis_presentationEvaluation->activated(0);
  19. ui->comboBox_exam_questionsEvaluation->activated(0);
  20. ui->checkBox_comment1_presentation->checkStateChanged(Qt::Checked);
  21. ui->radioButton_comment2_quality1->click();
  22. ui->radioButton_comment3_yes->click();
  23. ui->checkBox_comment4_explanations->checkStateChanged(Qt::Checked);
  24. ui->radioButton_comment4_quality1->click();
  25. ui->radioButton_comment5_confidence1->click();
  26. ui->radioButton_comment5_quality1->click();
  27. }
  28. void MainWindow::_calculate_thesisEvaluation()
  29. {
  30. double value = WEIGHT_THESIS_SUPERVISOR * _eval_thesis_supervisor
  31. + WEIGHT_THESIS_EXAMINER * _eval_thesis_examiner
  32. + WEIGHT_THESIS_PRESENTATION * _eval_thesis_presentation;
  33. _eval_thesis_final_text = _convert_evaluation_from_number(std::round(value * 100.0) / 100.0);
  34. }
  35. void MainWindow::_calculate_finalEvaluation()
  36. {
  37. double eval_thesis_final_num = _convert_evaluation_from_text(_eval_thesis_final_text);
  38. double value = (eval_thesis_final_num + _eval_exam_questions) / 2.0;
  39. if (_eval_exam_questions >= EVAL_NUM_VALUES.back() || eval_thesis_final_num >= EVAL_NUM_VALUES.back())
  40. _eval_final_text = EVAL_TOTAL_BAD;
  41. else if (value <= EVAL_TOTAL_WELL_THRESHOLD)
  42. _eval_final_text = EVAL_TOTAL_WELL;
  43. else
  44. _eval_final_text = EVAL_TOTAL_OK;
  45. }
  46. void MainWindow::_show_thesisEvaluation()
  47. {
  48. ui->label_thesis_finalEvaluation_text->setText(_eval_thesis_final_text);
  49. }
  50. void MainWindow::_show_finalEvaluation()
  51. {
  52. ui->label_finalEvaluation_text->setText(_eval_final_text);
  53. }
  54. void MainWindow::_show_finalComment()
  55. {
  56. ui->textEdit_finalComment->setText(_comment1 + _comment2 + _comment3 + _comment4 + _comment5);
  57. }
  58. QString MainWindow::_convert_evaluation_from_number(double x)
  59. {
  60. for (auto interval: EVAL_INTERVALS)
  61. {
  62. if (interval.in(x))
  63. return interval.getLabel();
  64. }
  65. return "-";
  66. }
  67. double MainWindow::_convert_evaluation_from_text(QString x)
  68. {
  69. for (size_t i = 0; i < EVAL_INTERVALS.size(); i++)
  70. {
  71. if (EVAL_INTERVALS[i].getLabel() == x)
  72. return EVAL_NUM_VALUES[i];
  73. }
  74. return 0;
  75. }
  76. void MainWindow::_compose_comment1()
  77. {
  78. QString first = "";
  79. QString second = "";
  80. QString third = "";
  81. if (_comm1_isPresentation && _comm1_isPrototype && _comm1_isVideo)
  82. {
  83. first = ui->checkBox_comment1_presentation->text() + ", ",
  84. second = ui->checkBox_comment1_prototype->text() + " a ",
  85. third = ui->checkBox_comment1_video->text();
  86. }
  87. else if (_comm1_isPresentation && _comm1_isPrototype)
  88. {
  89. first = ui->checkBox_comment1_presentation->text() + " a ",
  90. second = ui->checkBox_comment1_prototype->text();
  91. }
  92. else if (_comm1_isPresentation && _comm1_isVideo)
  93. {
  94. first = ui->checkBox_comment1_presentation->text() + " a ",
  95. second = ui->checkBox_comment1_video->text();
  96. }
  97. else if (_comm1_isPrototype && _comm1_isVideo)
  98. {
  99. first = ui->checkBox_comment1_prototype->text() + " a ",
  100. second = ui->checkBox_comment1_video->text();
  101. }
  102. else if (_comm1_isPresentation)
  103. {
  104. first = ui->checkBox_comment1_presentation->text();
  105. }
  106. else if (_comm1_isPrototype)
  107. {
  108. first = ui->checkBox_comment1_prototype->text();
  109. }
  110. else if (_comm1_isVideo)
  111. {
  112. first = ui->checkBox_comment1_video->text();
  113. }
  114. else
  115. {
  116. _comment1 = "";
  117. return;
  118. }
  119. _comment1 = QString("%1 %2%3%4, ")
  120. .arg(ui->label_comment1->text())
  121. .arg(first)
  122. .arg(second)
  123. .arg(third);
  124. }
  125. void MainWindow::_compose_comment2()
  126. {
  127. _comment2 = QString("%1 %2. ")
  128. .arg(ui->label_comment2->text())
  129. .arg(_comm2_selectedQuality);
  130. }
  131. void MainWindow::_compose_comment3()
  132. {
  133. _comment3 = QString("%1 %2. ")
  134. .arg(ui->label_comment3->text())
  135. .arg(_comm3_selectedAnswer);
  136. }
  137. void MainWindow::_compose_comment4()
  138. {
  139. _comment4 = QString("%1 %2%3. ")
  140. .arg(ui->label_comment4->text())
  141. .arg(_comm4_explanations)
  142. .arg(_comm4_selectedQuality);
  143. }
  144. void MainWindow::_compose_comment5()
  145. {
  146. QString selectedQuality = _comm5_isNoAnswer ? "" : " " + _comm5_selectedQuality;
  147. _comment5 = QString("%1 %2%3.")
  148. .arg(ui->label_comment5->text())
  149. .arg(_comm5_selectedConfidence)
  150. .arg(selectedQuality);
  151. }
  152. void MainWindow::on_comboBox_thesis_spervisorEvaluation_activated(int index)
  153. {
  154. _eval_thesis_supervisor = EVAL_NUM_VALUES[ui->comboBox_thesis_spervisorEvaluation->currentIndex()];
  155. _calculate_thesisEvaluation();
  156. _calculate_finalEvaluation();
  157. _show_thesisEvaluation();
  158. _show_finalEvaluation();
  159. }
  160. void MainWindow::on_comboBox_thesis_examinerEvaluation_activated(int index)
  161. {
  162. _eval_thesis_examiner = EVAL_NUM_VALUES[ui->comboBox_thesis_examinerEvaluation->currentIndex()];
  163. _calculate_thesisEvaluation();
  164. _calculate_finalEvaluation();
  165. _show_thesisEvaluation();
  166. _show_finalEvaluation();
  167. }
  168. void MainWindow::on_comboBox_thesis_presentationEvaluation_activated(int index)
  169. {
  170. _eval_thesis_presentation = EVAL_NUM_VALUES[ui->comboBox_thesis_presentationEvaluation->currentIndex()];
  171. _calculate_thesisEvaluation();
  172. _calculate_finalEvaluation();
  173. _show_thesisEvaluation();
  174. _show_finalEvaluation();
  175. }
  176. void MainWindow::on_comboBox_exam_questionsEvaluation_activated(int index)
  177. {
  178. _eval_exam_questions = EVAL_NUM_VALUES[ui->comboBox_exam_questionsEvaluation->currentIndex()];
  179. _calculate_finalEvaluation();
  180. _show_finalEvaluation();
  181. }
  182. void MainWindow::on_checkBox_comment1_presentation_checkStateChanged(const Qt::CheckState &arg1)
  183. {
  184. _comm1_isPresentation = arg1 == Qt::CheckState::Checked;
  185. _compose_comment1();
  186. _show_finalComment();
  187. }
  188. void MainWindow::on_checkBox_comment1_prototype_checkStateChanged(const Qt::CheckState &arg1)
  189. {
  190. _comm1_isPrototype = arg1 == Qt::CheckState::Checked;
  191. _compose_comment1();
  192. _show_finalComment();
  193. }
  194. void MainWindow::on_checkBox_comment1_video_checkStateChanged(const Qt::CheckState &arg1)
  195. {
  196. _comm1_isVideo = arg1 == Qt::CheckState::Checked;
  197. _compose_comment1();
  198. _show_finalComment();
  199. }
  200. void MainWindow::on_radioButton_comment2_quality1_clicked()
  201. {
  202. _comm2_selectedQuality = ui->radioButton_comment2_quality1->text();
  203. _compose_comment2();
  204. _show_finalComment();
  205. }
  206. void MainWindow::on_radioButton_comment2_quality2_clicked()
  207. {
  208. _comm2_selectedQuality = ui->radioButton_comment2_quality2->text();
  209. _compose_comment2();
  210. _show_finalComment();
  211. }
  212. void MainWindow::on_radioButton_comment2_quality3_clicked()
  213. {
  214. _comm2_selectedQuality = ui->radioButton_comment2_quality3->text();
  215. _compose_comment2();
  216. _show_finalComment();
  217. }
  218. void MainWindow::on_radioButton_comment2_quality4_clicked()
  219. {
  220. _comm2_selectedQuality = ui->radioButton_comment2_quality4->text();
  221. _compose_comment2();
  222. _show_finalComment();
  223. }
  224. void MainWindow::on_radioButton_comment2_quality5_clicked()
  225. {
  226. _comm2_selectedQuality = ui->radioButton_comment2_quality5->text();
  227. _compose_comment2();
  228. _show_finalComment();
  229. }
  230. void MainWindow::on_radioButton_comment3_yes_clicked()
  231. {
  232. _comm3_selectedAnswer = ui->radioButton_comment3_yes->text();
  233. _compose_comment3();
  234. _show_finalComment();
  235. }
  236. void MainWindow::on_radioButton_comment3_no_clicked()
  237. {
  238. _comm3_selectedAnswer = ui->radioButton_comment3_no->text();
  239. _compose_comment3();
  240. _show_finalComment();
  241. }
  242. void MainWindow::on_checkBox_comment4_explanations_checkStateChanged(const Qt::CheckState &arg1)
  243. {
  244. if (arg1 == Qt::CheckState::Checked)
  245. _comm4_explanations = ui->checkBox_comment4_explanations->text() + " ";
  246. else
  247. _comm4_explanations = "";
  248. _compose_comment4();
  249. _show_finalComment();
  250. }
  251. void MainWindow::on_radioButton_comment4_quality1_clicked()
  252. {
  253. _comm4_selectedQuality = ui->radioButton_comment4_quality1->text();
  254. _compose_comment4();
  255. _show_finalComment();
  256. }
  257. void MainWindow::on_radioButton_comment4_quality2_clicked()
  258. {
  259. _comm4_selectedQuality = ui->radioButton_comment4_quality2->text();
  260. _compose_comment4();
  261. _show_finalComment();
  262. }
  263. void MainWindow::on_radioButton_comment4_quality3_clicked()
  264. {
  265. _comm4_selectedQuality = ui->radioButton_comment4_quality3->text();
  266. _compose_comment4();
  267. _show_finalComment();
  268. }
  269. void MainWindow::on_radioButton_comment4_quality4_clicked()
  270. {
  271. _comm4_selectedQuality = ui->radioButton_comment4_quality4->text();
  272. _compose_comment4();
  273. _show_finalComment();
  274. }
  275. void MainWindow::on_radioButton_comment5_confidence1_clicked()
  276. {
  277. _comm5_isNoAnswer = false;
  278. _comm5_selectedConfidence = ui->radioButton_comment5_confidence1->text();
  279. _compose_comment5();
  280. _show_finalComment();
  281. }
  282. void MainWindow::on_radioButton_comment5_confidence2_clicked()
  283. {
  284. _comm5_isNoAnswer = false;
  285. _comm5_selectedConfidence = ui->radioButton_comment5_confidence2->text();
  286. _compose_comment5();
  287. _show_finalComment();
  288. }
  289. void MainWindow::on_radioButton_comment5_confidence3_clicked()
  290. {
  291. _comm5_isNoAnswer = true;
  292. _comm5_selectedConfidence = ui->radioButton_comment5_confidence3->text();
  293. _compose_comment5();
  294. _show_finalComment();
  295. }
  296. void MainWindow::on_radioButton_comment5_quality1_clicked()
  297. {
  298. _comm5_selectedQuality = ui->radioButton_comment5_quality1->text();
  299. _compose_comment5();
  300. _show_finalComment();
  301. }
  302. void MainWindow::on_radioButton_comment5_quality2_clicked()
  303. {
  304. _comm5_selectedQuality = ui->radioButton_comment5_quality2->text();
  305. _compose_comment5();
  306. _show_finalComment();
  307. }
  308. void MainWindow::on_radioButton_comment5_quality3_clicked()
  309. {
  310. _comm5_selectedQuality = ui->radioButton_comment5_quality3->text();
  311. _compose_comment5();
  312. _show_finalComment();
  313. }