upload_exercise.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use \ChamiloSession as Session;
  4. /**
  5. * Upload quiz: This script shows the upload quiz feature
  6. * Initial work by Isaac flores on Nov 4 of 2010
  7. * Encoding fixes Julio Montoya
  8. * @package chamilo.exercise
  9. */
  10. // setting the help
  11. $help_content = 'exercise_upload';
  12. require_once '../inc/global.inc.php';
  13. require_once api_get_path(LIBRARY_PATH) . 'pear/excelreader/reader.php';
  14. // Security check
  15. $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
  16. if (!$is_allowed_to_edit) {
  17. api_not_allowed(true);
  18. }
  19. // setting the tabs
  20. $this_section = SECTION_COURSES;
  21. $htmlHeadXtra[] = "<script>
  22. $(document).ready( function(){
  23. $('#user_custom_score').click(function() {
  24. $('#options').toggle();
  25. });
  26. });
  27. </script>";
  28. // Action handling
  29. lp_upload_quiz_action_handling();
  30. $interbreadcrumb[] = array(
  31. "url" => "exercise.php?".api_get_cidreq(),
  32. "name" => get_lang('Exercises'),
  33. );
  34. // Display the header
  35. Display :: display_header(get_lang('ImportExcelQuiz'), 'Exercises');
  36. if (isset($_GET['message'])) {
  37. if (in_array($_GET['message'], array('ExerciseEdited'))) {
  38. Display :: display_confirmation_message(get_lang($_GET['message']));
  39. }
  40. }
  41. // display the actions
  42. echo '<div class="actions">';
  43. echo lp_upload_quiz_actions();
  44. echo '</div>';
  45. // the main content
  46. lp_upload_quiz_main();
  47. function lp_upload_quiz_actions()
  48. {
  49. $return = '<a href="exercise.php?'.api_get_cidreq().'">'.
  50. Display::return_icon('back.png', get_lang('BackToExercisesList'),'',ICON_SIZE_MEDIUM).'</a>';
  51. return $return;
  52. }
  53. function lp_upload_quiz_secondary_actions()
  54. {
  55. $return = '<a href="exercise_report.php?' . api_get_cidreq() . '">' .
  56. Display :: return_icon('reporting32.png', get_lang('Tracking')) . get_lang('Tracking') . '</a>';
  57. return $return;
  58. }
  59. function lp_upload_quiz_main()
  60. {
  61. // variable initialisation
  62. $lp_id = isset($_GET['lp_id']) ? intval($_GET['lp_id']) : null;
  63. $form = new FormValidator(
  64. 'upload',
  65. 'POST',
  66. api_get_self().'?'.api_get_cidreq().'&lp_id='.$lp_id,
  67. '',
  68. array('enctype' => 'multipart/form-data')
  69. );
  70. $form->addElement('header', get_lang('ImportExcelQuiz'));
  71. $form->addElement('file', 'user_upload_quiz', get_lang('FileUpload'));
  72. $link = '<a href="../exercise/quiz_template.xls">'.
  73. Display::return_icon('export_excel.png', get_lang('DownloadExcelTemplate')).get_lang('DownloadExcelTemplate').'</a>';
  74. $form->addElement('label', '', $link);
  75. $table = new HTML_Table(array('class' => 'table'));
  76. $tableList = array(
  77. UNIQUE_ANSWER => get_lang('UniqueSelect'),
  78. MULTIPLE_ANSWER => get_lang('MultipleSelect'),
  79. FILL_IN_BLANKS => get_lang('FillBlanks'),
  80. MATCHING => get_lang('Matching'),
  81. FREE_ANSWER => get_lang('FreeAnswer'),
  82. GLOBAL_MULTIPLE_ANSWER => get_lang('GlobalMultipleAnswer')
  83. );
  84. $table->setHeaderContents(0, 0, get_lang('QuestionType'));
  85. $table->setHeaderContents(0, 1, '#');
  86. $row = 1;
  87. foreach ($tableList as $key => $label ) {
  88. $table->setCellContents($row, 0, $label);
  89. $table->setCellContents($row, 1, $key);
  90. $row++;
  91. }
  92. $table = $table->toHtml();
  93. $form->addElement('label', get_lang('QuestionType'), $table);
  94. $form->addElement(
  95. 'checkbox',
  96. 'user_custom_score',
  97. null,
  98. get_lang('UseCustomScoreForAllQuestions'),
  99. array('id' => 'user_custom_score')
  100. );
  101. $form->addElement('html', '<div id="options" style="display:none">');
  102. $form->addElement('text', 'correct_score', get_lang('CorrectScore'));
  103. $form->addElement('text', 'incorrect_score', get_lang('IncorrectScore'));
  104. $form->addElement('html', '</div>');
  105. $form->addRule('user_upload_quiz', get_lang('ThisFieldIsRequired'), 'required');
  106. $form->add_progress_bar();
  107. $form->addButtonUpload(get_lang('Upload'), 'submit_upload_quiz');
  108. // Display the upload field
  109. $form->display();
  110. }
  111. /**
  112. * Handles a given Excel spreadsheets as in the template provided
  113. */
  114. function lp_upload_quiz_action_handling()
  115. {
  116. global $debug;
  117. $_course = api_get_course_info();
  118. $courseId = $_course['real_id'];
  119. if (!isset($_POST['submit_upload_quiz'])) {
  120. return;
  121. }
  122. // Get the extension of the document.
  123. $path_info = pathinfo($_FILES['user_upload_quiz']['name']);
  124. // Check if the document is an Excel document
  125. if ($path_info['extension'] != 'xls') {
  126. return;
  127. }
  128. // Read the Excel document
  129. $data = new Spreadsheet_Excel_Reader();
  130. // Set output Encoding.
  131. $data->setOutputEncoding(api_get_system_encoding());
  132. // Reading the xls document.
  133. $data->read($_FILES['user_upload_quiz']['tmp_name']);
  134. $correctScore = isset($_POST['correct_score']) ? $_POST['correct_score'] : null;
  135. $incorrectScore = isset($_POST['incorrect_score']) ? $_POST['incorrect_score'] : null;
  136. $useCustomScore = isset($_POST['user_custom_score']) ? true : false;
  137. $propagateNegative = 0;
  138. if ($useCustomScore && !empty($incorrectScore)) {
  139. if ($incorrectScore < 0) {
  140. $propagateNegative = 1;
  141. }
  142. }
  143. // Variables
  144. $quiz_index = 0;
  145. $question_title_index = array();
  146. $question_name_index_init = array();
  147. $question_name_index_end = array();
  148. $score_index = array();
  149. $feedback_true_index = array();
  150. $feedback_false_index = array();
  151. $number_questions = 0;
  152. $question_description_index = array();
  153. $noNegativeScoreIndex = array();
  154. $questionTypeList = array();
  155. $questionTypeIndex = array();
  156. $categoryList = array();
  157. // Reading all the first column items sequentially to create breakpoints
  158. for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++) {
  159. if ($data->sheets[0]['cells'][$i][1] == 'Quiz' && $i == 1) {
  160. $quiz_index = $i; // Quiz title position, only occurs once
  161. } elseif ($data->sheets[0]['cells'][$i][1] == 'Question') {
  162. $question_title_index[] = $i; // Question title position line
  163. $question_name_index_init[] = $i + 1; // Questions name 1st position line
  164. $number_questions++;
  165. } elseif ($data->sheets[0]['cells'][$i][1] == 'Score') {
  166. $question_name_index_end[] = $i - 1; // Question name position
  167. $score_index[] = $i; // Question score position
  168. } elseif ($data->sheets[0]['cells'][$i][1] == 'FeedbackTrue') {
  169. $feedback_true_index[] = $i; // FeedbackTrue position (line)
  170. } elseif ($data->sheets[0]['cells'][$i][1] == 'FeedbackFalse') {
  171. $feedback_false_index[] = $i; // FeedbackFalse position (line)
  172. } elseif ($data->sheets[0]['cells'][$i][1] == 'EnrichQuestion') {
  173. $question_description_index[] = $i;
  174. } elseif ($data->sheets[0]['cells'][$i][1] == 'NoNegativeScore') {
  175. $noNegativeScoreIndex[] = $i;
  176. } elseif ($data->sheets[0]['cells'][$i][1] == 'QuestionType') {
  177. $questionTypeIndex[] = $i;
  178. }
  179. }
  180. // Variables
  181. $quiz = array();
  182. $question = array();
  183. $new_answer = array();
  184. $score_list = array();
  185. $feedback_true_list = array();
  186. $feedback_false_list = array();
  187. $question_description = array();
  188. $noNegativeScoreList = array();
  189. // Getting questions.
  190. $k = $z = $q = $l = $m = $n = 0;
  191. for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++) {
  192. if (is_array($data->sheets[0]['cells'][$i])) {
  193. $column_data = $data->sheets[0]['cells'][$i];
  194. // Fill all column with data to have a full array
  195. for ($x = 1; $x <= $data->sheets[0]['numCols']; $x++) {
  196. if (empty($column_data[$x])) {
  197. $data->sheets[0]['cells'][$i][$x] = '';
  198. }
  199. }
  200. // Array filled with data
  201. $column_data = $data->sheets[0]['cells'][$i];
  202. } else {
  203. $column_data = '';
  204. }
  205. // Fill quiz data
  206. if ($quiz_index == $i) {
  207. // The title always in the first position
  208. $quiz = $column_data;
  209. } elseif (in_array($i, $question_title_index)) {
  210. //a complete line where 1st column is 'Question'
  211. $question[$k] = $column_data;
  212. for ($counter = 0; $counter < 12; $counter++) {
  213. $myData = isset($data->sheets[0]['cells'][$i + $counter]) ? $data->sheets[0]['cells'][$i + $counter] : null;
  214. if (isset($myData[1]) && $myData[1] == 'QuestionType') {
  215. $questionTypeList[$k] = $myData[3];
  216. }
  217. if (isset($myData[1]) && $myData[1] == 'Category') {
  218. $categoryList[$k] = $myData[2];
  219. }
  220. }
  221. if (!isset($questionTypeList[$k])) {
  222. $questionTypeList[$k] = null;
  223. }
  224. $k++;
  225. } elseif (in_array($i, $score_index)) {
  226. //a complete line where 1st column is 'Score'
  227. $score_list[$z] = $column_data;
  228. $z++;
  229. } elseif (in_array($i, $feedback_true_index)) {
  230. //a complete line where 1st column is 'FeedbackTrue'
  231. $feedback_true_list[$q] = $column_data;
  232. $q++;
  233. } elseif (in_array($i, $feedback_false_index)) {
  234. //a complete line where 1st column is 'FeedbackFalse' for wrong answers
  235. $feedback_false_list[$l] = $column_data;
  236. $l++;
  237. } elseif (in_array($i, $question_description_index)) {
  238. //a complete line where 1st column is 'EnrichQuestion'
  239. $question_description[$m] = $column_data;
  240. $m++;
  241. } elseif (in_array($i, $noNegativeScoreIndex)) {
  242. //a complete line where 1st column is 'NoNegativeScore'
  243. $noNegativeScoreList[$z - 1] = $column_data;
  244. }
  245. }
  246. // Get answers
  247. for ($i = 0; $i < count($question_name_index_init); $i++) {
  248. for ($j = $question_name_index_init[$i]; $j <= $question_name_index_end[$i]; $j++) {
  249. if (is_array($data->sheets[0]['cells'][$j])) {
  250. $column_data = $data->sheets[0]['cells'][$j];
  251. // Fill all column with data
  252. for ($x = 1; $x <= $data->sheets[0]['numCols']; $x++) {
  253. if (empty($column_data[$x])) {
  254. $data->sheets[0]['cells'][$j][$x] = '';
  255. }
  256. }
  257. $column_data = $data->sheets[0]['cells'][$j];
  258. // Array filled of data
  259. if (is_array($column_data) && count($column_data) > 0) {
  260. $new_answer[$i][$j] = $column_data;
  261. }
  262. }
  263. }
  264. }
  265. // Quiz title.
  266. $quiz_title = $quiz[2];
  267. if ($quiz_title != '') {
  268. // Variables
  269. $type = 2;
  270. $random = $active = $results = $max_attempt = $expired_time = 0;
  271. // Make sure feedback is enabled (3 to disable), otherwise the fields
  272. // added to the XLS are not shown, which is confusing
  273. $feedback = 0;
  274. // Quiz object
  275. $exercise = new Exercise();
  276. $quiz_id = $exercise->createExercise(
  277. $quiz_title,
  278. $expired_time,
  279. $type,
  280. $random,
  281. $active,
  282. $results,
  283. $max_attempt,
  284. $feedback,
  285. $propagateNegative
  286. );
  287. if ($quiz_id) {
  288. // insert into the item_property table
  289. api_item_property_update(
  290. $_course,
  291. TOOL_QUIZ,
  292. $quiz_id,
  293. 'QuizAdded',
  294. api_get_user_id()
  295. );
  296. // Import questions.
  297. for ($i = 0; $i < $number_questions; $i++) {
  298. // Question name
  299. $question_title = $question[$i][2];
  300. $description = isset($question_description[$i][2]) ? $question_description[$i][2] : '';
  301. $categoryId = null;
  302. if (isset($categoryList[$i]) && !empty($categoryList[$i])) {
  303. $categoryName = $categoryList[$i];
  304. $categoryId = TestCategory::get_category_id_for_title($categoryName, $courseId);
  305. if (empty($categoryId)) {
  306. $category = new TestCategory(null, $categoryName, '');
  307. $categoryId = $category->addCategoryInBDD();
  308. }
  309. }
  310. $question_description_text = "<p></p>";
  311. if (!empty($description)) {
  312. // Question description.
  313. $question_description_text = "<p>".$description."</p>";
  314. }
  315. // Unique answers are the only question types available for now
  316. // through xls-format import
  317. $answerList = isset($new_answer[$i]) ? $new_answer[$i] : '';
  318. $question_id = null;
  319. if (isset($questionTypeList[$i])) {
  320. $detectQuestionType = intval($questionTypeList[$i]);
  321. } else {
  322. $detectQuestionType = detectQuestionType(
  323. $answerList,
  324. $score_list
  325. );
  326. }
  327. /** @var Question $answer */
  328. switch ($detectQuestionType) {
  329. case FREE_ANSWER:
  330. $answer = new FreeAnswer();
  331. break;
  332. case GLOBAL_MULTIPLE_ANSWER:
  333. $answer = new GlobalMultipleAnswer();
  334. break;
  335. case MULTIPLE_ANSWER:
  336. $answer = new MultipleAnswer();
  337. break;
  338. case FILL_IN_BLANKS:
  339. $answer = new FillBlanks();
  340. $question_description_text = '';
  341. break;
  342. case MATCHING:
  343. $answer = new Matching();
  344. break;
  345. case UNIQUE_ANSWER:
  346. default:
  347. $answer = new UniqueAnswer();
  348. break;
  349. }
  350. if ($question_title != '') {
  351. $question_id = $answer->create_question(
  352. $quiz_id,
  353. $question_title,
  354. $question_description_text,
  355. 0, // max score
  356. $answer->type
  357. );
  358. if (!empty($categoryId)) {
  359. TestCategory::add_category_for_question_id(
  360. $categoryId,
  361. $question_id,
  362. $courseId
  363. );
  364. }
  365. }
  366. switch ($detectQuestionType) {
  367. case GLOBAL_MULTIPLE_ANSWER:
  368. case MULTIPLE_ANSWER:
  369. case UNIQUE_ANSWER:
  370. $total = 0;
  371. if (is_array($answerList) && !empty($question_id)) {
  372. $id = 1;
  373. $objAnswer = new Answer($question_id, $courseId);
  374. $globalScore = $score_list[$i][3];
  375. // Calculate the number of correct answers to divide the
  376. // score between them when importing from CSV
  377. $numberRightAnswers = 0;
  378. foreach ($answerList as $answer_data) {
  379. if (strtolower($answer_data[3]) == 'x') {
  380. $numberRightAnswers++;
  381. }
  382. }
  383. foreach ($answerList as $answer_data) {
  384. $answerValue = $answer_data[2];
  385. $correct = 0;
  386. $score = 0;
  387. if (strtolower($answer_data[3]) == 'x') {
  388. $correct = 1;
  389. $score = $score_list[$i][3];
  390. $comment = $feedback_true_list[$i][2];
  391. } else {
  392. $comment = $feedback_false_list[$i][2];
  393. $floatVal = (float)$answer_data[3];
  394. if (is_numeric($floatVal)) {
  395. $score = $answer_data[3];
  396. }
  397. }
  398. if ($useCustomScore) {
  399. if ($correct) {
  400. $score = $correctScore;
  401. } else {
  402. $score = $incorrectScore;
  403. }
  404. }
  405. // Fixing scores:
  406. switch ($detectQuestionType) {
  407. case GLOBAL_MULTIPLE_ANSWER:
  408. if (isset($noNegativeScoreList[$i][3])) {
  409. if (!(strtolower($noNegativeScoreList[$i][3]) == 'x') &&
  410. !$correct
  411. ) {
  412. $score = $score_list[$i][3] * -1;
  413. }
  414. } else {
  415. $score = $score_list[$i][3] * -1;
  416. }
  417. $score /= $numberRightAnswers;
  418. break;
  419. case UNIQUE_ANSWER:
  420. break;
  421. case MULTIPLE_ANSWER:
  422. if (!$correct) {
  423. //$total = $total - $score;
  424. }
  425. break;
  426. }
  427. $objAnswer->createAnswer(
  428. $answerValue,
  429. $correct,
  430. $comment,
  431. $score,
  432. $id
  433. );
  434. $total += $score;
  435. $id++;
  436. }
  437. $objAnswer->save();
  438. $questionObj = Question::read(
  439. $question_id,
  440. $courseId
  441. );
  442. switch ($detectQuestionType) {
  443. case GLOBAL_MULTIPLE_ANSWER:
  444. $questionObj->updateWeighting($globalScore);
  445. break;
  446. case UNIQUE_ANSWER:
  447. case MULTIPLE_ANSWER:
  448. default:
  449. $questionObj->updateWeighting($total);
  450. break;
  451. }
  452. $questionObj->save();
  453. }
  454. break;
  455. case FREE_ANSWER:
  456. $questionObj = Question::read($question_id, $courseId);
  457. $globalScore = $score_list[$i][3];
  458. $questionObj->updateWeighting($globalScore);
  459. $questionObj->save();
  460. break;
  461. case FILL_IN_BLANKS:
  462. $scoreList = array();
  463. $size = array();
  464. $globalScore = 0;
  465. foreach ($answerList as $data) {
  466. $score = isset($data[3]) ? $data[3] : 0;
  467. $globalScore += $score;
  468. $scoreList[] = $score;
  469. $size[] = 200;
  470. }
  471. $scoreToString = implode(',', $scoreList);
  472. $sizeToString = implode(',', $size);
  473. //<p>Texte long avec les [mots] à [remplir] mis entre [crochets]</p>::10,10,10:200.36363999999998,200,200:0@'
  474. $answerValue = $description.'::'.$scoreToString.':'.$sizeToString.':0@';
  475. $objAnswer = new Answer($question_id, $courseId);
  476. $objAnswer->createAnswer(
  477. $answerValue,
  478. '', //$correct,
  479. '', //$comment,
  480. $globalScore,
  481. 1
  482. );
  483. $objAnswer->save();
  484. $questionObj = Question::read($question_id, $courseId);
  485. $questionObj->updateWeighting($globalScore);
  486. $questionObj->save();
  487. break;
  488. case MATCHING:
  489. $globalScore = $score_list[$i][3];
  490. $position = 1;
  491. $objAnswer = new Answer($question_id, $courseId);
  492. foreach ($answerList as $data) {
  493. $option = isset($data[3]) ? $data[3] : '';
  494. $objAnswer->createAnswer($option, 0, '', 0, $position);
  495. $position++;
  496. }
  497. $counter = 1;
  498. foreach ($answerList as $data) {
  499. $value = isset($data[2]) ? $data[2] : '';
  500. $position++;
  501. $objAnswer->createAnswer(
  502. $value,
  503. $counter,
  504. ' ',
  505. $globalScore,
  506. $position
  507. );
  508. $counter++;
  509. }
  510. $objAnswer->save();
  511. $questionObj = Question::read($question_id, $courseId);
  512. $questionObj->updateWeighting($globalScore);
  513. $questionObj->save();
  514. break;
  515. }
  516. }
  517. }
  518. if (isset($_SESSION['lpobject'])) {
  519. if ($debug > 0) {
  520. error_log('New LP - SESSION[lpobject] is defined', 0);
  521. }
  522. $oLP = unserialize($_SESSION['lpobject']);
  523. if (is_object($oLP)) {
  524. if ($debug > 0) {
  525. error_log('New LP - oLP is object', 0);
  526. }
  527. if ((empty($oLP->cc)) OR $oLP->cc != api_get_course_id()) {
  528. if ($debug > 0) {
  529. error_log('New LP - Course has changed, discard lp object', 0);
  530. }
  531. $oLP = null;
  532. Session::erase('oLP');
  533. Session::erase('lpobject');
  534. } else {
  535. $_SESSION['oLP'] = $oLP;
  536. }
  537. }
  538. }
  539. if (isset($_SESSION['oLP']) && isset($_GET['lp_id'])) {
  540. $previous = $_SESSION['oLP']->select_previous_item_id();
  541. $parent = 0;
  542. // Add a Quiz as Lp Item
  543. $_SESSION['oLP']->add_item($parent, $previous, TOOL_QUIZ, $quiz_id, $quiz_title, '');
  544. // Redirect to home page for add more content
  545. header('location: ../lp/lp_controller.php?'.api_get_cidreq().'&action=add_item&type=step&lp_id='.intval($_GET['lp_id']));
  546. exit;
  547. } else {
  548. // header('location: exercise.php?' . api_get_cidreq());
  549. echo '<script>window.location.href = "'.api_get_path(WEB_CODE_PATH).'exercise/admin.php?'.api_get_cidreq().'&exerciseId='.$quiz_id.'&session_id='.api_get_session_id().'"</script>';
  550. }
  551. }
  552. }
  553. /**
  554. * @param array $answers_data
  555. * @return int
  556. */
  557. function detectQuestionType($answers_data)
  558. {
  559. $correct = 0;
  560. $isNumeric = false;
  561. if (empty($answers_data)) {
  562. return FREE_ANSWER;
  563. }
  564. foreach ($answers_data as $answer_data) {
  565. if (strtolower($answer_data[3]) == 'x') {
  566. $correct++;
  567. } else {
  568. if (is_numeric($answer_data[3])) {
  569. $isNumeric = true;
  570. }
  571. }
  572. }
  573. if ($correct == 1) {
  574. $type = UNIQUE_ANSWER;
  575. } else {
  576. if ($correct > 1) {
  577. $type = MULTIPLE_ANSWER;
  578. } else {
  579. $type = FREE_ANSWER;
  580. }
  581. }
  582. if ($type == MULTIPLE_ANSWER) {
  583. if ($isNumeric) {
  584. $type = MULTIPLE_ANSWER;
  585. } else {
  586. $type = GLOBAL_MULTIPLE_ANSWER;
  587. }
  588. }
  589. return $type;
  590. }
  591. if (!isset($origin) || isset($origin) && $origin != 'learnpath') {
  592. //so we are not in learnpath tool
  593. Display :: display_footer();
  594. }