question_pool.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Question Pool
  5. * This script allows administrators to manage questions and add them into their exercises.
  6. * One question can be in several exercises
  7. * @package chamilo.exercise
  8. * @author Olivier Brouckaert
  9. * @author Julio Montoya adding support to query all questions from all session, courses, exercises
  10. */
  11. // name of the language file that needs to be included
  12. $language_file='exercice';
  13. require_once 'exercise.class.php';
  14. require_once 'exercise.lib.php';
  15. require_once 'question.class.php';
  16. require_once 'answer.class.php';
  17. require_once '../inc/global.inc.php';
  18. require_once api_get_path(LIBRARY_PATH).'course.lib.php';
  19. require_once api_get_path(LIBRARY_PATH).'sessionmanager.lib.php';
  20. $this_section=SECTION_COURSES;
  21. $is_allowedToEdit=api_is_allowed_to_edit(null,true);
  22. if ( empty ( $delete ) ) {
  23. $delete = intval($_GET['delete']);
  24. }
  25. if ( empty ( $recup ) ) {
  26. $recup = intval($_GET['recup']);
  27. }
  28. if ( empty ( $fromExercise ) ) {
  29. $fromExercise = intval($_GET['fromExercise']);
  30. }
  31. if(isset($_GET['exerciseId'])){
  32. $exerciseId = intval($_GET['exerciseId']);
  33. }
  34. if(isset($_GET['exerciseLevel'])){
  35. $exerciseLevel = intval($_REQUEST['exerciseLevel']);
  36. }
  37. if(isset($_GET['answerType'])){
  38. $answerType = intval($_REQUEST['answerType']);
  39. }
  40. $page = 0;
  41. if(!empty($_GET['page'])){
  42. $page = intval($_GET['page']);
  43. }
  44. $copy_question = 0;
  45. if(!empty($_GET['copy_question'])){
  46. $copy_question = intval($_GET['copy_question']);
  47. }
  48. //only that type of question
  49. if(!empty($_GET['type'])){
  50. $type = intval($_GET['type']);
  51. }
  52. $session_id = intval($_GET['session_id']);
  53. $selected_course = intval($_GET['selected_course']);
  54. // maximum number of questions on a same page
  55. $limitQuestPage=50;
  56. // document path
  57. $documentPath=api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
  58. // picture path
  59. $picturePath=$documentPath.'/images';
  60. if(!($objExcercise instanceOf Exercise) && !empty($fromExercise)) {
  61. $objExercise = new Exercise();
  62. $objExercise->read($fromExercise);
  63. }
  64. if(!($objExcercise instanceOf Exercise) && !empty($exerciseId)) {
  65. $objExercise = new Exercise();
  66. $objExercise->read($exerciseId);
  67. }
  68. if ($is_allowedToEdit) {
  69. //Duplicating a Question
  70. if ($copy_question != 0 && isset($fromExercise)) {
  71. $origin_course_id = intval($_GET['course_id']);
  72. $origin_course_info = api_get_course_info_by_id($origin_course_id);
  73. $current_course = api_get_course_info();
  74. $old_question_id = $copy_question;
  75. //Reading the source question
  76. $old_question_obj = Question::read($old_question_id, $origin_course_id);
  77. $old_question_obj->updateTitle($old_question_obj->selectTitle().' - '.get_lang('Copy'));
  78. //Duplicating the source question, in the current course
  79. $new_id = $old_question_obj->duplicate($current_course);
  80. //Reading new question
  81. $new_question_obj = Question::read($new_id);
  82. $new_question_obj->addToList($fromExercise);
  83. //Reading Answers obj of the current course
  84. $new_answer_obj = new Answer($old_question_id, $origin_course_id);
  85. $new_answer_obj->read();
  86. //Duplicating the Answers in the current course
  87. $new_answer_obj->duplicate($new_id, $current_course);
  88. // destruction of the Question object
  89. unset($new_question_obj);
  90. unset($old_question_obj);
  91. if(!$objExcercise instanceOf Exercise) {
  92. $objExercise = new Exercise();
  93. $objExercise->read($fromExercise);
  94. }
  95. // adds the question ID represented by $recup into the list of questions for the current exercise
  96. //$objExercise->addToList($new_id);
  97. api_session_register('objExercise');
  98. header("Location: admin.php?".api_get_cidreq()."&exerciseId=$fromExercise");
  99. exit();
  100. }
  101. // deletes a question from the data base and all exercises
  102. if($delete) {
  103. // construction of the Question object
  104. // if the question exists
  105. if($objQuestionTmp = Question::read($delete))
  106. {
  107. // deletes the question from all exercises
  108. $objQuestionTmp->delete();
  109. }
  110. // destruction of the Question object
  111. unset($objQuestionTmp);
  112. } elseif($recup && $fromExercise) {
  113. // gets an existing question and copies it into a new exercise
  114. $objQuestionTmp = Question :: read($recup);
  115. // if the question exists
  116. if($objQuestionTmp = Question :: read($recup)) {
  117. // adds the exercise ID represented by $fromExercise into the list of exercises for the current question
  118. $objQuestionTmp->addToList($fromExercise);
  119. }
  120. // destruction of the Question object
  121. unset($objQuestionTmp);
  122. if(!$objExcercise instanceOf Exercise) {
  123. $objExercise = new Exercise();
  124. $objExercise->read($fromExercise);
  125. }
  126. // adds the question ID represented by $recup into the list of questions for the current exercise
  127. $objExercise->addToList($recup);
  128. api_session_register('objExercise');
  129. header("Location: admin.php?".api_get_cidreq()."&exerciseId=$fromExercise");
  130. exit();
  131. } else if( isset($_POST['recup']) && is_array($_POST['recup']) && $fromExercise) {
  132. $list_recup = $_POST['recup'];
  133. foreach ($list_recup as $recup) {
  134. $recup = intval($recup);
  135. // if the question exists
  136. if($objQuestionTmp = Question :: read($recup)) {
  137. // adds the exercise ID represented by $fromExercise into the list of exercises for the current question
  138. $objQuestionTmp->addToList($fromExercise);
  139. }
  140. // destruction of the Question object
  141. unset($objQuestionTmp);
  142. if(!$objExcercise instanceOf Exercise) {
  143. $objExercise = new Exercise();
  144. $objExercise->read($fromExercise);
  145. }
  146. // adds the question ID represented by $recup into the list of questions for the current exercise
  147. $objExercise->addToList($recup);
  148. }
  149. api_session_register('objExercise');
  150. header("Location: admin.php?".api_get_cidreq()."&exerciseId=$fromExercise");
  151. exit();
  152. }
  153. }
  154. if (isset($_SESSION['gradebook'])){
  155. $gradebook= $_SESSION['gradebook'];
  156. }
  157. if (!empty($gradebook) && $gradebook=='view') {
  158. $interbreadcrumb[]= array ('url' => '../gradebook/'.Security::remove_XSS($_SESSION['gradebook_dest']),'name' => get_lang('ToolGradebook'));
  159. }
  160. $nameTools=get_lang('QuestionPool');
  161. $interbreadcrumb[]=array("url" => "exercice.php","name" => get_lang('Exercices'));
  162. // if admin of course
  163. if (!$is_allowedToEdit) {
  164. api_not_allowed(true);
  165. }
  166. $htmlHeadXtra[] = ' <script type="text/javascript">
  167. function submit_form(obj) {
  168. document.question_pool.submit();
  169. }
  170. </script>';
  171. Display::display_header($nameTools,'Exercise');
  172. // Menu
  173. echo '<div class="actions">';
  174. if (isset($type)) {
  175. $url = api_get_self().'?type=1';
  176. } else {
  177. $url = api_get_self();
  178. }
  179. echo '<a href="admin.php?'.api_get_cidreq().'&exerciseId='.$fromExercise.'">'.Display::return_icon('back.png', get_lang('GoBackToQuestionList'),'','32').'</a>';
  180. echo '</div>';
  181. //Title
  182. echo '<h2>'.$nameTools.'</h2>';
  183. //Form
  184. echo '<form name="question_pool" method="GET" action="'.$url.'">';
  185. if (isset($type)) {
  186. echo '<input type="hidden" name="type" value="1">';
  187. }
  188. echo '<input type="hidden" name="fromExercise" value="'.$fromExercise.'">';
  189. //Session list
  190. $session_list = SessionManager::get_sessions_by_coach(api_get_user_id());
  191. $session_select_list = array();
  192. foreach($session_list as $item) {
  193. $session_select_list[$item['id']] = $item['name'];
  194. }
  195. $select_session_html = Display::select('session_id', $session_select_list, $session_id, array('onchange'=>'submit_form(this);'));
  196. echo Display::form_row(get_lang('Session'), $select_session_html);
  197. //Course list
  198. if (!empty($session_id) && $session_id != '-1') {
  199. $course_list = SessionManager::get_course_list_by_session_id($session_id);
  200. } else {
  201. $course_list = CourseManager::get_course_list_of_user_as_course_admin(api_get_user_id());
  202. }
  203. $course_select_list = array();
  204. foreach ($course_list as $item) {
  205. $course_select_list[$item['id']] = $item['title'];
  206. }
  207. $select_course_html = Display::select('selected_course', $course_select_list, $selected_course, array('onchange'=>'submit_form(this);'));
  208. echo Display::form_row(get_lang('Course'), $select_course_html);
  209. if (empty($selected_course) || $selected_course == '-1') {
  210. $course_info = api_get_course_info();
  211. $db_name = $course_info['db_name'];
  212. } else {
  213. $course_info = CourseManager::get_course_information_by_id($selected_course);
  214. $db_name = $course_info['db_name'];
  215. }
  216. //Redefining table calls
  217. $TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION, $db_name);
  218. $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST, $db_name);
  219. $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION, $db_name);
  220. $TBL_REPONSES = Database::get_course_table(TABLE_QUIZ_ANSWER, $db_name);
  221. $exercise_list = get_all_exercises($course_info, $session_id);
  222. echo '<input type="hidden" name="fromExercise" value="'.$fromExercise.'">';
  223. //Exercise List
  224. $my_exercise_list = array();
  225. $my_exercise_list['0'] = get_lang('AllExercises');
  226. $my_exercise_list['-1'] = get_lang('OrphanQuestions');
  227. if (is_array($exercise_list)) {
  228. foreach($exercise_list as $row) {
  229. if ($row['id'] != $fromExercise) {
  230. $my_exercise_list[$row['id']] = $row['title'];
  231. }
  232. }
  233. }
  234. $select_exercise_html = Display::select('exerciseId', $my_exercise_list, $exerciseId, array('onchange'=>'submit_form(this);'), false);
  235. echo Display::form_row(get_lang('Exercise'), $select_exercise_html);
  236. //Difficulty list (only from 0 to 5)
  237. $select_difficulty_html = Display::select('exerciseLevel', array(0=>0, 1=>1,2=>2,3=>3,4=>4,5=>5), $exerciseLevel, array('onchange'=>'submit_form(this);'));
  238. echo Display::form_row(get_lang('Difficulty'), $select_difficulty_html);
  239. $question_list = Question::get_types_information();
  240. $new_question_list = array();
  241. foreach($question_list as $key=>$item) {
  242. $new_question_list[$key] = get_lang($item[1]);
  243. }
  244. //Answer type list
  245. $select_answer_html = Display::select('answerType', $new_question_list, $answerType, array('onchange'=>'submit_form(this);'));
  246. echo Display::form_row(get_lang('AnswerType'), $select_answer_html);
  247. $button = '<button class="save" type="submit" name="name" value="'.get_lang('Filter').'">'.get_lang('Filter').'</button>';
  248. echo Display::form_row('', $button);
  249. ?>
  250. </form>
  251. <div class="clear"></div>
  252. <form method="post" action="<?php echo $url.'?'.api_get_cidreq().'&fromExercise='.$fromExercise; ?>" >
  253. <?php
  254. echo '<table class="data_table">';
  255. $from=$page*$limitQuestPage;
  256. // if we have selected an exercise in the list-box 'Filter'
  257. if ($exerciseId > 0) {
  258. //$sql="SELECT id,question,type FROM $TBL_EXERCICE_QUESTION,$TBL_QUESTIONS WHERE question_id=id AND exercice_id='".Database::escape_string($exerciseId)."' ORDER BY question_order LIMIT $from, ".($limitQuestPage + 1);
  259. $where = '';
  260. if (isset($type) && $type==1) {
  261. $where = ' type = 1 AND ';
  262. }
  263. if (isset($exerciseLevel) && $exerciseLevel != -1) {
  264. $where .= ' level='.$exerciseLevel.' AND ';
  265. }
  266. if (isset($answerType) && $answerType != -1) {
  267. $where .= ' type='.$answerType.' AND ';
  268. }
  269. $sql="SELECT id,question,type,level
  270. FROM $TBL_EXERCICE_QUESTION,$TBL_QUESTIONS
  271. WHERE $where question_id=id AND exercice_id='".Database::escape_string($exerciseId)."'
  272. ORDER BY question_order";
  273. $result=Database::query($sql);
  274. while($row = Database::fetch_array($result, 'ASSOC')) {
  275. $main_question_list[] = $row;
  276. }
  277. } elseif($exerciseId == -1) {
  278. // if we have selected the option 'Orphan questions' in the list-box 'Filter'
  279. // 1. Old logic: When a test is deleted, the correspondent records in 'quiz' and 'quiz_rel_question' tables are deleted.
  280. //$sql='SELECT id, question, type, exercice_id FROM '.$TBL_QUESTIONS.' as questions LEFT JOIN '.$TBL_EXERCICE_QUESTION.' as quizz_questions ON questions.id=quizz_questions.question_id WHERE exercice_id IS NULL LIMIT $from, '.($limitQuestPage + 1);
  281. // 2. New logic: When a test is deleted, the field 'active' takes value -1 (it is in the correspondent record in 'quiz' table).
  282. //$sql='SELECT questions.id, questions.question, questions.type, quizz_questions.exercice_id FROM '.$TBL_QUESTIONS.
  283. // ' as questions LEFT JOIN '.$TBL_EXERCICE_QUESTION.' as quizz_questions ON questions.id=quizz_questions.question_id LEFT JOIN '.$TBL_EXERCICES.
  284. // ' as exercices ON exercice_id=exercices.id WHERE exercices.active = -1 LIMIT $from, '.($limitQuestPage + 1);
  285. // 3. This is more safe to changes, it is a mix between old and new logic.
  286. /*$sql='SELECT questions.id, questions.question, questions.type, quizz_questions.exercice_id FROM '.$TBL_QUESTIONS.
  287. ' as questions LEFT JOIN '.$TBL_EXERCICE_QUESTION.' as quizz_questions ON questions.id=quizz_questions.question_id LEFT JOIN '.$TBL_EXERCICES.
  288. ' as exercices ON exercice_id=exercices.id WHERE quizz_questions.exercice_id IS NULL OR exercices.active = -1 LIMIT '.$from.', '.($limitQuestPage + 1);
  289. */
  290. /* 4. Query changed because of the Level feature implemented
  291. $sql='SELECT id, question, type, exercice_id,level FROM '.$TBL_QUESTIONS.' as questions LEFT JOIN '.$TBL_EXERCICE_QUESTION.' as quizz_questions
  292. ON questions.id=quizz_questions.question_id AND exercice_id IS NULL '.
  293. (!is_null($exerciseLevel) && $exerciseLevel >= 0 ? 'WHERE level=\''.$exerciseLevel.'\' ' : '');
  294. */
  295. // 5. this is the combination of the 3 and 4 query because of the level feature implementation
  296. // we filter the type of question, because in the DirectFeedback we can only add questions with type=1 = UNIQUE_ANSWER
  297. $type_where= '';
  298. if (isset($type) && $type==1) {
  299. $type_where = ' AND questions.type = 1 ';
  300. }
  301. $level_where = '';
  302. if (isset($exerciseLevel) && $exerciseLevel!= -1 ) {
  303. $level_where = ' level='.$exerciseLevel.' AND ';
  304. }
  305. $answer_where = '';
  306. if (isset($answerType) && $answerType!= -1 ) {
  307. $answer_where = ' questions.type='.$answerType.' AND ';
  308. }
  309. $sql='SELECT questions.id, questions.question, questions.type, quizz_questions.exercice_id , level, session_id
  310. FROM '.$TBL_QUESTIONS.' as questions LEFT JOIN '.$TBL_EXERCICE_QUESTION.' as quizz_questions
  311. ON questions.id=quizz_questions.question_id LEFT JOIN '.$TBL_EXERCICES.' as exercices
  312. ON exercice_id=exercices.id
  313. WHERE '.$answer_where.' '.$level_where.' (quizz_questions.exercice_id IS NULL OR exercices.active = -1 ) '.$type_where.'
  314. LIMIT '.$from.', '.($limitQuestPage + 1);
  315. $result = Database::query($sql);
  316. while($row = Database::fetch_array($result, 'ASSOC')) {
  317. $main_question_list[] = $row;
  318. }
  319. } else {
  320. // if we have not selected any option in the list-box 'Filter'
  321. //$sql="SELECT id,question,type FROM $TBL_QUESTIONS LIMIT $from, ".($limitQuestPage + 1);
  322. $filter = '';
  323. if (isset($type) && $type==1){
  324. $filter .= ' AND qu.type = 1 ';
  325. }
  326. if (isset($exerciseLevel) && $exerciseLevel != -1) {
  327. $filter .= ' AND level='.$exerciseLevel.' ';
  328. }
  329. if (isset($answerType) && $answerType != -1) {
  330. $filter .= ' AND qu.type='.$answerType.' ';
  331. }
  332. $new_limit_page = $limitQuestPage + 1;
  333. if ($session_id != 0) {
  334. $main_question_list = array();
  335. if (!empty($course_list))
  336. foreach ($course_list as $course_item) {
  337. if (!empty($selected_course) && $selected_course != '-1') {
  338. if ($selected_course != $course_item['id']) {
  339. continue;
  340. }
  341. }
  342. $exercise_list = get_all_exercises($course_item, $session_id);
  343. if (!empty($exercise_list)) {
  344. foreach ($exercise_list as $exercise) {
  345. $my_exercise = new Exercise($course_item['id']);
  346. $my_exercise->read($exercise['id']);
  347. if (!empty($my_exercise)) {
  348. if (!empty($my_exercise->questionList)) {
  349. foreach ($my_exercise->questionList as $question_id) {
  350. $question_obj = Question::read($question_id, $course_item['id']);
  351. if ($exerciseLevel != '-1')
  352. if ($exerciseLevel != $question_obj->level) {
  353. continue;
  354. }
  355. if ($answerType != '-1')
  356. if ($answerType != $question_obj->type) {
  357. continue;
  358. }
  359. $question_row = array('id'=>$question_obj->id, 'question'=>$question_obj->question, 'type'=>$question_obj->type, 'level'=>$question_obj->level, 'exercise_id'=>$exercise['id']);
  360. $main_question_list[] = $question_row;
  361. }
  362. }
  363. }
  364. }
  365. }
  366. }
  367. } else {
  368. //By default
  369. $sql="SELECT qu.id, question, qu.type, level, q.session_id FROM $TBL_QUESTIONS as qu, $TBL_EXERCICE_QUESTION as qt, $TBL_EXERCICES as q
  370. WHERE q.id=qt.exercice_id AND qu.id=qt.question_id AND qt.exercice_id<>".$fromExercise." $filter ORDER BY session_id ASC LIMIT $from, $new_limit_page";
  371. }
  372. // forces the value to 0
  373. $exerciseId=0;
  374. }
  375. $result=Database::query($sql);
  376. $nbrQuestions=count($main_question_list);
  377. echo '<tr>',
  378. '<td colspan="',($fromExercise?4:4),'">',
  379. '<table border="0" cellpadding="0" cellspacing="0" width="100%">',
  380. '<tr>',
  381. '<td>';
  382. echo '</td>',
  383. '<td align="right">';
  384. if(!empty($page)) {
  385. echo '<a href="',api_get_self(),'?',api_get_cidreq(),'&exerciseId=',$exerciseId,'&fromExercise=',$fromExercise,'&page=',($page-1),'&answerType=',$answerType,'&exerciseLevel='.$exerciseLevel.'">';
  386. echo Display::return_icon('action_prev.png');
  387. echo '&nbsp;'.get_lang('PreviousPage'),'</a> | ';
  388. } elseif($nbrQuestions > $limitQuestPage) {
  389. echo Display::return_icon('action_prev_na.png');
  390. echo '&nbsp;'.get_lang('PreviousPage'),' | ';
  391. }
  392. if($nbrQuestions > $limitQuestPage) {
  393. echo '<a href="',api_get_self(),'?',api_get_cidreq(),'&exerciseId=',$exerciseId,'&fromExercise=',$fromExercise,'&page=',($page+1),'&answerType=',$answerType,'&exerciseLevel='.$exerciseLevel.'">',get_lang('NextPage').'&nbsp;';
  394. echo Display::return_icon('action_next.png');
  395. echo '</a>';
  396. } elseif($page) {
  397. echo get_lang('NextPage');
  398. echo '&nbsp;'.Display::return_icon('action_next_na.png');
  399. }
  400. echo '</td>
  401. </tr>
  402. </table>
  403. </td>
  404. </tr>
  405. <tr bgcolor="#e6e6e6">';
  406. if(!empty($fromExercise)) {
  407. if (api_get_session_id() == 0 ){
  408. echo '<th width="4%"> </th>';
  409. }
  410. echo '<th>',get_lang('Question'),'</th>',
  411. '<th>',get_lang('Level'),'</th>',
  412. '<th>',get_lang('Reuse'),'</th>';
  413. } else {
  414. echo '<td width="60%" align="center">',get_lang('Question'),'</td>',
  415. '<td width="20%" align="center">',get_lang('Modify'),'</td>',
  416. '<td width="16%" align="center">',get_lang('Delete'),'</td>';
  417. }
  418. echo '</tr>';
  419. $i=1;
  420. $session_id = api_get_session_id();
  421. if (!empty($main_question_list))
  422. foreach ($main_question_list as $row) {
  423. // if we come from the exercise administration to get a question,
  424. // don't show the questions already used by that exercise
  425. /*if (!$fromExercise) {echo '1'; }
  426. if (!isset($objExercise)){echo '2';}
  427. if (!($objExercise instanceOf Exercise)){echo '3';}
  428. if (!$objExercise->isInList($row['id'])) {echo '4';}
  429. */
  430. // original recipe -
  431. //if (!$fromExercise || !isset($objExercise) || !($objExercise instanceOf Exercise) || (!$objExercise->isInList($row['id'])))
  432. if (!$fromExercise || !isset($objExercise) || !($objExercise instanceOf Exercise) || (is_array($objExercise->questionList)) ) {
  433. echo '<tr ',($i%2==0?'class="row_odd"':'class="row_even"'),'>';
  434. if (api_get_session_id() == 0 ){
  435. echo '<td align="center"> <input type="checkbox" value="'.$row['id'].'" name="recup[]"/></td>';
  436. }
  437. echo ' <td><a href="admin.php?',api_get_cidreq(),'&editQuestion=',$row['id'],'&fromExercise='.$fromExercise.'&answerType='.$row['type'].'">',$row['question'],'</a></td>';
  438. echo ' <td align="center" >';
  439. if (empty($fromExercise)) {
  440. echo '<a href="admin.php?'.api_get_cidreq().'&amp;editQuestion=',$row['id'],'"><img src="../img/edit.gif" border="0" alt="',get_lang('Modify'),'"></a>',
  441. '</td>',
  442. '<td align="center">',
  443. '<a href="',api_get_self(),'?',api_get_cidreq(),'&exerciseId=',$exerciseId,'&delete=',$row['id'],'" onclick="javascript:if(!confirm(\'',addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)),'\')) return false;"><img src="../img/delete.gif" border="0" alt="',get_lang('Delete'),'"></a>';
  444. //'<a href="',api_get_self(),'?',api_get_cidreq(),'&exerciseId=',$exerciseId,'&delete=',$row['id'],'" onclick="javascript:if(!confirm(\'',addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)),'\')) return false;"><img src="../img/delete.gif" border="0" alt="',get_lang('Delete'),'"></a>';
  445. } else {
  446. echo $row['level'],'</td>',
  447. '<td align="center">';
  448. echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;copy_question='.$row['id'].'&course_id='.$selected_course.'&fromExercise=',$fromExercise,'">';
  449. echo ' '.Display::return_icon('cd.gif', get_lang('ReUseACopyInCurrentTest'));
  450. echo '</a> ';
  451. if ($row['session_id'] == $session_id) {
  452. if ($selected_course == api_get_course_int_id()) {
  453. echo '<a href="',api_get_self(),'?',api_get_cidreq(),'&recup=',$row['id'],'&fromExercise=',$fromExercise,'"><img src="../img/view_more_stats.gif" border="0" title="'.get_lang('InsertALinkToThisQuestionInTheExercise').'" alt="'.get_lang('InsertALinkToThisQuestionInTheExercise').'"></a>';
  454. }
  455. }
  456. }
  457. echo '</td>';
  458. echo '</tr>';
  459. // skips the last question, that is only used to know if we have or not to create a link "Next page"
  460. if($i == $limitQuestPage) {
  461. break;
  462. }
  463. $i++;
  464. }
  465. }
  466. if (!$nbrQuestions) {
  467. echo '<tr>',
  468. '<td colspan="',($fromExercise?4:4),'">',get_lang('NoQuestion'),'</td>',
  469. '</tr>';
  470. }
  471. echo '</table>';
  472. if (api_get_session_id() == 0 ){
  473. echo '<div style="width:100%; border-top:1px dotted #4171B5;">
  474. <button class="save" type="submit">'.get_lang('Reuse').'</button>
  475. </div></form>';
  476. }
  477. Display::display_footer();