admin.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Exercise administration
  5. * This script allows to manage (create, modify) an exercise and its questions
  6. *
  7. * Following scripts are includes for a best code understanding :
  8. *
  9. * - exercise.class.php : for the creation of an Exercise object
  10. * - question.class.php : for the creation of a Question object
  11. * - answer.class.php : for the creation of an Answer object
  12. * - exercise.lib.php : functions used in the exercise tool
  13. * - exercise_admin.inc.php : management of the exercise
  14. * - question_admin.inc.php : management of a question (statement & answers)
  15. * - statement_admin.inc.php : management of a statement
  16. * - answer_admin.inc.php : management of answers
  17. * - question_list_admin.inc.php : management of the question list
  18. *
  19. * Main variables used in this script :
  20. *
  21. * - $is_allowedToEdit : set to 1 if the user is allowed to manage the exercise
  22. * - $objExercise : exercise object
  23. * - $objQuestion : question object
  24. * - $objAnswer : answer object
  25. * - $aType : array with answer types
  26. * - $exerciseId : the exercise ID
  27. * - $picturePath : the path of question pictures
  28. * - $newQuestion : ask to create a new question
  29. * - $modifyQuestion : ID of the question to modify
  30. * - $editQuestion : ID of the question to edit
  31. * - $submitQuestion : ask to save question modifications
  32. * - $cancelQuestion : ask to cancel question modifications
  33. * - $deleteQuestion : ID of the question to delete
  34. * - $moveUp : ID of the question to move up
  35. * - $moveDown : ID of the question to move down
  36. * - $modifyExercise : ID of the exercise to modify
  37. * - $submitExercise : ask to save exercise modifications
  38. * - $cancelExercise : ask to cancel exercise modifications
  39. * - $modifyAnswers : ID of the question which we want to modify answers for
  40. * - $cancelAnswers : ask to cancel answer modifications
  41. * - $buttonBack : ask to go back to the previous page in answers of type "Fill in blanks"
  42. *
  43. * @package chamilo.exercise
  44. * @author Olivier Brouckaert
  45. * Modified by Hubert Borderiou 21-10-2011 Question by category
  46. */
  47. use \ChamiloSession as Session;
  48. require_once 'exercise.class.php';
  49. require_once 'question.class.php';
  50. require_once 'answer.class.php';
  51. // Name of the language file that needs to be included
  52. $language_file = 'exercice';
  53. //require_once '../inc/global.inc.php';
  54. $urlMainExercise = api_get_path(WEB_CODE_PATH).'exercice/';
  55. $current_course_tool = TOOL_QUIZ;
  56. $this_section = SECTION_COURSES;
  57. // Access control
  58. api_protect_course_script(true);
  59. $is_allowedToEdit = api_is_allowed_to_edit(null, true);
  60. if (!$is_allowedToEdit) {
  61. api_not_allowed(true);
  62. }
  63. /* stripslashes POST data */
  64. if ($_SERVER['REQUEST_METHOD'] == 'POST') {
  65. foreach ($_POST as $key => $val) {
  66. if (is_string($val)) {
  67. $_POST[$key] = stripslashes($val);
  68. } elseif (is_array($val)) {
  69. foreach ($val as $key2 => $val2) {
  70. $_POST[$key][$key2] = stripslashes($val2);
  71. }
  72. }
  73. $GLOBALS[$key] = $_POST[$key];
  74. }
  75. }
  76. // Get vars from GET
  77. if (empty($exerciseId)) {
  78. $exerciseId = isset($_GET['exerciseId']) ? intval($_GET['exerciseId']):'0';
  79. }
  80. if (empty($newQuestion)) {
  81. $newQuestion = isset($_GET['newQuestion']) ? $_GET['newQuestion'] : 0;
  82. }
  83. if (empty($modifyAnswers)) {
  84. $modifyAnswers = isset($_GET['modifyAnswers']) ? $_GET['modifyAnswers'] : 0;
  85. }
  86. if (empty($editQuestion)) {
  87. $editQuestion = isset($_GET['editQuestion']) ? $_GET['editQuestion'] : 0;
  88. }
  89. if (empty($modifyQuestion)) {
  90. $modifyQuestion = isset($_GET['modifyQuestion']) ? $_GET['modifyQuestion'] : 0;
  91. }
  92. if (empty($deleteQuestion)) {
  93. $deleteQuestion = isset($_GET['deleteQuestion']) ? $_GET['deleteQuestion'] : 0;
  94. }
  95. $clone_question = isset($_REQUEST['clone_question']) ? $_REQUEST['clone_question'] : 0;
  96. if (empty($questionId)) {
  97. $questionId = isset($_SESSION['questionId']) ? $_SESSION['questionId'] : 0;
  98. }
  99. if (empty($modifyExercise)) {
  100. $modifyExercise = isset($_GET['modifyExercise']) ? $_GET['modifyExercise'] : null;
  101. }
  102. $fromExercise = isset($fromExercise) ? $fromExercise : null;
  103. $cancelExercise = isset($cancelExercise) ? $cancelExercise : null;
  104. $cancelAnswers = isset($cancelAnswers) ? $cancelAnswers : null;
  105. $modifyIn = isset($modifyIn) ? $modifyIn : null;
  106. $cancelQuestion = isset($cancelQuestion) ? $cancelQuestion : null;
  107. /* Cleaning all incomplete attempts of the admin/teacher to avoid weird problems
  108. when changing the exercise settings, number of questions, etc */
  109. delete_all_incomplete_attempts(api_get_user_id(), $exerciseId, api_get_course_int_id(), api_get_session_id());
  110. /** @var Exercise $objExercise */
  111. $objExercise = Session::read('objExercise');
  112. /** @var Question $objQuestion */
  113. $objQuestion = Session::read('objQuestion');
  114. /** @var Answer $objAnswer */
  115. $objAnswer = Session::read('objAnswer');
  116. // document path
  117. $documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
  118. // picture path
  119. $picturePath = $documentPath.'/images';
  120. // audio path
  121. $audioPath = $documentPath.'/audio';
  122. // the 5 types of answers
  123. $aType = array(
  124. get_lang('UniqueSelect'),
  125. get_lang('MultipleSelect'),
  126. get_lang('FillBlanks'),
  127. get_lang('Matching'),
  128. get_lang('FreeAnswer')
  129. );
  130. // tables used in the exercise tool
  131. if (!empty($_GET['action']) && $_GET['action'] == 'exportqti2' && !empty($_GET['questionId'])) {
  132. require_once 'export/qti2/qti2_export.php';
  133. $export = export_question($_GET['questionId'], true);
  134. $qid = (int)$_GET['questionId'];
  135. $archive_path = api_get_path(SYS_ARCHIVE_PATH);
  136. $temp_dir_short = uniqid();
  137. $temp_zip_dir = $archive_path."/".$temp_dir_short;
  138. if (!is_dir($temp_zip_dir)) {
  139. mkdir($temp_zip_dir, api_get_permissions_for_new_directories());
  140. }
  141. $temp_zip_file = $temp_zip_dir."/".api_get_unique_id().".zip";
  142. $temp_xml_file = $temp_zip_dir."/qti2export_".$qid.'.xml';
  143. file_put_contents($temp_xml_file, $export);
  144. $zip_folder = new PclZip($temp_zip_file);
  145. $zip_folder->add($temp_xml_file, PCLZIP_OPT_REMOVE_ALL_PATH);
  146. $name = 'qti2_export_'.$qid.'.zip';
  147. DocumentManager::file_send_for_download($temp_zip_file, true, $name);
  148. unlink($temp_zip_file);
  149. unlink($temp_xml_file);
  150. rmdir($temp_zip_dir);
  151. //DocumentManager::string_send_for_download($export,true,'qti2export_q'.$_GET['questionId'].'.xml');
  152. exit; //otherwise following clicks may become buggy
  153. }
  154. // Initializes the Exercise object.
  155. if (!is_object($objExercise)) {
  156. // construction of the Exercise object
  157. $objExercise = new Exercise();
  158. // creation of a new exercise if wrong or not specified exercise ID
  159. if ($exerciseId) {
  160. $objExercise->read($exerciseId, true);
  161. }
  162. // saves the object into the session
  163. Session::write('objExercise', $objExercise);
  164. }
  165. if ($objExercise->fastEdition) {
  166. $htmlHeadXtra[] = api_get_jqgrid_js();
  167. }
  168. $nbrQuestions = $objExercise->getQuestionCount();
  169. // Initializes the Question object
  170. if ($editQuestion || $newQuestion || $modifyQuestion || $modifyAnswers) {
  171. if ($editQuestion || $newQuestion) {
  172. // reads question data
  173. if ($editQuestion) {
  174. // question not found
  175. if (!$objQuestion = Question::read($editQuestion, null, $objExercise)) {
  176. api_not_allowed();
  177. }
  178. // saves the object into the session
  179. Session::write('objQuestion', $objQuestion);
  180. }
  181. }
  182. // Checks if the object exists.
  183. if (is_object($objQuestion)) {
  184. // gets the question ID
  185. $questionId = $objQuestion->selectId();
  186. }
  187. }
  188. // If cancelling an exercise.
  189. if (!empty($cancelExercise)) {
  190. // existing exercise
  191. if ($exerciseId) {
  192. unset($modifyExercise);
  193. } else {
  194. // new exercise
  195. // goes back to the exercise list
  196. header('Location: '.$urlMainExercise.'exercice.php');
  197. exit();
  198. }
  199. }
  200. // if cancelling question creation/modification
  201. if (!empty($cancelQuestion)) {
  202. // if we are creating a new question from the question pool
  203. if (!$exerciseId && !$questionId) {
  204. // goes back to the question pool
  205. header('Location: '.$urlMainExercise.'question_pool.php');
  206. exit();
  207. } else {
  208. // goes back to the question viewing
  209. $editQuestion = $modifyQuestion;
  210. unset($newQuestion, $modifyQuestion);
  211. }
  212. }
  213. if (!empty($clone_question) && !empty($objExercise->id)) {
  214. $old_question_obj = Question::read($clone_question, api_get_course_int_id());
  215. $old_question_obj->question = $old_question_obj->question.' - '.get_lang('Copy');
  216. $new_id = $old_question_obj->duplicate();
  217. $new_question_obj = Question::read($new_id, api_get_course_int_id());
  218. $new_question_obj->addToList($objExercise->id);
  219. // This should be moved to the duplicate function
  220. $new_answer_obj = new Answer($clone_question, null, $objExercise);
  221. $new_answer_obj->read();
  222. $new_answer_obj->duplicate($new_id);
  223. // Reloading tne $objExercise obj
  224. $objExercise->read($objExercise->id);
  225. header('Location: '.$urlMainExercise.'admin.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id);
  226. exit;
  227. }
  228. // if cancelling answer creation/modification
  229. if (!empty($cancelAnswers)) {
  230. // goes back to the question viewing
  231. $editQuestion = $modifyAnswers;
  232. unset($modifyAnswers);
  233. }
  234. $nameTools = get_lang('ExerciseManagement');
  235. // modifies the query string that is used in the link of tool name
  236. if ($editQuestion || $modifyQuestion || $newQuestion || $modifyAnswers) {
  237. $nameTools = get_lang('QuestionManagement');
  238. }
  239. if (isset($_SESSION['gradebook'])) {
  240. $gradebook = $_SESSION['gradebook'];
  241. }
  242. if (!empty($gradebook) && $gradebook == 'view') {
  243. $interbreadcrumb[] = array(
  244. 'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
  245. 'name' => get_lang('ToolGradebook')
  246. );
  247. }
  248. $interbreadcrumb[] = array("url" => $urlMainExercise."exercice.php", "name" => get_lang('Exercices'));
  249. if (isset($_GET['newQuestion']) || isset($_GET['editQuestion'])) {
  250. $interbreadcrumb[] = array("url" => $urlMainExercise."admin.php?exerciseId=".$objExercise->id, "name" => $objExercise->name);
  251. } else {
  252. $interbreadcrumb[] = array("url" => "#", "name" => $objExercise->name);
  253. }
  254. // if the question is duplicated, disable the link of tool name
  255. if (!empty($modifyIn) && $modifyIn == 'thisExercise') {
  256. if ($buttonBack) {
  257. $modifyIn = 'allExercises';
  258. } else {
  259. $noPHP_SELF = true;
  260. }
  261. }
  262. $htmlHeadXtra[] = '<script>
  263. function multiple_answer_true_false_onchange(variable) {
  264. var result = variable.checked;
  265. var id = variable.id;
  266. var weight_id = "weighting_" + id;
  267. var array_result=new Array();
  268. array_result[1]="1";
  269. array_result[0]= "-0.50";
  270. array_result[-1]= "0";
  271. if (result) {
  272. result = 1;
  273. } else {
  274. result = 0;
  275. }
  276. document.getElementById(weight_id).value = array_result[result];
  277. }
  278. $(function() {
  279. $( "#dialog:ui-dialog" ).dialog( "destroy" );
  280. $( "#dialog-confirm" ).dialog({
  281. autoOpen: false,
  282. show: "blind",
  283. resizable: false,
  284. height:150,
  285. modal: false
  286. });
  287. $(".opener").click(function() {
  288. var targetUrl = $(this).attr("href");
  289. $( "#dialog-confirm" ).dialog({
  290. modal: true,
  291. buttons: {
  292. "'.get_lang("Yes").'": function() {
  293. location.href = targetUrl;
  294. $( this ).dialog( "close" );
  295. },
  296. "'.get_lang("No").'": function() {
  297. $( this ).dialog( "close" );
  298. }
  299. }
  300. });
  301. $( "#dialog-confirm" ).dialog("open");
  302. return false;
  303. });
  304. });
  305. </script>';
  306. $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_CODE_PATH).'plugin/hotspot/JavaScriptFlashGateway.js"></script>';
  307. $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_CODE_PATH).'plugin/hotspot/hotspot.js"></script>';
  308. $htmlHeadXtra[] = "<script>
  309. <!--
  310. // Globals
  311. // Major version of Flash required
  312. var requiredMajorVersion = 7;
  313. // Minor version of Flash required
  314. var requiredMinorVersion = 0;
  315. // Minor version of Flash required
  316. var requiredRevision = 0;
  317. // the version of javascript supported
  318. var jsVersion = 1.0;
  319. // -->
  320. </script>
  321. <script language=\"VBScript\" type=\"text/vbscript\">
  322. <!-- // Visual basic helper required to detect Flash Player ActiveX control version information
  323. Function VBGetSwfVer(i)
  324. on error resume next
  325. Dim swControl, swVersion
  326. swVersion = 0
  327. set swControl = CreateObject(\"ShockwaveFlash.ShockwaveFlash.\" + CStr(i))
  328. if (IsObject(swControl)) then
  329. swVersion = swControl.GetVariable(\"\$version\")
  330. end if
  331. VBGetSwfVer = swVersion
  332. End Function
  333. // -->
  334. </script>
  335. <script language=\"JavaScript1.1\" type=\"text/javascript\">
  336. <!-- // Detect Client Browser type
  337. var isIE = (navigator.appVersion.indexOf(\"MSIE\") != -1) ? true : false;
  338. var isWin = (navigator.appVersion.toLowerCase().indexOf(\"win\") != -1) ? true : false;
  339. var isOpera = (navigator.userAgent.indexOf(\"Opera\") != -1) ? true : false;
  340. jsVersion = 1.1;
  341. // JavaScript helper required to detect Flash Player PlugIn version information
  342. function JSGetSwfVer(i){
  343. // NS/Opera version >= 3 check for Flash plugin in plugin array
  344. if (navigator.plugins != null && navigator.plugins.length > 0) {
  345. if (navigator.plugins[\"Shockwave Flash 2.0\"] || navigator.plugins[\"Shockwave Flash\"]) {
  346. var swVer2 = navigator.plugins[\"Shockwave Flash 2.0\"] ? \" 2.0\" : \"\";
  347. var flashDescription = navigator.plugins[\"Shockwave Flash\" + swVer2].description;
  348. descArray = flashDescription.split(\" \");
  349. tempArrayMajor = descArray[2].split(\".\");
  350. versionMajor = tempArrayMajor[0];
  351. versionMinor = tempArrayMajor[1];
  352. if ( descArray[3] != \"\" ) {
  353. tempArrayMinor = descArray[3].split(\"r\");
  354. } else {
  355. tempArrayMinor = descArray[4].split(\"r\");
  356. }
  357. versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
  358. flashVer = versionMajor + \".\" + versionMinor + \".\" + versionRevision;
  359. } else {
  360. flashVer = -1;
  361. }
  362. }
  363. // MSN/WebTV 2.6 supports Flash 4
  364. else if (navigator.userAgent.toLowerCase().indexOf(\"webtv/2.6\") != -1) flashVer = 4;
  365. // WebTV 2.5 supports Flash 3
  366. else if (navigator.userAgent.toLowerCase().indexOf(\"webtv/2.5\") != -1) flashVer = 3;
  367. // older WebTV supports Flash 2
  368. else if (navigator.userAgent.toLowerCase().indexOf(\"webtv\") != -1) flashVer = 2;
  369. // Can't detect in all other cases
  370. else {
  371. flashVer = -1;
  372. }
  373. return flashVer;
  374. }
  375. // When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
  376. function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
  377. {
  378. reqVer = parseFloat(reqMajorVer + \".\" + reqRevision);
  379. // loop backwards through the versions until we find the newest version
  380. for (i=25;i>0;i--) {
  381. if (isIE && isWin && !isOpera) {
  382. versionStr = VBGetSwfVer(i);
  383. } else {
  384. versionStr = JSGetSwfVer(i);
  385. }
  386. if (versionStr == -1 ) {
  387. return false;
  388. } else if (versionStr != 0) {
  389. if(isIE && isWin && !isOpera) {
  390. tempArray = versionStr.split(\" \");
  391. tempString = tempArray[1];
  392. versionArray = tempString .split(\",\");
  393. } else {
  394. versionArray = versionStr.split(\".\");
  395. }
  396. versionMajor = versionArray[0];
  397. versionMinor = versionArray[1];
  398. versionRevision = versionArray[2];
  399. versionString = versionMajor + \".\" + versionRevision; // 7.0r24 == 7.24
  400. versionNum = parseFloat(versionString);
  401. // is the major.revision >= requested major.revision AND the minor version >= requested minor
  402. if ( (versionMajor > reqMajorVer) && (versionNum >= reqVer) ) {
  403. return true;
  404. } else {
  405. return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false );
  406. }
  407. }
  408. }
  409. }
  410. // -->
  411. </script>";
  412. Display::display_header($nameTools, 'Exercise');
  413. if ($objExercise->exercise_was_added_in_lp) {
  414. if ($objExercise->force_edit_exercise_in_lp == true) {
  415. Display::display_warning_message(get_lang('ForceEditingExerciseInLPWarning'));
  416. } else {
  417. Display::display_warning_message(get_lang('EditingExerciseCauseProblemsInLP'));
  418. }
  419. }
  420. // If we are in a test
  421. $inATest = isset($exerciseId) && $exerciseId > 0;
  422. if ($inATest) {
  423. echo '<div class="actions">';
  424. if (isset($_GET['hotspotadmin']) || isset($_GET['newQuestion']) || isset($_GET['myid'])) {
  425. echo '<a href="'.$urlMainExercise.'admin.php?exerciseId='.$exerciseId.'">'.Display::return_icon(
  426. 'back.png',
  427. get_lang('GoBackToQuestionList'),
  428. '',
  429. ICON_SIZE_MEDIUM
  430. ).'</a>';
  431. }
  432. if (!isset($_GET['hotspotadmin']) && !isset($_GET['newQuestion']) && !isset($_GET['myid']) && !isset($_GET['editQuestion'])) {
  433. echo '<a href="'.$urlMainExercise.'exercice.php?'.api_get_cidReq().'">'.Display::return_icon(
  434. 'back.png',
  435. get_lang('BackToExercisesList'),
  436. '',
  437. ICON_SIZE_MEDIUM
  438. ).'</a>';
  439. }
  440. echo '<a href="'.$urlMainExercise.'overview.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'&preview=1">'.Display::return_icon(
  441. 'preview_view.png',
  442. get_lang('Preview'),
  443. '',
  444. ICON_SIZE_MEDIUM
  445. ).'</a>';
  446. echo Display::url(
  447. Display::return_icon('test_results.png', get_lang('Results'), '', ICON_SIZE_MEDIUM),
  448. $urlMainExercise.'exercise_report.php?'.api_get_cidReq().'&exerciseId='.$objExercise->id
  449. );
  450. if ($objExercise->edit_exercise_in_lp == false) {
  451. echo '<a href="">'.Display::return_icon(
  452. 'settings_na.png',
  453. get_lang('ModifyExercise'),
  454. '',
  455. ICON_SIZE_MEDIUM
  456. ).'</a>';
  457. } else {
  458. echo '<a href="'.$urlMainExercise.'exercise_admin.php?'.api_get_cidreq().'&modifyExercise=yes&exerciseId='.$objExercise->id.'">'.
  459. Display::return_icon('settings.png', get_lang('ModifyExercise'), '', ICON_SIZE_MEDIUM ).'</a>';
  460. }
  461. // @todo if you have 5000 questions this will slow down everything
  462. /*
  463. $maxScoreAllQuestions = 0;
  464. if (!empty($objExercise->questionList)) {
  465. foreach ($objExercise->questionList as $q) {
  466. $question = Question::read($q);
  467. if ($question) {
  468. $maxScoreAllQuestions += $question->selectWeighting();
  469. }
  470. }
  471. }
  472. echo '<span style="float:right">'.sprintf(get_lang('XQuestionsWithTotalScoreY'), $objExercise->selectNbrQuestions(), $maxScoreAllQuestions ).'</span>';*/
  473. echo '</div>';
  474. } else {
  475. // we are in create a new question from question pool not in a test
  476. echo '<div class="actions">';
  477. echo '<a href="'.$urlMainExercise.'admin.php?exerciseId='.$objExercise->id.'&'.api_get_cidreq().'">'.
  478. Display::return_icon('back.png', get_lang('GoBackToQuestionList'),'', ICON_SIZE_MEDIUM ).'</a>';
  479. echo '</div>';
  480. }
  481. if (isset($_GET['message'])) {
  482. if (in_array($_GET['message'], array('ExerciseStored', 'ItemUpdated', 'ItemAdded'))) {
  483. Display::display_confirmation_message(get_lang($_GET['message']));
  484. }
  485. }
  486. if ($newQuestion || $editQuestion) {
  487. // statement management
  488. if ($editQuestion) {
  489. $type = $objQuestion->selectType();
  490. } else {
  491. $type = Security::remove_XSS($_REQUEST['answerType']);
  492. }
  493. echo '<input type="hidden" name="Type" value="'.$type.'" />';
  494. // Create/Edit question.
  495. require 'question_admin.inc.php';
  496. }
  497. if (isset($_GET['hotspotadmin'])) {
  498. if (!is_object($objQuestion)) {
  499. $objQuestion = Question :: read($_GET['hotspotadmin']);
  500. }
  501. if (!$objQuestion) {
  502. api_not_allowed();
  503. }
  504. require 'hotspot_admin.inc.php';
  505. }
  506. if (!$newQuestion && !$modifyQuestion && !$editQuestion && !isset($_GET['hotspotadmin'])) {
  507. if ($objExercise->randomByCat == EXERCISE_CATEGORY_RANDOM_SHUFFLED || EXERCISE_CATEGORY_RANDOM_ORDERED) {
  508. Display::display_normal_message(get_lang('AllQuestionsMustHaveACategory'));
  509. }
  510. // Question list (drag n drop view)
  511. // @todo this bad do not require files like this
  512. if ($objExercise->fastEdition) {
  513. require 'question_list_pagination_admin.inc.php';
  514. } else {
  515. require 'question_list_admin.inc.php';
  516. }
  517. }
  518. Session::write('objExercise', $objExercise);
  519. Session::write('objQuestion', $objQuestion);
  520. Session::write('objAnswer', $objAnswer);
  521. Display::display_footer();