exercise_show.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720
  1. <?php
  2. include('exercise.class.php');
  3. include('question.class.php');
  4. include('answer.class.php');
  5. // answer types
  6. define('UNIQUE_ANSWER', 1);
  7. define('MULTIPLE_ANSWER', 2);
  8. define('FILL_IN_BLANKS', 3);
  9. define('MATCHING', 4);
  10. define('FREE_ANSWER', 5);
  11. define('HOTSPOT', 6);
  12. $langFile='exercice';
  13. include('../inc/global.inc.php');
  14. $this_section=SECTION_COURSES;
  15. api_protect_course_script();
  16. include(api_get_path(LIBRARY_PATH).'text.lib.php');
  17. include_once(api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
  18. $TBL_EXERCICE_QUESTION = $_course['dbNameGlu'].'quiz_rel_question';
  19. $TBL_EXERCICES = $_course['dbNameGlu'].'quiz';
  20. $TBL_QUESTIONS = $_course['dbNameGlu'].'quiz_question';
  21. $TBL_REPONSES = $_course['dbNameGlu'].'quiz_answer';
  22. $main_user_table = Database :: get_main_table(MAIN_USER_TABLE);
  23. $main_course_user_table = Database :: get_main_table(MAIN_COURSE_USER_TABLE);
  24. $statsdb = $statsDbName;
  25. $TABLETRACK_ATTEMPT = $statsDbName."`.`track_e_attempt";
  26. $TABLETRACK_EXERCICES = $statsDbName."`.`track_e_exercices";
  27. $dsp_percent = false;
  28. $debug=0;
  29. if($debug>0){echo str_repeat('&nbsp;',0).'Entered exercise_result.php'."<br />\n";var_dump($_POST);}
  30. // general parameters passed via POST/GET
  31. if ( empty ( $origin ) ) {
  32. $origin = $_REQUEST['origin'];
  33. }
  34. if ( empty ( $learnpath_id ) ) {
  35. $learnpath_id = mysql_real_escape_string($_REQUEST['learnpath_id']);
  36. }
  37. if ( empty ( $learnpath_item_id ) ) {
  38. $learnpath_item_id = mysql_real_escape_string($_REQUEST['learnpath_item_id']);
  39. }
  40. if ( empty ( $formSent ) ) {
  41. $formSent= $_REQUEST['formSent'];
  42. }
  43. if ( empty ( $exerciseResult ) ) {
  44. $exerciseResult = $_SESSION['exerciseResult'];
  45. }
  46. if ( empty ( $questionId ) ) {
  47. $questionId = $_REQUEST['questionId'];
  48. }
  49. if ( empty ( $choice ) ) {
  50. $choice = $_REQUEST['choice'];
  51. }
  52. if ( empty ( $questionNum ) ) {
  53. $questionNum = mysql_real_escape_string($_REQUEST['questionNum']);
  54. }
  55. if ( empty ( $nbrQuestions ) ) {
  56. $nbrQuestions = mysql_real_escape_string($_REQUEST['nbrQuestions']);
  57. }
  58. if ( empty ( $questionList ) ) {
  59. $questionList = $_SESSION['questionList'];
  60. }
  61. if ( empty ( $objExercise ) ) {
  62. $objExercise = $_SESSION['objExercise'];
  63. }
  64. $is_allowedToEdit=$is_courseAdmin;
  65. $nameTools=get_lang('Exercice');
  66. $interbreadcrumb[]=array("url" => "exercice.php","name" => get_lang('Exercices'));
  67. Display::display_header($nameTools,"Exercise");
  68. //echo "<pre>";
  69. //print_r($_SESSION);
  70. //echo "</pre>";
  71. $emailId = $_REQUEST['email'];
  72. $user_name = $_REQUEST['user'];
  73. $test = $_REQUEST['test'];
  74. $dt = $_REQUEST['dt'];
  75. $marks = $_REQUEST['res'];
  76. $id = $_REQUEST['id'];
  77. ?>
  78. <style type="text/css">
  79. <!--
  80. #comments {
  81. position:absolute;
  82. left:795px;
  83. top:0px;
  84. width:200px;
  85. height:75px;
  86. z-index:1;
  87. }
  88. -->
  89. </style>
  90. <script language="javascript">
  91. function showfck(sid,marksid)
  92. {
  93. document.getElementById(sid).style.visibility='visible';
  94. document.getElementById(marksid).style.visibility='visible';
  95. }
  96. function getFCK(vals,marksid){
  97. var f=document.getElementById('myform');
  98. var m_id = marksid.split(',');
  99. for(var i=0;i<m_id.length;i++){
  100. var oHidn = document.createElement("input");
  101. oHidn.type = "hidden";
  102. var selname = oHidn.name = "marks_"+m_id[i];
  103. var selid = document.forms['marksform_'+m_id[i]].marks.selectedIndex;
  104. oHidn.value = document.forms['marksform_'+m_id[i]].marks.options[selid].text;
  105. f.appendChild(oHidn);
  106. }
  107. var ids = vals.split(',');
  108. for(var k=0;k<ids.length;k++){
  109. var oHidden = document.createElement("input");
  110. oHidden.type = "hidden";
  111. oHidden.name = "comments_"+ids[k];
  112. oEditor = FCKeditorAPI.GetInstance(oHidden.name) ;
  113. oHidden.value = oEditor.GetXHTML(true);
  114. f.appendChild(oHidden);
  115. }
  116. //f.submit();
  117. }
  118. </script>
  119. <?php
  120. //functions
  121. function get_comments($id,$question_id)
  122. {
  123. global $TABLETRACK_ATTEMPT;
  124. $sql = "select teacher_comment from `".$TABLETRACK_ATTEMPT."` where exe_id=$id and question_id = '$question_id' order by question_id";
  125. $sqlres = api_sql_query($sql, __FILE__, __LINE__);
  126. $comm = mysql_result($sqlres,0,"teacher_comment");
  127. return $comm;
  128. }
  129. function display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,$id,$questionId,$ans)
  130. {
  131. ?>
  132. <tr valign="top">
  133. <td width="5%" align="center">
  134. <img src="../img/<?php echo ($answerType == UNIQUE_ANSWER)?'radio':'checkbox'; echo $studentChoice?'_on':'_off'; ?>.gif"
  135. border="0" alt="" />
  136. </td>
  137. <td width="5%" align="center">
  138. <img src="../img/<?php echo ($answerType == UNIQUE_ANSWER)?'radio':'checkbox'; echo $answerCorrect?'_on':'_off'; ?>.gif"
  139. border="0" alt=" " />
  140. </td>
  141. <td width="45%">
  142. <?php
  143. $answer=api_parse_tex($answer);
  144. echo $answer; ?><hr style="border-top: 0.5px solid #4171B5;">
  145. </td>
  146. <?php if($ans==1)
  147. {$comm = get_comments($id,$questionId);
  148. //echo $comm;
  149. }?>
  150. </tr>
  151. <?php
  152. }
  153. function display_fill_in_blanks_answer($answer,$id,$questionId)
  154. {
  155. ?>
  156. <tr>
  157. <td>
  158. <?php echo nl2br($answer); ?>
  159. </td><?php
  160. if(!$is_allowedToEdit) {?>
  161. <td>
  162. <?php
  163. $comm = get_comments($id,$questionId);
  164. //echo $comm;
  165. ?>
  166. </td>
  167. </tr>
  168. <?php }
  169. }
  170. function display_free_answer($answer,$id,$questionId)
  171. {
  172. ?>
  173. <tr>
  174. <td>
  175. <?php echo nl2br(stripslashes($answer)); ?>
  176. </td> <?php if(!$is_allowedToEdit) {?>
  177. <td>
  178. <?php
  179. $comm = get_comments($id,$questionId);
  180. /*if ($comm!='')
  181. echo $comm;
  182. else
  183. echo get_lang('notCorrectedYet');
  184. */?>
  185. </td> <?php }?>
  186. </tr>
  187. <?php
  188. }
  189. /*
  190. ==============================================================================
  191. MAIN CODE
  192. ==============================================================================
  193. */
  194. ?>
  195. <table width="100%" border="0" cellspacing=0 cellpadding=0>
  196. <tr>
  197. <td colspan="2">
  198. <?php $exerciseTitle=api_parse_tex($test);
  199. $query = "select * from `".$TABLETRACK_ATTEMPT."` where exe_id='$id' group by question_id";
  200. $result =api_sql_query($query, __FILE__, __LINE__);
  201. ?>
  202. <h3><?php echo $test ?>: <?php echo get_lang("Result"); ?></h3>
  203. </td>
  204. </tr>
  205. <?php
  206. $i=$totalScore=$totalWeighting=0;
  207. if($debug>0){echo "ExerciseResult: "; var_dump($exerciseResult); echo "QuestionList: ";var_dump($questionList);}
  208. // for each question
  209. $questionList = array();
  210. $exerciseResult = array();
  211. $k=0;
  212. while ($row = mysql_fetch_array($result))
  213. {
  214. $questionList[] = $row['question_id'];
  215. $exerciseResult[] = $row['answer'];
  216. }
  217. foreach($questionList as $questionId)
  218. {
  219. $k++;
  220. $choice=$exerciseResult[$questionId];
  221. // creates a temporary Question object
  222. $objQuestionTmp=new Question();
  223. $objQuestionTmp->read($questionId);
  224. $questionName=$objQuestionTmp->selectTitle();
  225. $questionWeighting=$objQuestionTmp->selectWeighting();
  226. $answerType=$objQuestionTmp->selectType();
  227. $quesId =$objQuestionTmp->selectId(); //added by priya saini
  228. // destruction of the Question object
  229. unset($objQuestionTmp);
  230. if($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER)
  231. {
  232. $colspan=2;
  233. }
  234. if($answerType == MATCHING || $answerType == FREE_ANSWER)
  235. {
  236. $colspan=2;
  237. }
  238. else
  239. {
  240. $colspan=2;
  241. }?>
  242. <tr bgcolor="#E6E6E6">
  243. <td colspan="2" > <?php echo get_lang("Question").' '.($i+1); ?> </td>
  244. </tr>
  245. <tr>
  246. <td colspan="2"><?php echo $questionName; ?> </td>
  247. </tr>
  248. <tr>
  249. <td width="200" height="90" valign="top">
  250. <?php
  251. if($answerType == MULTIPLE_ANSWER)
  252. {?>
  253. <table width="355" border="0" cellspacing="3" cellpadding="3">
  254. <tr>
  255. <td>&nbsp;</td>
  256. </tr>
  257. <tr>
  258. <td><i><?php echo get_lang("Choice"); ?></i> </td>
  259. <td><i><?php echo get_lang("ExpectedChoice"); ?></i></td>
  260. <td><i><?php echo get_lang("Answer"); ?></i></td>
  261. </tr>
  262. <tr>
  263. <td>&nbsp;</td>
  264. </tr>
  265. <?php
  266. // construction of the Answer object
  267. $objAnswerTmp=new Answer($questionId);
  268. $nbrAnswers=$objAnswerTmp->selectNbrAnswers();
  269. $questionScore=0;
  270. for($answerId=1;$answerId <= $nbrAnswers;$answerId++)
  271. {
  272. $answer=$objAnswerTmp->selectAnswer($answerId);
  273. $answerComment=$objAnswerTmp->selectComment($answerId);
  274. $answerCorrect=$objAnswerTmp->isCorrect($answerId);
  275. $answerWeighting=$objAnswerTmp->selectWeighting($answerId);
  276. $queryans = "select * from `".$TABLETRACK_ATTEMPT."` where exe_id = $id and question_id= $questionId";
  277. $resultans = api_sql_query($queryans, __FILE__, __LINE__);
  278. while ($row = mysql_fetch_array($resultans))
  279. {
  280. $ind = $row['answer'];
  281. $choice[$ind] = 1;
  282. }
  283. $studentChoice=$choice[$answerId];
  284. if($studentChoice)
  285. {
  286. $questionScore+=$answerWeighting;
  287. $totalScore+=$answerWeighting;
  288. }
  289. ?>
  290. <tr>
  291. <td> <?php
  292. if($answerId==1)
  293. display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,$id,$questionId,$answerId);
  294. else
  295. display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,$id,$questionId,"");
  296. ?>
  297. </td>
  298. </tr>
  299. <?php
  300. $i++;
  301. }?>
  302. </table>
  303. <?php }
  304. else if ($answerType == UNIQUE_ANSWER)
  305. {?>
  306. <table width="355" border="0">
  307. <tr>
  308. <td>&nbsp;</td>
  309. </tr>
  310. <tr>
  311. <td><i><?php echo get_lang("Choice"); ?></i> </td>
  312. <td><i><?php echo get_lang("ExpectedChoice"); ?></i></td>
  313. <td><i><?php echo get_lang("Answer"); ?></i></td>
  314. </tr>
  315. <tr>
  316. <td>&nbsp;</td>
  317. </tr>
  318. <?php
  319. $objAnswerTmp=new Answer($questionId);
  320. $nbrAnswers=$objAnswerTmp->selectNbrAnswers();
  321. $questionScore=0;
  322. for($answerId=1;$answerId <= $nbrAnswers;$answerId++)
  323. {
  324. $answer=$objAnswerTmp->selectAnswer($answerId);
  325. $answerComment=$objAnswerTmp->selectComment($answerId);
  326. $answerCorrect=$objAnswerTmp->isCorrect($answerId);
  327. $answerWeighting=$objAnswerTmp->selectWeighting($answerId);
  328. $queryans = "select answer from `".$TABLETRACK_ATTEMPT."` where exe_id = $id and question_id= $questionId";
  329. $resultans = api_sql_query($queryans, __FILE__, __LINE__);
  330. $choice = mysql_result($resultans,0,"answer");
  331. $studentChoice=($choice == $answerId)?1:0;
  332. if($studentChoice)
  333. {
  334. $questionScore+=$answerWeighting;
  335. $totalScore+=$answerWeighting;
  336. }?>
  337. <tr>
  338. <td><?php if($answerId==1)
  339. display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,$id,$questionId,$answerId);
  340. else
  341. display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,$id,$questionId,"");
  342. ?>
  343. </td>
  344. </tr><?php
  345. $i++;
  346. }?>
  347. </table>
  348. <?php }
  349. elseif($answerType == FILL_IN_BLANKS)
  350. {?>
  351. <table width="355" border="0">
  352. <tr>
  353. <td>&nbsp;</td>
  354. </tr>
  355. <tr>
  356. <td><i><?php echo get_lang("Answer"); ?></i> </td>
  357. </tr>
  358. <tr>
  359. <td>&nbsp;</td>
  360. </tr>
  361. <?php
  362. $objAnswerTmp=new Answer($questionId);
  363. $nbrAnswers=$objAnswerTmp->selectNbrAnswers();
  364. $questionScore=0;
  365. for($answerId=1;$answerId <= $nbrAnswers;$answerId++)
  366. {
  367. $answer=$objAnswerTmp->selectAnswer($answerId);
  368. $answerComment=$objAnswerTmp->selectComment($answerId);
  369. $answerCorrect=$objAnswerTmp->isCorrect($answerId);
  370. $answerWeighting=$objAnswerTmp->selectWeighting($answerId);
  371. list($answer,$answerWeighting)=explode('::',$answer);
  372. // splits weightings that are joined with a comma
  373. $answerWeighting=explode(',',$answerWeighting);
  374. // we save the answer because it will be modified
  375. $temp=$answer;
  376. // TeX parsing
  377. // 1. find everything between the [tex] and [/tex] tags
  378. $startlocations=strpos($temp,'[tex]');
  379. $endlocations=strpos($temp,'[/tex]');
  380. if($startlocations !== false && $endlocations !== false)
  381. {
  382. $texstring=substr($temp,$startlocations,$endlocations-$startlocations+6);
  383. // 2. replace this by {texcode}
  384. $temp=str_replace($texstring,'{texcode}',$temp);
  385. }
  386. $j=0;
  387. // the loop will stop at the end of the text
  388. $i=0;
  389. while(1)
  390. {
  391. // quits the loop if there are no more blanks
  392. if(($pos = strpos($temp,'[')) === false)
  393. {
  394. // adds the end of the text
  395. $answer.=$temp;
  396. // TeX parsing
  397. $texstring = api_parse_tex($texstring);
  398. break;
  399. }
  400. $temp=substr($temp,$pos+1);
  401. // quits the loop if there are no more blanks
  402. if(($pos = strpos($temp,']')) === false)
  403. {
  404. break;
  405. }
  406. $queryfill = "select answer from `".$TABLETRACK_ATTEMPT."` where exe_id = $id and question_id= $questionId";
  407. $resfill = api_sql_query($queryfill, __FILE__, __LINE__);
  408. $str=mysql_result($resfill,0,"answer");
  409. preg_match_all ('#\[([^[/]*)/#', $str, $arr);
  410. $choice = $arr[1];
  411. $choice[$j]=trim($choice[$j]);
  412. // if the word entered by the student IS the same as the one defined by the professor
  413. if(strtolower(substr($temp,0,$pos)) == stripslashes(strtolower($choice[$j])))
  414. {
  415. // gives the related weighting to the student
  416. $questionScore+=$answerWeighting[$j];
  417. // increments total score
  418. $totalScore+=$answerWeighting[$j];
  419. }
  420. // else if the word entered by the student IS NOT the same as the one defined by the professor
  421. $j++;
  422. $temp=substr($temp,$pos+1);
  423. $i=$i+1;
  424. } $answer = $str;
  425. ?>
  426. <tr>
  427. <td> <?php display_fill_in_blanks_answer($answer,$id,$questionId); ?> </td>
  428. </tr><?php
  429. $i++;
  430. }?>
  431. </table>
  432. <?php }
  433. elseif($answerType == FREE_ANSWER)
  434. {?>
  435. <table width="355" border="0" cellspacing="0" cellpadding="0">
  436. <tr>
  437. <td>&nbsp;</td>
  438. </tr>
  439. <tr>
  440. <td><i><?php echo get_lang("Answer"); ?></i> </td>
  441. </tr>
  442. <tr>
  443. <td>&nbsp;</td>
  444. </tr>
  445. <?php
  446. $objAnswerTmp=new Answer($questionId);
  447. $nbrAnswers=$objAnswerTmp->selectNbrAnswers();
  448. $questionScore=0;
  449. for($answerId=1;$answerId <= $nbrAnswers;$answerId++)
  450. {
  451. $answer=$objAnswerTmp->selectAnswer($answerId);
  452. $answerComment=$objAnswerTmp->selectComment($answerId);
  453. $answerCorrect=$objAnswerTmp->isCorrect($answerId);
  454. $answerWeighting=$objAnswerTmp->selectWeighting($answerId);
  455. $queryfree = "select marks from `".$TABLETRACK_ATTEMPT."` where exe_id = $id and question_id= $questionId";
  456. $resfree = api_sql_query($queryfree, __FILE__, __LINE__);
  457. $questionScore= mysql_result($resfree,0,"marks");
  458. //to assign marks to open question
  459. $totalScore+=$questionScore;
  460. $query = "select answer from `".$TABLETRACK_ATTEMPT."` where exe_id = $id and question_id= $questionId";
  461. $resq=api_sql_query($query);
  462. $choice = mysql_result($resq,0,"answer");
  463. ?>
  464. <tr>
  465. <td valign="top"><?php display_free_answer($choice,$id,$questionId);?> </td>
  466. </tr><?php
  467. $i++;
  468. }?>
  469. </table>
  470. <?php }
  471. elseif($answerType == MATCHING)
  472. {?>
  473. <table width="355" height="71" border="0">
  474. <tr>
  475. <td>&nbsp;</td>
  476. </tr>
  477. <tr>
  478. <td><i><?php echo get_lang("ElementList"); ?></i> </td>
  479. <td><i><?php echo get_lang("CorrespondsTo"); ?></i></td>
  480. </tr>
  481. <tr>
  482. <td>&nbsp;</td>
  483. </tr>
  484. <?php
  485. $objAnswerTmp=new Answer($questionId);
  486. $nbrAnswers=$objAnswerTmp->selectNbrAnswers();
  487. $questionScore=0;
  488. for($answerId=1;$answerId <= $nbrAnswers;$answerId++)
  489. {
  490. $answer=$objAnswerTmp->selectAnswer($answerId);
  491. $answerComment=$objAnswerTmp->selectComment($answerId);
  492. $answerCorrect=$objAnswerTmp->isCorrect($answerId);
  493. $answerWeighting=$objAnswerTmp->selectWeighting($answerId);
  494. $querymatch = "select * from `".$TABLETRACK_ATTEMPT."` where exe_id = $id and question_id= $questionId";
  495. $resmatch = api_sql_query($querymatch, __FILE__, __LINE__);
  496. while ($row = mysql_fetch_array($resmatch))
  497. {
  498. $ind = $row['position'];
  499. $answ = $row['answer'];
  500. $choice[$ind] = $answ;
  501. }
  502. if($answerCorrect)
  503. {
  504. if($answerCorrect == $choice[$answerId])
  505. {
  506. $questionScore+=$answerWeighting;
  507. $totalScore+=$answerWeighting;
  508. $choice[$answerId]=$matching[$choice[$answerId]];
  509. }
  510. elseif(!$choice[$answerId])
  511. {
  512. $choice[$answerId]='&nbsp;&nbsp;&nbsp;';
  513. }
  514. else
  515. {
  516. $choice[$answerId]='<font color="red"><s>'.$matching[$choice[$answerId]].'</s></font>';
  517. }
  518. }
  519. else
  520. {
  521. $matching[$answerId]=$answer;
  522. }
  523. ?>
  524. <tr>
  525. <?php
  526. $answer=api_parse_tex($answer);
  527. //echo $answer; ?>
  528. <?php
  529. $query = "select position from `".$TABLETRACK_ATTEMPT."` where question_id = $questionId and exe_id=$id";
  530. $resapp = api_sql_query($query, __FILE__, __LINE__);
  531. while($row = mysql_fetch_array($resapp))
  532. {
  533. $tp = $row['position'];
  534. }
  535. foreach($choice as $key => $v)
  536. {
  537. if($key==$answerId)
  538. {
  539. echo "<td>".$answer."</td>";
  540. echo "<td>";
  541. echo $v.'/';
  542. }
  543. }
  544. ?> <font color="green"><b>
  545. <?php
  546. $matching[$answerCorrect]=api_parse_tex($matching[$answerCorrect]);
  547. echo $matching[$answerCorrect]; ?></b></font>
  548. </td>
  549. </tr><?php
  550. $i++;
  551. }?>
  552. </table>
  553. <?php }?>
  554. </td>
  555. <td width="346" valign = "top"><i>
  556. <?php echo get_lang("Comment"); ?></i>
  557. <?php if($is_allowedToEdit)
  558. {
  559. //if (isset($_REQUEST['showdiv']) && $questionId==$_REQUEST['ques_id'])
  560. //{
  561. $name = "fckdiv".$questionId;
  562. $marksname = "marksName".$questionId;
  563. ?>
  564. <a href="#" onclick="showfck('<?=$name?>','<?=$marksname?>');"><?php if ($answerType == FREE_ANSWER) echo "&nbsp;".get_lang('EditCommentsAndMarks'); else echo "&nbsp;".get_lang('AddComments');?></a>
  565. <?php
  566. $comnt = get_comments($id,$questionId);
  567. echo "<br> <br>".$comnt;
  568. ?>
  569. <div id="<?php echo $name; ?>" style="visibility:hidden">
  570. <?php
  571. $arrid[] = $questionId;
  572. $fck_attribute['Width'] = '400';
  573. $fck_attribute['Height'] = '150';
  574. $fck_attribute['ToolbarSet'] = 'Comment';
  575. $$questionId = new FormValidator('frmcomments'.$questionId,'post','');
  576. $renderer =& $$questionId->defaultRenderer();
  577. $renderer->setFormTemplate(
  578. '<form{attributes}><div align="left">{content}</div></form>');
  579. $renderer->setElementTemplate(
  580. '<div align="left">{element}</div>'
  581. );
  582. $comnt =get_comments($id,$questionId);
  583. ${user.$questionId}['comments_'.$questionId] = $comnt;
  584. $$questionId->addElement('html_editor','comments_'.$questionId,false);
  585. //$$questionId->addElement('submit','submitQuestion',get_lang('Ok'));
  586. $$questionId->setDefaults(${user.$questionId});
  587. $$questionId->display();
  588. ?>
  589. </div>
  590. <?php
  591. }
  592. else
  593. {
  594. $comnt = get_comments($id,$questionId);
  595. echo "<br> <br>".$comnt;
  596. }
  597. ?>
  598. </td>
  599. </tr>
  600. <tr>
  601. <td></td>
  602. <td align= "left" >
  603. <?php
  604. if($is_allowedToEdit)
  605. {
  606. if ($answerType == FREE_ANSWER)
  607. {
  608. $marksname = "marksName".$questionId;
  609. ?>
  610. <div id="<?php echo $marksname; ?>" style="visibility:hidden">
  611. <form name="marksform_<?=$questionId?>" method="post" action="">
  612. <?php
  613. $arrmarks[] = $questionId;
  614. echo "Assign Marks ";
  615. echo "<select name='marks' id='marks'>";
  616. for($i=0;$i<=$questionWeighting;$i++)
  617. {?>
  618. <option <?php if ($i==$questionScore) echo "selected='selected'";?>>
  619. <?php echo $i;
  620. ?></option>
  621. <?php } ?>
  622. </select>
  623. </form></div><?php
  624. }
  625. }?>
  626. </td><tr><td></td><td align="right"><b><?php echo get_lang('Score')." : $questionScore/$questionWeighting"; ?></b></td>
  627. </tr>
  628. <?php unset($objAnswerTmp);
  629. $i++;
  630. $totalWeighting+=$questionWeighting;
  631. }
  632. ?>
  633. <tr><td></td><td align=right><b><?php
  634. $query = "update `".$TABLETRACK_EXERCICES."` set exe_result = $totalScore where exe_id = '$id'";
  635. api_sql_query($query,__FILE__,__LINE__);
  636. echo get_lang('YourTotalScore')." ";
  637. if($dsp_percent == true)
  638. {
  639. echo number_format(($totalScore/$totalWeighting)*100,1,'.','')."%";
  640. }
  641. else
  642. {
  643. echo $totalScore."/".$totalWeighting;
  644. }
  645. ?> !</b>
  646. </td></tr>
  647. <tr><td></td>
  648. <td align="right">
  649. <br />
  650. <? $strids = implode(",",$arrid);
  651. $marksid = implode(",",$arrmarks);
  652. if($is_allowedToEdit)
  653. {
  654. ?>
  655. <form name="myform" id="myform" action="exercice.php?show=result&comments=update&exeid=<?php echo $id; ?>&test=<?php echo $test; ?>&emailid=<?php echo $emailId;?>" method="post">
  656. <input type="submit" value="<?php echo get_lang('Ok'); ?>" onclick="getFCK('<?=$strids?>','<?=$marksid?>');"/>
  657. </form>
  658. <?php } ?>
  659. </td>
  660. </tr>
  661. </table>