gradebook_view_result.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Script.
  5. *
  6. * @package chamilo.gradebook
  7. */
  8. require_once __DIR__.'/../inc/global.inc.php';
  9. require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/fe/exportgradebook.php';
  10. api_block_anonymous_users();
  11. $isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
  12. api_get_user_id(),
  13. api_get_course_info()
  14. );
  15. if (!$isDrhOfCourse) {
  16. GradebookUtils::block_students();
  17. }
  18. $interbreadcrumb[] = [
  19. 'url' => Category::getUrl(),
  20. 'name' => get_lang('Gradebook'),
  21. ];
  22. //load the evaluation & category
  23. $select_eval = (int) $_GET['selecteval'];
  24. if (empty($select_eval)) {
  25. api_not_allowed();
  26. }
  27. $displayscore = ScoreDisplay::instance();
  28. $eval = Evaluation::load($select_eval);
  29. $overwritescore = 0;
  30. if ($eval[0]->get_category_id() < 0) {
  31. // if category id is negative, then the evaluation's origin is a link
  32. $link = LinkFactory::get_evaluation_link($eval[0]->get_id());
  33. $currentcat = Category::load($link->get_category_id());
  34. } else {
  35. $currentcat = Category::load($eval[0]->get_category_id());
  36. }
  37. //load the result with the evaluation id
  38. if (isset($_GET['delete_mark'])) {
  39. $result = Result::load($_GET['delete_mark']);
  40. if (!empty($result[0])) {
  41. $result[0]->delete();
  42. }
  43. }
  44. if (isset($_GET['selecteval'])) {
  45. $allresults = Result :: load(null, null, $select_eval);
  46. $iscourse = !empty(api_get_course_id());
  47. }
  48. $allowMultipleAttempts = api_get_configuration_value('gradebook_multiple_evaluation_attempts');
  49. if (isset($_GET['action'])) {
  50. switch ($_GET['action']) {
  51. case 'delete_attempt':
  52. $result = Result::load($_GET['editres']);
  53. if ($allowMultipleAttempts && !empty($result) && isset($result[0]) && api_is_allowed_to_edit()) {
  54. /** @var Result $result */
  55. $result = $result[0];
  56. $url = api_get_self().'?selecteval='.$select_eval.'&'.api_get_cidreq().'&editres='.$result->get_id();
  57. $table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_RESULT_ATTEMPT);
  58. if (isset($_GET['result_attempt_id'])) {
  59. $attemptId = (int) $_GET['result_attempt_id'];
  60. $sql = "DELETE FROM $table WHERE result_id = ".$result->get_id()." AND id = $attemptId";
  61. Database::query($sql);
  62. Display::addFlash(Display::return_message(get_lang('Deleted')));
  63. }
  64. header('Location: '.$url.'&action=add_attempt');
  65. exit;
  66. }
  67. break;
  68. case 'add_attempt':
  69. $result = Result::load($_GET['editres']);
  70. if ($allowMultipleAttempts && !empty($result) && isset($result[0]) && api_is_allowed_to_edit()) {
  71. /** @var Result $result */
  72. $result = $result[0];
  73. $backUrl = api_get_self().'?selecteval='.$select_eval.'&'.api_get_cidreq();
  74. $interbreadcrumb[] = [
  75. 'url' => $backUrl,
  76. 'name' => get_lang('Details'),
  77. ];
  78. /** @var Evaluation $evaluation */
  79. $evaluation = $eval[0];
  80. $table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_RESULT_ATTEMPT);
  81. $now = api_get_utc_datetime();
  82. $url = api_get_self().'?selecteval='.$select_eval.'&'.api_get_cidreq().'&editres='.$result->get_id();
  83. $form = new FormValidator('attempt', 'post', $url.'&action=add_attempt');
  84. $form->addHeader(get_lang('AddResult'));
  85. $form->addLabel(get_lang('CurrentScore'), $result->get_score());
  86. $form->addFloat(
  87. 'score',
  88. [
  89. get_lang('Score'),
  90. null,
  91. '/ '.$evaluation->get_max(),
  92. ],
  93. true,
  94. [
  95. 'size' => '4',
  96. 'maxlength' => '5',
  97. ],
  98. false,
  99. 0,
  100. $evaluation->get_max()
  101. );
  102. $form->addTextarea('comment', get_lang('Comment'));
  103. $form->addButtonSave(get_lang('Save'));
  104. $attemptList = ResultTable::getResultAttemptTable($result, $url);
  105. $form->addLabel(get_lang('Attempts'), $attemptList);
  106. if ($form->validate()) {
  107. $values = $form->getSubmitValues();
  108. $newScore = $values['score'];
  109. $newScore = api_number_format(
  110. $newScore,
  111. api_get_setting('gradebook_number_decimals')
  112. );
  113. $params = [
  114. 'result_id' => $result->get_id(),
  115. 'score' => $newScore,
  116. 'comment' => $values['comment'],
  117. 'created_at' => $now,
  118. 'updated_at' => $now,
  119. ];
  120. Database::insert($table, $params);
  121. if ($newScore > $result->get_score()) {
  122. $result->set_score($newScore);
  123. $result->save();
  124. }
  125. Display::addFlash(Display::return_message(get_lang('Saved')));
  126. header('Location: '.api_get_self().'?selecteval='.$select_eval.'&'.api_get_cidreq());
  127. exit;
  128. }
  129. Display::display_header();
  130. $items[] = [
  131. 'url' => $backUrl,
  132. 'content' => Display::return_icon(
  133. 'back.png',
  134. get_lang('Back'),
  135. [],
  136. ICON_SIZE_MEDIUM
  137. ),
  138. ];
  139. echo Display::actions($items);
  140. $form->display();
  141. Display::display_footer();
  142. exit;
  143. }
  144. break;
  145. }
  146. }
  147. if (isset($_GET['editres'])) {
  148. $edit_res_xml = Security::remove_XSS($_GET['editres']);
  149. $resultedit = Result::load($edit_res_xml);
  150. $edit_res_form = new EvalForm(
  151. EvalForm::TYPE_RESULT_EDIT,
  152. $eval[0],
  153. $resultedit[0],
  154. 'edit_result_form',
  155. null,
  156. api_get_self().'?editres='.$resultedit[0]->get_id().'&selecteval='.$select_eval.'&'.api_get_cidreq()
  157. );
  158. if ($edit_res_form->validate()) {
  159. $values = $edit_res_form->exportValues();
  160. $result = new Result();
  161. $resultlog = new Result();
  162. $resultlog->addResultLog($values['hid_user_id'], $select_eval);
  163. $result->set_id($edit_res_xml);
  164. $result->set_user_id($values['hid_user_id']);
  165. $result->set_evaluation_id($select_eval);
  166. $row_value = isset($values['score']) ? $values['score'] : 0;
  167. if (!empty($row_value) || $row_value == 0) {
  168. $row_value = api_number_format(
  169. $row_value,
  170. api_get_setting('gradebook_number_decimals')
  171. );
  172. $result->set_score($row_value);
  173. }
  174. $result->save();
  175. if ($allowMultipleAttempts && !empty($result->get_id())) {
  176. $table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_RESULT_ATTEMPT);
  177. $now = api_get_utc_datetime();
  178. $params = [
  179. 'result_id' => $result->get_id(),
  180. 'score' => $row_value,
  181. 'comment' => $values['comment'],
  182. 'created_at' => $now,
  183. 'updated_at' => $now,
  184. ];
  185. Database::insert($table, $params);
  186. }
  187. Display::addFlash(Display::return_message(get_lang('ResultEdited'), 'normal', false));
  188. header('Location: gradebook_view_result.php?selecteval='.$select_eval.'&editresmessage=&'.api_get_cidreq());
  189. exit;
  190. }
  191. }
  192. $file_type = null;
  193. if (isset($_GET['import'])) {
  194. $interbreadcrumb[] = [
  195. 'url' => api_get_path(WEB_CODE_PATH).'gradebook/gradebook_view_result.php?selecteval='.$select_eval.'&'.api_get_cidreq(),
  196. 'name' => get_lang('ViewResult'),
  197. ];
  198. $import_result_form = new DataForm(
  199. DataForm::TYPE_IMPORT,
  200. 'import_result_form',
  201. null,
  202. api_get_self().'?import=&selecteval='.$select_eval,
  203. '_blank',
  204. ''
  205. );
  206. if (!$import_result_form->validate()) {
  207. Display :: display_header(get_lang('Import'));
  208. }
  209. $eval[0]->check_lock_permissions();
  210. if (isset($_POST['formSent']) && $_POST['formSent']) {
  211. if (!empty($_FILES['import_file']['name'])) {
  212. $values = $import_result_form->exportValues();
  213. $file_type = $_POST['file_type'];
  214. $file_name = $_FILES['import_file']['tmp_name'];
  215. $results = Import :: csvToArray($file_name);
  216. $nr_results_added = 0;
  217. foreach ($results as $index => $importedresult) {
  218. //check username & score
  219. $importedresult['user_id'] = UserManager::get_user_id_from_username($importedresult['username']);
  220. $added = '0';
  221. foreach ($allresults as $allresult) {
  222. if (($importedresult['user_id'] == $allresult->get_user_id())) {
  223. if ($importedresult['score'] != $allresult->get_score()) {
  224. if (!isset($values['overwrite'])) {
  225. header('Location: '.api_get_path(WEB_CODE_PATH).'gradebook/gradebook_view_result.php?selecteval='.$select_eval.'&import_score_error='.$importedresult['user_id']);
  226. exit;
  227. break;
  228. } else {
  229. GradebookUtils::overwritescore(
  230. $allresult->get_id(),
  231. $importedresult['score'],
  232. $eval[0]->get_max()
  233. );
  234. $overwritescore++;
  235. $added = '1';
  236. }
  237. } else {
  238. $added = '1';
  239. }
  240. }
  241. }
  242. if ($importedresult['user_id'] == null) {
  243. header('Location: gradebook_view_result.php?selecteval='.$select_eval.'&incorrectdata=');
  244. exit;
  245. }
  246. $userinfo = api_get_user_info($importedresult['user_id']);
  247. if ($userinfo['lastname'] != $importedresult['lastname'] ||
  248. $userinfo['firstname'] != $importedresult['firstname'] ||
  249. $userinfo['official_code'] != $importedresult['official_code']
  250. ) {
  251. if (!isset($values['ignoreerrors'])) {
  252. header('Location: gradebook_view_result.php?selecteval='.$select_eval.'&import_user_error='.$importedresult['user_id']);
  253. exit;
  254. }
  255. }
  256. if ($added != '1') {
  257. if ($importedresult['score'] > $eval[0]->get_max()) {
  258. header('Location: gradebook_view_result.php?selecteval='.$select_eval.'&overwritemax=');
  259. exit;
  260. }
  261. $result = new Result();
  262. $result->set_user_id($importedresult['user_id']);
  263. if (!empty($importedresult['score'])) {
  264. $result->set_score(
  265. api_number_format($importedresult['score'], api_get_setting('gradebook_number_decimals'))
  266. );
  267. }
  268. if (!empty($importedresult['date'])) {
  269. $result->set_date(api_get_utc_datetime($importedresult['date']));
  270. } else {
  271. $result->set_date(api_get_utc_datetime());
  272. }
  273. $result->set_evaluation_id($select_eval);
  274. $result->add();
  275. $nr_results_added++;
  276. }
  277. }
  278. } else {
  279. Display::addFlash(
  280. Display::return_message(
  281. get_lang('ImportNoFile'),
  282. 'warning',
  283. false
  284. )
  285. );
  286. header('Location: '.api_get_self().'?import=&selecteval='.$select_eval.'&importnofile=');
  287. exit;
  288. }
  289. if ($overwritescore != 0) {
  290. Display::addFlash(
  291. Display::return_message(
  292. get_lang('ImportOverWriteScore').' '.$overwritescore
  293. )
  294. );
  295. header('Location: '.api_get_self().'?selecteval='.$select_eval.'&importoverwritescore='.$overwritescore);
  296. exit;
  297. }
  298. if ($nr_results_added == 0) {
  299. Display::addFlash(
  300. Display::return_message(
  301. get_lang('ProblemUploadingFile'),
  302. 'warning',
  303. false
  304. )
  305. );
  306. header('Location: '.api_get_self().'?selecteval='.$select_eval.'&nothingadded=');
  307. exit;
  308. }
  309. Display::addFlash(
  310. Display::return_message(
  311. get_lang('FileUploadComplete'),
  312. 'success',
  313. false
  314. )
  315. );
  316. header('Location: '.api_get_self().'?selecteval='.$select_eval.'&importok=');
  317. exit;
  318. }
  319. }
  320. if (isset($_GET['export'])) {
  321. $interbreadcrumb[] = [
  322. 'url' => 'gradebook_view_result.php?selecteval='.$select_eval.'&'.api_get_cidreq(),
  323. 'name' => get_lang('ViewResult'),
  324. ];
  325. $locked_status = $eval[0]->get_locked();
  326. $export_result_form = new DataForm(
  327. DataForm :: TYPE_EXPORT,
  328. 'export_result_form',
  329. null,
  330. api_get_self().'?export=&selecteval='.$select_eval.'&'.api_get_cidreq(),
  331. '_blank',
  332. $locked_status
  333. );
  334. if (!$export_result_form->validate()) {
  335. Display::display_header(get_lang('Export'));
  336. }
  337. if ($export_result_form->validate()) {
  338. $export = $export_result_form->exportValues();
  339. $file_type = $export['file_type'];
  340. $filename = 'export_results_'.gmdate('Y-m-d_H-i-s');
  341. $results = Result::load(null, null, $select_eval);
  342. $data = []; //when file type is csv, add a header to the output file
  343. if ($file_type == 'csv') {
  344. $alldata[] = [
  345. 'username',
  346. 'official_code',
  347. 'lastname',
  348. 'firstname',
  349. 'score',
  350. 'date',
  351. ];
  352. }
  353. // export results to pdf file
  354. if ($file_type == 'pdf') {
  355. $number_decimals = api_get_setting('gradebook_number_decimals');
  356. $datagen = new ResultsDataGenerator($eval[0], $allresults);
  357. // set headers pdf
  358. !empty($_user['official_code']) ? $officialcode = $_user['official_code'].' - ' : '';
  359. $h1 = [get_lang('Teacher'), $officialcode.$_user['firstName'].', '.$_user['lastName']];
  360. $h2 = [get_lang('Score'), $eval[0]->get_max()];
  361. $h3 = [get_lang('Course'), $_course['name']];
  362. $h4 = [get_lang('Weight'), $eval[0]->get_weight()];
  363. $h5 = [get_lang('Session'), api_get_session_name(api_get_session_id())];
  364. $date = date('d-m-Y H:i:s', time());
  365. $h6 = [get_lang('DateTime'), api_convert_and_format_date($date, "%d/%m/%Y %H:%M")];
  366. $header_pdf = [$h1, $h2, $h3, $h4, $h5, $h6];
  367. // set footer pdf
  368. $f1 = '<hr />'.get_lang('Drh');
  369. $f2 = '<hr />'.get_lang('Teacher');
  370. $f3 = '<hr />'.get_lang('Date');
  371. $footer_pdf = [$f1, $f2, $f3];
  372. // set title pdf
  373. $title_pdf = $eval[0]->get_name();
  374. // set headers data table
  375. $head_ape_name = '';
  376. if (api_is_western_name_order()) {
  377. $head_ape_name = get_lang('FirstName').', '.get_lang('LastName');
  378. } else {
  379. $head_ape_name = get_lang('LastName').', '.get_lang('FirstName');
  380. }
  381. $head_table = [
  382. ['#', 3],
  383. [get_lang('Code'), 12],
  384. [$head_ape_name, 40],
  385. [get_lang('Score'), 12],
  386. ];
  387. if ($number_decimals == null) {
  388. $head_table[] = [get_lang('Letters'), 15];
  389. }
  390. $head_display_score = '';
  391. $scoredisplay = ScoreDisplay :: instance();
  392. $customdisplays = $scoredisplay->get_custom_score_display_settings();
  393. if (!empty($customdisplays) && $scoredisplay->is_custom()) {
  394. $head_display_score = get_lang('Display');
  395. $head_table[] = [$head_display_score, 15];
  396. }
  397. // get data table
  398. if (api_sort_by_first_name()) {
  399. $data_array = $datagen->get_data(
  400. ResultsDataGenerator::RDG_SORT_FIRSTNAME,
  401. 0,
  402. null,
  403. false,
  404. true
  405. );
  406. } else {
  407. $data_array = $datagen->get_data(
  408. ResultsDataGenerator::RDG_SORT_LASTNAME,
  409. 0,
  410. null,
  411. false,
  412. true
  413. );
  414. }
  415. $data_table = [];
  416. foreach ($data_array as $data) {
  417. $result = [];
  418. $user_info = api_get_user_info($data['id']);
  419. $result[] = $user_info['username'];
  420. if (api_is_western_name_order()) {
  421. $result[] = $user_info['firstname'].', '.$user_info['lastname'];
  422. } else {
  423. $result[] = $user_info['lastname'].', '.$user_info['firstname'];
  424. }
  425. if ($number_decimals == null) {
  426. if (empty($data['scoreletter']) && !is_numeric($data['score'])) {
  427. $result[] = get_lang('DidNotTakeTheExam');
  428. } else {
  429. $result[] = api_strtoupper(get_lang('Literal'.$data['scoreletter']));
  430. }
  431. } else {
  432. if (empty($data['score']) && !is_numeric($data['score'])) {
  433. $result[] = get_lang('DidNotTakeTheExamAcronym');
  434. } else {
  435. $result[] = $data['score'];
  436. }
  437. }
  438. if ($scoredisplay->is_custom()) {
  439. $result[] = $data['display'];
  440. }
  441. $data_table[] = $result;
  442. }
  443. export_pdf_with_html(
  444. $head_table,
  445. $data_table,
  446. $header_pdf,
  447. $footer_pdf,
  448. $title_pdf
  449. );
  450. }
  451. // export results to xml or csv file
  452. foreach ($results as $result) {
  453. $userinfo = api_get_user_info($result->get_user_id());
  454. $data['username'] = $userinfo['username']; //$result->get_user_id();
  455. $data['official_code'] = $userinfo['official_code'];
  456. $data['lastname'] = $userinfo['lastname'];
  457. $data['firstname'] = $userinfo['firstname'];
  458. $data['score'] = $result->get_score();
  459. $data['date'] = api_format_date($result->get_date(), "%d/%m/%Y %R");
  460. $alldata[] = $data;
  461. }
  462. switch ($file_type) {
  463. case 'xml':
  464. Export::arrayToXml(
  465. $alldata,
  466. $filename,
  467. 'Result',
  468. 'XMLResults'
  469. );
  470. exit;
  471. break;
  472. case 'csv':
  473. Export::arrayToCsv($alldata, $filename);
  474. exit;
  475. break;
  476. }
  477. }
  478. }
  479. if (isset($_GET['resultdelete'])) {
  480. $result = Result::load($_GET['resultdelete']);
  481. $result[0]->delete();
  482. Display::addFlash(Display::return_message(get_lang('ResultDeleted')));
  483. header('Location: gradebook_view_result.php?selecteval='.$select_eval.'&'.api_get_cidreq());
  484. exit;
  485. }
  486. if (isset($_POST['action'])) {
  487. $number_of_selected_items = count($_POST['id']);
  488. if ($number_of_selected_items == '0') {
  489. Display::addFlash(
  490. Display::return_message(
  491. get_lang('NoItemsSelected'),
  492. 'warning',
  493. false
  494. )
  495. );
  496. } else {
  497. switch ($_POST['action']) {
  498. case 'delete':
  499. $number_of_deleted_results = 0;
  500. foreach ($_POST['id'] as $indexstr) {
  501. $result = Result :: load($indexstr);
  502. $result[0]->delete();
  503. $number_of_deleted_results++;
  504. }
  505. Display::addFlash(Display::return_message(get_lang('ResultsDeleted'), 'confirmation', false));
  506. header('Location: gradebook_view_result.php?massdelete=&selecteval='.$select_eval.'&'.api_get_cidreq());
  507. exit;
  508. break;
  509. }
  510. }
  511. } // TODO - what if selecteval not set ?
  512. $addparams = ['selecteval' => $eval[0]->get_id()];
  513. if (isset($_GET['print'])) {
  514. $datagen = new ResultsDataGenerator($eval[0], $allresults);
  515. if (api_sort_by_first_name()) {
  516. $data_array = $datagen->get_data(
  517. ResultsDataGenerator::RDG_SORT_FIRSTNAME,
  518. 0,
  519. null,
  520. true
  521. );
  522. } else {
  523. $data_array = $datagen->get_data(
  524. ResultsDataGenerator::RDG_SORT_LASTNAME,
  525. 0,
  526. null,
  527. true
  528. );
  529. }
  530. if ($displayscore->is_custom()) {
  531. if (api_is_western_name_order()) {
  532. $header_names = [
  533. get_lang('FirstName'),
  534. get_lang('LastName'),
  535. get_lang('Score'),
  536. get_lang('Display'),
  537. ];
  538. } else {
  539. $header_names = [
  540. get_lang('LastName'),
  541. get_lang('FirstName'),
  542. get_lang('Score'),
  543. get_lang('Display'),
  544. ];
  545. }
  546. } else {
  547. if (api_is_western_name_order()) {
  548. $header_names = [get_lang('FirstName'), get_lang('LastName'), get_lang('Score')];
  549. } else {
  550. $header_names = [get_lang('LastName'), get_lang('FirstName'), get_lang('Score')];
  551. }
  552. }
  553. $newarray = [];
  554. foreach ($data_array as $data) {
  555. $newarray[] = array_slice($data, 3);
  556. }
  557. echo print_table(
  558. $newarray,
  559. $header_names,
  560. get_lang('ViewResult'),
  561. $eval[0]->get_name()
  562. );
  563. exit;
  564. } else {
  565. $resultTable = new ResultTable($eval[0], $allresults, $iscourse, $addparams);
  566. }
  567. $htmlHeadXtra[] = '<script>
  568. function confirmationuser() {
  569. if (confirm("'.get_lang('DeleteUser').'?"))
  570. {return true;}
  571. else
  572. {return false;}
  573. }
  574. function confirmationall () {
  575. if (confirm("'.get_lang('DeleteAll').'?"))
  576. {return true;}
  577. else
  578. {return false;}
  579. }
  580. </script>';
  581. if (isset($_GET['deleteall'])) {
  582. $eval[0]->delete_results();
  583. Display::addFlash(Display::return_message(get_lang('AllResultDeleted')));
  584. header('Location: '.api_get_path(WEB_CODE_PATH).'gradebook/gradebook_view_result.php?allresdeleted=&selecteval='.$select_eval.'&'.api_get_cidreq());
  585. exit;
  586. }
  587. if (!isset($_GET['export']) && (!isset($_GET['import']))) {
  588. if (!isset($_GET['selectcat'])) {
  589. $interbreadcrumb[] = [
  590. 'url' => Category::getUrl().'selectcat='.$currentcat[0]->get_id(),
  591. 'name' => get_lang('Details'),
  592. ];
  593. }
  594. $interbreadcrumb[] = [
  595. 'url' => api_get_path(WEB_CODE_PATH).'gradebook/gradebook_view_result.php?selecteval='.$select_eval.'&'.api_get_cidreq(),
  596. 'name' => get_lang('ViewResult'),
  597. ];
  598. Display::display_header();
  599. }
  600. if (isset($_GET['adduser'])) {
  601. echo Display::return_message(get_lang('UserAdded'), 'confirmation', false);
  602. }
  603. if (isset($_GET['incorrectdata'])) {
  604. echo Display::return_message(get_lang('IncorrectData'), 'warning', false);
  605. }
  606. if (isset($_GET['nouser'])) {
  607. echo Display::return_message(get_lang('NoUser'), 'warning', false);
  608. }
  609. if (isset($_GET['overwritemax'])) {
  610. echo Display::return_message(get_lang('OverWriteMax'), 'warning', false);
  611. }
  612. if (isset($_GET['import_user_error'])) {
  613. $userinfo = api_get_user_info($_GET['import_user_error']);
  614. echo Display::return_message(
  615. get_lang('UserInfoDoesNotMatch').' '.
  616. api_get_person_name($userinfo['firstname'], $userinfo['lastname']),
  617. 'warning'
  618. );
  619. }
  620. if (isset($_GET['import_score_error'])) {
  621. $userinfo = api_get_user_info($_GET['import_score_error']);
  622. echo Display::return_message(
  623. get_lang('ScoreDoesNotMatch').' '.
  624. api_get_person_name($userinfo['firstname'], $userinfo['lastname']),
  625. 'warning'
  626. );
  627. }
  628. if ($file_type == null) {
  629. //show the result header
  630. if (isset($export_result_form) && !(isset($edit_res_form))) {
  631. echo $export_result_form->display();
  632. DisplayGradebook::display_header_result($eval[0], $currentcat[0]->get_id(), 1);
  633. } else {
  634. if (isset($import_result_form)) {
  635. echo $import_result_form->display();
  636. }
  637. if (isset($edit_res_form)) {
  638. echo $edit_res_form->toHtml();
  639. }
  640. DisplayGradebook::display_header_result($eval[0], $currentcat[0]->get_id(), 1);
  641. }
  642. // Letter-based scores are built from lib/results_data_generator.class.php::get_score_display()
  643. $resultTable->display();
  644. Display::display_footer();
  645. }