upload_exercise.php 25 KB

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