question_list_pagination_admin.inc.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Code library for HotPotatoes integration.
  5. * @package chamilo.exercise
  6. */
  7. /**
  8. * QUESTION LIST ADMINISTRATION
  9. *
  10. * This script allows to manage the question list
  11. * It is included from the script admin.php
  12. *
  13. */
  14. // deletes a question from the exercise (not from the data base)
  15. if ($deleteQuestion) {
  16. // if the question exists
  17. if ($objQuestionTmp = Question::read($deleteQuestion)) {
  18. $objQuestionTmp->delete($exerciseId);
  19. // if the question has been removed from the exercise
  20. if ($objExercise->removeFromList($deleteQuestion)) {
  21. $nbrQuestions--;
  22. }
  23. }
  24. // destruction of the Question object
  25. unset($objQuestionTmp);
  26. }
  27. $token = Security::get_token();
  28. //jqgrid will use this URL to do the selects
  29. $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_question_list&exerciseId='.$exerciseId;
  30. //The order is important you need to check the the $column variable in the model.ajax.php file
  31. $columns = array(get_lang('Questions'), get_lang('Type'), get_lang('Category'), get_lang('Difficulty'), get_lang('Score'), get_lang('Actions'));
  32. //Column config
  33. $column_model = array(
  34. array('name' => 'question', 'index' => 'question', 'width' => '300', 'align' => 'left'),
  35. array(
  36. 'name' => 'type',
  37. 'index' => 'type',
  38. 'width' => '100',
  39. 'align' => 'left',
  40. 'sortable' => 'false'
  41. ),
  42. array(
  43. 'name' => 'category',
  44. 'index' => 'category',
  45. 'width' => '100',
  46. 'align' => 'left',
  47. 'sortable' => 'false'
  48. ),
  49. array(
  50. 'name' => 'level',
  51. 'index' => 'level',
  52. 'width' => '100',
  53. 'align' => 'left',
  54. 'sortable' => 'false'
  55. ),
  56. array(
  57. 'name' => 'score',
  58. 'index' => 'score',
  59. 'width' => '100',
  60. 'align' => 'left',
  61. 'sortable' => 'false'
  62. ),
  63. array(
  64. 'name' => 'actions',
  65. 'index' => 'actions',
  66. 'width' => '100',
  67. 'align' => 'left',
  68. 'formatter' => 'action_formatter',
  69. 'sortable' => 'false'
  70. )
  71. );
  72. //Autowidth
  73. $extra_params['autowidth'] = 'true';
  74. //height auto
  75. $extra_params['height'] = 'auto';
  76. $courseCode = api_get_course_id();
  77. $delete_link = null;
  78. if ($objExercise->edit_exercise_in_lp == true) {
  79. $delete_link = '&nbsp;<a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES))."\'".')) return false;" href="?cidReq='.$courseCode.'&sec_token='.$token.'&deleteQuestion=\'+options.rowId+\'">'.Display::return_icon( 'delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>';
  80. }
  81. //With this function we can add actions to the jgrid (edit, delete, etc)
  82. $action_links = 'function action_formatter(cellvalue, options, rowObject) {
  83. return \'<a href="?myid=1&cidReq='.$courseCode.'&editQuestion=\'+options.rowId+\'">'.Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL).'</a>'.
  84. '&nbsp;<a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES))."\'".')) return false;" href="?cidReq='.$courseCode.'&sec_token='.$token.'&clone_question=\'+options.rowId+\'">'.Display::return_icon('cd.gif',get_lang('Copy'), '',ICON_SIZE_SMALL).'</a>'.
  85. $delete_link.'\';
  86. }';
  87. ?>
  88. <script>
  89. $(function () {
  90. <?php
  91. // grid definition see the $career->display() function
  92. echo Display::grid_js('question_list', $url, $columns, $column_model, $extra_params, array(), $action_links, true);
  93. ?>
  94. });
  95. </script>
  96. <?php
  97. Question :: display_type_menu($objExercise);
  98. echo '<div style="clear:both;"></div>';
  99. echo Display::grid_html('question_list');