exercice.php 46 KB

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