gradebook.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. <?php // $Id: gradebook.php 14772 2008-04-07 15:37:18Z yannoo $
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2006-2008 Dokeos SPRL
  6. Copyright (c) 2006 Ghent University (UGent)
  7. Copyright (c) various contributors
  8. For a full list of contributors, see "credits.txt".
  9. The full license can be read in "license.txt".
  10. This program is free software; you can redistribute it and/or
  11. modify it under the terms of the GNU General Public License
  12. as published by the Free Software Foundation; either version 2
  13. of the License, or (at your option) any later version.
  14. See the GNU General Public License for more details.
  15. Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
  16. Mail: info@dokeos.com
  17. ==============================================================================
  18. */
  19. $language_file= 'gradebook';
  20. $cidReset= true;
  21. include_once ('../inc/global.inc.php');
  22. $this_section = SECTION_MYGRADEBOOK;
  23. include_once ('lib/be.inc.php');
  24. include_once ('lib/scoredisplay.class.php');
  25. include_once ('lib/gradebook_functions.inc.php');
  26. include_once ('lib/fe/catform.class.php');
  27. include_once ('lib/fe/evalform.class.php');
  28. include_once ('lib/fe/linkform.class.php');
  29. include_once ('lib/gradebook_data_generator.class.php');
  30. include_once ('lib/fe/gradebooktable.class.php');
  31. include_once ('lib/fe/displaygradebook.php');
  32. include_once ('lib/fe/userform.class.php');
  33. include_once (api_get_path(LIBRARY_PATH).'ezpdf/class.ezpdf.php');
  34. api_block_anonymous_users();
  35. $htmlHeadXtra[]= '<script type="text/javascript">
  36. function confirmation ()
  37. {
  38. if (confirm("' . get_lang('DeleteAll') . '?"))
  39. {return true;}
  40. else
  41. {return false;}
  42. }
  43. </script>';
  44. $filter_confirm_msg = true;
  45. $filter_warning_msg = true;
  46. // --------------------------------------------------------------------------------
  47. // - ACTIONS -
  48. // --------------------------------------------------------------------------------
  49. //this is called when there is no data for the course admin
  50. if (isset ($_GET['createallcategories']))
  51. {
  52. block_students();
  53. $coursecat= Category :: get_not_created_course_categories(api_get_user_id());
  54. if (!count($coursecat) == 0)
  55. {
  56. foreach ($coursecat as $row)
  57. {
  58. $cat= new Category();
  59. $cat->set_name($row[1]);
  60. $cat->set_course_code($row[0]);
  61. $cat->set_description(null);
  62. $cat->set_user_id(api_get_user_id());
  63. $cat->set_parent_id(0);
  64. $cat->set_weight(0);
  65. $cat->set_visible(0);
  66. $cat->add();
  67. unset ($cat);
  68. }
  69. }
  70. header('Location: gradebook.php?addallcat=&selectcat=0');
  71. exit;
  72. }
  73. //move a category
  74. if (isset ($_GET['movecat']))
  75. {
  76. block_students();
  77. $cats= Category :: load($_GET['movecat']);
  78. if (!isset ($_GET['targetcat']))
  79. {
  80. $move_form= new CatForm(CatForm :: TYPE_MOVE,
  81. $cats[0],
  82. 'move_cat_form',
  83. null,
  84. api_get_self() . '?movecat=' . Security::remove_XSS($_GET['movecat'])
  85. . '&selectcat=' . Security::remove_XSS($_GET['selectcat']));
  86. if ($move_form->validate())
  87. {
  88. header('Location: ' . api_get_self() . '?selectcat=' . Security::remove_XSS($_GET['selectcat'])
  89. . '&movecat=' . Security::remove_XSS($_GET['movecat'])
  90. . '&targetcat=' . $move_form->exportValue('move_cat'));
  91. exit;
  92. }
  93. }
  94. else
  95. {
  96. $targetcat= Category :: load($_GET['targetcat']);
  97. $course_to_crsind = ($cats[0]->get_course_code() != null && $targetcat[0]->get_course_code() == null);
  98. if (!($course_to_crsind && !isset($_GET['confirm'])))
  99. {
  100. $cats[0]->move_to_cat($targetcat[0]);
  101. header('Location: ' . api_get_self() . '?categorymoved=&selectcat=' . Security::remove_XSS($_GET['selectcat']));
  102. exit;
  103. }
  104. unset ($targetcat);
  105. }
  106. unset ($cats);
  107. }
  108. //move an evaluation
  109. if (isset ($_GET['moveeval']))
  110. {
  111. block_students();
  112. $evals= Evaluation :: load($_GET['moveeval']);
  113. if (!isset ($_GET['targetcat']))
  114. {
  115. $move_form= new EvalForm(EvalForm :: TYPE_MOVE,
  116. $evals[0],
  117. null,
  118. 'move_eval_form',
  119. null,
  120. api_get_self() . '?moveeval=' . Security::remove_XSS($_GET['moveeval'])
  121. . '&selectcat=' . Security::remove_XSS($_GET['selectcat']));
  122. if ($move_form->validate())
  123. {
  124. header('Location: ' .api_get_self() . '?selectcat=' . Security::remove_XSS($_GET['selectcat'])
  125. . '&moveeval=' . Security::remove_XSS($_GET['moveeval'])
  126. . '&targetcat=' . $move_form->exportValue('move_cat'));
  127. exit;
  128. }
  129. }
  130. else
  131. {
  132. $targetcat= Category :: load($_GET['targetcat']);
  133. $course_to_crsind = ($evals[0]->get_course_code() != null && $targetcat[0]->get_course_code() == null);
  134. if (!($course_to_crsind && !isset($_GET['confirm'])))
  135. {
  136. $evals[0]->move_to_cat($targetcat[0]);
  137. header('Location: ' . api_get_self() . '?evaluationmoved=&selectcat=' . Security::remove_XSS($_GET['selectcat']));
  138. exit;
  139. }
  140. unset ($targetcat);
  141. }
  142. unset ($evals);
  143. }
  144. //move a link
  145. if (isset ($_GET['movelink']))
  146. {
  147. block_students();
  148. $link= LinkFactory :: load($_GET['movelink']);
  149. $move_form= new LinkForm(LinkForm :: TYPE_MOVE, null, $link[0], 'move_link_form', null, api_get_self() . '?movelink=' . $_GET['movelink'] . '&selectcat=' . Security::remove_XSS($_GET['selectcat']));
  150. if ($move_form->validate())
  151. {
  152. $targetcat= Category :: load($move_form->exportValue('move_cat'));
  153. $link[0]->move_to_cat($targetcat[0]);
  154. unset ($link);
  155. header('Location: ' . api_get_self(). '?linkmoved=&selectcat=' . Security::remove_XSS($_GET['selectcat']));
  156. exit;
  157. }
  158. }
  159. //parameters for categories
  160. if (isset ($_GET['visiblecat']))
  161. {
  162. block_students();
  163. if (isset ($_GET['set_visible']))
  164. $visibility_command= 1;
  165. else
  166. $visibility_command= 0;
  167. $cats= Category :: load($_GET['visiblecat']);
  168. $cats[0]->set_visible($visibility_command);
  169. $cats[0]->save();
  170. $cats[0]->apply_visibility_to_children();
  171. unset ($cats);
  172. if ($visibility_command)
  173. {
  174. $confirmation_message = get_lang('ViMod');
  175. $filter_confirm_msg = false;
  176. }
  177. else
  178. {
  179. $confirmation_message = get_lang('InViMod');
  180. $filter_confirm_msg = false;
  181. }
  182. }
  183. if (isset ($_GET['deletecat']))
  184. {
  185. block_students();
  186. $cats= Category :: load($_GET['deletecat']);
  187. //delete all categories,subcategories and results
  188. if ($cats[0] != null)
  189. {
  190. if ($cats[0]->get_id() != 0) // better don't try to delete the root...
  191. $cats[0]->delete_all();
  192. }
  193. $confirmation_message = get_lang('CategoryDeleted');
  194. $filter_confirm_msg = false;
  195. }
  196. //parameters for evaluations
  197. if (isset ($_GET['visibleeval']))
  198. {
  199. block_students();
  200. if (isset ($_GET['set_visible']))
  201. $visibility_command= 1;
  202. else
  203. $visibility_command= 0;
  204. $eval= Evaluation :: load($_GET['visibleeval']);
  205. $eval[0]->set_visible($visibility_command);
  206. $eval[0]->save();
  207. unset ($eval);
  208. if ($visibility_command)
  209. {
  210. $confirmation_message = get_lang('ViMod');
  211. $filter_confirm_msg = false;
  212. }
  213. else
  214. {
  215. $confirmation_message = get_lang('InViMod');
  216. $filter_confirm_msg = false;
  217. }
  218. }
  219. if (isset ($_GET['deleteeval']))
  220. {
  221. block_students();
  222. $eval= Evaluation :: load($_GET['deleteeval']);
  223. if ($eval[0] != null)
  224. $eval[0]->delete_with_results();
  225. $confirmation_message = get_lang('EvaluationDeleted');
  226. $filter_confirm_msg = false;
  227. }
  228. //parameters for links
  229. if (isset ($_GET['visiblelink']))
  230. {
  231. block_students();
  232. if (isset ($_GET['set_visible']))
  233. $visibility_command= 1;
  234. else
  235. $visibility_command= 0;
  236. $link= LinkFactory :: load($_GET['visiblelink']);
  237. $link[0]->set_visible($visibility_command);
  238. $link[0]->save();
  239. unset ($link);
  240. if ($visibility_command)
  241. {
  242. $confirmation_message = get_lang('ViMod');
  243. $filter_confirm_msg = false;
  244. }
  245. else
  246. {
  247. $confirmation_message = get_lang('InViMod');
  248. $filter_confirm_msg = false;
  249. }
  250. }
  251. if (isset ($_GET['deletelink']))
  252. {
  253. block_students();
  254. $link= LinkFactory :: load($_GET['deletelink']);
  255. if ($link[0] != null)
  256. $link[0]->delete();
  257. unset ($link);
  258. $confirmation_message = get_lang('LinkDeleted');
  259. $filter_confirm_msg = false;
  260. }
  261. if ($course_to_crsind && !isset($_GET['confirm']))
  262. {
  263. block_students();
  264. if (!isset($_GET['movecat']) && !isset($_GET['moveeval']))
  265. die ('Error: movecat or moveeval not defined');
  266. $button = '<form name="confirm"
  267. method="post"
  268. action="'.api_get_self() .'?confirm='
  269. .(isset($_GET['movecat']) ? '&movecat=' . Security::remove_XSS($_GET['movecat'])
  270. : '&moveeval=' . Security::remove_XSS($_GET['moveeval']) )
  271. .'&selectcat=' . Security::remove_XSS($_GET['selectcat'])
  272. .'&targetcat=' . Security::remove_XSS($_GET['targetcat']).'">
  273. <input type="submit" value="'.get_lang('Ok').'">
  274. </form>';
  275. $warning_message = get_lang('MoveWarning').'<br><br>'.$button;
  276. $filter_warning_msg = false;
  277. }
  278. //actions on the sortabletable
  279. if (isset ($_POST['action']))
  280. {
  281. block_students();
  282. $number_of_selected_items= count($_POST['id']);
  283. if ($number_of_selected_items == '0')
  284. {
  285. $warning_message = get_lang('NoItemsSelected');
  286. $filter_warning_msg = false;
  287. }
  288. else
  289. {
  290. switch ($_POST['action'])
  291. {
  292. case 'delete' :
  293. $number_of_deleted_categories= 0;
  294. $number_of_deleted_evaluations= 0;
  295. $number_of_deleted_links= 0;
  296. foreach ($_POST['id'] as $indexstr)
  297. {
  298. if (substr($indexstr, 0, 4) == 'CATE')
  299. {
  300. $cats= Category :: load(substr($indexstr, 4));
  301. if ($cats[0] != null)
  302. $cats[0]->delete_all();
  303. $number_of_deleted_categories++;
  304. }
  305. if (substr($indexstr, 0, 4) == 'EVAL')
  306. {
  307. $eval= Evaluation :: load(substr($indexstr, 4));
  308. if ($eval[0] != null)
  309. $eval[0]->delete_with_results();
  310. $number_of_deleted_evaluations++;
  311. }
  312. if (substr($indexstr, 0, 4) == 'LINK')
  313. {
  314. $link= LinkFactory :: load(substr($indexstr, 4));
  315. if ($link[0] != null)
  316. $link[0]->delete();
  317. $number_of_deleted_links++;
  318. }
  319. }
  320. $confirmation_message = get_lang('DeletedCategories') . ' : <b>' . $number_of_deleted_categories . '</b><br />' . get_lang('DeletedEvaluations') . ' : <b>' . $number_of_deleted_evaluations . '</b><br />' . get_lang('DeletedLinks') . ' : <b>' . $number_of_deleted_links . '</b><br /><br />' . get_lang('TotalItems') . ' : <b>' . $number_of_selected_items . '</b>';
  321. $filter_confirm_msg = false;
  322. break;
  323. case 'setvisible' :
  324. foreach ($_POST['id'] as $indexstr)
  325. {
  326. if (substr($indexstr, 0, 4) == 'CATE')
  327. {
  328. $cats= Category :: load(substr($indexstr, 4));
  329. $cats[0]->set_visible(1);
  330. $cats[0]->save();
  331. $cats[0]->apply_visibility_to_children();
  332. }
  333. if (substr($indexstr, 0, 4) == 'EVAL')
  334. {
  335. $eval= Evaluation :: load(substr($indexstr, 4));
  336. $eval[0]->set_visible(1);
  337. $eval[0]->save();
  338. }
  339. if (substr($indexstr, 0, 4) == 'LINK')
  340. {
  341. $link= LinkFactory :: load(substr($indexstr, 4));
  342. $link[0]->set_visible(1);
  343. $link[0]->save();
  344. }
  345. }
  346. $confirmation_message = get_lang('ItemsVisible');
  347. $filter_confirm_msg = false;
  348. break;
  349. case 'setinvisible' :
  350. foreach ($_POST['id'] as $indexstr)
  351. {
  352. if (substr($indexstr, 0, 4) == 'CATE')
  353. {
  354. $cats= Category :: load(substr($indexstr, 4));
  355. $cats[0]->set_visible(0);
  356. $cats[0]->save();
  357. $cats[0]->apply_visibility_to_children();
  358. }
  359. if (substr($indexstr, 0, 4) == 'EVAL')
  360. {
  361. $eval= Evaluation :: load(substr($indexstr, 4));
  362. $eval[0]->set_visible(0);
  363. $eval[0]->save();
  364. }
  365. if (substr($indexstr, 0, 4) == 'LINK')
  366. {
  367. $link= LinkFactory :: load(substr($indexstr, 4));
  368. $link[0]->set_visible(0);
  369. $link[0]->save();
  370. }
  371. }
  372. $confirmation_message = get_lang('ItemsInVisible');
  373. $filter_confirm_msg = false;
  374. break;
  375. }
  376. }
  377. }
  378. if (isset ($_POST['submit']) && isset ($_POST['keyword']))
  379. {
  380. header('Location: ' . api_get_self() . '?selectcat=' . Security::remove_XSS($_GET['selectcat'])
  381. . '&search='.Security::remove_XSS($_POST['keyword']));
  382. exit;
  383. }
  384. // --------------------------------------------------------------------------------
  385. // - DISPLAY HEADERS AND MESSAGES -
  386. // --------------------------------------------------------------------------------
  387. if (!isset($_GET['exportpdf']) and !isset($_GET['export_certificate']))
  388. {
  389. if (isset ($_GET['studentoverview']))
  390. {
  391. $interbreadcrumb[]= array (
  392. 'url' => 'gradebook.php?selectcat=' . Security::remove_XSS($_GET['selectcat']),
  393. 'name' => get_lang('Gradebook')
  394. );
  395. Display :: display_header(get_lang('FlatView'));
  396. }
  397. elseif (isset ($_GET['search']))
  398. {
  399. $interbreadcrumb[]= array (
  400. 'url' => 'gradebook.php?selectcat=' . Security::remove_XSS($_GET['selectcat']),
  401. 'name' => get_lang('Gradebook')
  402. );
  403. Display :: display_header(get_lang('SearchResults'));
  404. } else
  405. {
  406. Display :: display_header(get_lang('Gradebook'));
  407. }
  408. }
  409. if (isset ($_GET['categorymoved']))
  410. Display :: display_confirmation_message(get_lang('CategoryMoved'),false);
  411. if (isset ($_GET['evaluationmoved']))
  412. Display :: display_confirmation_message(get_lang('EvaluationMoved'),false);
  413. if (isset ($_GET['linkmoved']))
  414. Display :: display_confirmation_message(get_lang('LinkMoved'),false);
  415. if (isset ($_GET['addcat']))
  416. Display :: display_confirmation_message(get_lang('CategoryAdded'),false);
  417. if (isset ($_GET['linkadded']))
  418. Display :: display_confirmation_message(get_lang('LinkAdded'),false);
  419. if (isset ($_GET['addresult']))
  420. Display :: display_confirmation_message(get_lang('ResultAdded'),false);
  421. if (isset ($_GET['editcat']))
  422. Display :: display_confirmation_message(get_lang('CategoryEdited'),false);
  423. if (isset ($_GET['editeval']))
  424. Display :: display_confirmation_message(get_lang('EvaluationEdited'),false);
  425. if (isset ($_GET['linkedited']))
  426. Display :: display_confirmation_message(get_lang('LinkEdited'),false);
  427. if (isset ($_GET['nolinkitems']))
  428. Display :: display_warning_message(get_lang('NoLinkItems'),false);
  429. if (isset ($_GET['addallcat']))
  430. Display :: display_normal_message(get_lang('AddAllCat'),false);
  431. if (isset ($confirmation_message))
  432. Display :: display_confirmation_message($confirmation_message,$filter_confirm_msg);
  433. if (isset ($warning_message))
  434. Display :: display_warning_message($warning_message,$filter_warning_msg);
  435. if (isset ($move_form))
  436. Display :: display_normal_message($move_form->toHtml(),false);
  437. // --------------------------------------------------------------------------------
  438. // - LOAD DATA & DISPLAY TABLE -
  439. // --------------------------------------------------------------------------------
  440. $is_platform_admin= api_is_platform_admin();
  441. $is_course_admin= api_is_allowed_to_create_course();
  442. //load data for category, evaluation and links
  443. if (!isset ($_GET['selectcat']) || empty ($_GET['selectcat']))
  444. $category= 0;
  445. else
  446. $category= $_GET['selectcat'];
  447. // search form
  448. $simple_search_form= new UserForm(UserForm :: TYPE_SIMPLE_SEARCH, null, 'simple_search_form', null, api_get_self() . '?selectcat=' . Security::remove_XSS($_GET['selectcat']));
  449. $values= $simple_search_form->exportValues();
  450. $keyword = '';
  451. if (isset($_GET['search']) && !empty($_GET['search']))
  452. $keyword = Security::remove_XSS($_GET['search']);
  453. if ($simple_search_form->validate() && (empty($keyword)))
  454. $keyword = $values['keyword'];
  455. if (!empty($keyword))
  456. {
  457. $cats= Category :: load($category);
  458. $allcat= array ();
  459. $alleval= Evaluation :: find_evaluations($keyword, $cats[0]->get_id());
  460. $alllink= LinkFactory :: find_links($keyword, $cats[0]->get_id());
  461. }
  462. elseif (isset ($_GET['studentoverview']))
  463. {
  464. $cats= Category :: load($category);
  465. $stud_id= (api_is_allowed_to_create_course() ? null : api_get_user_id());
  466. $allcat= array ();
  467. $alleval= $cats[0]->get_evaluations($stud_id, true);
  468. $alllink= $cats[0]->get_links($stud_id, true);
  469. if (isset ($_GET['exportpdf']))
  470. {
  471. $datagen = new GradebookDataGenerator ($allcat,$alleval, $alllink);
  472. $header_names = array(get_lang('Name'),get_lang('Description'),get_lang('Weight'),get_lang('Date'),get_lang('Results'));
  473. $data_array = $datagen->get_data(GradebookDataGenerator :: GDG_SORT_NAME,0,null,true);
  474. $newarray = array();
  475. foreach ($data_array as $data)
  476. $newarray[] = array_slice($data, 1);
  477. $pdf= new Cezpdf();
  478. $pdf->selectFont(api_get_path(LIBRARY_PATH).'ezpdf/fonts/Helvetica.afm');
  479. $pdf->ezSetMargins(30, 30, 50, 30);
  480. $pdf->ezSetY(810);
  481. $pdf->ezText(get_lang('FlatView').' ('. date('j/n/Y g:i') .')',12,array('justification'=>'center'));
  482. $pdf->line(50,790,550,790);
  483. $pdf->line(50,40,550,40);
  484. $pdf->ezSetY(750);
  485. $pdf->ezTable($newarray,$header_names,'',array('showHeadings'=>1,'shaded'=>1,'showLines'=>1,'rowGap'=>3,'width'=> 500));
  486. $pdf->ezStream();
  487. exit;
  488. }
  489. }
  490. elseif(!empty($_GET['export_certificate']))
  491. {
  492. $user_id = strval(intval($_GET['user']));
  493. if(!api_is_allowed_to_edit(true,true))
  494. {
  495. $user_id = api_get_user_id();
  496. }
  497. $category = Category :: load ($_GET['cat']);
  498. if($category[0]->is_certificate_available($user_id))
  499. {
  500. $user= get_user_info_from_id($user_id);
  501. $scoredisplay = ScoreDisplay :: instance();
  502. $scorecourse = $category[0]->calc_score($user_id);
  503. $scorecourse_display = (isset($scorecourse) ? $scoredisplay->display_score($scorecourse,SCORE_AVERAGE) : get_lang('NoResultsAvailable'));
  504. $cattotal = Category :: load(0);
  505. $scoretotal= $cattotal[0]->calc_score($user_id);
  506. $scoretotal_display = (isset($scoretotal) ? $scoredisplay->display_score($scoretotal,SCORE_PERCENT) : get_lang('NoResultsAvailable'));
  507. //prepare all necessary variables:
  508. $organization_name = api_get_setting('Institution');
  509. $portal_name = api_get_setting('siteName');
  510. $stud_fn = $user['firstname'];
  511. $stud_ln = $user['lastname'];
  512. $certif_text = sprintf(get_lang('CertificateWCertifiesStudentXFinishedCourseYWithGradeZ'),$organization_name,$stud_fn.' '.$stud_ln,$category[0]->get_name(),$scorecourse_display);
  513. $certif_text = str_replace("\\n","\n",$certif_text);
  514. $date = date('d/m/Y',time());
  515. $pdf= new Cezpdf('a4','landscape');
  516. $pdf->selectFont(api_get_path(LIBRARY_PATH).'ezpdf/fonts/Courier.afm');
  517. $pdf->ezSetMargins(30, 30, 50, 50);
  518. //line Y coordinates in landscape mode are upside down (500 is on top, 10 is on the bottom)
  519. $pdf->line(50,50,790,50);
  520. $pdf->line(50,550,790,550);
  521. $pdf->ezSetY(450);
  522. $pdf->ezImage(api_get_path(SYS_CODE_PATH).'img/dokeos_logo_certif.png',1,400,'','center','');
  523. $pdf->ezSetY(480);
  524. $pdf->ezText($certif_text,28,array('justification'=>'center'));
  525. //$pdf->ezSetY(750);
  526. $pdf->ezSetY(50);
  527. $pdf->ezText($date,18,array('justification'=>'center'));
  528. $pdf->ezSetY(580);
  529. $pdf->ezText($organization_name,22,array('justification'=>'left'));
  530. $pdf->ezSetY(580);
  531. $pdf->ezText($portal_name,22,array('justification'=>'right'));
  532. $pdf->ezStream();
  533. }
  534. exit;
  535. }
  536. else
  537. {
  538. $cats= Category :: load($category);
  539. $stud_id= (api_is_allowed_to_create_course() ? null : api_get_user_id());
  540. $allcat= $cats[0]->get_subcategories($stud_id);
  541. $alleval= $cats[0]->get_evaluations($stud_id);
  542. $alllink= $cats[0]->get_links($stud_id);
  543. }
  544. $addparams = array ('selectcat' => $cats[0]->get_id());
  545. if (isset($_GET['search']))
  546. $addparams['search'] = $keyword;
  547. if (isset ($_GET['studentoverview']))
  548. $addparams['studentoverview'] = '';
  549. $gradebooktable= new GradebookTable($cats[0], $allcat, $alleval, $alllink, $addparams);
  550. if ((empty ($allcat)) && (empty ($alleval)) && (empty ($alllink)) && (!$is_platform_admin) && ($is_course_admin) && (!isset ($_GET['selectcat'])))
  551. {
  552. Display :: display_normal_message(get_lang('GradebookWelcomeMessage') . '<br /><br /><form name="createcat" method="post" action="' . api_get_self() . '?createallcategories=1"><input type="submit" value="' . get_lang('CreateAllCat') . '"></form>',false);
  553. }
  554. //here we are in a sub category
  555. if ($category != '0')
  556. {
  557. DisplayGradebook :: display_header_gradebook($cats[0], 1, $_GET['selectcat'], $is_course_admin, $is_platform_admin, $simple_search_form);
  558. }
  559. //this is the root category
  560. else
  561. {
  562. DisplayGradebook :: display_header_gradebook($cats[0], (((count($allcat) == '0') && (!isset ($_GET['search']))) ? 0 : 1), 0, $is_course_admin, $is_platform_admin, $simple_search_form);
  563. }
  564. $gradebooktable->display();
  565. Display :: display_footer();
  566. ?>