PageRenderTime 35ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/Quản lý website thi trắc nghiệm qua mạng PHP/tracnghiem/inc/pages/reports-manager-3.inc.php

https://gitlab.com/phamngsinh/baitaplon_sinhvien
PHP | 147 lines | 146 code | 1 blank | 0 comment | 22 complexity | 9e84149d0e9abc987e71cd2d8083dcfd MD5 | raw file
  1. <?php
  2. $g_vars['page']['location'] = array('reports_manager', 'test_results', 'question_details', 'answer_details');
  3. $g_smarty->assign('g_vars', $g_vars);
  4. displayTemplate('_header');
  5. $f_resultid = (int)readGetVar('resultid');
  6. $f_answerid = (int)readGetVar('answerid');
  7. $g_vars['page']['selected_section'] = 'reportsmanager';
  8. $g_vars['page']['selected_tab'] = 'reportsmanager-3';
  9. $g_vars['page']['menu_2_items'] = getMenu2Items($g_vars['page']['selected_section']);
  10. writePanel2($g_vars['page']['menu_2_items']);
  11. $i_can_access = false;
  12. if($G_SESSION['access_reportsmanager'] > 1) {
  13. $i_can_access = true;
  14. } else {
  15. $i_rSet1 = $g_db->Execute("SELECT resultid FROM ".$srv_settings['table_prefix']."results WHERE userid=".$G_SESSION['userid']." AND resultid=".$f_resultid);
  16. if(!$i_rSet1) {
  17. showDBError(__FILE__, 1);
  18. } else {
  19. $i_can_access = $i_rSet1->RecordCount() > 0;
  20. }
  21. }
  22. if(!$i_can_access)
  23. $g_vars['page']['notifications'] = $lngstr['inf_cant_view_this_test_details'];
  24. writeErrorsWarningsBar();
  25. if($i_can_access) {
  26. $i_testid = 0;
  27. $i_rSet2 = $g_db->Execute("SELECT testid FROM ".$srv_settings['table_prefix']."results WHERE resultid=".$f_resultid);
  28. if(!$i_rSet2) {
  29. showDBError(__FILE__, 2);
  30. } else {
  31. if(!$i_rSet2->EOF) {
  32. $i_testid = $i_rSet2->fields["testid"];
  33. }
  34. $i_rSet2->Close();
  35. }
  36. $i_questionid = 0;
  37. $i_rSet3 = $g_db->Execute("SELECT questionid, result_answer_text, result_answer_points, result_answer_iscorrect, result_answer_feedback FROM ".$srv_settings['table_prefix']."results_answers WHERE resultid=".$f_resultid." AND result_answerid=".$f_answerid);
  38. if(!$i_rSet3) {
  39. showDBError(__FILE__, 3);
  40. } else {
  41. if(!$i_rSet3->EOF) {
  42. $i_questionid = (int)$i_rSet3->fields["questionid"];
  43. $i_result_answer_text = $i_rSet3->fields["result_answer_text"];
  44. $i_result_answer_points = $i_rSet3->fields["result_answer_points"];
  45. $i_result_answer_iscorrect = $i_rSet3->fields["result_answer_iscorrect"];
  46. $i_result_answer_feedback = $i_rSet3->fields["result_answer_feedback"];
  47. }
  48. $i_rSet3->Close();
  49. }
  50. $i_rSet4 = $g_db->Execute("SELECT * FROM ".$srv_settings['table_prefix']."questions WHERE questionid=".$i_questionid);
  51. if(!$i_rSet4) {
  52. showDBError(__FILE__, 4);
  53. } else {
  54. if(!$i_rSet4->EOF) {
  55. $i_questiontext = $i_rSet4->fields["question_text"];
  56. $i_questiontype = $i_rSet4->fields["question_type"];
  57. $i_questionpoints = $i_rSet4->fields["question_points"];
  58. }
  59. $i_rSet4->Close();
  60. }
  61. echo '<h2>'.$lngstr['page_reportsmanager']['correct_answer'].'</h2>';
  62. echo '<p><table cellpadding=0 cellspacing=5 border=0 width="100%">';
  63. echo '<tr><td colspan=2>'.$i_questiontext.'</td></tr>';
  64. $i_answers = array();
  65. $i_rSet5 = $g_db->Execute("SELECT answer_text, answer_correct FROM ".$srv_settings['table_prefix']."answers WHERE questionid=".$i_questionid." ORDER BY answerid");
  66. if(!$i_rSet5) {
  67. showDBError(__FILE__, 5);
  68. } else {
  69. $i_answerno = 1;
  70. while(!$i_rSet5->EOF) {
  71. $i_answers[$i_answerno] = $i_rSet5->fields["answer_text"];
  72. $i_answers_correct[$i_answerno] = $i_rSet5->fields["answer_correct"];
  73. $i_answerno++;
  74. $i_rSet5->MoveNext();
  75. }
  76. $i_rSet5->Close();
  77. }
  78. for($i=1;$i<$i_answerno;$i++) {
  79. echo '<tr>';
  80. switch($i_questiontype) {
  81. case QUESTION_TYPE_MULTIPLECHOICE:
  82. case QUESTION_TYPE_TRUEFALSE:
  83. echo '<td width=23 valign=top><nobr><img src="images/select_0'.($i_answers_correct[$i] ? '1' : '0').'.gif" width=13 height=15><img src="image/1x1.gif" width=9 height=1></nobr></td>';
  84. echo '<td width="100%">'.$i_answers[$i].'</td></tr>';
  85. break;
  86. case QUESTION_TYPE_MULTIPLEANSWER:
  87. echo '<td width=23 valign=top><nobr><img src="images/select_1'.($i_answers_correct[$i] ? '2' : '0').'.gif" width=13 height=15><img src="image/1x1.gif" width=9 height=1></nobr></td>';
  88. echo '<td width="100%">'.$i_answers[$i].'</td></tr>';
  89. break;
  90. case QUESTION_TYPE_FILLINTHEBLANK:
  91. echo '<td width=23 valign=top><nobr><img src="images/select_12.gif" width=13 height=15><img src="image/1x1.gif" width=9 height=1></nobr></td>';
  92. echo '<td width="100%">'.nl2br($i_answers[$i]).'</td></tr>';
  93. break;
  94. }
  95. }
  96. echo '</table>';
  97. echo '<h2>'.$lngstr['page_reportsmanager']['your_answer'].'</h2>';
  98. echo '<p><table cellpadding=0 cellspacing=5 border=0 width="100%">';
  99. switch($i_questiontype) {
  100. case QUESTION_TYPE_MULTIPLECHOICE:
  101. case QUESTION_TYPE_TRUEFALSE:
  102. $i_answers_given = (int)$i_result_answer_text;
  103. echo '<tr><td width=23 valign=top><nobr><img src="images/select_0'.($i_answers_correct[$i_answers_given] ? '1' : '0').'.gif" width=13 height=15><img src="image/1x1.gif" width=9 height=1></nobr></td>';
  104. echo '<td>'.$i_answers[$i_answers_given].'</td></tr>';
  105. break;
  106. case QUESTION_TYPE_MULTIPLEANSWER:
  107. $i_answers_given = explode(QUESTION_TYPE_MULTIPLEANSWER_BREAK, $i_result_answer_text);
  108. foreach($i_answers_given as $i_answer_given) {
  109. echo '<tr><td width=23 valign=top><nobr><img src="images/select_1'.($i_answers_correct[$i_answer_given] ? '2' : '0').'.gif" width=13 height=15><img src="image/1x1.gif" width=9 height=1></nobr></td>';
  110. echo '<td>'.$i_answers[$i_answer_given].'</td></tr>';
  111. }
  112. break;
  113. case QUESTION_TYPE_FILLINTHEBLANK:
  114. echo '<tr><td width=23 valign=top><nobr><img src="images/select_1'.($i_answers[1]==$i_result_answer_text ? '2' : '0').'.gif" width=13 height=15><img src="image/1x1.gif" width=9 height=1></nobr></td>';
  115. echo '<td>'.nl2br($i_result_answer_text).'</td></tr>';
  116. break;
  117. case QUESTION_TYPE_ESSAY:
  118. echo '<tr><td width=23 valign=top><nobr><img src="images/select_'.($i_result_answer_iscorrect==IGT_ANSWER_IS_UNDEFINED ? '13' : ($i_result_answer_iscorrect==IGT_ANSWER_IS_CORRECT ? '12' : ($i_result_answer_iscorrect==IGT_ANSWER_IS_PARTIALLYCORRECT ? '11' : '10'))).'.gif" width=13 height=15><img src="image/1x1.gif" width=9 height=1></nobr></td>';
  119. echo '<td>'.nl2br($i_result_answer_text).'</td></tr>';
  120. if($G_SESSION['access_reportsmanager'] > 2) {
  121. echo '<tr>';
  122. echo '<td width=23></td>';
  123. echo '<td width="100%">';
  124. echo '<p><form method=post action="reports-manager.php?resultid='.$f_resultid.'&answerid='.$f_answerid.'&action=setpoints">';
  125. echo '<table class=rowtable2 cellpadding=5 cellspacing=1 border=0 width="100%">';
  126. $i_rowno = 0;
  127. if($i_result_answer_iscorrect == IGT_ANSWER_IS_UNDEFINED)
  128. $i_result_answer_points = '';
  129. writeTR2($lngstr['page_editquestion_points'], getInputElement('points', $i_result_answer_points, 3));
  130. writeTR2($lngstr['page_reportsmanager']['answerfeedback'], getTextArea('feedback', $i_result_answer_feedback));
  131. echo '</table>';
  132. echo '<p class=center><input class=btn type=submit name=bsubmit value=" '.$lngstr['button_set'].' "></p></form>';
  133. echo '</td></tr>';
  134. } else {
  135. echo '<tr>';
  136. echo '<td width=23></td>';
  137. echo '<td width="100%"><strong>';
  138. echo nl2br($i_result_answer_feedback);
  139. echo '</strong></td></tr>';
  140. }
  141. break;
  142. }
  143. echo '</table>';
  144. }
  145. displayTemplate('_footer');
  146. ?>