exercice.php 56 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349
  1. <?php
  2. // $Id: exercice.php 22201 2009-07-17 19:57:03Z cfasanando $
  3. /* For licensing terms, see /dokeos_license.txt */
  4. /**
  5. * Exercise list: This script shows the list of exercises for administrators and students.
  6. * @package dokeos.exercise
  7. * @author Olivier Brouckaert, original author
  8. * @author Denes Nagy, HotPotatoes integration
  9. * @author Wolfgang Schneider, code/html cleanup
  10. * @version $Id:exercice.php 12269 2007-05-03 14:17:37Z elixir_julian $
  11. */
  12. // name of the language file that needs to be included
  13. $language_file = 'exercice';
  14. // including the global library
  15. require_once '../inc/global.inc.php';
  16. require_once '../gradebook/lib/be.inc.php';
  17. // setting the tabs
  18. $this_section = SECTION_COURSES;
  19. // access control
  20. api_protect_course_script(true);
  21. $show = (isset ($_GET['show']) && $_GET['show'] == 'result') ? 'result' : 'test'; // moved down to fix bug: http://www.dokeos.com/forum/viewtopic.php?p=18609#18609
  22. // including additional libraries
  23. require_once 'exercise.class.php';
  24. require_once 'question.class.php';
  25. require_once 'answer.class.php';
  26. require_once api_get_path(LIBRARY_PATH) . 'fileManage.lib.php';
  27. require_once api_get_path(LIBRARY_PATH) . 'fileUpload.lib.php';
  28. require_once 'hotpotatoes.lib.php';
  29. require_once api_get_path(LIBRARY_PATH) . 'document.lib.php';
  30. require_once api_get_path(LIBRARY_PATH) . 'mail.lib.inc.php';
  31. require_once api_get_path(LIBRARY_PATH) . 'usermanager.lib.php';
  32. /*
  33. -----------------------------------------------------------
  34. Constants and variables
  35. -----------------------------------------------------------
  36. */
  37. $is_allowedToEdit = api_is_allowed_to_edit();
  38. $is_tutor = api_is_allowed_to_edit(true);
  39. $is_tutor_course = api_is_course_tutor();
  40. $tbl_course_rel_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
  41. $TBL_USER = Database :: get_main_table(TABLE_MAIN_USER);
  42. $TBL_DOCUMENT = Database :: get_course_table(TABLE_DOCUMENT);
  43. $TBL_ITEM_PROPERTY = Database :: get_course_table(TABLE_ITEM_PROPERTY);
  44. $TBL_EXERCICE_ANSWER = Database :: get_course_table(TABLE_QUIZ_ANSWER);
  45. $TBL_EXERCICE_QUESTION = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION);
  46. $TBL_EXERCICES = Database :: get_course_table(TABLE_QUIZ_TEST);
  47. $TBL_QUESTIONS = Database :: get_course_table(TABLE_QUIZ_QUESTION);
  48. $TBL_TRACK_EXERCICES = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
  49. $TBL_TRACK_HOTPOTATOES = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES);
  50. $TBL_TRACK_ATTEMPT = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
  51. $TBL_TRACK_ATTEMPT_RECORDING = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);
  52. $TBL_LP_ITEM_VIEW = Database :: get_course_table(TABLE_LP_ITEM_VIEW);
  53. $TBL_LP_ITEM = Database :: get_course_table(TABLE_LP_ITEM);
  54. $TBL_LP_VIEW = Database :: get_course_table(TABLE_LP_VIEW);
  55. // document path
  56. $documentPath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . "/document";
  57. // picture path
  58. $picturePath = $documentPath . '/images';
  59. // audio path
  60. $audioPath = $documentPath . '/audio';
  61. // hotpotatoes
  62. $uploadPath = DIR_HOTPOTATOES; //defined in main_api
  63. $exercicePath = api_get_self();
  64. $exfile = explode('/', $exercicePath);
  65. $exfile = strtolower($exfile[sizeof($exfile) - 1]);
  66. $exercicePath = substr($exercicePath, 0, strpos($exercicePath, $exfile));
  67. $exercicePath = $exercicePath . "exercice.php";
  68. // maximum number of exercises on a same page
  69. $limitExPage = 50;
  70. // Clear the exercise session
  71. if (isset ($_SESSION['objExercise'])) {
  72. api_session_unregister('objExercise');
  73. }
  74. if (isset ($_SESSION['objQuestion'])) {
  75. api_session_unregister('objQuestion');
  76. }
  77. if (isset ($_SESSION['objAnswer'])) {
  78. api_session_unregister('objAnswer');
  79. }
  80. if (isset ($_SESSION['questionList'])) {
  81. api_session_unregister('questionList');
  82. }
  83. if (isset ($_SESSION['exerciseResult'])) {
  84. api_session_unregister('exerciseResult');
  85. }
  86. //general POST/GET/SESSION/COOKIES parameters recovery
  87. if (empty ($origin)) {
  88. $origin = Security::remove_XSS($_REQUEST['origin']);
  89. }
  90. if (empty ($choice)) {
  91. $choice = $_REQUEST['choice'];
  92. }
  93. if (empty ($hpchoice)) {
  94. $hpchoice = $_REQUEST['hpchoice'];
  95. }
  96. if (empty ($exerciseId)) {
  97. $exerciseId = Database :: escape_string($_REQUEST['exerciseId']);
  98. }
  99. if (empty ($file)) {
  100. $file = Database :: escape_string($_REQUEST['file']);
  101. }
  102. $learnpath_id = Database :: escape_string(Security::remove_XSS($_REQUEST['learnpath_id']));
  103. $learnpath_item_id = Database :: escape_string(Security::remove_XSS($_REQUEST['learnpath_item_id']));
  104. $page = Database :: escape_string($_REQUEST['page']);
  105. if ($origin == 'learnpath') {
  106. $show = 'result';
  107. }
  108. if ($_GET['delete'] == 'delete' && ($is_allowedToEdit || api_is_coach()) && !empty ($_GET['did']) && $_GET['did'] == strval(intval($_GET['did']))) {
  109. $sql = 'DELETE FROM ' . Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES) . ' WHERE exe_id = ' . $_GET['did']; //_GET[did] filtered by entry condition
  110. api_sql_query($sql, __FILE__, __LINE__);
  111. $filter=Security::remove_XSS($_GET['filter']);
  112. header('Location: exercice.php?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '&show=result&filter=' . $filter . '');
  113. exit;
  114. }
  115. if ($show == 'result' && $_REQUEST['comments'] == 'update' && ($is_allowedToEdit || $is_tutor) && $_GET['exeid']== strval(intval($_GET['exeid']))) {
  116. $id = $_GET['exeid']; //filtered by post-condition
  117. $emailid = $_GET['emailid'];
  118. $test = $_GET['test'];
  119. $from = $_SESSION['_user']['mail'];
  120. $from_name = api_get_person_name($_SESSION['_user']['firstName'], $_SESSION['_user']['lastName'], null, PERSON_NAME_EMAIL_ADDRESS);
  121. $url = api_get_path(WEB_CODE_PATH) . 'exercice/exercice.php?' . api_get_cidreq() . '&show=result';
  122. $TBL_RECORDING = Database :: get_statistic_table('track_e_attempt_recording');
  123. $total_weighting = $_REQUEST['totalWeighting'];
  124. $my_post_info=array();
  125. $post_content_id=array();
  126. $comments_exist=false;
  127. foreach ($_POST as $key_index=>$key_value) {
  128. $my_post_info=explode('_',$key_index);
  129. $post_content_id[]=$my_post_info[1];
  130. if ($my_post_info[0]=='comments') {
  131. $comments_exist=true;
  132. }
  133. }
  134. $loop_in_track=($comments_exist===true) ? (count($_POST)/2) : count($_POST);
  135. $array_content_id_exe=array();
  136. if ($comments_exist===true) {
  137. $array_content_id_exe=array_slice($post_content_id,$loop_in_track);
  138. } else {
  139. $array_content_id_exe=$post_content_id;
  140. }
  141. for ($i=0;$i<$loop_in_track;$i++) {
  142. $my_marks=Database::escape_string($_POST['marks_'.$array_content_id_exe[$i]]);
  143. $contain_comments=Database::escape_string($_POST['comments_'.$array_content_id_exe[$i]]);
  144. if (isset($contain_comments)) {
  145. $my_comments=Database::escape_string($_POST['comments_'.$array_content_id_exe[$i]]);
  146. } else {
  147. $my_comments='';
  148. }
  149. $my_questionid=$array_content_id_exe[$i];
  150. $sql = "SELECT question from $TBL_QUESTIONS WHERE id = '$my_questionid'";
  151. $result =api_sql_query($sql, __FILE__, __LINE__);
  152. $ques_name = Database::result($result,0,"question");
  153. $query = "UPDATE $TBL_TRACK_ATTEMPT SET marks = '$my_marks',teacher_comment = '$my_comments'
  154. WHERE question_id = '".$my_questionid."'
  155. AND exe_id='".$id."'";
  156. api_sql_query($query, __FILE__, __LINE__);
  157. $qry = 'SELECT sum(marks) as tot
  158. FROM '.$TBL_TRACK_ATTEMPT.' WHERE exe_id = '.intval($id).'
  159. GROUP BY question_id';
  160. $res = api_sql_query($qry,__FILE__,__LINE__);
  161. $tot = Database::result($res,0,'tot');
  162. //updating also the total weight
  163. $totquery = "UPDATE $TBL_TRACK_EXERCICES SET exe_result = '".Database::escape_string($tot)."', exe_weighting = '".Database::escape_string($total_weighting)."'
  164. WHERE exe_Id='".Database::escape_string($id)."'";
  165. api_sql_query($totquery, __FILE__, __LINE__);
  166. $recording_changes = 'INSERT INTO '.$TBL_RECORDING.' ' .
  167. '(exe_id,
  168. question_id,
  169. marks,
  170. insert_date,
  171. author,
  172. teacher_comment)
  173. VALUES
  174. ('."'$id','".$my_questionid."','$my_marks','".date('Y-m-d H:i:s')."','".api_get_user_id()."'".',"'.$my_comments.'")';
  175. api_sql_query($recording_changes, __FILE__, __LINE__);
  176. }
  177. $post_content_id=array();
  178. $array_content_id_exe=array();
  179. /*foreach ($_POST as $key => $v) {
  180. $keyexp = explode('_', $key);
  181. $id = Database :: escape_string($id);
  182. $v = Database :: escape_string($v);
  183. $my_questionid = Database :: escape_string($keyexp[1]);
  184. if ($keyexp[0] == "marks") {
  185. $sql = "SELECT question from $TBL_QUESTIONS WHERE id = '$my_questionid'";
  186. $result = api_sql_query($sql, __FILE__, __LINE__);
  187. $ques_name = Database :: result($result, 0, "question");
  188. $query = "UPDATE $TBL_TRACK_ATTEMPT SET marks = '" . $v . "'
  189. WHERE question_id = '" . $my_questionid . "'
  190. AND exe_id='" . $id . "'";
  191. api_sql_query($query, __FILE__, __LINE__);
  192. $qry = 'SELECT sum(marks) as tot
  193. FROM ' . $TBL_TRACK_ATTEMPT . ' WHERE exe_id = ' . intval($id) . '
  194. GROUP BY question_id';
  195. $res = api_sql_query($qry, __FILE__, __LINE__);
  196. $tot = Database :: result($res, 0, 'tot');
  197. //updating also the total weight
  198. $totquery = "UPDATE $TBL_TRACK_EXERCICES SET exe_result = '" . Database :: escape_string($tot) . "', exe_weighting = '" . Database :: escape_string($total_weighting) . "'
  199. WHERE exe_Id='" . Database :: escape_string($id) . "'";
  200. api_sql_query($totquery, __FILE__, __LINE__);
  201. $recording_changes = 'INSERT INTO ' . $TBL_RECORDING . ' ' .
  202. '(exe_id,
  203. question_id,
  204. marks,
  205. insert_date,
  206. author)
  207. VALUES
  208. (' . "'$id','" . $my_questionid . "','$v','" . date('Y-m-d H:i:s') . "','" . api_get_user_id() . "'" . ')';
  209. api_sql_query($recording_changes, __FILE__, __LINE__);
  210. } else {
  211. $query = "UPDATE $TBL_TRACK_ATTEMPT SET teacher_comment = '" . $v . "'
  212. WHERE question_id = '" . $my_questionid . "'
  213. AND exe_id = '" . $id . "'";
  214. api_sql_query($query, __FILE__, __LINE__);
  215. $recording_changes = 'INSERT INTO ' . $TBL_RECORDING . ' ' .
  216. '(exe_id,
  217. question_id,
  218. teacher_comment,
  219. insert_date,
  220. author)
  221. VALUES
  222. (' . "'$id','" . $my_questionid . "','$v','" . date('Y-m-d H:i:s') . "','" . api_get_user_id() . "'" . ')';
  223. api_sql_query($recording_changes, __FILE__, __LINE__);
  224. }
  225. }*/
  226. $qry = 'SELECT DISTINCT question_id, marks
  227. FROM ' . $TBL_TRACK_ATTEMPT . ' where exe_id = ' . intval($id) . '
  228. GROUP BY question_id';
  229. $res = api_sql_query($qry, __FILE__, __LINE__);
  230. $tot = 0;
  231. while ($row = Database :: fetch_array($res, 'ASSOC')) {
  232. $tot += $row['marks'];
  233. }
  234. $totquery = "UPDATE $TBL_TRACK_EXERCICES SET exe_result = '" . Database :: escape_string($tot) . "' WHERE exe_Id='" . Database :: escape_string($id) . "'";
  235. //search items
  236. if (isset($_POST['my_exe_exo_id']) && isset($_POST['student_id'])) {
  237. $sql_lp='SELECT li.id as lp_item_id,li.lp_id,li.item_type,li.path,liv.id AS lp_view_id,liv.user_id,max(liv.view_count) AS view_count FROM '.$TBL_LP_ITEM.' li
  238. INNER JOIN '.$TBL_LP_VIEW.' liv ON li.lp_id=liv.lp_id WHERE li.path="'.Database::escape_string(Security::remove_XSS($_POST['my_exe_exo_id'])).'" AND li.item_type="quiz" AND user_id="'.Database::escape_string(Security::remove_XSS($_POST['student_id'])).'" ';
  239. $rs_lp=Database::query($sql_lp,__FILE__,__LINE__);
  240. if (!($rs_lp===false)) {
  241. $row_lp=Database::fetch_array($rs_lp);
  242. //update score in learnig path
  243. $sql_lp_view='UPDATE '.$TBL_LP_ITEM_VIEW.' liv SET score ="'.$tot.'" WHERE liv.lp_item_id="'.(int)$row_lp['lp_item_id'].'" AND liv.lp_view_id="'.(int)$row_lp['lp_view_id'].'" AND liv.view_count="'.(int)$row_lp['view_count'].'" ;';
  244. $rs_lp_view=Database::query($sql_lp_view,__FILE__, __LINE__);
  245. }
  246. }
  247. Database::query($totquery, __FILE__, __LINE__);
  248. $subject = get_lang('ExamSheetVCC');
  249. $htmlmessage = '<html>' .
  250. '<head>' .
  251. '<style type="text/css">' .
  252. '<!--' .
  253. '.body{' .
  254. 'font-family: Verdana, Arial, Helvetica, sans-serif;' .
  255. 'font-weight: Normal;' .
  256. 'color: #000000;' .
  257. '}' .
  258. '.style8 {font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; color: #006699; }' .
  259. '.style10 {' .
  260. ' font-family: Verdana, Arial, Helvetica, sans-serif;' .
  261. ' font-size: 12px;' .
  262. ' font-weight: bold;' .
  263. '}' .
  264. '.style16 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; }' .
  265. '-->' .
  266. '</style>' .
  267. '</head>' .
  268. '<body>' .
  269. '<div>' .
  270. ' <p>' . get_lang('DearStudentEmailIntroduction') . '</p>' .
  271. ' <p class="style10"> ' . get_lang('AttemptVCC') . ' </p>' .
  272. ' <table width="417">' .
  273. ' <tr>' .
  274. ' <td width="229" valign="top" bgcolor="E5EDF8">&nbsp;&nbsp;<span class="style10">' . get_lang('Question') . '</span></td>' .
  275. ' <td width="469" valign="top" bgcolor="#F3F3F3"><span class="style16">#ques_name#</span></td>' .
  276. ' </tr>' .
  277. ' <tr>' .
  278. ' <td width="229" valign="top" bgcolor="E5EDF8">&nbsp;&nbsp;<span class="style10">' . get_lang('Exercice') . '</span></td>' .
  279. ' <td width="469" valign="top" bgcolor="#F3F3F3"><span class="style16">#test#</span></td>' .
  280. ' </tr>' .
  281. ' </table>' .
  282. ' <p>' . get_lang('ClickLinkToViewComment') . ' <a href="#url#">#url#</a><br />' .
  283. ' <br />' .
  284. ' ' . get_lang('Regards') . ' </p>' .
  285. ' </div>' .
  286. ' </body>' .
  287. ' </html>';
  288. $message = '<p>' . sprintf(get_lang('AttemptVCCLong'), Security::remove_XSS($test)) . ' <A href="#url#">#url#</A></p><br />';
  289. $mess = str_replace("#test#", Security::remove_XSS($test), $message);
  290. //$message= str_replace("#ques_name#",$ques_name,$mess);
  291. $message = str_replace("#url#", $url, $mess);
  292. $mess = $message;
  293. $headers = " MIME-Version: 1.0 \r\n";
  294. $headers .= "User-Agent: Dokeos/1.6";
  295. $headers .= "Content-Transfer-Encoding: 7bit";
  296. $headers .= 'From: ' . $from_name . ' <' . $from . '>' . "\r\n";
  297. $headers = "From:$from_name\r\nReply-to: $to\r\nContent-type: text/html; charset=" . ($charset ? $charset : 'ISO-8859-15');
  298. //mail($emailid, $subject, $mess,$headers);
  299. api_mail_html($emailid, $emailid, $subject, $mess, $from_name, $from);
  300. if (in_array($origin, array (
  301. 'tracking_course',
  302. 'user_course'
  303. ))) {
  304. if (isset ($_POST['lp_item_id']) && isset ($_POST['lp_item_view_id']) && isset ($_POST['student_id']) && isset ($_POST['total_score']) && isset ($_POST['total_time']) && isset ($_POST['totalWeighting'])) {
  305. $lp_item_id = $_POST['lp_item_id'];
  306. $lp_item_view_id = $_POST['lp_item_view_id'];
  307. $student_id = $_POST['student_id'];
  308. $totalWeighting = $_POST['totalWeighting'];
  309. if ($lp_item_id == strval(intval($lp_item_id)) && $lp_item_view_id == strval(intval($lp_item_view_id)) && $student_id == strval(intval($student_id))) {
  310. $score = Database :: escape_string($_POST['total_score']);
  311. $total_time = Database :: escape_string($_POST['total_time']);
  312. $lp_item_id = Database :: escape_string($lp_item_id);
  313. $lp_item_view_id = Database :: escape_string($lp_item_view_id);
  314. $student_id = Database :: escape_string($student_id);
  315. $totalWeighting = Database :: escape_string($totalWeighting);
  316. // get max view_count from lp_item_view
  317. /*$sql = "SELECT MAX(view_count) FROM $TBL_LP_ITEM_VIEW WHERE lp_item_id = '" . (int) $lp_item_view_id . "'
  318. AND lp_view_id = (SELECT id from $TBL_LP_VIEW WHERE user_id = '" . (int) $student_id . "' and lp_id='" . (int) $lp_item_id . "')";
  319. $res_max_view_count = api_sql_query($sql, __FILE__, __LINE__);
  320. $row_max_view_count = Database :: fetch_row($res_max_view_count);
  321. $max_view_count = (int) $row_max_view_count[0];
  322. // update score and total_time from last attempt when you qualify the exercise in Learning path detail
  323. $sql_update_score = "UPDATE $TBL_LP_ITEM_VIEW SET score = '" . (float) $score . "',total_time = '" . (int) $total_time . "' WHERE lp_item_id = '" . (int) $lp_item_view_id . "'
  324. AND lp_view_id = (SELECT id from $TBL_LP_VIEW WHERE user_id = '" . (int) $student_id . "' and lp_id='" . (int) $lp_item_id . "') AND view_count = '$max_view_count'";
  325. api_sql_query($sql_update_score, __FILE__, __LINE__);
  326. // update score and total_time from last attempt when you qualify the exercise in Learning path detail
  327. $sql_update_score = "UPDATE $TBL_LP_ITEM_VIEW SET score = '" . (float) $score . "',total_time = '" . (int) $total_time . "' WHERE lp_item_id = '" . (int) $lp_item_view_id . "'
  328. AND lp_view_id = (SELECT id from $TBL_LP_VIEW WHERE user_id = '" . (int) $student_id . "' and lp_id='" . (int) $lp_item_id . "') AND view_count = '$max_view_count'";
  329. api_sql_query($sql_update_score, __FILE__, __LINE__);*/
  330. // update max_score from a exercise in lp
  331. $sql_update_max_score = "UPDATE $TBL_LP_ITEM SET max_score = '" . (float) $totalWeighting . "' WHERE id = '" . (int) $lp_item_view_id . "'";
  332. api_sql_query($sql_update_max_score, __FILE__, __LINE__);
  333. }
  334. }
  335. if ($origin == 'tracking_course' && !empty($_POST['lp_item_id'])) {
  336. //Redirect to the course detail in lp
  337. header('location: ../mySpace/lp_tracking.php?course=' . Security :: remove_XSS($_GET['course']) . '&origin=' . $origin . '&lp_id=' . Security :: remove_XSS($_POST['lp_item_id']) . '&student_id=' . Security :: remove_XSS($_GET['student']).'&from='.Security::remove_XSS($_GET['from']));
  338. } else {
  339. //Redirect to the reporting
  340. header('location: ../mySpace/myStudents.php?origin=' . $origin . '&student=' . Security :: remove_XSS($_GET['student']) . '&details=true&course=' . Security :: remove_XSS($_GET['course']));
  341. }
  342. }
  343. }
  344. if (!empty($_GET['gradebook']) && $_GET['gradebook']=='view' ) {
  345. $_SESSION['gradebook']=Security::remove_XSS($_GET['gradebook']);
  346. $gradebook= $_SESSION['gradebook'];
  347. } elseif (empty($_GET['gradebook'])) {
  348. unset($_SESSION['gradebook']);
  349. $gradebook= '';
  350. }
  351. if (!empty($gradebook) && $gradebook=='view') {
  352. $interbreadcrumb[] = array (
  353. 'url' => '../gradebook/' . $_SESSION['gradebook_dest'],
  354. 'name' => get_lang('Gradebook')
  355. );
  356. }
  357. if ($show != 'result') {
  358. $nameTools = get_lang('Exercices');
  359. } else {
  360. if ($is_allowedToEdit || $is_tutor) {
  361. $nameTools = get_lang('StudentScore');
  362. $interbreadcrumb[] = array (
  363. "url" => "exercice.php?gradebook=$gradebook",
  364. "name" => get_lang('Exercices')
  365. );
  366. } else {
  367. $nameTools = get_lang('YourScore');
  368. $interbreadcrumb[] = array (
  369. "url" => "exercice.php?gradebook=$gradebook",
  370. "name" => get_lang('Exercices')
  371. );
  372. }
  373. }
  374. // need functions of statsutils lib to display previous exercices scores
  375. include_once (api_get_path(LIBRARY_PATH) . 'statsUtils.lib.inc.php');
  376. if ($is_allowedToEdit && !empty ($choice) && $choice == 'exportqti2') {
  377. require_once ('export/qti2/qti2_export.php');
  378. $export = export_exercise($exerciseId, true);
  379. require_once (api_get_path(LIBRARY_PATH) . 'pclzip/pclzip.lib.php');
  380. $archive_path = api_get_path(SYS_ARCHIVE_PATH);
  381. $temp_dir_short = uniqid();
  382. $temp_zip_dir = $archive_path . "/" . $temp_dir_short;
  383. if (!is_dir($temp_zip_dir))
  384. mkdir($temp_zip_dir);
  385. $temp_zip_file = $temp_zip_dir . "/" . md5(time()) . ".zip";
  386. $temp_xml_file = $temp_zip_dir . "/qti2export_" . $exerciseId . '.xml';
  387. file_put_contents($temp_xml_file, $export);
  388. $zip_folder = new PclZip($temp_zip_file);
  389. $zip_folder->add($temp_xml_file, PCLZIP_OPT_REMOVE_ALL_PATH);
  390. $name = 'qti2_export_' . $exerciseId . '.zip';
  391. //DocumentManager::string_send_for_download($export,true,'qti2export_'.$exerciseId.'.xml');
  392. DocumentManager :: file_send_for_download($temp_zip_file, true, $name);
  393. unlink($temp_zip_file);
  394. unlink($temp_xml_file);
  395. rmdir($temp_zip_dir);
  396. exit (); //otherwise following clicks may become buggy
  397. }
  398. if (!empty ($_POST['export_user_fields'])) {
  399. switch ($_POST['export_user_fields']) {
  400. case 'export_user_fields' :
  401. $_SESSION['export_user_fields'] = true;
  402. break;
  403. case 'do_not_export_user_fields' :
  404. default :
  405. $_SESSION['export_user_fields'] = false;
  406. break;
  407. }
  408. }
  409. if (!empty ($_POST['export_report']) && $_POST['export_report'] == 'export_report') {
  410. if (api_is_platform_admin() || api_is_course_admin() || api_is_course_tutor() || api_is_course_coach()) {
  411. $user_id = null;
  412. if (empty ($_SESSION['export_user_fields']))
  413. $_SESSION['export_user_fields'] = false;
  414. if (!$is_allowedToEdit and !$is_tutor) {
  415. $user_id = api_get_user_id();
  416. }
  417. require_once ('exercise_result.class.php');
  418. switch ($_POST['export_format']) {
  419. case 'xls' :
  420. $export = new ExerciseResult();
  421. $export->exportCompleteReportXLS($documentPath, $user_id, $_SESSION['export_user_fields']);
  422. exit;
  423. break;
  424. case 'csv' :
  425. default :
  426. $export = new ExerciseResult();
  427. $export->exportCompleteReportCSV($documentPath, $user_id, $_SESSION['export_user_fields']);
  428. exit;
  429. break;
  430. }
  431. } else {
  432. api_not_allowed(true);
  433. }
  434. }
  435. if ($origin != 'learnpath') {
  436. //so we are not in learnpath tool
  437. Display :: display_header($nameTools, "Exercise");
  438. if (isset ($_GET['message'])) {
  439. if (in_array($_GET['message'], array (
  440. 'ExerciseEdited'
  441. ))) {
  442. Display :: display_confirmation_message(get_lang($_GET['message']));
  443. }
  444. }
  445. } else {
  446. echo '<link rel="stylesheet" type="text/css" href="' . api_get_path(WEB_CODE_PATH) . 'css/default.css"/>';
  447. }
  448. event_access_tool(TOOL_QUIZ);
  449. // Tool introduction
  450. Display :: display_introduction_section(TOOL_QUIZ);
  451. // selects $limitExPage exercises at the same time
  452. $from = $page * $limitExPage;
  453. $sql = "SELECT count(id) FROM $TBL_EXERCICES";
  454. $res = api_sql_query($sql, __FILE__, __LINE__);
  455. list ($nbrexerc) = Database :: fetch_array($res);
  456. HotPotGCt($documentPath, 1, $_user['user_id']);
  457. $tbl_grade_link = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
  458. // only for administrator
  459. if ($is_allowedToEdit) {
  460. if (!empty ($choice)) {
  461. // construction of Exercise
  462. $objExerciseTmp = new Exercise();
  463. if ($objExerciseTmp->read($exerciseId)) {
  464. switch ($choice) {
  465. case 'delete' : // deletes an exercise
  466. $objExerciseTmp->delete();
  467. //delete link of exercise of gradebook tool
  468. $sql = 'SELECT gl.id FROM ' . $tbl_grade_link . ' gl WHERE gl.type="1" AND gl.ref_id="' . $exerciseId . '";';
  469. $result = api_sql_query($sql, __FILE__, __LINE__);
  470. $row = Database :: fetch_array($result, 'ASSOC');
  471. $link = LinkFactory :: load($row['id']);
  472. if ($link[0] != null) {
  473. $link[0]->delete();
  474. }
  475. Display :: display_confirmation_message(get_lang('ExerciseDeleted'));
  476. break;
  477. case 'enable' : // enables an exercise
  478. $objExerciseTmp->enable();
  479. $objExerciseTmp->save();
  480. // "WHAT'S NEW" notification: update table item_property (previously last_tooledit)
  481. Display :: display_confirmation_message(get_lang('VisibilityChanged'));
  482. break;
  483. case 'disable' : // disables an exercise
  484. $objExerciseTmp->disable();
  485. $objExerciseTmp->save();
  486. Display :: display_confirmation_message(get_lang('VisibilityChanged'));
  487. break;
  488. case 'disable_results' : //disable the results for the learners
  489. $objExerciseTmp->disable_results();
  490. $objExerciseTmp->save();
  491. Display :: display_confirmation_message(get_lang('ResultsDisabled'));
  492. break;
  493. case 'enable_results' : //disable the results for the learners
  494. $objExerciseTmp->enable_results();
  495. $objExerciseTmp->save();
  496. Display :: display_confirmation_message(get_lang('ResultsEnabled'));
  497. break;
  498. }
  499. }
  500. // destruction of Exercise
  501. unset ($objExerciseTmp);
  502. }
  503. if (!empty ($hpchoice)) {
  504. switch ($hpchoice) {
  505. case 'delete' : // deletes an exercise
  506. $imgparams = array ();
  507. $imgcount = 0;
  508. GetImgParams($file, $documentPath, $imgparams, $imgcount);
  509. $fld = GetFolderName($file);
  510. for ($i = 0; $i < $imgcount; $i++) {
  511. my_delete($documentPath . $uploadPath . "/" . $fld . "/" . $imgparams[$i]);
  512. update_db_info("delete", $uploadPath . "/" . $fld . "/" . $imgparams[$i]);
  513. }
  514. if (my_delete($documentPath . $file)) {
  515. update_db_info("delete", $file);
  516. }
  517. my_delete($documentPath . $uploadPath . "/" . $fld . "/");
  518. break;
  519. case 'enable' : // enables an exercise
  520. $newVisibilityStatus = "1"; //"visible"
  521. $query = "SELECT id FROM $TBL_DOCUMENT WHERE path='" . Database :: escape_string($file) . "'";
  522. $res = api_sql_query($query, __FILE__, __LINE__);
  523. $row = Database :: fetch_array($res, 'ASSOC');
  524. api_item_property_update($_course, TOOL_DOCUMENT, $row['id'], 'visible', $_user['user_id']);
  525. //$dialogBox = get_lang('ViMod');
  526. break;
  527. case 'disable' : // disables an exercise
  528. $newVisibilityStatus = "0"; //"invisible"
  529. $query = "SELECT id FROM $TBL_DOCUMENT WHERE path='" . Database :: escape_string($file) . "'";
  530. $res = api_sql_query($query, __FILE__, __LINE__);
  531. $row = Database :: fetch_array($res, 'ASSOC');
  532. api_item_property_update($_course, TOOL_DOCUMENT, $row['id'], 'invisible', $_user['user_id']);
  533. #$query = "UPDATE $TBL_DOCUMENT SET visibility='$newVisibilityStatus' WHERE path=\"".$file."\""; //added by Toon
  534. #api_sql_query($query,__FILE__,__LINE__);
  535. //$dialogBox = get_lang('ViMod');
  536. break;
  537. default :
  538. break;
  539. }
  540. }
  541. if ($show == 'test') {
  542. $sql = "SELECT id,title,type,active,description, results_disabled FROM $TBL_EXERCICES WHERE active<>'-1' ORDER BY title LIMIT " . (int) $from . "," . (int) ($limitExPage +1);
  543. $result = api_sql_query($sql, __FILE__, __LINE__);
  544. }
  545. }
  546. elseif ($show == 'test') { // only for students //fin
  547. $sql = "SELECT id,title,type,description, results_disabled FROM $TBL_EXERCICES WHERE active='1' ORDER BY title LIMIT " . (int) $from . "," . (int) ($limitExPage +1);
  548. $result = api_sql_query($sql, __FILE__, __LINE__);
  549. }
  550. // the actions
  551. echo '<div class="actions">';
  552. // display the next and previous link if needed
  553. $from = $page * $limitExPage;
  554. $sql = "SELECT count(id) FROM $TBL_EXERCICES";
  555. $res = api_sql_query($sql, __FILE__, __LINE__);
  556. list ($nbrexerc) = Database :: fetch_array($res);
  557. HotPotGCt($documentPath, 1, $_user['user_id']);
  558. // only for administrator
  559. if ($is_allowedToEdit) {
  560. if ($show == 'test') {
  561. $sql = "SELECT id,title,type,active,description, results_disabled FROM $TBL_EXERCICES WHERE active<>'-1' ORDER BY title LIMIT " . (int) $from . "," . (int) ($limitExPage +1);
  562. $result = api_sql_query($sql, __FILE__, __LINE__);
  563. }
  564. }
  565. elseif ($show == 'test') { // only for students
  566. $sql = "SELECT id,title,type,description, results_disabled FROM $TBL_EXERCICES WHERE active='1' ORDER BY title LIMIT " . (int) $from . "," . (int) ($limitExPage +1);
  567. $result = api_sql_query($sql, __FILE__, __LINE__);
  568. }
  569. if ($show == 'test') {
  570. $nbrExercises = Database :: num_rows($result);
  571. //get HotPotatoes files (active and inactive)
  572. $res = api_sql_query("SELECT *
  573. FROM $TBL_DOCUMENT
  574. WHERE
  575. path LIKE '" . Database :: escape_string($uploadPath) . "/%/%'", __FILE__, __LINE__);
  576. $nbrTests = Database :: num_rows($res);
  577. $res = api_sql_query("SELECT *
  578. FROM $TBL_DOCUMENT d, $TBL_ITEM_PROPERTY ip
  579. WHERE d.id = ip.ref
  580. AND ip.tool = '" . TOOL_DOCUMENT . "'
  581. AND d.path LIKE '" . Database :: escape_string($uploadPath) . "/%/%'
  582. AND ip.visibility='1'", __FILE__, __LINE__);
  583. $nbrActiveTests = Database :: num_rows($res);
  584. if ($is_allowedToEdit) {
  585. //if user is allowed to edit, also show hidden HP tests
  586. $nbrHpTests = $nbrTests;
  587. } else {
  588. $nbrHpTests = $nbrActiveTests;
  589. }
  590. $nbrNextTests = $nbrexerc - $nbrHpTests - (($page * $limitExPage));
  591. echo '<span style="float:right">';
  592. //show pages navigation link for previous page
  593. if ($page) {
  594. echo "<a href=\"" . api_get_self() . "?" . api_get_cidreq() . "&amp;page=" . ($page -1) . "\">" . Display :: return_icon('previous.gif') . get_lang("PreviousPage") . "</a> | ";
  595. }
  596. elseif ($nbrExercises + $nbrNextTests > $limitExPage) {
  597. echo Display :: return_icon('previous.gif') . get_lang('PreviousPage') . " | ";
  598. }
  599. //show pages navigation link for previous page
  600. if ($nbrExercises + $nbrNextTests > $limitExPage) {
  601. echo "<a href=\"" . api_get_self() . "?" . api_get_cidreq() . "&amp;page=" . ($page +1) . "\">" . get_lang("NextPage") . Display :: return_icon('next.gif') . "</a>";
  602. }
  603. elseif ($page) {
  604. echo get_lang("NextPage") . Display :: return_icon('next.gif');
  605. }
  606. echo '</span>';
  607. }
  608. if ($_configuration['tracking_enabled']) {
  609. if ($show == 'result') {
  610. /*if (!function_exists('make_select'))
  611. {
  612. function make_select($name,$values,$checked='')
  613. {
  614. $output .= '<select name="'.$name.'" >';
  615. foreach($values as $key => $value)
  616. {
  617. //$output .= '<option value="'.$key.'" '.(($checked==$key)?'selected="selected"':'').'>'.$value.'</option>';
  618. }
  619. $output .= '</select>';
  620. return $output;
  621. }
  622. }*/
  623. /*if (!function_exists('make_select_users'))
  624. {
  625. function make_select_users($name,$values,$checked='')
  626. {
  627. $output .= '<select name="'.$name.'" >';
  628. $output .= '<option value="all">'.get_lang('EveryBody').'</option>';
  629. foreach($values as $key => $value)
  630. {
  631. $output .= '<option value="'.$key.'" '.(($checked==$key)?'selected="selected"':'').'>'.$value.'</option>';
  632. }
  633. $output .= '</select>';
  634. return $output;
  635. }
  636. }*/
  637. if (api_is_allowed_to_edit()) {
  638. if (!$_GET['filter']) {
  639. $filter_by_not_revised = true;
  640. $filter = 1;
  641. } else {
  642. $filter=Security::remove_XSS($_GET['filter']);
  643. }
  644. $filter = (int) $_GET['filter'];
  645. switch ($filter) {
  646. case 1 :
  647. $filter_by_not_revised = true;
  648. break;
  649. case 2 :
  650. $filter_by_revised = true;
  651. break;
  652. default :
  653. null;
  654. }
  655. if ($_GET['filter'] == '1' or !isset ($_GET['filter']) or $_GET['filter'] == 0 ) {
  656. $view_result = '<a href="' . api_get_self() . '?cidReq=' . api_get_course_id() . '&show=result&filter=2&gradebook='.$gradebook.'" >'.Display :: return_icon('check.gif', get_lang('ShowCorrectedOnly')).get_lang('ShowCorrectedOnly').'</a>';
  657. } else {
  658. $view_result = '<a href="' .api_get_self() . '?cidReq=' . api_get_course_id() . '&show=result&filter=1&gradebook='.$gradebook.'" >'.Display :: return_icon('un_check.gif', get_lang('ShowUnCorrectedOnly')).get_lang('ShowUnCorrectedOnly').'</a>';
  659. }
  660. //$form_filter = '<form method="post" action="'.api_get_self().'?cidReq='.api_get_course_id().'&show=result">';
  661. //$form_filter .= make_select('filter',array(1=>get_lang('FilterByNotRevised'),2=>get_lang('FilterByRevised')),$filter);
  662. //$form_filter .= '<button class="save" type="submit">'.get_lang('FilterExercices').'</button></form>';
  663. echo $view_result;
  664. }
  665. }
  666. /*if (api_is_allowed_to_edit())
  667. {
  668. $user_count = count($user_list_name);
  669. if ($user_count >0 ) {
  670. $form_filter = '<form method="post" action="'.api_get_self().'?cidReq='.api_get_course_id().'&show=result">';
  671. $user_list_for_select =array();
  672. for ($i=0;$i<$user_count;$i++) {
  673. $user_list_for_select[$user_list_id[$i]]=$user_list_name[$i];
  674. }
  675. $form_filter .= make_select_users('filter_by_user',$user_list_for_select,(int)$_REQUEST['filter_by_user']);
  676. $form_filter .= '<input type="hidden" name="filter" value="'.$filter.'">';
  677. $form_filter .= '<input type="submit" value="'.get_lang('FilterExercicesByUsers').'"></form>';
  678. echo $form_filter;
  679. }
  680. } */
  681. }
  682. if (($is_allowedToEdit) and ($origin != 'learnpath')) {
  683. if ($_GET['show'] != 'result') {
  684. echo '<a href="exercise_admin.php?' . api_get_cidreq() . '">' . Display :: return_icon('new_test.gif', get_lang('NewEx')) . get_lang('NewEx') . '</a>';
  685. echo '<a href="question_create.php?' . api_get_cidreq() . '">' . Display :: return_icon('question_add.gif', get_lang('AddQuestionToExercise')) . get_lang('AddQuestionToExercise') . '</a>';
  686. echo '<a href="hotpotatoes.php">' . Display :: return_icon('jqz.gif', get_lang('ImportHotPotatoesQuiz')) . get_lang('ImportHotPotatoesQuiz') . '</a>';
  687. echo '<a href="' . api_add_url_param($_SERVER['REQUEST_URI'], 'show=result') . '">' . Display :: return_icon('show_test_results.gif', get_lang('Results')) . get_lang('Results') . '</a>';
  688. }
  689. // the actions for the statistics
  690. if ($show == 'result') {
  691. // the form
  692. if (api_is_platform_admin() || api_is_course_admin() || api_is_course_tutor() || api_is_course_coach()) {
  693. if ($_SESSION['export_user_fields'] == true) {
  694. $alt = get_lang('ExportWithUserFields');
  695. $extra_user_fields = '<input type="hidden" name="export_user_fields" value="export_user_fields">';
  696. } else {
  697. $alt = get_lang('ExportWithoutUserFields');
  698. $extra_user_fields = '<input type="hidden" name="export_user_fields" value="do_not_export_user_fields">';
  699. }
  700. //echo '<a href="javascript: void(0);" onclick="javascript: document.form1a.submit();">'.Display::return_icon('excel.gif',get_lang('ExportAsCSV')).get_lang('ExportAsCSV').'</a>';
  701. echo '<a href="javascript: void(0);" onclick="javascript: document.form1b.submit();">' . Display :: return_icon('excel.gif', get_lang('ExportAsXLS')) . get_lang('ExportAsXLS') . '</a>';
  702. //echo '<a href="javascript: void(0);" onclick="javascript: document.form1c.submit();">'.Display::return_icon('synthese_view.gif',$alt).$alt.'</a>';
  703. echo '<a href="' . api_add_url_param($_SERVER['REQUEST_URI'], 'show=test') . '">' . Display :: return_icon('quiz.gif', get_lang('BackToExercisesList')) . get_lang('BackToExercisesList') . '</a>';
  704. echo '<form id="form1a" name="form1a" method="post" action="' . api_get_self() . '?show=' . Security :: remove_XSS($_GET['show']) . '">';
  705. echo '<input type="hidden" name="export_report" value="export_report">';
  706. echo '<input type="hidden" name="export_format" value="csv">';
  707. echo '</form>';
  708. echo '<form id="form1b" name="form1b" method="post" action="' . api_get_self() . '?show=' . Security :: remove_XSS($_GET['show']) . '">';
  709. echo '<input type="hidden" name="export_report" value="export_report">';
  710. echo '<input type="hidden" name="export_format" value="xls">';
  711. echo '</form>';
  712. //echo '<form id="form1c" name="form1c" method="post" action="'.api_get_self().'?show='.Security::remove_XSS($_GET['show']).'">';
  713. //echo $extra_user_fields;
  714. //echo '</form>';
  715. }
  716. }
  717. } else {
  718. //the student view
  719. if ($show == 'result') {
  720. echo '<a href="' . api_add_url_param($_SERVER['REQUEST_URI'], 'show=test') . '">' . Display :: return_icon('quiz.gif', get_lang('BackToExercisesList')) . get_lang('BackToExercisesList') . '</a>';
  721. } else {
  722. echo '<a href="' . api_add_url_param($_SERVER['REQUEST_URI'], 'show=result') . '">' . Display :: return_icon('show_test_results.gif', get_lang('Results')) . get_lang('Results') . '</a>';
  723. }
  724. }
  725. echo '</div>'; // closing the actions div
  726. if ($show == 'test') {
  727. ?>
  728. <table class="data_table">
  729. <?php
  730. if (($is_allowedToEdit) and ($origin != 'learnpath')) {
  731. ?>
  732. <tr class="row_odd">
  733. <th colspan="3"><?php echo get_lang('ExerciseName');?></th>
  734. <th><?php echo get_lang('QuantityQuestions');?></th>
  735. <!--<th>--><?php
  736. ?>
  737. <!--</th>-->
  738. <th><?php echo get_lang('Modify');?></th>
  739. </tr>
  740. <?php
  741. } else {
  742. //student only
  743. ?> <tr>
  744. <th colspan="2"><?php echo get_lang('ExerciseName');?></th>
  745. <th><?php echo get_lang('QuantityQuestions');?></th>
  746. <th><?php echo get_lang('State');?></th>
  747. </tr>
  748. <?php
  749. }
  750. // show message if no HP test to show
  751. if (!($nbrExercises + $nbrHpTests)) {
  752. ?>
  753. <tr>
  754. <td <?php echo ($is_allowedToEdit?'colspan="6"':'colspan="5"'); ?>><?php echo get_lang("NoEx"); ?></td>
  755. </tr>
  756. <?php
  757. }
  758. $i = 1;
  759. // while list exercises
  760. if ($origin != 'learnpath') {
  761. //avoid sending empty parameters
  762. $myorigin = (empty ($origin) ? '' : '&origin=' . $origin);
  763. $mylpid = (empty ($learnpath_id) ? '' : '&learnpath_id=' . $learnpath_id);
  764. $mylpitemid = (empty ($learnpath_item_id) ? '' : '&learnpath_item_id=' . $learnpath_item_id);
  765. while ($row = Database :: fetch_array($result)) {
  766. if ($i % 2 == 0)
  767. $s_class = "row_odd";
  768. else
  769. $s_class = "row_even";
  770. // prof only
  771. if ($is_allowedToEdit) {
  772. echo '<tr class="' . $s_class . '">' . "\n";
  773. ?>
  774. <td width="30" align="left"><?php Display::display_icon('quiz.gif', get_lang('Exercice'))?></td>
  775. <td width="15" valign="left"><?php echo ($i+($page*$limitExPage)).'.'; ?></td>
  776. <?php $row['title']=api_parse_tex($row['title']); ?>
  777. <td><a href="exercice_submit.php?<?php echo api_get_cidreq().$myorigin.$mylpid.$mylpitemid; ?>&amp;exerciseId=<?php echo $row['id']; ?>" <?php if(!$row['active']) echo 'class="invisible"'; ?>><?php echo $row['title']; ?></a></td>
  778. <td align="center"> <?php
  779. $exid = $row['id'];
  780. //count number exercice - teacher
  781. $sqlquery = "SELECT count(*) FROM $TBL_EXERCICE_QUESTION WHERE exercice_id = '" . Database :: escape_string($exid) . "'";
  782. $sqlresult = api_sql_query($sqlquery);
  783. $rowi = Database :: result($sqlresult, 0);
  784. //count number random exercice - teacher
  785. $sql_random_query = 'SELECT type,random,active,results_disabled,max_attempt FROM ' . $TBL_EXERCICES . ' WHERE id="' . Database :: escape_string($exid) . '" ';
  786. $rs_random = api_sql_query($sql_random_query, __FILE__, __LINE__);
  787. $row_random = Database :: fetch_array($rs_random);
  788. if ($row_random['random'] > 0) {
  789. echo $row_random['random'] . ' ' . api_strtolower(get_lang(($row_random['random'] > 1 ? 'Questions' : 'Question'))) . '</td>';
  790. } else {
  791. echo $rowi . ' ' . api_strtolower(get_lang(($rowi > 1 ? 'Questions' : 'Question'))) . '</td>';
  792. }
  793. //echo '<td><a href="exercice.php?choice=exportqti2&exerciseId='.$row['id'].'"><img src="../img/export.png" border="0" title="IMS/QTI" /></a></td>';
  794. ?>
  795. <td>
  796. <a href="admin.php?exerciseId=<?php echo $row['id']; ?>"><img src="../img/wizard_small.gif" border="0" title="<?php echo api_htmlentities(get_lang('Edit'),ENT_QUOTES,$charset); ?>" alt="<?php echo api_htmlentities(get_lang('Edit'),ENT_QUOTES,$charset); ?>" /></a>
  797. <?php
  798. if ($row['results_disabled']) {
  799. //echo '<a href="exercice.php?choice=enable_results&page='.$page.'&exerciseId='.$row['id'].'" title="'.get_lang('EnableResults').'" alt="'.get_lang('EnableResults').'"><img src="../img/lp_quiz_na.gif" border="0" alt="'.api_htmlentities(get_lang('EnableResults'),ENT_QUOTES,$charset).'" /></a>';
  800. } else {
  801. //echo '<a href="exercice.php?choice=disable_results&page='.$page.'&exerciseId='.$row['id'].'" title="'.get_lang('DisableResults').'" alt="'.get_lang('DisableResults').'"><img src="../img/lp_quiz.gif" border="0" alt="'.api_htmlentities(get_lang('DisableResults'),ENT_QUOTES,$charset).'" /></a>';
  802. }
  803. ?>
  804. <!--<a href="exercise_admin.php?modifyExercise=yes&exerciseId=--><?php
  805. ?>
  806. <!--"> <img src="../img/edit.gif" border="0" title="--><?php
  807. ?>
  808. <!--" alt="--><?php
  809. ?>
  810. <!--" /></a>-->
  811. <a href="exercice.php?choice=delete&exerciseId=<?php echo $row['id']; ?>" onclick="javascript:if(!confirm('<?php echo addslashes(api_htmlentities(get_lang('AreYouSureToDelete'),ENT_QUOTES,$charset)); echo " ".$row['title']; echo "?"; ?>')) return false;"> <img src="../img/delete.gif" border="0" alt="<?php echo api_htmlentities(get_lang('Delete'),ENT_QUOTES,$charset); ?>" /></a>
  812. <?php
  813. //if active
  814. if ($row['active']) {
  815. ?>
  816. <a href="exercice.php?choice=disable&page=<?php echo $page; ?>&exerciseId=<?php echo $row['id']; ?>"> <img src="../img/visible.gif" border="0" alt="<?php echo api_htmlentities(get_lang('Deactivate'),ENT_QUOTES,$charset); ?>" /></a>
  817. <?php
  818. } else {
  819. // else if not active
  820. ?>
  821. <a href="exercice.php?choice=enable&page=<?php echo $page; ?>&exerciseId=<?php echo $row['id']; ?>"> <img src="../img/invisible.gif" border="0" alt="<?php echo api_htmlentities(get_lang('Activate'),ENT_QUOTES,$charset); ?>" /></a>
  822. <?php
  823. }
  824. echo "</td>";
  825. echo "</tr>\n";
  826. } else { // student only
  827. ?>
  828. <tr>
  829. <td><?php echo ($i+($page*$limitExPage)).'.'; ?></td>
  830. <?php $row['title']=api_parse_tex($row['title']);?>
  831. <td><a href="exercice_submit.php?<?php echo api_get_cidreq().$myorigin.$mylpid.$myllpitemid; ?>&exerciseId=<?php echo $row['id']; ?>"><?php echo $row['title']; ?></a></td>
  832. <td align="center"> <?php
  833. $exid = $row['id'];
  834. //count number exercise questions
  835. $sqlquery = "SELECT count(*) FROM $TBL_EXERCICE_QUESTION WHERE exercice_id = '" . Database :: escape_string($exid) . "'";
  836. $sqlresult = api_sql_query($sqlquery);
  837. $rowi = Database :: result($sqlresult, 0);
  838. //count number random exercice
  839. $sql_random_query = 'SELECT type,random,active,results_disabled,max_attempt FROM ' . $TBL_EXERCICES . ' WHERE id="' . Database :: escape_string($exid) . '" ';
  840. $rs_random = api_sql_query($sql_random_query, __FILE__, __LINE__);
  841. $row_random = Database :: fetch_array($rs_random);
  842. if ($row_random['random'] > 0) {
  843. echo $row_random['random'] . ' ' . api_strtolower(get_lang(($row_random['random'] > 1 ? 'Questions' : 'Question')));
  844. } else {
  845. //show results student
  846. echo $rowi . ' ' . api_strtolower(get_lang(($rowi > 1 ? 'Questions' : 'Question')));
  847. }
  848. ?> </td>
  849. <td align="center"><?php
  850. $eid = $row['id'];
  851. $uid = api_get_user_id();
  852. //this query might be improved later on by ordering by the new "tms" field rather than by exe_id
  853. $qry = "SELECT * FROM $TBL_TRACK_EXERCICES
  854. WHERE exe_exo_id = '" . Database :: escape_string($eid) . "' and exe_user_id = '" . Database :: escape_string($uid) . "' AND exe_cours_id = '" . api_get_course_id() . "' AND status <>'incomplete' AND orig_lp_id = 0 AND orig_lp_item_id = 0 AND session_id = '" . api_get_session_id() . "'
  855. ORDER BY exe_id DESC";
  856. $qryres = api_sql_query($qry);
  857. $num = Database :: num_rows($qryres);
  858. //hide the results
  859. $my_result_disabled = $row['results_disabled'];
  860. if ($my_result_disabled == 0) {
  861. if ($num > 0) {
  862. $row = Database :: fetch_array($qryres);
  863. $percentage = 0;
  864. if ($row['exe_weighting'] != 0) {
  865. $percentage = ($row['exe_result'] / $row['exe_weighting']) * 100;
  866. }
  867. echo get_lang('Attempted') . ' (' . get_lang('Score') . ': ';
  868. printf("%1.2f\n", $percentage);
  869. echo " %)";
  870. } else {
  871. echo get_lang('NotAttempted');
  872. }
  873. } else {
  874. echo get_lang('CantShowResults');
  875. }
  876. ?></td>
  877. </tr>
  878. <?php
  879. }
  880. // skips the last exercise, that is only used to know if we have or not to create a link "Next page"
  881. if ($i == $limitExPage) {
  882. break;
  883. }
  884. $i++;
  885. } // end while()
  886. $ind = $i;
  887. if (($from + $limitExPage -1) > $nbrexerc) {
  888. if ($from > $nbrexerc) {
  889. $from = $from - $nbrexerc;
  890. $to = $limitExPage;
  891. } else {
  892. $to = $limitExPage - ($nbrexerc - $from);
  893. $from = 0;
  894. }
  895. } else {
  896. $to = $limitExPage;
  897. }
  898. if ($is_allowedToEdit) {
  899. $sql = "SELECT d.path as path, d.comment as comment, ip.visibility as visibility
  900. FROM $TBL_DOCUMENT d, $TBL_ITEM_PROPERTY ip
  901. WHERE d.id = ip.ref AND ip.tool = '" . TOOL_DOCUMENT . "' AND
  902. (d.path LIKE '%htm%')
  903. AND d.path LIKE '" . Database :: escape_string($uploadPath) . "/%/%' LIMIT " . (int) $from . "," . (int) $to; // only .htm or .html files listed
  904. } else {
  905. $sql = "SELECT d.path as path, d.comment as comment, ip.visibility as visibility
  906. FROM $TBL_DOCUMENT d, $TBL_ITEM_PROPERTY ip
  907. WHERE d.id = ip.ref AND ip.tool = '" . TOOL_DOCUMENT . "' AND
  908. (d.path LIKE '%htm%')
  909. AND d.path LIKE '" . Database :: escape_string($uploadPath) . "/%/%' AND ip.visibility='1' LIMIT " . (int) $from . "," . (int) $to;
  910. }
  911. $result = api_sql_query($sql, __FILE__, __LINE__);
  912. while ($row = Database :: fetch_array($result, 'ASSOC')) {
  913. $attribute['path'][] = $row['path'];
  914. $attribute['visibility'][] = $row['visibility'];
  915. $attribute['comment'][] = $row['comment'];
  916. }
  917. $nbrActiveTests = 0;
  918. if (is_array($attribute['path'])) {
  919. while (list ($key, $path) = each($attribute['path'])) {
  920. list ($a, $vis) = each($attribute['visibility']);
  921. if (strcmp($vis, "1") == 0) {
  922. $active = 1;
  923. } else {
  924. $active = 0;
  925. }
  926. echo "<tr>\n";
  927. $title = GetQuizName($path, $documentPath);
  928. if ($title == '') {
  929. $title = basename($path);
  930. }
  931. // prof only
  932. if ($is_allowedToEdit) {
  933. /************/
  934. ?>
  935. <tr>
  936. <td><img src="../img/jqz.gif" alt="HotPotatoes" /></td>
  937. <td><?php echo ($ind+($page*$limitExPage)).'.'; ?></td>
  938. <td><a href="showinframes.php?file=<?php echo $path?>&cid=<?php echo $_course['official_code'];?>&uid=<?php echo $_user['user_id'];?>" <?php if(!$active) echo 'class="invisible"'; ?>><?php echo $title?></a></td>
  939. <td></td>
  940. <td><a href="adminhp.php?hotpotatoesName=<?php echo $path; ?>"> <img src="../img/edit.gif" border="0" alt="<?php echo api_htmlentities(get_lang('Modify'),ENT_QUOTES,$charset); ?>" /></a>
  941. <img src="../img/wizard_gray_small.gif" border="0" title="<?php echo api_htmlentities(get_lang('Edit'),ENT_QUOTES,$charset); ?>" alt="<?php echo api_htmlentities(get_lang('Edit'),ENT_QUOTES,$charset); ?>" />
  942. <a href="<?php echo $exercicePath; ?>?hpchoice=delete&amp;file=<?php echo $path; ?>" onclick="javascript:if(!confirm('<?php echo addslashes(api_htmlentities(get_lang('AreYouSure'),ENT_QUOTES,$charset).$title."?"); ?>')) return false;"><img src="../img/delete.gif" border="0" alt="<?php echo api_htmlentities(get_lang('Delete'),ENT_QUOTES,$charset); ?>" /></a>
  943. <?php
  944. // if active
  945. if ($active) {
  946. $nbrActiveTests = $nbrActiveTests +1;
  947. ?>
  948. <a href="<?php echo $exercicePath; ?>?hpchoice=disable&amp;page=<?php echo $page; ?>&amp;file=<?php echo $path; ?>"><img src="../img/visible.gif" border="0" alt="<?php echo api_htmlentities(get_lang('Deactivate'),ENT_QUOTES,$charset); ?>" /></a>
  949. <?php
  950. } else { // else if not active
  951. ?>
  952. <a href="<?php echo $exercicePath; ?>?hpchoice=enable&amp;page=<?php echo $page; ?>&amp;file=<?php echo $path; ?>"><img src="../img/invisible.gif" border="0" alt="<?php echo api_htmlentities(get_lang('Activate'),ENT_QUOTES,$charset); ?>" /></a>
  953. <?php
  954. }
  955. echo '<img src="../img/lp_quiz_na.gif" border="0" alt="" />';
  956. /****************/
  957. ?></td>
  958. <?php
  959. } else { // student only
  960. if ($active == 1) {
  961. $nbrActiveTests = $nbrActiveTests +1;
  962. ?>
  963. <tr>
  964. <td><?php echo ($ind+($page*$limitExPage)).'.'; ?><!--<img src="../img/jqz.jpg" alt="HotPotatoes" />--></td>
  965. <td>&nbsp;</td>
  966. <td><a href="showinframes.php?<?php echo api_get_cidreq()."&amp;file=".$path."&amp;cid=".$_course['official_code']."&amp;uid=".$_user['user_id'].'"'; if(!$active) echo 'class="invisible"'; ?>"><?php echo $title;?></a></td>
  967. <td>&nbsp;</td><td>&nbsp;</td>
  968. </tr>
  969. <?php
  970. }
  971. }
  972. ?>
  973. <?php
  974. if ($ind == $limitExPage) {
  975. break;
  976. }
  977. if ($is_allowedToEdit) {
  978. $ind++;
  979. } else {
  980. if ($active == 1) {
  981. $ind++;
  982. }
  983. }
  984. }
  985. }
  986. } //end if ($origin != 'learnpath') {
  987. ?>
  988. </table>
  989. <?php
  990. }
  991. /*****************************************/
  992. /* Exercise Results (uses tracking tool) */
  993. /*****************************************/
  994. // if tracking is enabled
  995. if ($_configuration['tracking_enabled'] && ($show == 'result')) {
  996. ?>
  997. <table class="data_table">
  998. <tr class="row_odd">
  999. <?php if($is_allowedToEdit || $is_tutor): ?>
  1000. <th><?php echo get_lang('User'); ?></th><?php endif; ?>
  1001. <th><?php echo get_lang('Exercice'); ?></th>
  1002. <th><?php echo get_lang('Duration'); ?></th>
  1003. <th><?php echo get_lang('Date'); ?></th>
  1004. <th><?php echo get_lang('Result'); ?></th>
  1005. <th><?php echo (($is_allowedToEdit||$is_tutor)?get_lang("CorrectTest"):get_lang("ViewTest")); ?></th>
  1006. </tr>
  1007. <?php
  1008. $session_id_and = '';
  1009. if (api_get_session_id() != 0) {
  1010. $session_id_and = ' AND session_id = ' . api_get_session_id() . ' ';
  1011. }
  1012. if ($is_allowedToEdit || $is_tutor) {
  1013. $user_id_and = '';
  1014. if (!empty ($_POST['filter_by_user'])) {
  1015. if ($_POST['filter_by_user'] == 'all') {
  1016. $user_id_and = " AND user_id like '%'";
  1017. } else {
  1018. $user_id_and = " AND user_id = '" . Database :: escape_string((int) $_POST['filter_by_user']) . "' ";
  1019. }
  1020. }
  1021. if ($_GET['gradebook'] == 'view') {
  1022. $exercise_where_query = 'te.exe_exo_id =ce.id AND ';
  1023. }
  1024. $sql="SELECT ".(api_is_western_name_order() ? "CONCAT(firstname,' ',lastname)" : "CONCAT(lastname,' ',firstname)")." as users, ce.title, te.exe_result ,
  1025. te.exe_weighting, UNIX_TIMESTAMP(te.exe_date), te.exe_id, email, UNIX_TIMESTAMP(te.start_date), steps_counter,cuser.user_id,te.exe_duration
  1026. FROM $TBL_EXERCICES AS ce , $TBL_TRACK_EXERCICES AS te, $TBL_USER AS user,$tbl_course_rel_user AS cuser
  1027. WHERE user.user_id=cuser.user_id AND te.exe_exo_id = ce.id AND te.status != 'incomplete' AND cuser.user_id=te.exe_user_id AND te.exe_cours_id='" . Database :: escape_string($_cid) . "'
  1028. AND cuser.status<>1 $user_id_and $session_id_and AND ce.active <>-1 AND orig_lp_id = 0 AND orig_lp_item_id = 0
  1029. AND cuser.course_code=te.exe_cours_id ORDER BY users, te.exe_cours_id ASC, ce.title ASC, te.exe_date DESC";
  1030. $hpsql="SELECT ".(api_is_western_name_order() ? "CONCAT(tu.firstname,' ',tu.lastname)" : "CONCAT(tu.lastname,' ',tu.firstname)").", tth.exe_name,
  1031. tth.exe_result , tth.exe_weighting, UNIX_TIMESTAMP(tth.exe_date)
  1032. FROM $TBL_TRACK_HOTPOTATOES tth, $TBL_USER tu
  1033. WHERE tu.user_id=tth.exe_user_id AND tth.exe_cours_id = '" . Database :: escape_string($_cid) . " $user_id_and '
  1034. ORDER BY tth.exe_cours_id ASC, tth.exe_date DESC";
  1035. } else {
  1036. // get only this user's results
  1037. $user_id_and = ' AND te.exe_user_id = ' . Database :: escape_string(api_get_user_id()) . ' ';
  1038. $sql="SELECT ".(api_is_western_name_order() ? "CONCAT(firstname,' ',lastname)" : "CONCAT(lastname,' ',firstname)")." as users,ce.title, te.exe_result ,
  1039. te.exe_weighting, UNIX_TIMESTAMP(te.exe_date), te.exe_id, email, UNIX_TIMESTAMP(te.start_date), steps_counter,cuser.user_id,te.exe_duration, ce.results_disabled
  1040. FROM $TBL_EXERCICES AS ce , $TBL_TRACK_EXERCICES AS te, $TBL_USER AS user,$tbl_course_rel_user AS cuser
  1041. WHERE user.user_id=cuser.user_id AND te.exe_exo_id = ce.id AND te.status != 'incomplete' AND cuser.user_id=te.exe_user_id AND te.exe_cours_id='" . Database :: escape_string($_cid) . "'
  1042. AND cuser.status<>1 $user_id_and $session_id_and AND ce.active <>-1 AND orig_lp_id = 0 AND orig_lp_item_id = 0
  1043. AND cuser.course_code=te.exe_cours_id ORDER BY users, te.exe_cours_id ASC, ce.title ASC, te.exe_date DESC";
  1044. $hpsql = "SELECT '',exe_name, exe_result , exe_weighting, UNIX_TIMESTAMP(exe_date)
  1045. FROM $TBL_TRACK_HOTPOTATOES
  1046. WHERE exe_user_id = '" . $_user['user_id'] . "' AND exe_cours_id = '" . Database :: escape_string($_cid) . "'
  1047. ORDER BY exe_cours_id ASC, exe_date DESC";
  1048. }
  1049. $results = getManyResultsXCol($sql, 12);
  1050. $hpresults = getManyResultsXCol($hpsql, 5);
  1051. $NoTestRes = 0;
  1052. $NoHPTestRes = 0;
  1053. //Print the results of tests
  1054. $lang_nostartdate = get_lang('NoStartDate') . ' / ';
  1055. if (is_array($results)) {
  1056. $users_array_id = array ();
  1057. if ($_GET['gradebook'] == 'view') {
  1058. $filter_by_no_revised = true;
  1059. $from_gradebook = true;
  1060. }
  1061. $sizeof = sizeof($results);
  1062. $user_list_name = $user_list_id = array ();
  1063. for ($i = 0; $i < $sizeof; $i++) {
  1064. $revised = false;
  1065. $sql_exe = 'SELECT exe_id FROM ' . Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING) . '
  1066. WHERE author != ' . "''" . ' AND exe_id = ' . "'" . Database :: escape_string($results[$i][5]) . "'" . ' LIMIT 1';
  1067. $query = api_sql_query($sql_exe, __FILE__, __LINE__);
  1068. if (Database :: num_rows($query) > 0) {
  1069. $revised = true;
  1070. }
  1071. if ($filter_by_not_revised && $revised == true) {
  1072. continue;
  1073. }
  1074. if ($filter_by_revised && $revised == false) {
  1075. continue;
  1076. }
  1077. if ($from_gradebook && ($is_allowedToEdit || $is_tutor)) {
  1078. if (in_array($results[$i][1] . $results[$i][0], $users_array_id)) {
  1079. continue;
  1080. }
  1081. $users_array_id[] = $results[$i][1] . $results[$i][0];
  1082. }
  1083. $user_list_name[] = $results[$i][0];
  1084. $user_list_id[] = $results[$i][9];
  1085. $id = $results[$i][5];
  1086. $mailid = $results[$i][6];
  1087. $user = $results[$i][0];
  1088. $test = $results[$i][1];
  1089. $dt = strftime($dateTimeFormatLong, $results[$i][4]);
  1090. $res = $results[$i][2];
  1091. $duration = intval($results[$i][10]);
  1092. // we filter the results if we have the permission to
  1093. if (isset ($results[$i][11]))
  1094. $result_disabled = intval($results[$i][11]);
  1095. else
  1096. $result_disabled = 0;
  1097. if ($result_disabled == 0) {
  1098. echo '<tr';
  1099. if ($i % 2 == 0) {
  1100. echo 'class="row_odd"';
  1101. } else {
  1102. echo 'class="row_even"';
  1103. }
  1104. echo '>';
  1105. $add_start_date = $lang_nostartdate;
  1106. if ($is_allowedToEdit || $is_tutor) {
  1107. $user = $results[$i][0];
  1108. echo '<td>' . $user . ' </td>';
  1109. }
  1110. echo '<td>' . $test . '</td>';
  1111. echo '<td>';
  1112. if ($results[$i][7] > 1) {
  1113. echo ceil((($results[$i][4] - $results[$i][7]) / 60)) . ' ' . get_lang('MinMinutes');
  1114. if ($results[$i][8] > 1) {
  1115. echo ' ( ' . $results[$i][8] . ' ' . get_lang('Steps') . ' )';
  1116. }
  1117. $add_start_date = format_locale_date('%b %d, %Y %H:%M', $results[$i][7]) . ' / ';
  1118. } else {
  1119. echo get_lang('NoLogOfDuration');
  1120. }
  1121. echo '</td>';
  1122. echo '<td>' . $add_start_date . format_locale_date('%b %d, %Y %H:%M', $results[$i][4]) . '</td>'; //get_lang('dateTimeFormatLong')
  1123. // there are already a duration test period calculated??
  1124. //echo '<td>'.sprintf(get_lang('DurationFormat'), $duration).'</td>';
  1125. // if the float look like 10.00 we show only 10
  1126. $my_res = float_format($results[$i][2],1);
  1127. $my_total = float_format($results[$i][3],1);
  1128. echo '<td>' . round(($my_res / ($my_total != 0 ? $my_total : 1)) * 100, 2) . '% (' . $my_res . ' / ' . $my_total . ')</td>';
  1129. // Is hard to read this!!
  1130. /*
  1131. echo '<td>'.(($is_allowedToEdit||$is_tutor)?
  1132. "<a href='exercise_show.php?user=$user&dt=$dt&res=$res&id=$id&email=$mailid'>".
  1133. (($revised)?get_lang('Edit'):get_lang('Qualify'))."</a>".
  1134. ((api_is_platform_admin() || $is_tutor)?' - <a href="exercice.php?cidReq='.htmlentities($_GET['cidReq']).'&show=result&filter='.$filter.'&delete=delete&did='.$id.'" onclick="javascript:if(!confirm(\''.sprintf(get_lang('DeleteAttempt'),$user,$dt).'\')) return false;">'.get_lang('Delete').'</a>':'')
  1135. .(($is_allowedToEdit)?' - <a href="exercice_history.php?cidReq='.htmlentities($_GET['cidReq']).'&exe_id='.$id.'">'.get_lang('ViewHistoryChange').'</a>':'')
  1136. :(($revised)?"<a href='exercise_show.php?dt=$dt&res=$res&id=$id'>".get_lang('Show')."</a>":'')).'</td>';
  1137. */
  1138. echo '<td>';
  1139. if ($is_allowedToEdit || $is_tutor) {
  1140. if ($revised) {
  1141. echo "<a href='exercise_show.php?action=edit&user=$user&dt=$dt&res=$res&id=$id&email=$mailid'>".Display :: return_icon('edit.gif', get_lang('Edit'));
  1142. echo '&nbsp;';
  1143. } else {
  1144. echo "<a href='exercise_show.php?action=qualify&user=$user&dt=$dt&res=$res&id=$id&email=$mailid'>".Display :: return_icon('quizz_small.gif', get_lang('Qualify'));
  1145. echo '&nbsp;';
  1146. }
  1147. echo "</a>";
  1148. if (api_is_platform_admin() || $is_tutor)
  1149. echo ' <a href="exercice.php?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '&show=result&filter=' . $filter . '&delete=delete&did=' . $id . '" onclick="javascript:if(!confirm(\'' . sprintf(get_lang('DeleteAttempt'), $user, $dt) . '\')) return false;">'.Display :: return_icon('delete.gif', get_lang('Delete')).'</a>';
  1150. echo '&nbsp;';
  1151. if ($is_allowedToEdit)
  1152. echo ' <a href="exercice_history.php?cidReq=' . security::remove_XSS($_GET['cidReq']) . '&exe_id=' . $id . '">' .Display :: return_icon('history.gif', get_lang('ViewHistoryChange')).'</a>';
  1153. } else {
  1154. if ($revised)
  1155. echo "<a href='exercise_show.php?dt=$dt&res=$res&id=$id'>" . get_lang('Show') . "</a> ";
  1156. else
  1157. echo '&nbsp;' . get_lang('NoResult');
  1158. }
  1159. echo '</td>';
  1160. echo '</tr>';
  1161. }
  1162. }
  1163. } else {
  1164. $NoTestRes = 1;
  1165. }
  1166. // Print the Result of Hotpotatoes Tests
  1167. if (is_array($hpresults)) {
  1168. for ($i = 0; $i < sizeof($hpresults); $i++) {
  1169. $title = GetQuizName($hpresults[$i][1], $documentPath);
  1170. if ($title == '') {
  1171. $title = basename($hpresults[$i][1]);
  1172. }
  1173. echo '<tr>';
  1174. if ($is_allowedToEdit) {
  1175. echo '<td class="content">' . $hpresults[$i][0] . '</td>';
  1176. }
  1177. echo '<td class="content">' . $title . '</td>';
  1178. echo '<td class="content">' . strftime($dateTimeFormatLong, $hpresults[$i][4]) . '</td>';
  1179. echo '<td class="content">' . round(($hpresults[$i][2] / ($hpresults[$i][3] != 0 ? $hpresults[$i][3] : 1)) * 100, 2) . '% (' . $hpresults[$i][2] . ' / ' . $hpresults[$i][3] . ')</td>';
  1180. echo '<td></td>'; //there is no possibility to edit the results of a Hotpotatoes test
  1181. echo '</tr>';
  1182. }
  1183. } else {
  1184. $NoHPTestRes = 1;
  1185. }
  1186. if ($NoTestRes == 1 && $NoHPTestRes == 1) {
  1187. ?>
  1188. <tr>
  1189. <td colspan="6"><?php echo get_lang("NoResult"); ?></td>
  1190. </tr>
  1191. <?php
  1192. }
  1193. ?>
  1194. </table>
  1195. <br />
  1196. <?php
  1197. }
  1198. if ($origin != 'learnpath') { //so we are not in learnpath tool
  1199. Display :: display_footer();
  1200. } else {
  1201. ?>
  1202. <link rel="stylesheet" type="text/css" href="<?php echo $clarolineRepositoryWeb ?>css/default.css" />
  1203. <?php
  1204. }
  1205. ?>