question_pool.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  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. /**
  12. * Code
  13. */
  14. // name of the language file that needs to be included
  15. $language_file='exercice';
  16. require_once 'exercise.class.php';
  17. require_once 'exercise.lib.php';
  18. require_once 'question.class.php';
  19. require_once 'answer.class.php';
  20. require_once '../inc/global.inc.php';
  21. require_once api_get_path(LIBRARY_PATH).'course.lib.php';
  22. require_once api_get_path(LIBRARY_PATH).'sessionmanager.lib.php';
  23. $this_section=SECTION_COURSES;
  24. $is_allowedToEdit=api_is_allowed_to_edit(null,true);
  25. if ( empty ( $delete ) ) {
  26. $delete = intval($_GET['delete']);
  27. }
  28. if ( empty ( $recup ) ) {
  29. $recup = intval($_GET['recup']);
  30. }
  31. if ( empty ( $fromExercise ) ) {
  32. $fromExercise = intval($_GET['fromExercise']);
  33. }
  34. if(isset($_GET['exerciseId'])){
  35. $exerciseId = intval($_GET['exerciseId']);
  36. }
  37. if(isset($_GET['exerciseLevel'])){
  38. $exerciseLevel = intval($_REQUEST['exerciseLevel']);
  39. }
  40. if(isset($_GET['answerType'])){
  41. $answerType = intval($_REQUEST['answerType']);
  42. }
  43. $page = 0;
  44. if(!empty($_GET['page'])){
  45. $page = intval($_GET['page']);
  46. }
  47. $copy_question = 0;
  48. if(!empty($_GET['copy_question'])){
  49. $copy_question = intval($_GET['copy_question']);
  50. }
  51. //only that type of question
  52. if(!empty($_GET['type'])){
  53. $type = intval($_GET['type']);
  54. }
  55. $session_id = intval($_GET['session_id']);
  56. $selected_course = intval($_GET['selected_course']);
  57. // maximum number of questions on a same page
  58. $limitQuestPage=50;
  59. // document path
  60. $documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
  61. // picture path
  62. $picturePath = $documentPath.'/images';
  63. if(!($objExcercise instanceOf Exercise) && !empty($fromExercise)) {
  64. $objExercise = new Exercise();
  65. $objExercise->read($fromExercise);
  66. }
  67. $nameTools = get_lang('QuestionPool');
  68. $interbreadcrumb[] = array("url" => "exercice.php","name" => get_lang('Exercices'));
  69. $interbreadcrumb[] = array("url" => "admin.php?exerciseId=".$objExercise->id, "name" => $objExercise->name);
  70. if ($is_allowedToEdit) {
  71. //Duplicating a Question
  72. if ($copy_question != 0 && isset($fromExercise)) {
  73. $origin_course_id = intval($_GET['course_id']);
  74. $origin_course_info = api_get_course_info_by_id($origin_course_id);
  75. $current_course = api_get_course_info();
  76. $old_question_id = $copy_question;
  77. //Reading the source question
  78. $old_question_obj = Question::read($old_question_id, $origin_course_id);
  79. $old_question_obj->updateTitle($old_question_obj->selectTitle().' - '.get_lang('Copy'));
  80. //Duplicating the source question, in the current course
  81. $new_id = $old_question_obj->duplicate($current_course);
  82. //Reading new question
  83. $new_question_obj = Question::read($new_id);
  84. $new_question_obj->addToList($fromExercise);
  85. //Reading Answers obj of the current course
  86. $new_answer_obj = new Answer($old_question_id, $origin_course_id);
  87. $new_answer_obj->read();
  88. //Duplicating the Answers in the current course
  89. $new_answer_obj->duplicate($new_id, $current_course);
  90. // destruction of the Question object
  91. unset($new_question_obj);
  92. unset($old_question_obj);
  93. if (!$objExcercise instanceOf Exercise) {
  94. $objExercise = new Exercise();
  95. $objExercise->read($fromExercise);
  96. }
  97. // adds the question ID represented by $recup into the list of questions for the current exercise
  98. //$objExercise->addToList($new_id);
  99. api_session_register('objExercise');
  100. header("Location: admin.php?".api_get_cidreq()."&exerciseId=$fromExercise");
  101. exit();
  102. }
  103. // deletes a question from the data base and all exercises
  104. if($delete) {
  105. // construction of the Question object
  106. // if the question exists
  107. if($objQuestionTmp = Question::read($delete))
  108. {
  109. // deletes the question from all exercises
  110. $objQuestionTmp->delete();
  111. }
  112. // destruction of the Question object
  113. unset($objQuestionTmp);
  114. } elseif($recup && $fromExercise) {
  115. // gets an existing question and copies it into a new exercise
  116. $objQuestionTmp = Question :: read($recup);
  117. // if the question exists
  118. if($objQuestionTmp = Question :: read($recup)) {
  119. // adds the exercise ID represented by $fromExercise into the list of exercises for the current question
  120. $objQuestionTmp->addToList($fromExercise);
  121. }
  122. // destruction of the Question object
  123. unset($objQuestionTmp);
  124. if (!$objExcercise instanceOf Exercise) {
  125. $objExercise = new Exercise();
  126. $objExercise->read($fromExercise);
  127. }
  128. // adds the question ID represented by $recup into the list of questions for the current exercise
  129. $objExercise->addToList($recup);
  130. api_session_register('objExercise');
  131. header("Location: admin.php?".api_get_cidreq()."&exerciseId=$fromExercise");
  132. exit();
  133. } else if( isset($_POST['recup']) && is_array($_POST['recup']) && $fromExercise) {
  134. $list_recup = $_POST['recup'];
  135. foreach ($list_recup as $recup) {
  136. $recup = intval($recup);
  137. // if the question exists
  138. if($objQuestionTmp = Question :: read($recup)) {
  139. // adds the exercise ID represented by $fromExercise into the list of exercises for the current question
  140. $objQuestionTmp->addToList($fromExercise);
  141. }
  142. // destruction of the Question object
  143. unset($objQuestionTmp);
  144. if(!$objExcercise instanceOf Exercise) {
  145. $objExercise = new Exercise();
  146. $objExercise->read($fromExercise);
  147. }
  148. // adds the question ID represented by $recup into the list of questions for the current exercise
  149. $objExercise->addToList($recup);
  150. }
  151. api_session_register('objExercise');
  152. header("Location: admin.php?".api_get_cidreq()."&exerciseId=$fromExercise");
  153. exit();
  154. }
  155. }
  156. if (isset($_SESSION['gradebook'])){
  157. $gradebook= $_SESSION['gradebook'];
  158. }
  159. if (!empty($gradebook) && $gradebook=='view') {
  160. $interbreadcrumb[]= array ('url' => '../gradebook/'.Security::remove_XSS($_SESSION['gradebook_dest']),'name' => get_lang('ToolGradebook'));
  161. }
  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. //Answer type
  240. $question_list = Question::get_types_information();
  241. $new_question_list = array();
  242. $objExercise->feedbacktype;
  243. foreach ($question_list as $key=>$item) {
  244. if ($objExercise->feedbacktype == EXERCISE_FEEDBACK_TYPE_DIRECT) {
  245. if (!in_array($key, array(HOT_SPOT_DELINEATION, UNIQUE_ANSWER))) {
  246. continue;
  247. }
  248. $new_question_list[$key] = get_lang($item[1]);
  249. } else {
  250. if ($key == HOT_SPOT_DELINEATION) {
  251. continue;
  252. }
  253. $new_question_list[$key] = get_lang($item[1]);
  254. }
  255. }
  256. //Answer type list
  257. $select_answer_html = Display::select('answerType', $new_question_list, $answerType, array('onchange'=>'submit_form(this);'));
  258. echo Display::form_row(get_lang('AnswerType'), $select_answer_html);
  259. $button = '<button class="save" type="submit" name="name" value="'.get_lang('Filter').'">'.get_lang('Filter').'</button>';
  260. echo Display::form_row('', $button);
  261. ?>
  262. </form>
  263. <div class="clear"></div>
  264. <form method="post" action="<?php echo $url.'?'.api_get_cidreq().'&fromExercise='.$fromExercise; ?>" >
  265. <?php
  266. echo '<table class="data_table">';
  267. $from=$page*$limitQuestPage;
  268. // if we have selected an exercise in the list-box 'Filter'
  269. if ($exerciseId > 0) {
  270. //$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);
  271. $where = '';
  272. if (isset($type) && $type==1) {
  273. $where = ' type = 1 AND ';
  274. }
  275. if (isset($exerciseLevel) && $exerciseLevel != -1) {
  276. $where .= ' level='.$exerciseLevel.' AND ';
  277. }
  278. if (isset($answerType) && $answerType != -1) {
  279. $where .= ' type='.$answerType.' AND ';
  280. }
  281. $sql="SELECT id,question,type,level
  282. FROM $TBL_EXERCICE_QUESTION,$TBL_QUESTIONS
  283. WHERE $where question_id=id AND exercice_id='".Database::escape_string($exerciseId)."'
  284. ORDER BY question_order";
  285. $result=Database::query($sql);
  286. while($row = Database::fetch_array($result, 'ASSOC')) {
  287. $main_question_list[] = $row;
  288. }
  289. } elseif($exerciseId == -1) {
  290. // if we have selected the option 'Orphan questions' in the list-box 'Filter'
  291. // 1. Old logic: When a test is deleted, the correspondent records in 'quiz' and 'quiz_rel_question' tables are deleted.
  292. //$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);
  293. // 2. New logic: When a test is deleted, the field 'active' takes value -1 (it is in the correspondent record in 'quiz' table).
  294. //$sql='SELECT questions.id, questions.question, questions.type, quizz_questions.exercice_id FROM '.$TBL_QUESTIONS.
  295. // ' as questions LEFT JOIN '.$TBL_EXERCICE_QUESTION.' as quizz_questions ON questions.id=quizz_questions.question_id LEFT JOIN '.$TBL_EXERCICES.
  296. // ' as exercices ON exercice_id=exercices.id WHERE exercices.active = -1 LIMIT $from, '.($limitQuestPage + 1);
  297. // 3. This is more safe to changes, it is a mix between old and new logic.
  298. /*$sql='SELECT questions.id, questions.question, questions.type, quizz_questions.exercice_id FROM '.$TBL_QUESTIONS.
  299. ' as questions LEFT JOIN '.$TBL_EXERCICE_QUESTION.' as quizz_questions ON questions.id=quizz_questions.question_id LEFT JOIN '.$TBL_EXERCICES.
  300. ' as exercices ON exercice_id=exercices.id WHERE quizz_questions.exercice_id IS NULL OR exercices.active = -1 LIMIT '.$from.', '.($limitQuestPage + 1);
  301. */
  302. /* 4. Query changed because of the Level feature implemented
  303. $sql='SELECT id, question, type, exercice_id,level FROM '.$TBL_QUESTIONS.' as questions LEFT JOIN '.$TBL_EXERCICE_QUESTION.' as quizz_questions
  304. ON questions.id=quizz_questions.question_id AND exercice_id IS NULL '.
  305. (!is_null($exerciseLevel) && $exerciseLevel >= 0 ? 'WHERE level=\''.$exerciseLevel.'\' ' : '');
  306. */
  307. // 5. this is the combination of the 3 and 4 query because of the level feature implementation
  308. // we filter the type of question, because in the DirectFeedback we can only add questions with type=1 = UNIQUE_ANSWER
  309. $type_where= '';
  310. if (isset($type) && $type==1) {
  311. $type_where = ' AND questions.type = 1 ';
  312. }
  313. $level_where = '';
  314. if (isset($exerciseLevel) && $exerciseLevel!= -1 ) {
  315. $level_where = ' level='.$exerciseLevel.' AND ';
  316. }
  317. $answer_where = '';
  318. if (isset($answerType) && $answerType != -1 ) {
  319. $answer_where = ' questions.type='.$answerType.' AND ';
  320. }
  321. $sql='SELECT questions.id, questions.question, questions.type, quizz_questions.exercice_id , level, session_id
  322. FROM '.$TBL_QUESTIONS.' as questions LEFT JOIN '.$TBL_EXERCICE_QUESTION.' as quizz_questions
  323. ON questions.id=quizz_questions.question_id LEFT JOIN '.$TBL_EXERCICES.' as exercices
  324. ON exercice_id=exercices.id
  325. WHERE '.$answer_where.' '.$level_where.' (quizz_questions.exercice_id IS NULL OR exercices.active = -1 ) '.$type_where.'
  326. LIMIT '.$from.', '.($limitQuestPage + 1);
  327. $result = Database::query($sql);
  328. while($row = Database::fetch_array($result, 'ASSOC')) {
  329. $main_question_list[] = $row;
  330. }
  331. } else {
  332. // if we have not selected any option in the list-box 'Filter'
  333. //$sql="SELECT id,question,type FROM $TBL_QUESTIONS LIMIT $from, ".($limitQuestPage + 1);
  334. $filter = '';
  335. if (isset($type) && $type==1){
  336. $filter .= ' AND qu.type = 1 ';
  337. }
  338. if (isset($exerciseLevel) && $exerciseLevel != -1) {
  339. $filter .= ' AND level='.$exerciseLevel.' ';
  340. }
  341. if (isset($answerType) && $answerType != -1) {
  342. $filter .= ' AND qu.type='.$answerType.' ';
  343. }
  344. if ($objExercise->feedbacktype != EXERCISE_FEEDBACK_TYPE_DIRECT) {
  345. $filter .= ' AND qu.type <> '.HOT_SPOT_DELINEATION.' ';
  346. }
  347. $new_limit_page = $limitQuestPage + 1;
  348. if ($session_id != 0) {
  349. $main_question_list = array();
  350. if (!empty($course_list))
  351. foreach ($course_list as $course_item) {
  352. if (!empty($selected_course) && $selected_course != '-1') {
  353. if ($selected_course != $course_item['id']) {
  354. continue;
  355. }
  356. }
  357. $exercise_list = get_all_exercises($course_item, $session_id);
  358. if (!empty($exercise_list)) {
  359. foreach ($exercise_list as $exercise) {
  360. $my_exercise = new Exercise($course_item['id']);
  361. $my_exercise->read($exercise['id']);
  362. if (!empty($my_exercise)) {
  363. if (!empty($my_exercise->questionList)) {
  364. foreach ($my_exercise->questionList as $question_id) {
  365. $question_obj = Question::read($question_id, $course_item['id']);
  366. if ($exerciseLevel != '-1')
  367. if ($exerciseLevel != $question_obj->level) {
  368. continue;
  369. }
  370. if ($answerType != '-1')
  371. if ($answerType != $question_obj->type) {
  372. continue;
  373. }
  374. if ($objExercise->feedbacktype != EXERCISE_FEEDBACK_TYPE_DIRECT) {
  375. if ($question_obj->type == HOT_SPOT_DELINEATION) {
  376. continue;
  377. }
  378. }
  379. $question_row = array('id'=>$question_obj->id, 'question'=>$question_obj->question, 'type'=>$question_obj->type, 'level'=>$question_obj->level, 'exercise_id'=>$exercise['id']);
  380. $main_question_list[] = $question_row;
  381. }
  382. }
  383. }
  384. }
  385. }
  386. }
  387. } else {
  388. //By default
  389. $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
  390. 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";
  391. }
  392. // forces the value to 0
  393. $exerciseId=0;
  394. }
  395. $nbrQuestions = count($main_question_list);
  396. echo '<tr>',
  397. '<td colspan="',($fromExercise?4:4),'">',
  398. '<table border="0" cellpadding="0" cellspacing="0" width="100%">',
  399. '<tr>',
  400. '<td>';
  401. echo '</td>',
  402. '<td align="right">';
  403. if(!empty($page)) {
  404. echo '<a href="',api_get_self(),'?',api_get_cidreq(),'&exerciseId=',$exerciseId,'&fromExercise=',$fromExercise,'&page=',($page-1),'&answerType=',$answerType,'&exerciseLevel='.$exerciseLevel.'">';
  405. echo Display::return_icon('action_prev.png');
  406. echo '&nbsp;'.get_lang('PreviousPage'),'</a> | ';
  407. } elseif($nbrQuestions > $limitQuestPage) {
  408. echo Display::return_icon('action_prev_na.png');
  409. echo '&nbsp;'.get_lang('PreviousPage'),' | ';
  410. }
  411. if($nbrQuestions > $limitQuestPage) {
  412. echo '<a href="',api_get_self(),'?',api_get_cidreq(),'&exerciseId=',$exerciseId,'&fromExercise=',$fromExercise,'&page=',($page+1),'&answerType=',$answerType,'&exerciseLevel='.$exerciseLevel.'">',get_lang('NextPage').'&nbsp;';
  413. echo Display::return_icon('action_next.png');
  414. echo '</a>';
  415. } elseif($page) {
  416. echo get_lang('NextPage');
  417. echo '&nbsp;'.Display::return_icon('action_next_na.png');
  418. }
  419. echo '</td>
  420. </tr>
  421. </table>
  422. </td>
  423. </tr>
  424. <tr bgcolor="#e6e6e6">';
  425. if (!empty($fromExercise)) {
  426. if (api_get_session_id() == 0 ){
  427. echo '<th width="4%"> </th>';
  428. }
  429. echo '<th>',get_lang('Question'),'</th>',
  430. '<th>',get_lang('Level'),'</th>',
  431. '<th>',get_lang('Reuse'),'</th>';
  432. } else {
  433. echo '<td width="60%" align="center">',get_lang('Question'),'</td>',
  434. '<td width="20%" align="center">',get_lang('Modify'),'</td>',
  435. '<td width="16%" align="center">',get_lang('Delete'),'</td>';
  436. }
  437. echo '</tr>';
  438. $i=1;
  439. $session_id = api_get_session_id();
  440. if (!empty($main_question_list))
  441. foreach ($main_question_list as $row) {
  442. // if we come from the exercise administration to get a question,
  443. // don't show the questions already used by that exercise
  444. // original recipe -
  445. //if (!$fromExercise || !isset($objExercise) || !($objExercise instanceOf Exercise) || (!$objExercise->isInList($row['id'])))
  446. if (!$fromExercise || !isset($objExercise) || !($objExercise instanceOf Exercise) || (is_array($objExercise->questionList)) ) {
  447. echo '<tr ',($i%2==0?'class="row_odd"':'class="row_even"'),'>';
  448. if (api_get_session_id() == 0 ){
  449. echo '<td align="center"> <input type="checkbox" value="'.$row['id'].'" name="recup[]"/></td>';
  450. }
  451. echo ' <td><a href="admin.php?',api_get_cidreq(),'&editQuestion=',$row['id'],'&fromExercise='.$fromExercise.'&answerType='.$row['type'].'">',$row['question'],'</a></td>';
  452. echo ' <td align="center" >';
  453. if (empty($fromExercise)) {
  454. echo '<a href="admin.php?'.api_get_cidreq().'&amp;editQuestion=',$row['id'],'"><img src="../img/edit.gif" border="0" alt="',get_lang('Modify'),'"></a>',
  455. '</td>',
  456. '<td align="center">',
  457. '<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>';
  458. //'<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>';
  459. } else {
  460. echo $row['level'],'</td>',
  461. '<td align="center">';
  462. echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;copy_question='.$row['id'].'&course_id='.$selected_course.'&fromExercise=',$fromExercise,'">';
  463. echo ' '.Display::return_icon('cd.gif', get_lang('ReUseACopyInCurrentTest'));
  464. echo '</a> ';
  465. if ($row['session_id'] == $session_id) {
  466. if ($selected_course == api_get_course_int_id()) {
  467. 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>';
  468. }
  469. }
  470. }
  471. echo '</td>';
  472. echo '</tr>';
  473. // skips the last question, that is only used to know if we have or not to create a link "Next page"
  474. if($i == $limitQuestPage) {
  475. break;
  476. }
  477. $i++;
  478. }
  479. }
  480. if (!$nbrQuestions) {
  481. echo '<tr>',
  482. '<td colspan="',($fromExercise?4:4),'">',get_lang('NoQuestion'),'</td>',
  483. '</tr>';
  484. }
  485. echo '</table>';
  486. if (api_get_session_id() == 0 ){
  487. echo '<div style="width:100%; border-top:1px dotted #4171B5;">
  488. <button class="save" type="submit">'.get_lang('Reuse').'</button>
  489. </div></form>';
  490. }
  491. Display::display_footer();