admin.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use ChamiloSession as Session;
  4. /**
  5. * Exercise administration
  6. * This script allows to manage (create, modify) an exercise and its questions
  7. *
  8. * Following scripts are includes for a best code understanding :
  9. *
  10. * - exercise.class.php : for the creation of an Exercise object
  11. * - question.class.php : for the creation of a Question object
  12. * - answer.class.php : for the creation of an Answer object
  13. * - exercise.lib.php : functions used in the exercise tool
  14. * - exercise_admin.inc.php : management of the exercise
  15. * - question_admin.inc.php : management of a question (statement & answers)
  16. * - statement_admin.inc.php : management of a statement
  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. $current_course_tool = TOOL_QUIZ;
  48. $this_section = SECTION_COURSES;
  49. // Access control
  50. api_protect_course_script(true);
  51. $is_allowedToEdit = api_is_allowed_to_edit(null, true, false, false);
  52. $sessionId = api_get_session_id();
  53. $studentViewActive = api_is_student_view_active();
  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. $questionId = Session::read('questionId');
  90. if (empty($modifyExercise)) {
  91. $modifyExercise = isset($_GET['modifyExercise']) ? $_GET['modifyExercise'] : null;
  92. }
  93. $fromExercise = isset($fromExercise) ? $fromExercise : null;
  94. $cancelExercise = isset($cancelExercise) ? $cancelExercise : null;
  95. $cancelAnswers = isset($cancelAnswers) ? $cancelAnswers : null;
  96. $modifyIn = isset($modifyIn) ? $modifyIn : null;
  97. $cancelQuestion = isset($cancelQuestion) ? $cancelQuestion : null;
  98. /* Cleaning all incomplete attempts of the admin/teacher to avoid weird problems
  99. when changing the exercise settings, number of questions, etc */
  100. Event::delete_all_incomplete_attempts(
  101. api_get_user_id(),
  102. $exerciseId,
  103. api_get_course_int_id(),
  104. api_get_session_id()
  105. );
  106. // get from session
  107. $objExercise = Session::read('objExercise');
  108. $objQuestion = Session::read('objQuestion');
  109. if (isset($_REQUEST['convertAnswer'])) {
  110. $objQuestion = $objQuestion->swapSimpleAnswerTypes();
  111. Session::write('objQuestion', $objQuestion);
  112. }
  113. $objAnswer = Session::read('objAnswer');
  114. // document path
  115. $documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
  116. // picture path
  117. $picturePath = $documentPath.'/images';
  118. // audio path
  119. $audioPath = $documentPath.'/audio';
  120. // the 5 types of answers
  121. $aType = array(
  122. get_lang('UniqueSelect'),
  123. get_lang('MultipleSelect'),
  124. get_lang('FillBlanks'),
  125. get_lang('Matching'),
  126. get_lang('FreeAnswer')
  127. );
  128. // tables used in the exercise tool
  129. if (!empty($_GET['action']) && $_GET['action'] == 'exportqti2' && !empty($_GET['questionId'])) {
  130. require_once 'export/qti2/qti2_export.php';
  131. $export = export_question_qti($_GET['questionId'], true);
  132. $qid = (int)$_GET['questionId'];
  133. $archive_path = api_get_path(SYS_ARCHIVE_PATH);
  134. $temp_dir_short = uniqid();
  135. $temp_zip_dir = $archive_path."/".$temp_dir_short;
  136. if (!is_dir($temp_zip_dir)) {
  137. mkdir($temp_zip_dir, api_get_permissions_for_new_directories());
  138. }
  139. $temp_zip_file = $temp_zip_dir."/".api_get_unique_id().".zip";
  140. $temp_xml_file = $temp_zip_dir."/qti2export_".$qid.'.xml';
  141. file_put_contents($temp_xml_file, $export);
  142. $zip_folder = new PclZip($temp_zip_file);
  143. $zip_folder->add($temp_xml_file, PCLZIP_OPT_REMOVE_ALL_PATH);
  144. $name = 'qti2_export_'.$qid.'.zip';
  145. DocumentManager::file_send_for_download($temp_zip_file, true, $name);
  146. unlink($temp_zip_file);
  147. unlink($temp_xml_file);
  148. rmdir($temp_zip_dir);
  149. //DocumentManager::string_send_for_download($export,true,'qti2export_q'.$_GET['questionId'].'.xml');
  150. exit; //otherwise following clicks may become buggy
  151. }
  152. // Exercise object creation.
  153. if (!is_object($objExercise)) {
  154. // construction of the Exercise object
  155. $objExercise = new Exercise();
  156. // creation of a new exercise if wrong or not specified exercise ID
  157. if ($exerciseId) {
  158. $objExercise->read($exerciseId);
  159. }
  160. // saves the object into the session
  161. Session::write('objExercise', $objExercise);
  162. }
  163. // Exercise can be edited in their course.
  164. if ($objExercise->sessionId != $sessionId) {
  165. api_not_allowed(true);
  166. }
  167. // doesn't select the exercise ID if we come from the question pool
  168. if (!$fromExercise) {
  169. // gets the right exercise ID, and if 0 creates a new exercise
  170. if (!$exerciseId = $objExercise->selectId()) {
  171. $modifyExercise='yes';
  172. }
  173. }
  174. $nbrQuestions = $objExercise->selectNbrQuestions();
  175. // Question object creation.
  176. if ($editQuestion || $newQuestion || $modifyQuestion || $modifyAnswers) {
  177. if ($editQuestion || $newQuestion) {
  178. // reads question data
  179. if ($editQuestion) {
  180. // question not found
  181. if (!$objQuestion = Question::read($editQuestion)) {
  182. api_not_allowed();
  183. }
  184. // saves the object into the session
  185. Session::write('objQuestion', $objQuestion);
  186. }
  187. }
  188. // checks if the object exists
  189. if (is_object($objQuestion)) {
  190. // gets the question ID
  191. $questionId = $objQuestion->selectId();
  192. }
  193. }
  194. // if cancelling an exercise
  195. if ($cancelExercise) {
  196. // existing exercise
  197. if ($exerciseId) {
  198. unset($modifyExercise);
  199. } else {
  200. // new exercise
  201. // goes back to the exercise list
  202. header('Location: '.api_get_path(WEB_CODE_PATH).'exercise/exercise.php?'.api_get_cidreq());
  203. exit();
  204. }
  205. }
  206. // if cancelling question creation/modification
  207. if ($cancelQuestion) {
  208. // if we are creating a new question from the question pool
  209. if (!$exerciseId && !$questionId) {
  210. // goes back to the question pool
  211. header('Location: question_pool.php?'.api_get_cidreq());
  212. exit();
  213. } else {
  214. // goes back to the question viewing
  215. $editQuestion = $modifyQuestion;
  216. unset($newQuestion,$modifyQuestion);
  217. }
  218. }
  219. if (!empty($clone_question) && !empty($objExercise->id)) {
  220. $old_question_obj = Question::read($clone_question);
  221. $old_question_obj->question = $old_question_obj->question.' - '.get_lang('Copy');
  222. $new_id = $old_question_obj->duplicate();
  223. $new_question_obj = Question::read($new_id);
  224. $new_question_obj->addToList($exerciseId);
  225. // This should be moved to the duplicate function
  226. $new_answer_obj = new Answer($clone_question);
  227. $new_answer_obj->read();
  228. $new_answer_obj->duplicate($new_id);
  229. //Reloading tne $objExercise obj
  230. $objExercise->read($objExercise->id);
  231. header('Location: admin.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id);
  232. exit;
  233. }
  234. // if cancelling answer creation/modification
  235. if ($cancelAnswers) {
  236. // goes back to the question viewing
  237. $editQuestion = $modifyAnswers;
  238. unset($modifyAnswers);
  239. }
  240. $nameTools = null;
  241. // modifies the query string that is used in the link of tool name
  242. if ($editQuestion || $modifyQuestion || $newQuestion || $modifyAnswers) {
  243. $nameTools = get_lang('QuestionManagement');
  244. }
  245. if (api_is_in_gradebook()) {
  246. $interbreadcrumb[]= array(
  247. 'url' => api_get_path(WEB_CODE_PATH).'gradebook/index.php?'.api_get_cidreq(),
  248. 'name' => get_lang('ToolGradebook')
  249. );
  250. }
  251. $interbreadcrumb[] = array("url" => "exercise.php?".api_get_cidreq(),"name" => get_lang('Exercises'));
  252. if (isset($_GET['newQuestion']) || isset($_GET['editQuestion']) ) {
  253. $interbreadcrumb[] = array("url" => "admin.php?exerciseId=".$objExercise->id.'&'.api_get_cidreq(), "name" => $objExercise->name);
  254. } else {
  255. $interbreadcrumb[] = array("url" => "#", "name" => $objExercise->name);
  256. }
  257. // shows a link to go back to the question pool
  258. if (!$exerciseId && $nameTools != get_lang('ExerciseManagement')){
  259. $interbreadcrumb[]=array(
  260. "url" => api_get_path(WEB_CODE_PATH)."exercise/question_pool.php?fromExercise=$fromExercise&".api_get_cidreq(),
  261. "name" => get_lang('QuestionPool')
  262. );
  263. }
  264. // if the question is duplicated, disable the link of tool name
  265. if ($modifyIn == 'thisExercise') {
  266. if($buttonBack) {
  267. $modifyIn='allExercises';
  268. } else {
  269. $noPHP_SELF=true;
  270. }
  271. }
  272. $htmlHeadXtra[] = '<script>
  273. function multiple_answer_true_false_onchange(variable) {
  274. var result = variable.checked;
  275. var id = variable.id;
  276. var weight_id = "weighting_" + id;
  277. var array_result=new Array();
  278. array_result[1]="1";
  279. array_result[0]= "-0.50";
  280. array_result[-1]= "0";
  281. if (result) {
  282. result = 1;
  283. } else {
  284. result = 0;
  285. }
  286. document.getElementById(weight_id).value = array_result[result];
  287. }
  288. </script>';
  289. $htmlHeadXtra[] = api_get_css('components/jsplumb/dist/js/jsPlumb-2.0.4.js');
  290. $htmlHeadXtra[] = api_get_js('components/jquery.ui.touch/jquery.ui.touch.js');
  291. $template = \Chamilo\CoreBundle\Framework\Container::getTwig();
  292. $htmlHeadXtra[] = $template->render(
  293. 'ChamiloCoreBundle:default/exercise:submit.html.twig',
  294. ['shuffle_answers' => $objExercise->getShuffle()]
  295. );
  296. $htmlHeadXtra[] = api_get_js('components/xcolor/jquery.xcolor.js');
  297. $htmlHeadXtra2 = array();
  298. $htmlHeadXtra2[] = "<script type=\"text/javascript\" src=\"../plugin/hotspot/JavaScriptFlashGateway.js\"></script>
  299. <script src=\"../plugin/hotspot/hotspot.js\" type=\"text/javascript\"></script>
  300. <script language=\"JavaScript\" type=\"text/javascript\">
  301. <!--
  302. // -----------------------------------------------------------------------------
  303. // Globals
  304. // Major version of Flash required
  305. var requiredMajorVersion = 7;
  306. // Minor version of Flash required
  307. var requiredMinorVersion = 0;
  308. // Minor version of Flash required
  309. var requiredRevision = 0;
  310. // the version of javascript supported
  311. var jsVersion = 1.0;
  312. // -----------------------------------------------------------------------------
  313. // -->
  314. </script>
  315. <script language=\"VBScript\" type=\"text/vbscript\">
  316. <!-- // Visual basic helper required to detect Flash Player ActiveX control version information
  317. Function VBGetSwfVer(i)
  318. on error resume next
  319. Dim swControl, swVersion
  320. swVersion = 0
  321. set swControl = CreateObject(\"ShockwaveFlash.ShockwaveFlash.\" + CStr(i))
  322. if (IsObject(swControl)) then
  323. swVersion = swControl.GetVariable(\"\$version\")
  324. end if
  325. VBGetSwfVer = swVersion
  326. End Function
  327. // -->
  328. </script>
  329. <script language=\"JavaScript1.1\" type=\"text/javascript\">
  330. <!-- // Detect Client Browser type
  331. var isIE = (navigator.appVersion.indexOf(\"MSIE\") != -1) ? true : false;
  332. var isWin = (navigator.appVersion.toLowerCase().indexOf(\"win\") != -1) ? true : false;
  333. var isOpera = (navigator.userAgent.indexOf(\"Opera\") != -1) ? true : false;
  334. jsVersion = 1.1;
  335. // JavaScript helper required to detect Flash Player PlugIn version information
  336. function JSGetSwfVer(i){
  337. // NS/Opera version >= 3 check for Flash plugin in plugin array
  338. if (navigator.plugins != null && navigator.plugins.length > 0) {
  339. if (navigator.plugins[\"Shockwave Flash 2.0\"] || navigator.plugins[\"Shockwave Flash\"]) {
  340. var swVer2 = navigator.plugins[\"Shockwave Flash 2.0\"] ? \" 2.0\" : \"\";
  341. var flashDescription = navigator.plugins[\"Shockwave Flash\" + swVer2].description;
  342. descArray = flashDescription.split(\" \");
  343. tempArrayMajor = descArray[2].split(\".\");
  344. versionMajor = tempArrayMajor[0];
  345. versionMinor = tempArrayMajor[1];
  346. if ( descArray[3] != \"\" ) {
  347. tempArrayMinor = descArray[3].split(\"r\");
  348. } else {
  349. tempArrayMinor = descArray[4].split(\"r\");
  350. }
  351. versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
  352. flashVer = versionMajor + \".\" + versionMinor + \".\" + versionRevision;
  353. } else {
  354. flashVer = -1;
  355. }
  356. }
  357. // MSN/WebTV 2.6 supports Flash 4
  358. else if (navigator.userAgent.toLowerCase().indexOf(\"webtv/2.6\") != -1) flashVer = 4;
  359. // WebTV 2.5 supports Flash 3
  360. else if (navigator.userAgent.toLowerCase().indexOf(\"webtv/2.5\") != -1) flashVer = 3;
  361. // older WebTV supports Flash 2
  362. else if (navigator.userAgent.toLowerCase().indexOf(\"webtv\") != -1) flashVer = 2;
  363. // Can't detect in all other cases
  364. else {
  365. flashVer = -1;
  366. }
  367. return flashVer;
  368. }
  369. // When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
  370. function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
  371. {
  372. reqVer = parseFloat(reqMajorVer + \".\" + reqRevision);
  373. // loop backwards through the versions until we find the newest version
  374. for (i=25;i>0;i--) {
  375. if (isIE && isWin && !isOpera) {
  376. versionStr = VBGetSwfVer(i);
  377. } else {
  378. versionStr = JSGetSwfVer(i);
  379. }
  380. if (versionStr == -1 ) {
  381. return false;
  382. } else if (versionStr != 0) {
  383. if(isIE && isWin && !isOpera) {
  384. tempArray = versionStr.split(\" \");
  385. tempString = tempArray[1];
  386. versionArray = tempString .split(\",\");
  387. } else {
  388. versionArray = versionStr.split(\".\");
  389. }
  390. versionMajor = versionArray[0];
  391. versionMinor = versionArray[1];
  392. versionRevision = versionArray[2];
  393. versionString = versionMajor + \".\" + versionRevision; // 7.0r24 == 7.24
  394. versionNum = parseFloat(versionString);
  395. // is the major.revision >= requested major.revision AND the minor version >= requested minor
  396. if ( (versionMajor > reqMajorVer) && (versionNum >= reqVer) ) {
  397. return true;
  398. } else {
  399. return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false );
  400. }
  401. }
  402. }
  403. }
  404. // -->
  405. </script>";
  406. //Display::display_header($nameTools,'Exercise');
  407. /*
  408. if ($objExercise->exercise_was_added_in_lp) {
  409. if ($objExercise->force_edit_exercise_in_lp == true) {
  410. Display::display_warning_message(get_lang('ForceEditingExerciseInLPWarning'));
  411. } else {
  412. Display::display_warning_message(get_lang('EditingExerciseCauseProblemsInLP'));
  413. }
  414. }*/
  415. // If we are in a test
  416. $inATest = isset($exerciseId) && $exerciseId > 0;
  417. if ($inATest) {
  418. echo '<div class="actions">';
  419. if (isset($_GET['hotspotadmin']) || isset($_GET['newQuestion']) || isset($_GET['myid']))
  420. echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercise/admin.php?exerciseId='.$exerciseId.'&'.api_get_cidReq().'">'.
  421. Display::return_icon('back.png', get_lang('GoBackToQuestionList'),'',ICON_SIZE_MEDIUM).'</a>';
  422. if (!isset($_GET['hotspotadmin']) && !isset($_GET['newQuestion']) && !isset($_GET['myid']) && !isset($_GET['editQuestion'])) {
  423. echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercise/exercise.php?'.api_get_cidReq().'">'.
  424. Display::return_icon('back.png', get_lang('BackToExercisesList'),'',ICON_SIZE_MEDIUM).'</a>';
  425. }
  426. echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercise/overview.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'&preview=1">'.
  427. Display::return_icon('preview_view.png', get_lang('Preview'),'',ICON_SIZE_MEDIUM).'</a>';
  428. echo Display::url(
  429. Display::return_icon('test_results.png', get_lang('Results'),'',ICON_SIZE_MEDIUM),
  430. api_get_path(WEB_CODE_PATH).'exercise/exercise_report.php?'.api_get_cidReq().'&exerciseId='.$objExercise->id
  431. );
  432. echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercise/exercise_admin.php?'.api_get_cidreq().'&modifyExercise=yes&exerciseId='.$objExercise->id.'">'.
  433. Display::return_icon('settings.png', get_lang('ModifyExercise'),'',ICON_SIZE_MEDIUM).'</a>';
  434. $maxScoreAllQuestions = 0;
  435. if (!empty($objExercise->questionList)) {
  436. foreach ($objExercise->questionList as $q) {
  437. $question = Question::read($q);
  438. if ($question) {
  439. $maxScoreAllQuestions += $question->selectWeighting();
  440. }
  441. }
  442. }
  443. echo '</div>';
  444. echo '<div class="alert alert-info">'.sprintf(get_lang('XQuestionsWithTotalScoreY'), $objExercise->selectNbrQuestions(), $maxScoreAllQuestions).'</div>';
  445. } else if (isset($_GET['newQuestion'])) {
  446. // we are in create a new question from question pool not in a test
  447. echo '<div class="actions">';
  448. echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercise/admin.php?'.api_get_cidreq().'">'.
  449. Display::return_icon('back.png', get_lang('GoBackToQuestionList'),'',ICON_SIZE_MEDIUM).'</a>';
  450. echo '</div>';
  451. } else {
  452. // If we are in question_pool but not in an test, go back to question create in pool
  453. echo '<div class="actions">';
  454. echo '<a href="'.api_get_path(WEB_CODE_PATH).'exercise/question_pool.php?'.api_get_cidreq().'">'.
  455. Display::return_icon('back.png', get_lang('GoBackToQuestionList'),'',ICON_SIZE_MEDIUM).
  456. '</a>';
  457. echo '</div>';
  458. }
  459. if (isset($_GET['message'])) {
  460. if (in_array($_GET['message'], array('ExerciseStored', 'ItemUpdated', 'ItemAdded'))) {
  461. Display::display_confirmation_message(get_lang($_GET['message']));
  462. }
  463. }
  464. if ($newQuestion || $editQuestion) {
  465. // Question management
  466. $type = isset($_REQUEST['answerType']) ? Security::remove_XSS($_REQUEST['answerType']) : null;
  467. echo '<input type="hidden" name="Type" value="'.$type.'" />';
  468. if ($newQuestion === 'yes') {
  469. $objExercise->edit_exercise_in_lp = true;
  470. require 'question_admin.inc.php';
  471. }
  472. if ($editQuestion) {
  473. // Question preview if teacher clicked the "switch to student"
  474. if ($studentViewActive && $is_allowedToEdit) {
  475. echo '<div class="main-question">';
  476. echo Display::div($objQuestion->selectTitle(), array('class' => 'question_title'));
  477. ExerciseLib::showQuestion(
  478. $editQuestion,
  479. false,
  480. null,
  481. null,
  482. false,
  483. true,
  484. false,
  485. true,
  486. $objExercise->feedback_type,
  487. true
  488. );
  489. echo '</div>';
  490. } else {
  491. require 'question_admin.inc.php';
  492. }
  493. }
  494. }
  495. if (isset($_GET['hotspotadmin'])) {
  496. if (!is_object($objQuestion)) {
  497. $objQuestion = Question :: read($_GET['hotspotadmin']);
  498. }
  499. if (!$objQuestion) {
  500. api_not_allowed();
  501. }
  502. require 'hotspot_admin.inc.php';
  503. }
  504. if (!$newQuestion && !$modifyQuestion && !$editQuestion && !isset($_GET['hotspotadmin'])) {
  505. // question list management
  506. require 'question_list_admin.inc.php';
  507. }
  508. // if we are in question authoring, display warning to user is feedback not shown at the end of the test -ref #6619
  509. // this test to display only message in the question authoring page and not in the question list page too
  510. // if (is_object($objQuestion) && $objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_EXAM && ($newQuestion || $modifyQuestion || $editQuestion)) {
  511. if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_EXAM) {
  512. Display::display_normal_message(get_lang("TestFeedbackNotShown"));
  513. }
  514. Session::write('objExercise', $objExercise);
  515. Session::write('objQuestion', $objQuestion);
  516. Session::write('objAnswer', $objAnswer);