exercice.php 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Exercise list: This script shows the list of exercises for administrators and students.
  5. * @package chamilo.exercise
  6. * @author Olivier Brouckaert, original author
  7. * @author Denes Nagy, HotPotatoes integration
  8. * @author Wolfgang Schneider, code/html cleanup
  9. * @author Julio Montoya <gugli100@gmail.com>, lots of cleanup + several improvements
  10. * Modified by hubert.borderiou (question category)
  11. */
  12. // name of the language file that needs to be included
  13. use \ChamiloSession as Session;
  14. $language_file = array('exercice', 'tracking');
  15. // including the global library
  16. require_once '../inc/global.inc.php';
  17. $current_course_tool = TOOL_QUIZ;
  18. // Setting the tabs
  19. $this_section = SECTION_COURSES;
  20. $htmlHeadXtra[] = api_get_js('qtip2/jquery.qtip.min.js');
  21. $htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/qtip2/jquery.qtip.min.css');
  22. // Access control
  23. api_protect_course_script(true);
  24. // including additional libraries
  25. require_once 'hotpotatoes.lib.php';
  26. /* Constants and variables */
  27. $is_allowedToEdit = api_is_allowed_to_edit(null, true);
  28. $is_tutor = api_is_allowed_to_edit(true);
  29. $is_tutor_course = api_is_course_tutor();
  30. $courseInfo = api_get_course_info();
  31. $courseId = api_get_course_int_id();
  32. $userId = api_get_user_id();
  33. $userInfo = api_get_user_info();
  34. $isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
  35. $userId,
  36. $courseInfo
  37. );
  38. $TBL_DOCUMENT = Database :: get_course_table(TABLE_DOCUMENT);
  39. $TBL_ITEM_PROPERTY = Database :: get_course_table(TABLE_ITEM_PROPERTY);
  40. $TBL_EXERCICE_QUESTION = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION);
  41. $TBL_EXERCICES = Database :: get_course_table(TABLE_QUIZ_TEST);
  42. $TBL_TRACK_EXERCICES = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
  43. // document path
  44. $documentPath = api_get_path(SYS_COURSE_PATH).$courseInfo['path']."/document";
  45. // picture path
  46. $picturePath = $documentPath.'/images';
  47. // audio path
  48. $audioPath = $documentPath.'/audio';
  49. // hot potatoes
  50. $uploadPath = DIR_HOTPOTATOES; //defined in main_api
  51. $exercicePath = api_get_self();
  52. $exfile = explode('/', $exercicePath);
  53. $exfile = strtolower($exfile[sizeof($exfile) - 1]);
  54. $exercicePath = substr($exercicePath, 0, strpos($exercicePath, $exfile));
  55. $exercicePath = $exercicePath."exercice.php";
  56. // Clear the exercise session
  57. if (isset($_SESSION['objExercise'])) {
  58. Session::erase('objExercise');
  59. }
  60. if (isset($_SESSION['objQuestion'])) {
  61. Session::erase('objQuestion');
  62. }
  63. if (isset($_SESSION['objAnswer'])) {
  64. Session::erase('objAnswer');
  65. }
  66. if (isset($_SESSION['questionList'])) {
  67. Session::erase('questionList');
  68. }
  69. if (isset($_SESSION['exerciseResult'])) {
  70. Session::erase('exerciseResult');
  71. }
  72. //General POST/GET/SESSION/COOKIES parameters recovery
  73. $origin = isset($_REQUEST['origin']) ? Security::remove_XSS($_REQUEST['origin']) : null;
  74. $choice = isset($_REQUEST['choice']) ? Security::remove_XSS($_REQUEST['choice']) : null;
  75. $hpchoice = isset($_REQUEST['hpchoice']) ? Security::remove_XSS($_REQUEST['hpchoice']) : null;
  76. $exerciseId = isset($_REQUEST['exerciseId']) ? Security::remove_XSS($_REQUEST['exerciseId']) : null;
  77. $file = isset($_REQUEST['file']) ? Database::escape_string($_REQUEST['file']) : null;
  78. $learnpath_id = isset($_REQUEST['learnpath_id']) ? intval($_REQUEST['learnpath_id']) : null;
  79. $learnpath_item_id = isset($_REQUEST['learnpath_item_id']) ? intval($_REQUEST['learnpath_item_id']) : null;
  80. $page = isset($_REQUEST['page']) ? intval($_REQUEST['page']) : null;
  81. if ($page < 0) {
  82. $page = 1;
  83. }
  84. if (!empty($_GET['gradebook']) && $_GET['gradebook'] == 'view') {
  85. $_SESSION['gradebook'] = Security::remove_XSS($_GET['gradebook']);
  86. $gradebook = $_SESSION['gradebook'];
  87. } elseif (empty($_GET['gradebook'])) {
  88. unset($_SESSION['gradebook']);
  89. $gradebook = '';
  90. }
  91. if (!empty($gradebook) && $gradebook == 'view') {
  92. $interbreadcrumb[] = array('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('ToolGradebook'));
  93. }
  94. $nameTools = get_lang('Exercices');
  95. $errorXmlExport = null;
  96. if ($is_allowedToEdit && !empty($choice) && $choice == 'exportqti2') {
  97. require_once 'export/qti2/qti2_export.php';
  98. $export = export_exercise($exerciseId, true);
  99. require_once api_get_path(LIBRARY_PATH).'pclzip/pclzip.lib.php';
  100. $archive_path = api_get_path(SYS_ARCHIVE_PATH);
  101. $temp_dir_short = api_get_unique_id();
  102. $temp_zip_dir = $archive_path.$temp_dir_short;
  103. if (!is_dir($temp_zip_dir)) {
  104. mkdir($temp_zip_dir, api_get_permissions_for_new_directories());
  105. }
  106. $temp_zip_file = $temp_zip_dir."/".api_get_unique_id().".zip";
  107. $temp_xml_file = $temp_zip_dir."/qti2export_".$exerciseId.'.xml';
  108. file_put_contents($temp_xml_file, $export);
  109. $xmlReader = new XMLReader();
  110. $xmlReader->open($temp_xml_file);
  111. $xmlReader->setParserProperty(XMLReader::VALIDATE, true);
  112. $isValid = $xmlReader->isValid();
  113. if ($isValid) {
  114. $zip_folder = new PclZip($temp_zip_file);
  115. $zip_folder->add($temp_xml_file, PCLZIP_OPT_REMOVE_ALL_PATH);
  116. $name = 'qti2_export_'.$exerciseId.'.zip';
  117. DocumentManager::file_send_for_download($temp_zip_file, true, $name);
  118. unlink($temp_zip_file);
  119. unlink($temp_xml_file);
  120. rmdir($temp_zip_dir);
  121. exit; //otherwise following clicks may become buggy
  122. } else {
  123. $errorXmlExport = Display :: return_message(get_lang('ErrorWritingXMLFile'), 'error');
  124. }
  125. }
  126. if ($origin != 'learnpath') {
  127. //so we are not in learnpath tool
  128. Display :: display_header($nameTools, get_lang('Exercise'));
  129. if (isset($_GET['message'])) {
  130. if (in_array($_GET['message'], array('ExerciseEdited'))) {
  131. Display :: display_confirmation_message(get_lang($_GET['message']));
  132. }
  133. }
  134. } else {
  135. Display :: display_reduced_header();
  136. }
  137. Event::event_access_tool(TOOL_QUIZ);
  138. // Tool introduction
  139. Display :: display_introduction_section(TOOL_QUIZ);
  140. if (!empty($errorXmlExport)) {
  141. echo $errorXmlExport;
  142. }
  143. HotPotGCt($documentPath, 1, $userId);
  144. // Only for administrator
  145. if ($is_allowedToEdit) {
  146. if (!empty($choice)) {
  147. // All test choice, clean all test's results
  148. if ($choice == 'clean_all_test') {
  149. $check = Security::check_token('get');
  150. if ($check) {
  151. // list des exercices dans un test
  152. // we got variable $courseId $courseInfo session api_get_session_id()
  153. $exerciseList = ExerciseLib::get_all_exercises_for_course_id(
  154. $courseInfo,
  155. api_get_session_id(),
  156. $courseId,
  157. false
  158. );
  159. $quantity_results_deleted = 0;
  160. foreach ($exerciseList as $exeItem) {
  161. // delete result for test, if not in a gradebook
  162. $exercise_action_locked = api_resource_is_locked_by_gradebook($exeItem['id'], LINK_EXERCISE);
  163. if ($exercise_action_locked == false) {
  164. $objExerciseTmp = new Exercise();
  165. if ($objExerciseTmp->read($exeItem['id'])) {
  166. $quantity_results_deleted += $objExerciseTmp->clean_results(true);
  167. }
  168. }
  169. }
  170. Display:: display_confirmation_message(
  171. sprintf(
  172. get_lang('XResultsCleaned'),
  173. $quantity_results_deleted
  174. )
  175. );
  176. }
  177. }
  178. // single exercise choice
  179. // construction of Exercise
  180. $objExerciseTmp = new Exercise();
  181. $check = Security::check_token('get');
  182. $exercise_action_locked = api_resource_is_locked_by_gradebook(
  183. $exerciseId,
  184. LINK_EXERCISE
  185. );
  186. if ($objExerciseTmp->read($exerciseId)) {
  187. if ($check) {
  188. switch ($choice) {
  189. case 'delete' :
  190. // deletes an exercise
  191. if ($exercise_action_locked == false) {
  192. $objExerciseTmp->delete();
  193. $link_info = GradebookUtils::is_resource_in_course_gradebook(api_get_course_id(), 1, $exerciseId, api_get_session_id());
  194. if ($link_info !== false) {
  195. GradebookUtils::remove_resource_from_course_gradebook($link_info['id']);
  196. }
  197. Display :: display_confirmation_message(get_lang('ExerciseDeleted'));
  198. }
  199. break;
  200. case 'enable' :
  201. // enables an exercise
  202. $objExerciseTmp->enable();
  203. $objExerciseTmp->save();
  204. api_item_property_update($courseInfo, TOOL_QUIZ, $objExerciseTmp->id, 'visible', $userId);
  205. // "WHAT'S NEW" notification: update table item_property (previously last_tooledit)
  206. Display :: display_confirmation_message(get_lang('VisibilityChanged'));
  207. break;
  208. case 'disable' :
  209. // disables an exercise
  210. $objExerciseTmp->disable();
  211. $objExerciseTmp->save();
  212. api_item_property_update($courseInfo, TOOL_QUIZ, $objExerciseTmp->id, 'invisible', $userId);
  213. Display :: display_confirmation_message(get_lang('VisibilityChanged'));
  214. break;
  215. case 'disable_results' :
  216. //disable the results for the learners
  217. $objExerciseTmp->disable_results();
  218. $objExerciseTmp->save();
  219. Display :: display_confirmation_message(get_lang('ResultsDisabled'));
  220. break;
  221. case 'enable_results' :
  222. //disable the results for the learners
  223. $objExerciseTmp->enable_results();
  224. $objExerciseTmp->save();
  225. Display :: display_confirmation_message(get_lang('ResultsEnabled'));
  226. break;
  227. case 'clean_results' :
  228. //clean student results
  229. if ($exercise_action_locked == false) {
  230. $quantity_results_deleted = $objExerciseTmp->clean_results(true);
  231. Display :: display_confirmation_message(sprintf(get_lang('XResultsCleaned'), $quantity_results_deleted));
  232. }
  233. break;
  234. case 'copy_exercise' : //copy an exercise
  235. $objExerciseTmp->copy_exercise();
  236. Display :: display_confirmation_message(get_lang('ExerciseCopied'));
  237. break;
  238. }
  239. }
  240. }
  241. // destruction of Exercise
  242. unset($objExerciseTmp);
  243. Security::clear_token();
  244. }
  245. if (!empty($hpchoice)) {
  246. switch ($hpchoice) {
  247. case 'delete' :
  248. // deletes an exercise
  249. $imgparams = array();
  250. $imgcount = 0;
  251. GetImgParams($file, $documentPath, $imgparams, $imgcount);
  252. $fld = GetFolderName($file);
  253. for ($i = 0; $i < $imgcount; $i++) {
  254. my_delete($documentPath.$uploadPath."/".$fld."/".$imgparams[$i]);
  255. update_db_info("delete", $uploadPath."/".$fld."/".$imgparams[$i]);
  256. }
  257. if (!is_dir($documentPath.$uploadPath."/".$fld."/")) {
  258. my_delete($documentPath.$file);
  259. update_db_info("delete", $file);
  260. } else {
  261. if (my_delete($documentPath.$file)) {
  262. update_db_info("delete", $file);
  263. }
  264. }
  265. /* hotpotatoes folder may contains several tests so
  266. don't delete folder if not empty :
  267. http://support.chamilo.org/issues/2165
  268. */
  269. if (!(strstr($uploadPath, DIR_HOTPOTATOES) && !folder_is_empty($documentPath.$uploadPath."/".$fld."/"))) {
  270. my_delete($documentPath.$uploadPath."/".$fld."/");
  271. }
  272. break;
  273. case 'enable' : // enables an exercise
  274. $newVisibilityStatus = "1"; //"visible"
  275. $query = "SELECT id FROM $TBL_DOCUMENT
  276. WHERE c_id = $courseId AND path='".Database :: escape_string($file)."'";
  277. $res = Database::query($query);
  278. $row = Database :: fetch_array($res, 'ASSOC');
  279. api_item_property_update(
  280. $courseInfo,
  281. TOOL_DOCUMENT,
  282. $row['id'],
  283. 'visible',
  284. $userId
  285. );
  286. //$dialogBox = get_lang('ViMod');
  287. break;
  288. case 'disable' : // disables an exercise
  289. $newVisibilityStatus = "0"; //"invisible"
  290. $query = "SELECT id FROM $TBL_DOCUMENT
  291. WHERE c_id = $courseId AND path='".Database :: escape_string($file)."'";
  292. $res = Database::query($query);
  293. $row = Database :: fetch_array($res, 'ASSOC');
  294. api_item_property_update(
  295. $courseInfo,
  296. TOOL_DOCUMENT,
  297. $row['id'],
  298. 'invisible',
  299. $userId
  300. );
  301. break;
  302. default :
  303. break;
  304. }
  305. }
  306. }
  307. // Actions div bar
  308. if ($is_allowedToEdit) {
  309. echo '<div class="actions">';
  310. }
  311. // Selects $limit exercises at the same time
  312. // maximum number of exercises on a same page
  313. $limit = 50;
  314. // Display the next and previous link if needed
  315. $from = $page * $limit;
  316. HotPotGCt($documentPath, 1, $userId);
  317. //condition for the session
  318. $course_code = api_get_course_id();
  319. $session_id = api_get_session_id();
  320. $condition_session = api_get_session_condition($session_id, true, true);
  321. // Only for administrators
  322. if ($is_allowedToEdit) {
  323. $total_sql = "SELECT count(id) as count FROM $TBL_EXERCICES
  324. WHERE c_id = $courseId AND active<>'-1' $condition_session ";
  325. $sql = "SELECT * FROM $TBL_EXERCICES
  326. WHERE c_id = $courseId AND active<>'-1' $condition_session
  327. ORDER BY title LIMIT ".$from.",".$limit;
  328. } else {
  329. // Only for students
  330. $total_sql = "SELECT count(id) as count FROM $TBL_EXERCICES
  331. WHERE c_id = $courseId AND active = '1' $condition_session ";
  332. $sql = "SELECT * FROM $TBL_EXERCICES
  333. WHERE c_id = $courseId AND
  334. active='1' $condition_session
  335. ORDER BY title LIMIT ".$from.",".$limit;
  336. }
  337. $result = Database::query($sql);
  338. $exercises_count = Database :: num_rows($result);
  339. $result_total = Database::query($total_sql);
  340. $total_exercises = 0;
  341. if (Database :: num_rows($result_total)) {
  342. $result_total = Database::fetch_array($result_total);
  343. $total_exercises = $result_total['count'];
  344. }
  345. //get HotPotatoes files (active and inactive)
  346. if ($is_allowedToEdit) {
  347. $sql = "SELECT * FROM $TBL_DOCUMENT
  348. WHERE
  349. c_id = $courseId AND
  350. path LIKE '".Database :: escape_string($uploadPath.'/%/%')."'";
  351. $res = Database::query($sql);
  352. $hp_count = Database :: num_rows($res);
  353. } else {
  354. $sql = "SELECT * FROM $TBL_DOCUMENT d, $TBL_ITEM_PROPERTY ip
  355. WHERE
  356. d.id = ip.ref AND
  357. ip.tool = '".TOOL_DOCUMENT."' AND
  358. d.path LIKE '".Database :: escape_string($uploadPath.'/%/%')."' AND
  359. ip.visibility ='1' AND
  360. d.c_id = ".$courseId." AND
  361. ip.c_id = ".$courseId;
  362. $res = Database::query($sql);
  363. $hp_count = Database :: num_rows($res);
  364. }
  365. $total = $total_exercises + $hp_count;
  366. $token = Security::get_token();
  367. if ($is_allowedToEdit && $origin != 'learnpath') {
  368. echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercice/exercise_admin.php?'.api_get_cidreq().'">'.
  369. Display :: return_icon('new_exercice.png', get_lang('NewEx'), '', ICON_SIZE_MEDIUM).'</a>';
  370. echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercice/question_create.php?'.api_get_cidreq().'">'.
  371. Display :: return_icon('new_question.png', get_lang('AddQ'), '', ICON_SIZE_MEDIUM).'</a>';
  372. // Question category
  373. echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercice/tests_category.php?'.api_get_cidreq().'">';
  374. echo Display::return_icon('question_category_show.gif', get_lang('QuestionCategory'));
  375. echo '</a>';
  376. echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercice/question_pool.php?'.api_get_cidreq().'">';
  377. echo Display::return_icon('database.png', get_lang('QuestionPool'),'', ICON_SIZE_MEDIUM);
  378. echo '</a>';
  379. //echo Display::url(Display::return_icon('looknfeel.png', get_lang('Media')), 'media.php?' . api_get_cidreq());
  380. // end question category
  381. echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercice/hotpotatoes.php?'.api_get_cidreq().'">'.Display :: return_icon('import_hotpotatoes.png', get_lang('ImportHotPotatoesQuiz'), '', ICON_SIZE_MEDIUM).'</a>';
  382. // link to import qti2 ...
  383. echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercice/qti2.php?'.api_get_cidreq().'">'.Display :: return_icon('import_qti2.png', get_lang('ImportQtiQuiz'), '', ICON_SIZE_MEDIUM).'</a>';
  384. echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercice/aiken.php?'.api_get_cidreq().'">'.Display :: return_icon('import_aiken.png', get_lang('ImportAikenQuiz'), '', ICON_SIZE_MEDIUM).'</a>';
  385. echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercice/upload_exercise.php?'.api_get_cidreq().'">'.Display :: return_icon('import_excel.png', get_lang('ImportExcelQuiz'), '', ICON_SIZE_MEDIUM).'</a>';
  386. echo Display::url(
  387. Display::return_icon(
  388. 'clean_all.png',
  389. get_lang('CleanAllStudentsResultsForAllTests'), '', ICON_SIZE_MEDIUM),
  390. '',
  391. array(
  392. 'onclick' => "javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('AreYouSureToEmptyAllTestResults'), ENT_QUOTES, $charset))."')) return false;",
  393. 'href' => api_get_path(WEB_CODE_PATH).'exercice/exercice.php?'.api_get_cidreq().'&choice=clean_all_test&sec_token='.$token
  394. )
  395. );
  396. }
  397. if ($is_allowedToEdit) {
  398. echo '</div>'; // closing the actions div
  399. }
  400. if ($total > $limit) {
  401. echo '<div style="float:right;height:20px;">';
  402. //show pages navigation link for previous page
  403. if ($page) {
  404. echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&amp;page=".($page - 1)."\">".Display :: return_icon('action_prev.png', get_lang('PreviousPage'))."</a>";
  405. } elseif ($total_exercises + $hp_count > $limit) {
  406. echo Display :: return_icon('action_prev_na.png', get_lang('PreviousPage'));
  407. }
  408. //show pages navigation link for previous page
  409. if ($total_exercises > $from + $limit || $hp_count > $from + $limit) {
  410. echo ' '."<a href=\"".api_get_self()."?".api_get_cidreq()."&amp;page=".($page + 1)."\">".Display::return_icon('action_next.png', get_lang('NextPage'))."</a>";
  411. } elseif ($page) {
  412. echo ' '.Display :: return_icon('action_next_na.png', get_lang('NextPage'));
  413. }
  414. echo '</div>';
  415. }
  416. $i = 1;
  417. $online_icon = Display::return_icon('online.png', get_lang('Visible'), array('width' => '12px'));
  418. $offline_icon = Display::return_icon('offline.png', get_lang('Invisible'), array('width' => '12px'));
  419. $exercise_list = array();
  420. $exercise_obj = new Exercise();
  421. $list_ordered = null;
  422. while ($row = Database :: fetch_array($result, 'ASSOC')) {
  423. $exercise_list[$row['id']] = $row;
  424. }
  425. if (isset($list_ordered) && !empty($list_ordered)) {
  426. $new_question_list = array();
  427. foreach ($list_ordered as $exercise_id) {
  428. if (isset($exercise_list[$exercise_id])) {
  429. $new_question_list[] = $exercise_list[$exercise_id];
  430. }
  431. }
  432. $exercise_list = $new_question_list;
  433. }
  434. echo '<table class="'.Display::return_default_table_class().'">';
  435. /* Listing exercises */
  436. if (!empty($exercise_list)) {
  437. if ($origin != 'learnpath') {
  438. //avoid sending empty parameters
  439. $myorigin = (empty($origin) ? '' : '&origin='.$origin);
  440. $mylpid = (empty($learnpath_id) ? '' : '&learnpath_id='.$learnpath_id);
  441. $mylpitemid = (empty($learnpath_item_id) ? '' : '&learnpath_item_id='.$learnpath_item_id);
  442. // $token = Security::get_token(); // has been moved above
  443. $i = 1;
  444. if ($is_allowedToEdit) {
  445. $headers = array(
  446. array('name' => get_lang('ExerciseName')),
  447. array('name' => get_lang('QuantityQuestions'), 'params' => array('width' => '100px')),
  448. array('name' => get_lang('Actions'), 'params' => array('width' => '180px')));
  449. } else {
  450. $headers = array(
  451. array('name' => get_lang('ExerciseName')),
  452. array('name' => get_lang('Status')),
  453. );
  454. if ($isDrhOfCourse) {
  455. $headers[] = array(
  456. 'name' => get_lang('Actions'),
  457. 'params' => array('width' => '180px')
  458. );
  459. }
  460. }
  461. $header_list = '';
  462. foreach ($headers as $header) {
  463. $params = isset($header['params']) ? $header['params'] : null;
  464. $header_list .= Display::tag('th', $header['name'], $params);
  465. }
  466. echo Display::tag('tr', $header_list);
  467. $count = 0;
  468. foreach ($exercise_list as $row) {
  469. $my_exercise_id = $row['id'];
  470. $exercise_obj = new Exercise();
  471. $exercise_obj->read($my_exercise_id);
  472. if (empty($exercise_obj->id)) {
  473. continue;
  474. }
  475. $locked = $exercise_obj->is_gradebook_locked;
  476. $i++;
  477. //validacion when belongs to a session
  478. $session_img = api_get_session_image($row['session_id'], $userInfo['status']);
  479. $time_limits = false;
  480. if ($row['start_time'] != '0000-00-00 00:00:00' || $row['end_time'] != '0000-00-00 00:00:00') {
  481. $time_limits = true;
  482. }
  483. if ($time_limits) {
  484. // check if start time
  485. $start_time = false;
  486. if ($row['start_time'] != '0000-00-00 00:00:00') {
  487. $start_time = api_strtotime($row['start_time'], 'UTC');
  488. }
  489. $end_time = false;
  490. if ($row['end_time'] != '0000-00-00 00:00:00') {
  491. $end_time = api_strtotime($row['end_time'], 'UTC');
  492. }
  493. $now = time();
  494. $is_actived_time = false;
  495. //If both "clocks" are enable
  496. if ($start_time && $end_time) {
  497. if ($now > $start_time && $end_time > $now) {
  498. $is_actived_time = true;
  499. }
  500. } else {
  501. //we check the start and end
  502. if ($start_time) {
  503. if ($now > $start_time) {
  504. $is_actived_time = true;
  505. }
  506. }
  507. if ($end_time) {
  508. if ($end_time > $now) {
  509. $is_actived_time = true;
  510. }
  511. }
  512. }
  513. }
  514. // Blocking empty start times see BT#2800
  515. global $_custom;
  516. if (isset($_custom['exercises_hidden_when_no_start_date']) &&
  517. $_custom['exercises_hidden_when_no_start_date']
  518. ) {
  519. if (empty($row['start_time']) ||
  520. $row['start_time'] == '0000-00-00 00:00:00'
  521. ) {
  522. $time_limits = true;
  523. $is_actived_time = false;
  524. }
  525. }
  526. $cut_title = $exercise_obj->getCutTitle();
  527. $alt_title = '';
  528. if ($cut_title != $row['title']) {
  529. $alt_title = ' title = "'.$row['title'].'" ';
  530. }
  531. // Teacher only
  532. if ($is_allowedToEdit) {
  533. $lp_blocked = null;
  534. if ($exercise_obj->exercise_was_added_in_lp == true) {
  535. $lp_blocked = Display::div(
  536. get_lang('AddedToLPCannotBeAccessed'),
  537. array('class' => 'lp_content_type_label')
  538. );
  539. }
  540. $visibility = api_get_item_visibility($courseInfo, TOOL_QUIZ, $my_exercise_id);
  541. if ($row['active'] == 0 || $visibility == 0) {
  542. $title = Display::tag('font', $cut_title, array('style' => 'color:grey'));
  543. } else {
  544. $title = $cut_title;
  545. }
  546. $count_exercise_not_validated = intval(
  547. Event::count_exercise_result_not_validated(
  548. $my_exercise_id,
  549. $courseId,
  550. $session_id
  551. )
  552. );
  553. $move = Display::return_icon('all_directions.png',get_lang('Move'), array('class'=>'moved', 'style'=>'margin-bottom:-0.5em;'));
  554. $move = null;
  555. $class_tip = '';
  556. if (!empty($count_exercise_not_validated)) {
  557. $results_text = $count_exercise_not_validated == 1 ? get_lang('ResultNotRevised') : get_lang('ResultsNotRevised');
  558. $title .= '<span class="exercise_tooltip" style="display: none;">'.$count_exercise_not_validated.' '.$results_text.' </span>';
  559. $class_tip = 'link_tooltip';
  560. }
  561. //$class_tip = 'exercise_link';
  562. $url = $move.'<a '.$alt_title.' class="'.$class_tip.'" id="tooltip_'.$row['id'].'" href="overview.php?'.api_get_cidreq().$myorigin.$mylpid.$mylpitemid.'&exerciseId='.$row['id'].'"><img src="../img/quiz.gif" /> '.$title.' </a>';
  563. $item = Display::tag('td', $url.' '.$session_img.$lp_blocked);
  564. // Count number exercise - teacher
  565. $sql = "SELECT count(*) FROM $TBL_EXERCICE_QUESTION
  566. WHERE c_id = $courseId AND exercice_id = $my_exercise_id";
  567. $sqlresult = Database::query($sql);
  568. $rowi = Database :: result($sqlresult, 0);
  569. if ($session_id == $row['session_id']) {
  570. // Settings
  571. $actions = Display::url(
  572. Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL),
  573. 'admin.php?'.api_get_cidreq().'&exerciseId='.$row['id']
  574. );
  575. // Exercise results
  576. $actions .='<a href="exercise_report.php?'.api_get_cidreq().'&exerciseId='.$row['id'].'">'.
  577. Display :: return_icon('test_results.png', get_lang('Results'), '', ICON_SIZE_SMALL).'</a>';
  578. // Export
  579. $actions .= Display::url(
  580. Display::return_icon('cd.gif', get_lang('CopyExercise')),
  581. '',
  582. array(
  583. 'onclick' => "javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('AreYouSureToCopy'), ENT_QUOTES, $charset))." ".addslashes($row['title'])."?"."')) return false;",
  584. 'href' => 'exercice.php?'.api_get_cidreq().'&choice=copy_exercise&sec_token='.$token.'&exerciseId='.$row['id']
  585. )
  586. );
  587. // Clean exercise
  588. if ($locked == false) {
  589. $actions .= Display::url(
  590. Display::return_icon('clean.png', get_lang('CleanStudentResults'), '', ICON_SIZE_SMALL),
  591. '',
  592. array(
  593. 'onclick' => "javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('AreYouSureToDeleteResults'), ENT_QUOTES, $charset))." ".addslashes($row['title'])."?"."')) return false;",
  594. 'href' => 'exercice.php?'.api_get_cidreq().'&choice=clean_results&sec_token='.$token.'&exerciseId='.$row['id']
  595. )
  596. );
  597. } else {
  598. $actions .= Display::return_icon('clean_na.png', get_lang('ResourceLockedByGradebook'), '', ICON_SIZE_SMALL);
  599. }
  600. // Visible / invisible
  601. // Check if this exercise was added in a LP
  602. if ($exercise_obj->exercise_was_added_in_lp == true) {
  603. $actions .= Display::return_icon('invisible.png', get_lang('AddedToLPCannotBeAccessed'), '', ICON_SIZE_SMALL);
  604. } else {
  605. if ($row['active'] == 0 || $visibility == 0) {
  606. $actions .= Display::url(Display::return_icon('invisible.png', get_lang('Activate'), '', ICON_SIZE_SMALL), 'exercice.php?'.api_get_cidreq().'&choice=enable&sec_token='.$token.'&page='.$page.'&exerciseId='.$row['id']);
  607. } else {
  608. // else if not active
  609. $actions .= Display::url(Display::return_icon('visible.png', get_lang('Deactivate'), '', ICON_SIZE_SMALL), 'exercice.php?'.api_get_cidreq().'&choice=disable&sec_token='.$token.'&page='.$page.'&exerciseId='.$row['id']);
  610. }
  611. }
  612. // Export qti ...
  613. $actions .= Display::url(Display::return_icon('export_qti2.png', 'IMS/QTI', '', ICON_SIZE_SMALL), 'exercice.php?choice=exportqti2&exerciseId='.$row['id'].'&'.api_get_cidreq());
  614. } else {
  615. // not session
  616. $actions = Display::return_icon('edit_na.png', get_lang('ExerciseEditionNotAvailableInSession'));
  617. $actions .='<a href="exercise_report.php?'.api_get_cidreq().'&exerciseId='.$row['id'].'">'.
  618. Display :: return_icon('test_results.png', get_lang('Results'), '', ICON_SIZE_SMALL).'</a>';
  619. $actions .= Display::url(Display::return_icon('cd.gif', get_lang('CopyExercise')), '', array('onclick' => "javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('AreYouSureToCopy'), ENT_QUOTES, $charset))." ".addslashes($row['title'])."?"."')) return false;", 'href' => 'exercice.php?'.api_get_cidreq().'&choice=copy_exercise&sec_token='.$token.'&exerciseId='.$row['id']));
  620. }
  621. // Delete
  622. if ($session_id == $row['session_id']) {
  623. if ($locked == false) {
  624. $actions .= Display::url(
  625. Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL), '',
  626. array('onclick' => "javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('AreYouSureToDelete'), ENT_QUOTES, $charset))." ".addslashes($row['title'])."?"."')) return false;", 'href' => 'exercice.php?'.api_get_cidreq().'&choice=delete&sec_token='.$token.'&exerciseId='.$row['id']));
  627. } else {
  628. $actions .= Display::return_icon('delete_na.png', get_lang('ResourceLockedByGradebook'), '', ICON_SIZE_SMALL);
  629. }
  630. }
  631. // Number of questions
  632. $random_label = null;
  633. if ($row['random'] > 0 || $row['random'] == -1) {
  634. // if random == -1 means use random questions with all questions
  635. $random_number_of_question = $row['random'];
  636. if ($random_number_of_question == -1) {
  637. $random_number_of_question = $rowi;
  638. }
  639. if ($row['random_by_category'] > 0) {
  640. $nbQuestionsTotal = Testcategory::getNumberOfQuestionRandomByCategory(
  641. $my_exercise_id,
  642. $random_number_of_question
  643. );
  644. $number_of_questions = $nbQuestionsTotal." ";
  645. $number_of_questions .= ($nbQuestionsTotal > 1) ? get_lang("QuestionsLowerCase") : get_lang("QuestionLowerCase");
  646. $number_of_questions .= " - ";
  647. $number_of_questions .= min(Testcategory::getNumberMaxQuestionByCat($my_exercise_id), $random_number_of_question).' '.get_lang('QuestionByCategory');
  648. } else {
  649. $random_label = ' ('.get_lang('Random').') ';
  650. $number_of_questions = $random_number_of_question.' '.$random_label;
  651. //Bug if we set a random value bigger than the real number of questions
  652. if ($random_number_of_question > $rowi) {
  653. $number_of_questions = $rowi.' '.$random_label;
  654. }
  655. }
  656. } else {
  657. $number_of_questions = $rowi;
  658. }
  659. //Attempts
  660. //$attempts = ExerciseLib::get_count_exam_results($row['id']).' '.get_lang('Attempts');
  661. //$item .= Display::tag('td',$attempts);
  662. $item .= Display::tag('td', $number_of_questions);
  663. } else {
  664. // Student only.
  665. $visibility = api_get_item_visibility($courseInfo, TOOL_QUIZ, $my_exercise_id);
  666. if ($visibility == 0) {
  667. continue;
  668. }
  669. $url = '<a '.$alt_title.' href="overview.php?'.api_get_cidreq().$myorigin.$mylpid.$mylpitemid.'&exerciseId='.$row['id'].'">'.
  670. $cut_title.'</a>';
  671. // Link of the exercise.
  672. $item = Display::tag('td', $url.' '.$session_img);
  673. // Count number exercise questions.
  674. /*$sql = "SELECT count(*) FROM $TBL_EXERCICE_QUESTION
  675. WHERE c_id = $courseId AND exercice_id = ".$row['id'];
  676. $sqlresult = Database::query($sql);
  677. $rowi = Database::result($sqlresult, 0);
  678. if ($row['random'] > 0) {
  679. $row['random'].' '.api_strtolower(get_lang(($row['random'] > 1 ? 'Questions' : 'Question')));
  680. } else {
  681. //show results student
  682. $rowi.' '.api_strtolower(get_lang(($rowi > 1 ? 'Questions' : 'Question')));
  683. }*/
  684. // This query might be improved later on by ordering by the new "tms" field rather than by exe_id
  685. // Don't remove this marker: note-query-exe-results
  686. $sql = "SELECT * FROM $TBL_TRACK_EXERCICES
  687. WHERE
  688. exe_exo_id = ".$row['id']." AND
  689. exe_user_id = ".$userId." AND
  690. c_id = ".api_get_course_int_id()." AND
  691. status <> 'incomplete' AND
  692. orig_lp_id = 0 AND
  693. orig_lp_item_id = 0 AND
  694. session_id = '".api_get_session_id()."'
  695. ORDER BY exe_id DESC";
  696. $qryres = Database::query($sql);
  697. $num = Database :: num_rows($qryres);
  698. // Hide the results.
  699. $my_result_disabled = $row['results_disabled'];
  700. // Time limits are on
  701. if ($time_limits) {
  702. // Exam is ready to be taken
  703. if ($is_actived_time) {
  704. // Show results 697 $attempt_text = get_lang('LatestAttempt').' : ';
  705. if ($my_result_disabled == 0 || $my_result_disabled == 2) {
  706. //More than one attempt
  707. if ($num > 0) {
  708. $row_track = Database :: fetch_array($qryres);
  709. $attempt_text = get_lang('LatestAttempt').' : ';
  710. $attempt_text .= ExerciseLib::show_score($row_track['exe_result'], $row_track['exe_weighting']);
  711. } else {
  712. //No attempts
  713. $attempt_text = get_lang('NotAttempted');
  714. }
  715. } else {
  716. $attempt_text = get_lang('CantShowResults');
  717. }
  718. } else {
  719. //Quiz not ready due to time limits 700 $attempt_text = get_lang('NotAttempted');
  720. //@todo use the is_visible function
  721. if ($row['start_time'] != '0000-00-00 00:00:00' && $row['end_time'] != '0000-00-00 00:00:00') {
  722. $today = time();
  723. $start_time = api_strtotime($row['start_time'], 'UTC');
  724. $end_time = api_strtotime($row['end_time'], 'UTC');
  725. if ($today < $start_time) {
  726. $attempt_text = sprintf(get_lang('ExerciseWillBeActivatedFromXToY'), api_convert_and_format_date($row['start_time']), api_convert_and_format_date($row['end_time']));
  727. } else {
  728. if ($today > $end_time) {
  729. $attempt_text = sprintf(get_lang('ExerciseWasActivatedFromXToY'), api_convert_and_format_date($row['start_time']), api_convert_and_format_date($row['end_time']));
  730. }
  731. }
  732. } else {
  733. //$attempt_text = get_lang('ExamNotAvailableAtThisTime');
  734. if ($row['start_time'] != '0000-00-00 00:00:00') {
  735. $attempt_text = sprintf(get_lang('ExerciseAvailableFromX'), api_convert_and_format_date($row['start_time']));
  736. }
  737. if ($row['end_time'] != '0000-00-00 00:00:00') {
  738. $attempt_text = sprintf(get_lang('ExerciseAvailableUntilX'), api_convert_and_format_date($row['end_time']));
  739. }
  740. }
  741. }
  742. } else {
  743. // Normal behaviour.
  744. // Show results.
  745. if ($my_result_disabled == 0 || $my_result_disabled == 2) {
  746. if ($num > 0) {
  747. $row_track = Database :: fetch_array($qryres);
  748. $attempt_text = get_lang('LatestAttempt').' : ';
  749. $attempt_text .= ExerciseLib::show_score($row_track['exe_result'], $row_track['exe_weighting']);
  750. } else {
  751. $attempt_text = get_lang('NotAttempted');
  752. }
  753. } else {
  754. $attempt_text = get_lang('CantShowResults');
  755. }
  756. }
  757. $class_tip = '';
  758. if (empty($num)) {
  759. $num = '';
  760. } else {
  761. $class_tip = 'link_tooltip';
  762. //@todo use sprintf and show the results validated by the teacher
  763. if ($num == 1) {
  764. $num = $num.' '.get_lang('Result');
  765. } else {
  766. $num = $num.' '.get_lang('Results');
  767. }
  768. $num = '<span class="tooltip" style="display: none;">'.$num.'</span>';
  769. }
  770. $item .= Display::tag('td', $attempt_text);
  771. }
  772. $class = 'row_even';
  773. if ($count % 2) {
  774. $class = 'row_odd';
  775. }
  776. if ($is_allowedToEdit) {
  777. $item .= Display::tag('td', $actions, array('class' => 'td_actions'));
  778. } else {
  779. if ($isDrhOfCourse) {
  780. $actions ='<a href="exercise_report.php?'.api_get_cidreq().'&exerciseId='.$row['id'].'">'.
  781. Display :: return_icon('test_results.png', get_lang('Results'), '', ICON_SIZE_SMALL).'</a>';
  782. $item .= Display::tag('td', $actions, array('class' => 'td_actions'));
  783. }
  784. }
  785. echo Display::tag(
  786. 'tr',
  787. $item,
  788. array(
  789. 'id' => 'exercise_list_' . $my_exercise_id,
  790. 'class' => $class
  791. )
  792. );
  793. $count++;
  794. } // end foreach()
  795. }
  796. }
  797. // end exercise list
  798. // Hotpotatoes results
  799. $hotpotatoes_exist = false;
  800. if ($is_allowedToEdit) {
  801. $sql = "SELECT d.path as path, d.comment as comment, ip.visibility as visibility
  802. FROM $TBL_DOCUMENT d, $TBL_ITEM_PROPERTY ip
  803. WHERE
  804. d.c_id = $courseId AND
  805. ip.c_id = $courseId AND
  806. d.id = ip.ref AND
  807. ip.tool = '".TOOL_DOCUMENT."' AND
  808. (d.path LIKE '%htm%') AND
  809. d.path LIKE '".Database :: escape_string($uploadPath.'/%/%')."'
  810. LIMIT ".$from.",".$limit; // only .htm or .html files listed
  811. } else {
  812. $sql = "SELECT d.path as path, d.comment as comment, ip.visibility as visibility
  813. FROM $TBL_DOCUMENT d, $TBL_ITEM_PROPERTY ip
  814. WHERE
  815. d.c_id = $courseId AND
  816. ip.c_id = $courseId AND
  817. d.id = ip.ref AND
  818. ip.tool = '".TOOL_DOCUMENT."' AND
  819. (d.path LIKE '%htm%') AND
  820. d.path LIKE '".Database :: escape_string($uploadPath.'/%/%')."' AND
  821. ip.visibility='1'
  822. LIMIT ".$from.",".$limit;
  823. }
  824. $result = Database::query($sql);
  825. while ($row = Database :: fetch_array($result, 'ASSOC')) {
  826. $attribute['path'][] = $row['path'];
  827. $attribute['visibility'][] = $row['visibility'];
  828. $attribute['comment'][] = $row['comment'];
  829. }
  830. $nbrActiveTests = 0;
  831. if (isset($attribute['path']) && is_array($attribute['path'])) {
  832. $hotpotatoes_exist = true;
  833. while (list($key, $path) = each($attribute['path'])) {
  834. $item = '';
  835. list ($a, $vis) = each($attribute['visibility']);
  836. if (strcmp($vis, "1") == 0) {
  837. $active = 1;
  838. } else {
  839. $active = 0;
  840. }
  841. $title = GetQuizName($path, $documentPath);
  842. if ($title == '') {
  843. $title = basename($path);
  844. }
  845. $class = 'row_even';
  846. if ($count % 2) {
  847. $class = 'row_odd';
  848. }
  849. // prof only
  850. if ($is_allowedToEdit) {
  851. $item = Display::tag('td', '<img src="../img/hotpotatoes_s.png" alt="HotPotatoes" /> <a href="showinframes.php?file='.$path.'&cid='.api_get_course_id().'&uid='.$userId.'" '.(!$active ? 'class="invisible"' : '').' >'.$title.'</a> ');
  852. $item .= Display::tag('td', '-');
  853. $actions = Display::url(
  854. Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL),
  855. 'adminhp.php?'.api_get_cidreq().'&hotpotatoesName='.$path
  856. );
  857. $actions .='<a href="hotpotatoes_exercise_report.php?'.api_get_cidreq().'&path='.$path.'">'.
  858. Display :: return_icon('test_results.png', get_lang('Results'), '', ICON_SIZE_SMALL).'</a>';
  859. // if active
  860. if ($active) {
  861. $nbrActiveTests = $nbrActiveTests + 1;
  862. $actions .= ' <a href="'.$exercicePath.'?'.api_get_cidreq().'&hpchoice=disable&amp;page='.$page.'&amp;file='.$path.'">'.
  863. Display::return_icon('visible.png', get_lang('Deactivate'), '', ICON_SIZE_SMALL).'</a>';
  864. } else { // else if not active
  865. $actions .=' <a href="'.$exercicePath.'?'.api_get_cidreq().'&hpchoice=enable&amp;page='.$page.'&amp;file='.$path.'">'.
  866. Display::return_icon('invisible.png', get_lang('Activate'), '', ICON_SIZE_SMALL).'</a>';
  867. }
  868. $actions .= '<a href="'.$exercicePath.'?'.api_get_cidreq().'&amp;hpchoice=delete&amp;file='.$path.'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('AreYouSureToDelete'), ENT_QUOTES, $charset).' '.$title."?").'\')) return false;">'.
  869. Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>';
  870. $item .= Display::tag('td', $actions);
  871. echo Display::tag('tr', $item, array('class' => $class));
  872. } else {
  873. // Student only
  874. if ($active == 1) {
  875. $attempt = ExerciseLib::getLatestHotPotatoResult(
  876. $path,
  877. $userId,
  878. api_get_course_int_id(),
  879. api_get_session_id()
  880. );
  881. $nbrActiveTests = $nbrActiveTests + 1;
  882. $item .= Display::tag('td', '<a href="showinframes.php?'.api_get_cidreq().'&file='.$path.'&cid='.api_get_course_id().'&uid='.$userId.'" '.(!$active ? 'class="invisible"' : '').' >'.$title.'</a>');
  883. if (!empty($attempt)) {
  884. $actions = '<a href="hotpotatoes_exercise_report.php?'.api_get_cidreq().'&path='.$path.'&filter_by_user='.$userId.'">'.Display :: return_icon('test_results.png', get_lang('Results'), '', ICON_SIZE_SMALL).'</a>';
  885. $attemptText = get_lang('LatestAttempt').' : ';
  886. $attemptText .= ExerciseLib::show_score($attempt['exe_result'], $attempt['exe_weighting']).' ';
  887. $attemptText .= $actions;
  888. } else {
  889. // No attempts.
  890. $attemptText = get_lang('NotAttempted').' ';
  891. }
  892. $item .= Display::tag('td', $attemptText);
  893. if ($isDrhOfCourse) {
  894. $actions ='<a href="hotpotatoes_exercise_report.php?'.api_get_cidreq().'&path='.$path.'">'.
  895. Display :: return_icon('test_results.png', get_lang('Results'), '', ICON_SIZE_SMALL).'</a>';
  896. $item .= Display::tag('td', $actions, array('class' => 'td_actions'));
  897. }
  898. echo Display::tag(
  899. 'tr',
  900. $item,
  901. array('class' => $class)
  902. );
  903. }
  904. }
  905. $count++;
  906. }
  907. }
  908. echo '</table>';
  909. if (empty($exercise_list) && $hotpotatoes_exist == false) {
  910. if ($is_allowedToEdit && $origin != 'learnpath') {
  911. echo '<div id="no-data-view">';
  912. echo '<h2>'.get_lang('Quiz').'</h2>';
  913. echo Display::return_icon('quiz.png', '', array(), 64);
  914. echo '<div class="controls">';
  915. echo Display::url(get_lang('NewEx'), 'exercise_admin.php?'.api_get_cidreq(), array('class' => 'btn'));
  916. echo '</div>';
  917. echo '</div>';
  918. }
  919. }
  920. if ($origin != 'learnpath') { //so we are not in learnpath tool
  921. Display :: display_footer();
  922. }