exercice.php 45 KB

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