exercise_report.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Exercise list: This script shows the list of exercises for administrators and students.
  5. * @package chamilo.exercise
  6. * @author Julio Montoya <gugli100@gmail.com> jqgrid integration
  7. * Modified by hubert.borderiou (question category)
  8. *
  9. * @todo fix excel export
  10. *
  11. */
  12. /**
  13. * Code
  14. */
  15. // name of the language file that needs to be included
  16. $language_file = array('exercice');
  17. // including the global library
  18. require_once '../inc/global.inc.php';
  19. require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be.inc.php';
  20. $urlMainExercise = api_get_path(WEB_CODE_PATH).'exercice/';
  21. // Setting the tabs
  22. $this_section = SECTION_COURSES;
  23. $htmlHeadXtra[] = api_get_jqgrid_js();
  24. // Access control
  25. api_protect_course_script(true, false, true);
  26. // including additional libraries
  27. require_once 'exercise.class.php';
  28. require_once 'question.class.php';
  29. require_once 'answer.class.php';
  30. require_once 'hotpotatoes.lib.php';
  31. // need functions of statsutils lib to display previous exercices scores
  32. require_once api_get_path(LIBRARY_PATH).'statsUtils.lib.inc.php';
  33. // document path
  34. $documentPath = api_get_path(SYS_COURSE_PATH).$_course['path']."/document";
  35. /* Constants and variables */
  36. $is_allowedToEdit = api_is_allowed_to_edit(null, true) || api_is_drh();
  37. $is_tutor = api_is_allowed_to_edit(true);
  38. $TBL_QUESTIONS = Database :: get_course_table(TABLE_QUIZ_QUESTION);
  39. $TBL_TRACK_EXERCICES = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
  40. $TBL_TRACK_ATTEMPT = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
  41. $TBL_TRACK_ATTEMPT_RECORDING = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);
  42. $TBL_LP_ITEM_VIEW = Database :: get_course_table(TABLE_LP_ITEM_VIEW);
  43. $course_id = api_get_course_int_id();
  44. $exercise_id = isset($_REQUEST['exerciseId']) ? intval($_REQUEST['exerciseId']) : null;
  45. $filter_user = isset($_REQUEST['filter_by_user']) ? intval($_REQUEST['filter_by_user']) : null;
  46. $gradebook = isset($_REQUEST['gradebook']) ? Security::remove_XSS($_REQUEST['gradebook']) : null;
  47. $locked = api_resource_is_locked_by_gradebook($exercise_id, LINK_EXERCISE);
  48. if (empty($exercise_id)) {
  49. api_not_allowed(true);
  50. }
  51. if (!$is_allowedToEdit) {
  52. api_not_allowed(true);
  53. }
  54. // @todo check if the $parameters is used
  55. if (!empty($exercise_id)) {
  56. $parameters['exerciseId'] = $exercise_id;
  57. }
  58. if (!empty($_GET['path'])) {
  59. $parameters['path'] = Security::remove_XSS($_GET['path']);
  60. }
  61. if (!empty($_REQUEST['export_report']) && $_REQUEST['export_report'] == '1') {
  62. if (api_is_platform_admin() || api_is_course_admin() || api_is_course_tutor() || api_is_course_coach()) {
  63. $load_extra_data = false;
  64. if (isset($_REQUEST['extra_data']) && $_REQUEST['extra_data'] == 1) {
  65. $load_extra_data = true;
  66. }
  67. require_once 'exercise_result.class.php';
  68. switch ($_GET['export_format']) {
  69. case 'xls':
  70. $export = new ExerciseResult();
  71. $export->exportCompleteReportXLS(
  72. $documentPath,
  73. null,
  74. $load_extra_data,
  75. null,
  76. $_GET['exerciseId'],
  77. $_GET['hotpotato_name']
  78. );
  79. exit;
  80. break;
  81. case 'csv':
  82. default:
  83. $export = new ExerciseResult();
  84. $export->exportCompleteReportCSV(
  85. $documentPath,
  86. null,
  87. $load_extra_data,
  88. null,
  89. $_GET['exerciseId'],
  90. $_GET['hotpotato_name']
  91. );
  92. exit;
  93. break;
  94. }
  95. } else {
  96. api_not_allowed(true);
  97. }
  98. }
  99. //Send student email @todo move this code in a class, library
  100. if (isset($_REQUEST['comments']) && $_REQUEST['comments'] == 'update' && ($is_allowedToEdit || $is_tutor) && $_GET['exeid'] == strval(intval($_GET['exeid']))) {
  101. $id = intval($_GET['exeid']); //filtered by post-condition
  102. $track_exercise_info = ExerciseLib::get_exercise_track_exercise_info($id);
  103. if (empty($track_exercise_info)) {
  104. api_not_allowed();
  105. }
  106. $test = $track_exercise_info['title'];
  107. $student_id = $track_exercise_info['exe_user_id'];
  108. $session_id = $track_exercise_info['session_id'];
  109. $lp_id = $track_exercise_info['orig_lp_id'];
  110. //$lp_item_id = $track_exercise_info['orig_lp_item_id'];
  111. $lp_item_view_id = $track_exercise_info['orig_lp_item_view_id'];
  112. $course_info = api_get_course_info();
  113. // Teacher data
  114. $teacher_info = api_get_user_info(api_get_user_id());
  115. $from_name = api_get_person_name(
  116. $teacher_info['firstname'],
  117. $teacher_info['lastname'],
  118. null,
  119. PERSON_NAME_EMAIL_ADDRESS
  120. );
  121. $url = api_get_path(WEB_CODE_PATH).'exercice/result.php?id='.$track_exercise_info['exe_id'].'&'.api_get_cidreq(
  122. ).'&show_headers=1&id_session='.$session_id;
  123. $my_post_info = array();
  124. $post_content_id = array();
  125. $comments_exist = false;
  126. foreach ($_POST as $key_index => $key_value) {
  127. $my_post_info = explode('_', $key_index);
  128. $post_content_id[] = $my_post_info[1];
  129. if ($my_post_info[0] == 'comments') {
  130. $comments_exist = true;
  131. }
  132. }
  133. $loop_in_track = ($comments_exist === true) ? (count($_POST) / 2) : count($_POST);
  134. $array_content_id_exe = array();
  135. if ($comments_exist === true) {
  136. $array_content_id_exe = array_slice($post_content_id, $loop_in_track);
  137. } else {
  138. $array_content_id_exe = $post_content_id;
  139. }
  140. for ($i = 0; $i < $loop_in_track; $i++) {
  141. $my_marks = null;
  142. if (isset($_POST['marks_'.$array_content_id_exe[$i]])) {
  143. $my_marks = Database::escape_string($_POST['marks_'.$array_content_id_exe[$i]]);
  144. }
  145. $contain_comments = null;
  146. if (isset($_POST['comments_'.$array_content_id_exe[$i]])) {
  147. $contain_comments = Database::escape_string($_POST['comments_'.$array_content_id_exe[$i]]);
  148. }
  149. if (isset($contain_comments)) {
  150. $my_comments = Database::escape_string($_POST['comments_'.$array_content_id_exe[$i]]);
  151. } else {
  152. $my_comments = '';
  153. }
  154. $my_questionid = intval($array_content_id_exe[$i]);
  155. $sql = "SELECT question from $TBL_QUESTIONS WHERE c_id = $course_id AND iid = '$my_questionid'";
  156. $result = Database::query($sql);
  157. Database::result($result, 0, "question");
  158. $query = "UPDATE $TBL_TRACK_ATTEMPT SET marks = '$my_marks', teacher_comment = '$my_comments'
  159. WHERE question_id = ".$my_questionid." AND exe_id=".$id;
  160. Database::query($query);
  161. //Saving results in the track recording table
  162. $recording_changes = 'INSERT INTO '.$TBL_TRACK_ATTEMPT_RECORDING.' (exe_id, question_id, marks, insert_date, author, teacher_comment)
  163. VALUES ('."'$id','".$my_questionid."','$my_marks','".api_get_utc_datetime()."','".api_get_user_id()."'".',"'.$my_comments.'")';
  164. Database::query($recording_changes);
  165. }
  166. $qry = 'SELECT DISTINCT question_id, marks FROM '.$TBL_TRACK_ATTEMPT.' WHERE exe_id = '.$id.' GROUP BY question_id';
  167. $res = Database::query($qry);
  168. $tot = 0;
  169. while ($row = Database :: fetch_array($res, 'ASSOC')) {
  170. $tot += $row['marks'];
  171. }
  172. $totquery = "UPDATE $TBL_TRACK_EXERCICES SET exe_result = '".floatval($tot)."' WHERE exe_id = ".$id;
  173. Database::query($totquery);
  174. if (isset($_POST['send_notification'])) {
  175. //@todo move this somewhere else
  176. $subject = get_lang('ExamSheetVCC');
  177. $message = '<p>'.get_lang('DearStudentEmailIntroduction').'</p><p>'.get_lang('AttemptVCC');
  178. $message .= '<h3>'.get_lang('CourseName').'</h3><p>'.Security::remove_XSS($course_info['name']).'';
  179. $message .= '<h3>'.get_lang('Exercise').'</h3><p>'.Security::remove_XSS($test);
  180. //Only for exercises not in a LP
  181. if ($lp_id == 0) {
  182. $message .= '<p>'.get_lang('ClickLinkToViewComment').' <a href="#url#">#url#</a><br />';
  183. }
  184. $message .= '<p>'.get_lang('Regards').'</p>';
  185. $message .= $from_name;
  186. $message = str_replace("#test#", Security::remove_XSS($test), $message);
  187. $message = str_replace("#url#", $url, $message);
  188. MessageManager::send_message_simple($student_id, $subject, $message, api_get_user_id());
  189. }
  190. // Updating LP score here
  191. if (in_array($origin, array('tracking_course', 'user_course', 'correct_exercise_in_lp'))) {
  192. $sql_update_score = "UPDATE $TBL_LP_ITEM_VIEW SET score = '".floatval(
  193. $tot
  194. )."' WHERE c_id = ".$course_id." AND id = ".$lp_item_view_id;
  195. Database::query($sql_update_score);
  196. if ($origin == 'tracking_course') {
  197. //Redirect to the course detail in lp
  198. header('Location: '.$urlMainExercise.'exercice.php?course='.Security :: remove_XSS($_GET['course']));
  199. exit;
  200. } else {
  201. // Redirect to the reporting
  202. header(
  203. 'Location: '.api_get_path(WEB_CODE_PATH).'mySpace/myStudents.php?origin='.$origin.'&student='.$student_id.'&details=true&course='.$course_id.'&session_id='.$session_id
  204. );
  205. exit;
  206. }
  207. }
  208. }
  209. $actions = null;
  210. if (isset($origin) && $origin == 'learnpath') {
  211. $actions .= '<a href="exercice.php">'.Display :: return_icon(
  212. 'back.png',
  213. get_lang('GoBackToQuestionList'),
  214. '',
  215. ICON_SIZE_MEDIUM
  216. ).'</a>';
  217. } else {
  218. if ($is_allowedToEdit) {
  219. // the form
  220. if (api_is_platform_admin() || api_is_course_admin() || api_is_course_tutor() || api_is_course_coach()) {
  221. // @todo check if $path is used
  222. $path = isset($_GET['path']) ? Security::remove_XSS($_GET['path']) : null;
  223. $actions .= '<a href="admin.php?exerciseId='.intval($_GET['exerciseId']).'">'.Display :: return_icon('back.png',get_lang('GoBackToQuestionList'),'',ICON_SIZE_MEDIUM).'</a>';
  224. $actions .= '<a href="live_stats.php?'.api_get_cidreq().'&exerciseId='.$exercise_id.'">'.Display :: return_icon('activity_monitor.png',get_lang('LiveResults'), '', ICON_SIZE_MEDIUM ).'</a>';
  225. $actions .= '<a href="stats.php?'.api_get_cidreq().'&exerciseId='.$exercise_id.'">'.Display :: return_icon('statistics.png',get_lang('ReportByQuestion'), '', ICON_SIZE_MEDIUM).'</a>';
  226. $actions .= '<a id="export_opener" href="'.api_get_self().'?export_report=1&hotpotato_name='.$path.'&exerciseId='.intval($_GET['exerciseId']).'" >'.
  227. Display::return_icon('save.png', get_lang('Export'), '', ICON_SIZE_MEDIUM).'</a>';
  228. $actions .= '<a href="recalculate_scores.php?'.api_get_cidreq().'&exerciseId='.$exercise_id.'">'.Display :: return_icon('history.png',get_lang('RecalculateResults'), '', ICON_SIZE_MEDIUM).'</a>';
  229. }
  230. }
  231. }
  232. //Deleting an attempt
  233. if (($is_allowedToEdit || $is_tutor || api_is_coach()) && isset($_GET['delete']) && $_GET['delete'] == 'delete' && !empty ($_GET['did']) && $locked == false
  234. ) {
  235. $exe_id = intval($_GET['did']);
  236. if (!empty($exe_id)) {
  237. $sql = 'DELETE FROM '.$TBL_TRACK_EXERCICES.' WHERE exe_id = '.$exe_id;
  238. Database::query($sql);
  239. $sql = 'DELETE FROM '.$TBL_TRACK_ATTEMPT.' WHERE exe_id = '.$exe_id;
  240. Database::query($sql);
  241. header(
  242. 'Location: exercise_report.php?cidReq='.Security::remove_XSS($_GET['cidReq']).'&exerciseId='.$exercise_id
  243. );
  244. exit;
  245. }
  246. }
  247. if ($is_allowedToEdit || $is_tutor) {
  248. $nameTools = get_lang('StudentScore');
  249. $interbreadcrumb[] = array("url" => "exercice.php?gradebook=$gradebook", "name" => get_lang('Exercices'));
  250. $objExerciseTmp = new Exercise();
  251. if ($objExerciseTmp->read($exercise_id)) {
  252. $interbreadcrumb[] = array("url" => "admin.php?exerciseId=".$exercise_id, "name" => $objExerciseTmp->name);
  253. }
  254. } else {
  255. $interbreadcrumb[] = array("url" => "exercice.php?gradebook=$gradebook", "name" => get_lang('Exercices'));
  256. $objExerciseTmp = new Exercise();
  257. if ($objExerciseTmp->read($exercise_id)) {
  258. $nameTools = get_lang('Results').': '.$objExerciseTmp->name;
  259. }
  260. }
  261. Display :: display_header($nameTools);
  262. $actions = Display::div($actions, array('class' => 'actions'));
  263. $extra = '<script>
  264. $(document).ready(function() {
  265. $( "#dialog:ui-dialog" ).dialog( "destroy" );
  266. $( "#dialog-confirm" ).dialog({
  267. autoOpen: false,
  268. show: "blind",
  269. resizable: false,
  270. height:300,
  271. modal: true
  272. });
  273. $("#export_opener").click(function() {
  274. var targetUrl = $(this).attr("href");
  275. $( "#dialog-confirm" ).dialog({
  276. width:400,
  277. height:300,
  278. buttons: {
  279. "'.addslashes(get_lang('Download')).'": function() {
  280. var export_format = $("input[name=export_format]:checked").val();
  281. var extra_data = $("input[name=load_extra_data]:checked").val();
  282. location.href = targetUrl+"&export_format="+export_format+"&extra_data="+extra_data;
  283. $( this ).dialog( "close" );
  284. },
  285. }
  286. });
  287. $( "#dialog-confirm" ).dialog("open");
  288. return false;
  289. });
  290. });
  291. </script>';
  292. $extra .= '<div id="dialog-confirm" title="'.get_lang("ConfirmYourChoice").'">';
  293. $form = new FormValidator('report', 'post', null, null, array('class' => 'form-vertical'));
  294. $form->addElement(
  295. 'radio',
  296. 'export_format',
  297. null,
  298. get_lang('ExportAsCSV'),
  299. 'csv',
  300. array('id' => 'export_format_csv_label')
  301. );
  302. $form->addElement(
  303. 'radio',
  304. 'export_format',
  305. null,
  306. get_lang('ExportAsXLS'),
  307. 'xls',
  308. array('id' => 'export_format_xls_label')
  309. );
  310. $form->addElement(
  311. 'checkbox',
  312. 'load_extra_data',
  313. null,
  314. get_lang('LoadExtraData'),
  315. '0',
  316. array('id' => 'export_format_xls_label')
  317. );
  318. $form->setDefaults(array('export_format' => 'csv'));
  319. $extra .= $form->return_form();
  320. $extra .= '</div>';
  321. if ($is_allowedToEdit) {
  322. echo $extra;
  323. }
  324. echo $actions;
  325. $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_exercise_results&exerciseId='.$exercise_id.'&filter_by_user='.$filter_user;
  326. $action_links = '';
  327. //Generating group list
  328. $group_list = GroupManager::get_group_list();
  329. $group_parameters = array('group_all:'.get_lang('All'), 'group_none:'.get_lang('None'));
  330. foreach ($group_list as $group) {
  331. $group_parameters[] = $group['id'].':'.$group['name'];
  332. }
  333. if (!empty($group_parameters)) {
  334. $group_parameters = implode(';', $group_parameters);
  335. }
  336. if ($is_allowedToEdit || $is_tutor) {
  337. //The order is important you need to check the the $column variable in the model.ajax.php file
  338. $columns = array(
  339. get_lang('FirstName'),
  340. get_lang('LastName'),
  341. get_lang('LoginName'),
  342. get_lang('Group'),
  343. get_lang('Duration').' ('.get_lang('MinMinute').')',
  344. get_lang('StartDate'),
  345. get_lang('EndDate'),
  346. get_lang('Score'),
  347. get_lang('Status'),
  348. get_lang('ToolLearnpath'),
  349. get_lang('Actions')
  350. );
  351. //Column config
  352. $column_model = array(
  353. array('name' => 'firstname', 'index' => 'firstname', 'width' => '50', 'align' => 'left', 'search' => 'true'),
  354. array(
  355. 'name' => 'lastname',
  356. 'index' => 'lastname',
  357. 'width' => '50',
  358. 'align' => 'left',
  359. 'formatter' => 'action_formatter',
  360. 'search' => 'true'
  361. ),
  362. array(
  363. 'name' => 'login',
  364. 'index' => 'username',
  365. 'width' => '40',
  366. 'align' => 'left',
  367. 'search' => 'true',
  368. 'hidden' => 'true'
  369. ),
  370. array(
  371. 'name' => 'group_name',
  372. 'index' => 'group_id',
  373. 'width' => '40',
  374. 'align' => 'left',
  375. 'search' => 'true',
  376. 'stype' => 'select',
  377. //for the bottom bar
  378. 'searchoptions' => array(
  379. 'defaultValue' => 'group_all',
  380. 'value' => $group_parameters
  381. ),
  382. //for the top bar
  383. 'editoptions' => array('value' => $group_parameters)
  384. ),
  385. array('name' => 'duration', 'index' => 'exe_duration', 'width' => '30', 'align' => 'left', 'search' => 'true'),
  386. array('name' => 'start_date', 'index' => 'start_date', 'width' => '60', 'align' => 'left', 'search' => 'true'),
  387. array('name' => 'exe_date', 'index' => 'exe_date', 'width' => '60', 'align' => 'left', 'search' => 'true'),
  388. array('name' => 'score', 'index' => 'exe_result', 'width' => '50', 'align' => 'left', 'search' => 'true'),
  389. array(
  390. 'name' => 'status',
  391. 'index' => 'revised',
  392. 'width' => '40',
  393. 'align' => 'left',
  394. 'search' => 'true',
  395. 'stype' => 'select',
  396. //for the bottom bar
  397. 'searchoptions' => array(
  398. 'defaultValue' => '',
  399. 'value' => ':'.get_lang('All').';1:'.get_lang('Validated').';0:'.get_lang('NotValidated')
  400. ),
  401. //for the top bar
  402. 'editoptions' => array(
  403. 'value' => ':'.get_lang('All').';1:'.get_lang('Validated').';0:'.get_lang(
  404. 'NotValidated'
  405. )
  406. )
  407. ),
  408. array('name' => 'lp', 'index' => 'lp', 'width' => '60', 'align' => 'left', 'search' => 'false'),
  409. array('name' => 'actions', 'index' => 'actions', 'width' => '60', 'align' => 'left', 'search' => 'false')
  410. );
  411. $action_links = '
  412. // add username as title in lastname filed - ref 4226
  413. function action_formatter(cellvalue, options, rowObject) {
  414. // rowObject is firstname,lastname,login,... get the third word
  415. var loginx = "'.api_htmlentities(sprintf(get_lang("LoginX"), ":::"), ENT_QUOTES).'";
  416. var tabLoginx = loginx.split(/:::/);
  417. // tabLoginx[0] is before and tabLoginx[1] is after :::
  418. // may be empty string but is defined
  419. return "<span title=\""+tabLoginx[0]+rowObject[2]+tabLoginx[1]+"\">"+cellvalue+"</span>";
  420. }';
  421. }
  422. //Autowidth
  423. $extra_params['autowidth'] = 'true';
  424. //height auto
  425. $extra_params['height'] = 'auto';
  426. ?>
  427. <script>
  428. function setSearchSelect(columnName) {
  429. $("#results").jqGrid('setColProp', columnName, {
  430. searchoptions:{
  431. dataInit:function (el) {
  432. $("option[value='1']", el).attr("selected", "selected");
  433. setTimeout(function () {
  434. $(el).trigger('change');
  435. }, 1000);
  436. }
  437. }
  438. });
  439. }
  440. function exportExcel() {
  441. var mya = new Array();
  442. mya = $("#results").getDataIDs(); // Get All IDs
  443. var data = $("#results").getRowData(mya[0]); // Get First row to get the labels
  444. var colNames = new Array();
  445. var ii = 0;
  446. for (var i in data) {
  447. colNames[ii++] = i;
  448. } // capture col names
  449. var html = "";
  450. for (i = 0; i < mya.length; i++) {
  451. data = $("#results").getRowData(mya[i]); // get each row
  452. for (j = 0; j < colNames.length; j++) {
  453. html = html + data[colNames[j]] + ","; // output each column as tab delimited
  454. }
  455. html = html + "\n"; // output each row with end of line
  456. }
  457. html = html + "\n"; // end of line at the end
  458. var form = $("#export_report_form");
  459. $("#csvBuffer").attr('value', html);
  460. form.target = '_blank';
  461. form.submit();
  462. }
  463. $(function () {
  464. <?php
  465. echo Display::grid_js('results', $url, $columns, $column_model, $extra_params, array(), $action_links, true);
  466. if ($is_allowedToEdit || $is_tutor) {
  467. ?>
  468. //setSearchSelect("status");
  469. //
  470. //view:true, del:false, add:false, edit:false, excel:true}
  471. $("#results").jqGrid('navGrid', '#results_pager', {view:true, edit:false, add:false, del:false, excel:false},
  472. {height:280, reloadAfterSubmit:false}, // view options
  473. {height:280, reloadAfterSubmit:false}, // edit options
  474. {height:280, reloadAfterSubmit:false}, // add options
  475. {reloadAfterSubmit:false}, // del options
  476. {width:500} // search options
  477. );
  478. /*
  479. // add custom button to export the data to excel
  480. jQuery("#results").jqGrid('navButtonAdd','#results_pager',{
  481. caption:"",
  482. onClickButton : function () {
  483. //exportExcel();
  484. }
  485. });*/
  486. /*
  487. jQuery('#sessions').jqGrid('navButtonAdd','#sessions_pager',{id:'pager_csv',caption:'',title:'Export To CSV',onClickButton : function(e)
  488. {
  489. try {
  490. jQuery("#sessions").jqGrid('excelExport',{tag:'csv', url:'grid.php'});
  491. } catch (e) {
  492. window.location= 'grid.php?oper=csv';
  493. }
  494. },buttonicon:'ui-icon-document'})
  495. */
  496. //Adding search options
  497. var options = {
  498. 'stringResult': true,
  499. 'autosearch' : true,
  500. 'searchOnEnter':false
  501. }
  502. jQuery("#results").jqGrid('filterToolbar', options);
  503. var sgrid = $("#results")[0];
  504. sgrid.triggerToolbar();
  505. <?php } ?>
  506. });
  507. </script>
  508. <form id="export_report_form" method="post" action="exercise_report.php">
  509. <input type="hidden" name="csvBuffer" id="csvBuffer" value=""/>
  510. <input type="hidden" name="export_report" id="export_report" value="1"/>
  511. <input type="hidden" name="exerciseId" id="exerciseId" value="<?php echo $exercise_id ?>"/>
  512. </form>
  513. <?php
  514. echo Display::grid_html('results');
  515. Display :: display_footer();