admin.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  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. * - question_list_admin.inc.php : management of the question list
  17. *
  18. * Main variables used in this script :
  19. *
  20. * - $is_allowedToEdit : set to 1 if the user is allowed to manage the exercise
  21. * - $objExercise : exercise object
  22. * - $objQuestion : question object
  23. * - $objAnswer : answer object
  24. * - $aType : array with answer types
  25. * - $exerciseId : the exercise ID
  26. * - $picturePath : the path of question pictures
  27. * - $newQuestion : ask to create a new question
  28. * - $modifyQuestion : ID of the question to modify
  29. * - $editQuestion : ID of the question to edit
  30. * - $submitQuestion : ask to save question modifications
  31. * - $cancelQuestion : ask to cancel question modifications
  32. * - $deleteQuestion : ID of the question to delete
  33. * - $moveUp : ID of the question to move up
  34. * - $moveDown : ID of the question to move down
  35. * - $modifyExercise : ID of the exercise to modify
  36. * - $submitExercise : ask to save exercise modifications
  37. * - $cancelExercise : ask to cancel exercise modifications
  38. * - $modifyAnswers : ID of the question which we want to modify answers for
  39. * - $cancelAnswers : ask to cancel answer modifications
  40. * - $buttonBack : ask to go back to the previous page in answers of type "Fill in blanks"
  41. *
  42. * @package chamilo.exercise
  43. * @author Olivier Brouckaert
  44. * Modified by Hubert Borderiou 21-10-2011 Question by category
  45. */
  46. use ChamiloSession as Session;
  47. require_once '../inc/global.inc.php';
  48. $current_course_tool = TOOL_QUIZ;
  49. $this_section = SECTION_COURSES;
  50. // Access control
  51. api_protect_course_script(true);
  52. $is_allowedToEdit = api_is_allowed_to_edit(null,true);
  53. $sessionId = api_get_session_id();
  54. if (!$is_allowedToEdit) {
  55. api_not_allowed(true);
  56. }
  57. /* stripslashes POST data */
  58. if($_SERVER['REQUEST_METHOD'] == 'POST') {
  59. foreach($_POST as $key=>$val) {
  60. if(is_string($val)) {
  61. $_POST[$key]=stripslashes($val);
  62. } elseif(is_array($val)) {
  63. foreach($val as $key2=>$val2) {
  64. $_POST[$key][$key2]=stripslashes($val2);
  65. }
  66. }
  67. $GLOBALS[$key]=$_POST[$key];
  68. }
  69. }
  70. if (empty($exerciseId)) {
  71. $exerciseId = isset($_GET['exerciseId']) ? intval($_GET['exerciseId']):'0';
  72. }
  73. if (empty($newQuestion)) {
  74. $newQuestion = isset($_GET['newQuestion']) ? $_GET['newQuestion'] : 0;
  75. }
  76. if (empty($modifyAnswers)) {
  77. $modifyAnswers = isset($_GET['modifyAnswers']) ? $_GET['modifyAnswers'] : 0;
  78. }
  79. if (empty($editQuestion)) {
  80. $editQuestion = isset($_GET['editQuestion']) ? $_GET['editQuestion'] : 0;
  81. }
  82. if (empty($modifyQuestion)) {
  83. $modifyQuestion = isset($_GET['modifyQuestion']) ? $_GET['modifyQuestion'] : 0;
  84. }
  85. if (empty($deleteQuestion)) {
  86. $deleteQuestion = isset($_GET['deleteQuestion']) ? $_GET['deleteQuestion'] : 0;
  87. }
  88. $clone_question = isset($_REQUEST['clone_question']) ? $_REQUEST['clone_question'] : 0;
  89. if (empty($questionId)) {
  90. $questionId = isset($_SESSION['questionId']) ? $_SESSION['questionId'] : 0;
  91. }
  92. if (empty($modifyExercise)) {
  93. $modifyExercise = isset($_GET['modifyExercise']) ? $_GET['modifyExercise'] : null;
  94. }
  95. $fromExercise = isset($fromExercise) ? $fromExercise : null;
  96. $cancelExercise = isset($cancelExercise) ? $cancelExercise : null;
  97. $cancelAnswers = isset($cancelAnswers) ? $cancelAnswers : null;
  98. $modifyIn = isset($modifyIn) ? $modifyIn : null;
  99. $cancelQuestion = isset($cancelQuestion) ? $cancelQuestion : null;
  100. /* Cleaning all incomplete attempts of the admin/teacher to avoid weird problems
  101. when changing the exercise settings, number of questions, etc */
  102. Event::delete_all_incomplete_attempts(
  103. api_get_user_id(),
  104. $exerciseId,
  105. api_get_course_int_id(),
  106. api_get_session_id()
  107. );
  108. // get from session
  109. $objExercise = isset($_SESSION['objExercise']) ? $_SESSION['objExercise'] : null;
  110. $objQuestion = isset($_SESSION['objQuestion']) ? $_SESSION['objQuestion'] : null;
  111. if (isset($_REQUEST['convertAnswer'])) {
  112. $objQuestion = $objQuestion->swapSimpleAnswerTypes();
  113. $_SESSION['objQuestion'] = $objQuestion;
  114. }
  115. $objAnswer = isset($_SESSION['objAnswer']) ? $_SESSION['objAnswer'] : null;
  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_qti($_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. // Exercise object creation.
  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);
  161. }
  162. // saves the object into the session
  163. Session::write('objExercise', $objExercise);
  164. }
  165. // Exercise can be edited in their course.
  166. if ($objExercise->sessionId != $sessionId) {
  167. api_not_allowed(true);
  168. /*header('Location: '.api_get_path(WEB_CODE_PATH).'exercice/exercise.php?'.api_get_cidreq());
  169. exit;*/
  170. }
  171. // doesn't select the exercise ID if we come from the question pool
  172. if (!$fromExercise) {
  173. // gets the right exercise ID, and if 0 creates a new exercise
  174. if (!$exerciseId = $objExercise->selectId()) {
  175. $modifyExercise='yes';
  176. }
  177. }
  178. $nbrQuestions = $objExercise->selectNbrQuestions();
  179. // Question object creation.
  180. if ($editQuestion || $newQuestion || $modifyQuestion || $modifyAnswers) {
  181. if ($editQuestion || $newQuestion) {
  182. // reads question data
  183. if ($editQuestion) {
  184. // question not found
  185. if (!$objQuestion = Question::read($editQuestion)) {
  186. api_not_allowed();
  187. }
  188. // saves the object into the session
  189. Session::write('objQuestion', $objQuestion);
  190. }
  191. }
  192. // checks if the object exists
  193. if (is_object($objQuestion)) {
  194. // gets the question ID
  195. $questionId = $objQuestion->selectId();
  196. }
  197. }
  198. // if cancelling an exercise
  199. if ($cancelExercise) {
  200. // existing exercise
  201. if ($exerciseId) {
  202. unset($modifyExercise);
  203. } else {
  204. // new exercise
  205. // goes back to the exercise list
  206. header('Location: '.api_get_path(WEB_CODE_PATH).'exercice/exercise.php?'.api_get_cidreq());
  207. exit();
  208. }
  209. }
  210. // if cancelling question creation/modification
  211. if ($cancelQuestion) {
  212. // if we are creating a new question from the question pool
  213. if (!$exerciseId && !$questionId) {
  214. // goes back to the question pool
  215. header('Location: question_pool.php');
  216. exit();
  217. } else {
  218. // goes back to the question viewing
  219. $editQuestion=$modifyQuestion;
  220. unset($newQuestion,$modifyQuestion);
  221. }
  222. }
  223. if (!empty($clone_question) && !empty($objExercise->id)) {
  224. $old_question_obj = Question::read($clone_question);
  225. $old_question_obj->question = $old_question_obj->question.' - '.get_lang('Copy');
  226. $new_id = $old_question_obj->duplicate();
  227. $new_question_obj = Question::read($new_id);
  228. $new_question_obj->addToList($exerciseId);
  229. // This should be moved to the duplicate function
  230. $new_answer_obj = new Answer($clone_question);
  231. $new_answer_obj->read();
  232. $new_answer_obj->duplicate($new_id);
  233. //Reloading tne $objExercise obj
  234. $objExercise->read($objExercise->id);
  235. header('Location: admin.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id);
  236. exit;
  237. }
  238. // if cancelling answer creation/modification
  239. if ($cancelAnswers) {
  240. // goes back to the question viewing
  241. $editQuestion=$modifyAnswers;
  242. unset($modifyAnswers);
  243. }
  244. $nameTools = null;
  245. // modifies the query string that is used in the link of tool name
  246. if ($editQuestion || $modifyQuestion || $newQuestion || $modifyAnswers) {
  247. $nameTools = get_lang('QuestionManagement');
  248. }
  249. if (isset($_SESSION['gradebook'])){
  250. $gradebook= $_SESSION['gradebook'];
  251. }
  252. if (!empty($gradebook) && $gradebook=='view') {
  253. $interbreadcrumb[]= array(
  254. 'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
  255. 'name' => get_lang('ToolGradebook')
  256. );
  257. }
  258. $interbreadcrumb[] = array("url" => "exercise.php","name" => get_lang('Exercises'));
  259. if (isset($_GET['newQuestion']) || isset($_GET['editQuestion']) ) {
  260. $interbreadcrumb[] = array("url" => "admin.php?exerciseId=".$objExercise->id, "name" => $objExercise->name);
  261. } else {
  262. $interbreadcrumb[] = array("url" => "#", "name" => $objExercise->name);
  263. }
  264. // shows a link to go back to the question pool
  265. if (!$exerciseId && $nameTools != get_lang('ExerciseManagement')){
  266. $interbreadcrumb[]=array(
  267. "url" => api_get_path(WEB_CODE_PATH)."exercice/question_pool.php?fromExercise=$fromExercise&".api_get_cidreq(),
  268. "name" => get_lang('QuestionPool')
  269. );
  270. }
  271. // if the question is duplicated, disable the link of tool name
  272. if ($modifyIn == 'thisExercise') {
  273. if($buttonBack) {
  274. $modifyIn='allExercises';
  275. } else {
  276. $noPHP_SELF=true;
  277. }
  278. }
  279. $htmlHeadXtra[] = '<script>
  280. function multiple_answer_true_false_onchange(variable) {
  281. var result = variable.checked;
  282. var id = variable.id;
  283. var weight_id = "weighting_" + id;
  284. var array_result=new Array();
  285. array_result[1]="1";
  286. array_result[0]= "-0.50";
  287. array_result[-1]= "0";
  288. if (result) {
  289. result = 1;
  290. } else {
  291. result = 0;
  292. }
  293. document.getElementById(weight_id).value = array_result[result];
  294. }
  295. </script>';
  296. $htmlHeadXtra[] = api_get_js('jquery.jsPlumb.all.js');
  297. $template = new Template();
  298. $htmlHeadXtra[] = $template->fetch('default/exercise/submit.js.tpl');
  299. $htmlHeadXtra[] = api_get_js('d3/jquery.xcolor.js');
  300. $htmlHeadXtra[] = "<script type=\"text/javascript\" src=\"../plugin/hotspot/JavaScriptFlashGateway.js\"></script>
  301. <script src=\"../plugin/hotspot/hotspot.js\" type=\"text/javascript\"></script>
  302. <script language=\"JavaScript\" type=\"text/javascript\">
  303. <!--
  304. // -----------------------------------------------------------------------------
  305. // Globals
  306. // Major version of Flash required
  307. var requiredMajorVersion = 7;
  308. // Minor version of Flash required
  309. var requiredMinorVersion = 0;
  310. // Minor version of Flash required
  311. var requiredRevision = 0;
  312. // the version of javascript supported
  313. var jsVersion = 1.0;
  314. // -----------------------------------------------------------------------------
  315. // -->
  316. </script>
  317. <script language=\"VBScript\" type=\"text/vbscript\">
  318. <!-- // Visual basic helper required to detect Flash Player ActiveX control version information
  319. Function VBGetSwfVer(i)
  320. on error resume next
  321. Dim swControl, swVersion
  322. swVersion = 0
  323. set swControl = CreateObject(\"ShockwaveFlash.ShockwaveFlash.\" + CStr(i))
  324. if (IsObject(swControl)) then
  325. swVersion = swControl.GetVariable(\"\$version\")
  326. end if
  327. VBGetSwfVer = swVersion
  328. End Function
  329. // -->
  330. </script>
  331. <script language=\"JavaScript1.1\" type=\"text/javascript\">
  332. <!-- // Detect Client Browser type
  333. var isIE = (navigator.appVersion.indexOf(\"MSIE\") != -1) ? true : false;
  334. var isWin = (navigator.appVersion.toLowerCase().indexOf(\"win\") != -1) ? true : false;
  335. var isOpera = (navigator.userAgent.indexOf(\"Opera\") != -1) ? true : false;
  336. jsVersion = 1.1;
  337. // JavaScript helper required to detect Flash Player PlugIn version information
  338. function JSGetSwfVer(i){
  339. // NS/Opera version >= 3 check for Flash plugin in plugin array
  340. if (navigator.plugins != null && navigator.plugins.length > 0) {
  341. if (navigator.plugins[\"Shockwave Flash 2.0\"] || navigator.plugins[\"Shockwave Flash\"]) {
  342. var swVer2 = navigator.plugins[\"Shockwave Flash 2.0\"] ? \" 2.0\" : \"\";
  343. var flashDescription = navigator.plugins[\"Shockwave Flash\" + swVer2].description;
  344. descArray = flashDescription.split(\" \");
  345. tempArrayMajor = descArray[2].split(\".\");
  346. versionMajor = tempArrayMajor[0];
  347. versionMinor = tempArrayMajor[1];
  348. if ( descArray[3] != \"\" ) {
  349. tempArrayMinor = descArray[3].split(\"r\");
  350. } else {
  351. tempArrayMinor = descArray[4].split(\"r\");
  352. }
  353. versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
  354. flashVer = versionMajor + \".\" + versionMinor + \".\" + versionRevision;
  355. } else {
  356. flashVer = -1;
  357. }
  358. }
  359. // MSN/WebTV 2.6 supports Flash 4
  360. else if (navigator.userAgent.toLowerCase().indexOf(\"webtv/2.6\") != -1) flashVer = 4;
  361. // WebTV 2.5 supports Flash 3
  362. else if (navigator.userAgent.toLowerCase().indexOf(\"webtv/2.5\") != -1) flashVer = 3;
  363. // older WebTV supports Flash 2
  364. else if (navigator.userAgent.toLowerCase().indexOf(\"webtv\") != -1) flashVer = 2;
  365. // Can't detect in all other cases
  366. else {
  367. flashVer = -1;
  368. }
  369. return flashVer;
  370. }
  371. // When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
  372. function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
  373. {
  374. reqVer = parseFloat(reqMajorVer + \".\" + reqRevision);
  375. // loop backwards through the versions until we find the newest version
  376. for (i=25;i>0;i--) {
  377. if (isIE && isWin && !isOpera) {
  378. versionStr = VBGetSwfVer(i);
  379. } else {
  380. versionStr = JSGetSwfVer(i);
  381. }
  382. if (versionStr == -1 ) {
  383. return false;
  384. } else if (versionStr != 0) {
  385. if(isIE && isWin && !isOpera) {
  386. tempArray = versionStr.split(\" \");
  387. tempString = tempArray[1];
  388. versionArray = tempString .split(\",\");
  389. } else {
  390. versionArray = versionStr.split(\".\");
  391. }
  392. versionMajor = versionArray[0];
  393. versionMinor = versionArray[1];
  394. versionRevision = versionArray[2];
  395. versionString = versionMajor + \".\" + versionRevision; // 7.0r24 == 7.24
  396. versionNum = parseFloat(versionString);
  397. // is the major.revision >= requested major.revision AND the minor version >= requested minor
  398. if ( (versionMajor > reqMajorVer) && (versionNum >= reqVer) ) {
  399. return true;
  400. } else {
  401. return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false );
  402. }
  403. }
  404. }
  405. }
  406. // -->
  407. </script>";
  408. Display::display_header($nameTools,'Exercise');
  409. /*
  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="'.api_get_path(WEB_CODE_PATH).'exercice/admin.php?exerciseId='.$exerciseId.'&'.api_get_cidReq().'">'.
  423. Display::return_icon('back.png', get_lang('GoBackToQuestionList'),'',ICON_SIZE_MEDIUM).'</a>';
  424. if (!isset($_GET['hotspotadmin']) && !isset($_GET['newQuestion']) && !isset($_GET['myid']) && !isset($_GET['editQuestion'])) {
  425. echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercice/exercise.php?'.api_get_cidReq().'">'.
  426. Display::return_icon('back.png', get_lang('BackToExercisesList'),'',ICON_SIZE_MEDIUM).'</a>';
  427. }
  428. echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercice/overview.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'&preview=1">'.
  429. Display::return_icon('preview_view.png', get_lang('Preview'),'',ICON_SIZE_MEDIUM).'</a>';
  430. echo Display::url(
  431. Display::return_icon('test_results.png', get_lang('Results'),'',ICON_SIZE_MEDIUM),
  432. api_get_path(WEB_CODE_PATH).'exercice/exercise_report.php?'.api_get_cidReq().'&exerciseId='.$objExercise->id
  433. );
  434. echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercice/exercise_admin.php?'.api_get_cidreq().'&modifyExercise=yes&exerciseId='.$objExercise->id.'">'.
  435. Display::return_icon('settings.png', get_lang('ModifyExercise'),'',ICON_SIZE_MEDIUM).'</a>';
  436. $maxScoreAllQuestions = 0;
  437. if (!empty($objExercise->questionList)) {
  438. foreach ($objExercise->questionList as $q) {
  439. $question = Question::read($q);
  440. if ($question) {
  441. $maxScoreAllQuestions += $question->selectWeighting();
  442. }
  443. }
  444. }
  445. echo '</div>';
  446. echo '<div class="alert alert-info">'.sprintf(get_lang('XQuestionsWithTotalScoreY'), $objExercise->selectNbrQuestions(), $maxScoreAllQuestions).'</div>';
  447. } else if (isset($_GET['newQuestion'])) {
  448. // we are in create a new question from question pool not in a test
  449. echo '<div class="actions">';
  450. echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercice/admin.php?'.api_get_cidreq().'">'.
  451. Display::return_icon('back.png', get_lang('GoBackToQuestionList'),'',ICON_SIZE_MEDIUM).'</a>';
  452. echo '</div>';
  453. } else {
  454. // If we are in question_pool but not in an test, go back to question create in pool
  455. echo '<div class="actions">';
  456. echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercice/question_pool.php?'.api_get_cidreq().'">'.
  457. Display::return_icon('back.png', get_lang('GoBackToQuestionList'),'',ICON_SIZE_MEDIUM).
  458. '</a>';
  459. echo '</div>';
  460. }
  461. if (isset($_GET['message'])) {
  462. if (in_array($_GET['message'], array('ExerciseStored', 'ItemUpdated', 'ItemAdded'))) {
  463. Display::display_confirmation_message(get_lang($_GET['message']));
  464. }
  465. }
  466. if ($newQuestion || $editQuestion) {
  467. // Question management
  468. $type = isset($_REQUEST['answerType']) ? Security::remove_XSS($_REQUEST['answerType']) : null;
  469. echo '<input type="hidden" name="Type" value="'.$type.'" />';
  470. if ($newQuestion == 'yes') {
  471. $objExercise->edit_exercise_in_lp = true;
  472. }
  473. require 'question_admin.inc.php';
  474. }
  475. if (isset($_GET['hotspotadmin'])) {
  476. if (!is_object($objQuestion)) {
  477. $objQuestion = Question :: read($_GET['hotspotadmin']);
  478. }
  479. if (!$objQuestion) {
  480. api_not_allowed();
  481. }
  482. require 'hotspot_admin.inc.php';
  483. }
  484. if (!$newQuestion && !$modifyQuestion && !$editQuestion && !isset($_GET['hotspotadmin'])) {
  485. // question list management
  486. require 'question_list_admin.inc.php';
  487. }
  488. // if we are in question authoring, display warning to user is feedback not shown at the end of the test -ref #6619
  489. // this test to display only message in the question authoring page and not in the question list page too
  490. // if (is_object($objQuestion) && $objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_EXAM && ($newQuestion || $modifyQuestion || $editQuestion)) {
  491. if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_EXAM) {
  492. Display::display_normal_message(get_lang("TestFeedbackNotShown"));
  493. }
  494. Session::write('objExercise', $objExercise);
  495. Session::write('objQuestion', $objQuestion);
  496. Session::write('objAnswer', $objAnswer);
  497. Display::display_footer();