admin.php 20 KB

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