gradebook_view_result.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  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. $resultedit = Result::load($_GET['editres']);
  149. $edit_res_form = new EvalForm(
  150. EvalForm::TYPE_RESULT_EDIT,
  151. $eval[0],
  152. $resultedit[0],
  153. 'edit_result_form',
  154. null,
  155. api_get_self().'?editres='.$resultedit[0]->get_id().'&selecteval='.$select_eval.'&'.api_get_cidreq()
  156. );
  157. if ($edit_res_form->validate()) {
  158. $values = $edit_res_form->exportValues();
  159. $result = new Result();
  160. $resultlog = new Result();
  161. $resultlog->addResultLog($values['hid_user_id'], $select_eval);
  162. $result->set_id($_GET['editres']);
  163. $result->set_user_id($values['hid_user_id']);
  164. $result->set_evaluation_id($select_eval);
  165. $row_value = isset($values['score']) ? $values['score'] : 0;
  166. if (!empty($row_value) || $row_value == 0) {
  167. $row_value = api_number_format(
  168. $row_value,
  169. api_get_setting('gradebook_number_decimals')
  170. );
  171. $result->set_score($row_value);
  172. }
  173. $result->save();
  174. if ($allowMultipleAttempts && !empty($result->get_id())) {
  175. $table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_RESULT_ATTEMPT);
  176. $now = api_get_utc_datetime();
  177. $params = [
  178. 'result_id' => $result->get_id(),
  179. 'score' => $row_value,
  180. 'comment' => $values['comment'],
  181. 'created_at' => $now,
  182. 'updated_at' => $now,
  183. ];
  184. Database::insert($table, $params);
  185. }
  186. Display::addFlash(Display::return_message(get_lang('ResultEdited'), 'normal', false));
  187. header('Location: gradebook_view_result.php?selecteval='.$select_eval.'&editresmessage=&'.api_get_cidreq());
  188. exit;
  189. }
  190. }
  191. $file_type = null;
  192. if (isset($_GET['import'])) {
  193. $interbreadcrumb[] = [
  194. 'url' => api_get_path(WEB_CODE_PATH).'gradebook/gradebook_view_result.php?selecteval='.$select_eval.'&'.api_get_cidreq(),
  195. 'name' => get_lang('ViewResult'),
  196. ];
  197. $import_result_form = new DataForm(
  198. DataForm::TYPE_IMPORT,
  199. 'import_result_form',
  200. null,
  201. api_get_self().'?import=&selecteval='.$select_eval,
  202. '_blank',
  203. ''
  204. );
  205. if (!$import_result_form->validate()) {
  206. Display :: display_header(get_lang('Import'));
  207. }
  208. $eval[0]->check_lock_permissions();
  209. if (isset($_POST['formSent']) && $_POST['formSent']) {
  210. if (!empty($_FILES['import_file']['name'])) {
  211. $values = $import_result_form->exportValues();
  212. $file_type = $_POST['file_type'];
  213. $file_name = $_FILES['import_file']['tmp_name'];
  214. $results = Import :: csvToArray($file_name);
  215. $nr_results_added = 0;
  216. foreach ($results as $index => $importedresult) {
  217. //check username & score
  218. $importedresult['user_id'] = UserManager::get_user_id_from_username($importedresult['username']);
  219. $added = '0';
  220. foreach ($allresults as $allresult) {
  221. if (($importedresult['user_id'] == $allresult->get_user_id())) {
  222. if ($importedresult['score'] != $allresult->get_score()) {
  223. if (!isset($values['overwrite'])) {
  224. header('Location: '.api_get_path(WEB_CODE_PATH).'gradebook/gradebook_view_result.php?selecteval='.$select_eval.'&import_score_error='.$importedresult['user_id']);
  225. exit;
  226. break;
  227. } else {
  228. GradebookUtils::overwritescore(
  229. $allresult->get_id(),
  230. $importedresult['score'],
  231. $eval[0]->get_max()
  232. );
  233. $overwritescore++;
  234. $added = '1';
  235. }
  236. } else {
  237. $added = '1';
  238. }
  239. }
  240. }
  241. if ($importedresult['user_id'] == null) {
  242. header('Location: gradebook_view_result.php?selecteval='.$select_eval.'&incorrectdata=');
  243. exit;
  244. }
  245. $userinfo = api_get_user_info($importedresult['user_id']);
  246. if ($userinfo['lastname'] != $importedresult['lastname'] ||
  247. $userinfo['firstname'] != $importedresult['firstname'] ||
  248. $userinfo['official_code'] != $importedresult['official_code']
  249. ) {
  250. if (!isset($values['ignoreerrors'])) {
  251. header('Location: gradebook_view_result.php?selecteval='.$select_eval.'&import_user_error='.$importedresult['user_id']);
  252. exit;
  253. }
  254. }
  255. if ($added != '1') {
  256. if ($importedresult['score'] > $eval[0]->get_max()) {
  257. header('Location: gradebook_view_result.php?selecteval='.$select_eval.'&overwritemax=');
  258. exit;
  259. }
  260. $result = new Result();
  261. $result->set_user_id($importedresult['user_id']);
  262. if (!empty($importedresult['score'])) {
  263. $result->set_score(
  264. api_number_format($importedresult['score'], api_get_setting('gradebook_number_decimals'))
  265. );
  266. }
  267. if (!empty($importedresult['date'])) {
  268. $result->set_date(api_get_utc_datetime($importedresult['date']));
  269. } else {
  270. $result->set_date(api_get_utc_datetime());
  271. }
  272. $result->set_evaluation_id($select_eval);
  273. $result->add();
  274. $nr_results_added++;
  275. }
  276. }
  277. } else {
  278. Display::addFlash(
  279. Display::return_message(
  280. get_lang('ImportNoFile'),
  281. 'warning',
  282. false
  283. )
  284. );
  285. header('Location: '.api_get_self().'?import=&selecteval='.$select_eval.'&importnofile=');
  286. exit;
  287. }
  288. if ($overwritescore != 0) {
  289. Display::addFlash(
  290. Display::return_message(
  291. get_lang('ImportOverWriteScore').' '.$overwritescore
  292. )
  293. );
  294. header('Location: '.api_get_self().'?selecteval='.$select_eval.'&importoverwritescore='.$overwritescore);
  295. exit;
  296. }
  297. if ($nr_results_added == 0) {
  298. Display::addFlash(
  299. Display::return_message(
  300. get_lang('ProblemUploadingFile'),
  301. 'warning',
  302. false
  303. )
  304. );
  305. header('Location: '.api_get_self().'?selecteval='.$select_eval.'&nothingadded=');
  306. exit;
  307. }
  308. Display::addFlash(
  309. Display::return_message(
  310. get_lang('FileUploadComplete'),
  311. 'success',
  312. false
  313. )
  314. );
  315. header('Location: '.api_get_self().'?selecteval='.$select_eval.'&importok=');
  316. exit;
  317. }
  318. }
  319. if (isset($_GET['export'])) {
  320. $interbreadcrumb[] = [
  321. 'url' => 'gradebook_view_result.php?selecteval='.$select_eval.'&'.api_get_cidreq(),
  322. 'name' => get_lang('ViewResult'),
  323. ];
  324. $locked_status = $eval[0]->get_locked();
  325. $export_result_form = new DataForm(
  326. DataForm::TYPE_EXPORT,
  327. 'export_result_form',
  328. null,
  329. api_get_self().'?export=&selecteval='.$select_eval.'&'.api_get_cidreq(),
  330. '_blank',
  331. $locked_status
  332. );
  333. if (!$export_result_form->validate()) {
  334. Display::display_header(get_lang('Export'));
  335. }
  336. if ($export_result_form->validate()) {
  337. $export = $export_result_form->exportValues();
  338. $file_type = $export['file_type'];
  339. $filename = 'export_results_'.gmdate('Y-m-d_H-i-s');
  340. $results = Result::load(null, null, $select_eval);
  341. $data = []; //when file type is csv, add a header to the output file
  342. if ($file_type == 'csv') {
  343. $alldata[] = [
  344. 'username',
  345. 'official_code',
  346. 'lastname',
  347. 'firstname',
  348. 'score',
  349. 'date',
  350. ];
  351. }
  352. // export results to pdf file
  353. if ($file_type == 'pdf') {
  354. $number_decimals = api_get_setting('gradebook_number_decimals');
  355. $datagen = new ResultsDataGenerator($eval[0], $allresults);
  356. // set headers pdf
  357. !empty($_user['official_code']) ? $officialcode = $_user['official_code'].' - ' : '';
  358. $h1 = [get_lang('Teacher'), $officialcode.$_user['firstName'].', '.$_user['lastName']];
  359. $h2 = [get_lang('Score'), $eval[0]->get_max()];
  360. $h3 = [get_lang('Course'), $_course['name']];
  361. $h4 = [get_lang('Weight'), $eval[0]->get_weight()];
  362. $h5 = [get_lang('Session'), api_get_session_name(api_get_session_id())];
  363. $date = date('d-m-Y H:i:s', time());
  364. $h6 = [get_lang('DateTime'), api_convert_and_format_date($date, "%d/%m/%Y %H:%M")];
  365. $header_pdf = [$h1, $h2, $h3, $h4, $h5, $h6];
  366. // set footer pdf
  367. $f1 = '<hr />'.get_lang('Drh');
  368. $f2 = '<hr />'.get_lang('Teacher');
  369. $f3 = '<hr />'.get_lang('Date');
  370. $footer_pdf = [$f1, $f2, $f3];
  371. // set title pdf
  372. $title_pdf = $eval[0]->get_name();
  373. // set headers data table
  374. $head_ape_name = '';
  375. if (api_is_western_name_order()) {
  376. $head_ape_name = get_lang('FirstName').', '.get_lang('LastName');
  377. } else {
  378. $head_ape_name = get_lang('LastName').', '.get_lang('FirstName');
  379. }
  380. $head_table = [
  381. ['#', 3],
  382. [get_lang('Code'), 12],
  383. [$head_ape_name, 40],
  384. [get_lang('Score'), 12],
  385. ];
  386. if ($number_decimals == null) {
  387. $head_table[] = [get_lang('Letters'), 15];
  388. }
  389. $head_display_score = '';
  390. $scoredisplay = ScoreDisplay :: instance();
  391. $customdisplays = $scoredisplay->get_custom_score_display_settings();
  392. if (!empty($customdisplays) && $scoredisplay->is_custom()) {
  393. $head_display_score = get_lang('Display');
  394. $head_table[] = [$head_display_score, 15];
  395. }
  396. // get data table
  397. if (api_sort_by_first_name()) {
  398. $data_array = $datagen->get_data(
  399. ResultsDataGenerator::RDG_SORT_FIRSTNAME,
  400. 0,
  401. null,
  402. false,
  403. true
  404. );
  405. } else {
  406. $data_array = $datagen->get_data(
  407. ResultsDataGenerator::RDG_SORT_LASTNAME,
  408. 0,
  409. null,
  410. false,
  411. true
  412. );
  413. }
  414. $data_table = [];
  415. foreach ($data_array as $data) {
  416. $result = [];
  417. $user_info = api_get_user_info($data['id']);
  418. $result[] = $user_info['username'];
  419. if (api_is_western_name_order()) {
  420. $result[] = $user_info['firstname'].', '.$user_info['lastname'];
  421. } else {
  422. $result[] = $user_info['lastname'].', '.$user_info['firstname'];
  423. }
  424. if ($number_decimals == null) {
  425. if (empty($data['scoreletter']) && !is_numeric($data['score'])) {
  426. $result[] = get_lang('DidNotTakeTheExam');
  427. } else {
  428. $result[] = api_strtoupper(get_lang('Literal'.$data['scoreletter']));
  429. }
  430. } else {
  431. if (empty($data['score']) && !is_numeric($data['score'])) {
  432. $result[] = get_lang('DidNotTakeTheExamAcronym');
  433. } else {
  434. $result[] = $data['score'];
  435. }
  436. }
  437. if ($scoredisplay->is_custom()) {
  438. $result[] = $data['display'];
  439. }
  440. $data_table[] = $result;
  441. }
  442. export_pdf_with_html(
  443. $head_table,
  444. $data_table,
  445. $header_pdf,
  446. $footer_pdf,
  447. $title_pdf
  448. );
  449. }
  450. // export results to xml or csv file
  451. foreach ($results as $result) {
  452. $userinfo = api_get_user_info($result->get_user_id());
  453. $data['username'] = $userinfo['username']; //$result->get_user_id();
  454. $data['official_code'] = $userinfo['official_code'];
  455. $data['lastname'] = $userinfo['lastname'];
  456. $data['firstname'] = $userinfo['firstname'];
  457. $data['score'] = $result->get_score();
  458. $data['date'] = api_format_date($result->get_date(), "%d/%m/%Y %R");
  459. $alldata[] = $data;
  460. }
  461. switch ($file_type) {
  462. case 'xml':
  463. Export::arrayToXml(
  464. $alldata,
  465. $filename,
  466. 'Result',
  467. 'XMLResults'
  468. );
  469. exit;
  470. break;
  471. case 'csv':
  472. Export::arrayToCsv($alldata, $filename);
  473. exit;
  474. break;
  475. }
  476. }
  477. }
  478. if (isset($_GET['resultdelete'])) {
  479. $result = Result::load($_GET['resultdelete']);
  480. $result[0]->delete();
  481. Display::addFlash(Display::return_message(get_lang('ResultDeleted')));
  482. header('Location: gradebook_view_result.php?selecteval='.$select_eval.'&'.api_get_cidreq());
  483. exit;
  484. }
  485. if (isset($_POST['action'])) {
  486. $number_of_selected_items = count($_POST['id']);
  487. if ($number_of_selected_items == '0') {
  488. Display::addFlash(
  489. Display::return_message(
  490. get_lang('NoItemsSelected'),
  491. 'warning',
  492. false
  493. )
  494. );
  495. } else {
  496. switch ($_POST['action']) {
  497. case 'delete':
  498. $number_of_deleted_results = 0;
  499. foreach ($_POST['id'] as $indexstr) {
  500. $result = Result :: load($indexstr);
  501. $result[0]->delete();
  502. $number_of_deleted_results++;
  503. }
  504. Display::addFlash(Display::return_message(get_lang('ResultsDeleted'), 'confirmation', false));
  505. header('Location: gradebook_view_result.php?massdelete=&selecteval='.$select_eval.'&'.api_get_cidreq());
  506. exit;
  507. break;
  508. }
  509. }
  510. } // TODO - what if selecteval not set ?
  511. $addparams = ['selecteval' => $eval[0]->get_id()];
  512. if (isset($_GET['print'])) {
  513. $datagen = new ResultsDataGenerator($eval[0], $allresults);
  514. if (api_sort_by_first_name()) {
  515. $data_array = $datagen->get_data(
  516. ResultsDataGenerator::RDG_SORT_FIRSTNAME,
  517. 0,
  518. null,
  519. true
  520. );
  521. } else {
  522. $data_array = $datagen->get_data(
  523. ResultsDataGenerator::RDG_SORT_LASTNAME,
  524. 0,
  525. null,
  526. true
  527. );
  528. }
  529. if ($displayscore->is_custom()) {
  530. if (api_is_western_name_order()) {
  531. $header_names = [
  532. get_lang('FirstName'),
  533. get_lang('LastName'),
  534. get_lang('Score'),
  535. get_lang('Display'),
  536. ];
  537. } else {
  538. $header_names = [
  539. get_lang('LastName'),
  540. get_lang('FirstName'),
  541. get_lang('Score'),
  542. get_lang('Display'),
  543. ];
  544. }
  545. } else {
  546. if (api_is_western_name_order()) {
  547. $header_names = [get_lang('FirstName'), get_lang('LastName'), get_lang('Score')];
  548. } else {
  549. $header_names = [get_lang('LastName'), get_lang('FirstName'), get_lang('Score')];
  550. }
  551. }
  552. $newarray = [];
  553. foreach ($data_array as $data) {
  554. $newarray[] = array_slice($data, 3);
  555. }
  556. echo print_table(
  557. $newarray,
  558. $header_names,
  559. get_lang('ViewResult'),
  560. $eval[0]->get_name()
  561. );
  562. exit;
  563. } else {
  564. $resultTable = new ResultTable($eval[0], $allresults, $iscourse, $addparams);
  565. }
  566. $htmlHeadXtra[] = '<script>
  567. function confirmationuser() {
  568. if (confirm("'.get_lang('DeleteUser').'?"))
  569. {return true;}
  570. else
  571. {return false;}
  572. }
  573. function confirmationall () {
  574. if (confirm("'.get_lang('DeleteAll').'?"))
  575. {return true;}
  576. else
  577. {return false;}
  578. }
  579. </script>';
  580. if (isset($_GET['deleteall'])) {
  581. $eval[0]->delete_results();
  582. Display::addFlash(Display::return_message(get_lang('AllResultDeleted')));
  583. header('Location: '.api_get_path(WEB_CODE_PATH).'gradebook/gradebook_view_result.php?allresdeleted=&selecteval='.$select_eval.'&'.api_get_cidreq());
  584. exit;
  585. }
  586. if (!isset($_GET['export']) && (!isset($_GET['import']))) {
  587. if (!isset($_GET['selectcat'])) {
  588. $interbreadcrumb[] = [
  589. 'url' => Category::getUrl().'selectcat='.$currentcat[0]->get_id(),
  590. 'name' => get_lang('Details'),
  591. ];
  592. }
  593. $interbreadcrumb[] = [
  594. 'url' => api_get_path(WEB_CODE_PATH).'gradebook/gradebook_view_result.php?selecteval='.$select_eval.'&'.api_get_cidreq(),
  595. 'name' => get_lang('ViewResult'),
  596. ];
  597. Display::display_header();
  598. }
  599. if (isset($_GET['adduser'])) {
  600. echo Display::return_message(get_lang('UserAdded'), 'confirmation', false);
  601. }
  602. if (isset($_GET['incorrectdata'])) {
  603. echo Display::return_message(get_lang('IncorrectData'), 'warning', false);
  604. }
  605. if (isset($_GET['nouser'])) {
  606. echo Display::return_message(get_lang('NoUser'), 'warning', false);
  607. }
  608. if (isset($_GET['overwritemax'])) {
  609. echo Display::return_message(get_lang('OverWriteMax'), 'warning', false);
  610. }
  611. if (isset($_GET['import_user_error'])) {
  612. $userinfo = api_get_user_info($_GET['import_user_error']);
  613. echo Display::return_message(
  614. get_lang('UserInfoDoesNotMatch').' '.
  615. api_get_person_name($userinfo['firstname'], $userinfo['lastname']),
  616. 'warning'
  617. );
  618. }
  619. if (isset($_GET['import_score_error'])) {
  620. $userinfo = api_get_user_info($_GET['import_score_error']);
  621. echo Display::return_message(
  622. get_lang('ScoreDoesNotMatch').' '.
  623. api_get_person_name($userinfo['firstname'], $userinfo['lastname']),
  624. 'warning'
  625. );
  626. }
  627. if ($file_type == null) {
  628. //show the result header
  629. if (isset($export_result_form) && !(isset($edit_res_form))) {
  630. echo $export_result_form->display();
  631. DisplayGradebook::display_header_result($eval[0], $currentcat[0]->get_id(), 1);
  632. } else {
  633. if (isset($import_result_form)) {
  634. echo $import_result_form->display();
  635. }
  636. if (isset($edit_res_form)) {
  637. echo $edit_res_form->toHtml();
  638. }
  639. DisplayGradebook::display_header_result($eval[0], $currentcat[0]->get_id(), 1);
  640. }
  641. // Letter-based scores are built from lib/results_data_generator.class.php::get_score_display()
  642. $resultTable->display();
  643. Display::display_footer();
  644. }