question_pool.php 23 KB

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