session_import.php 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * @package chamilo.admin
  5. */
  6. $language_file = array('admin', 'registration');
  7. $cidReset = true;
  8. //require_once '../inc/global.inc.php';
  9. $this_section = SECTION_PLATFORM_ADMIN;
  10. api_protect_admin_script(true);
  11. require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
  12. require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php';
  13. $form_sent = 0;
  14. $error_message = ''; // Avoid conflict with the global variable $error_msg (array type) in add_course.conf.php.
  15. if (isset($_GET['action']) && $_GET['action'] == 'show_message') {
  16. $error_message = Security::remove_XSS($_GET['message']);
  17. }
  18. $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
  19. $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
  20. $tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
  21. $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
  22. $tbl_session_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
  23. $tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
  24. $tbl_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
  25. $tool_name = get_lang('ImportSessionListXMLCSV');
  26. $interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
  27. $interbreadcrumb[] = array('url' => 'session_list.php','name' => get_lang('SessionList'));
  28. set_time_limit(0);
  29. // Set this option to true to enforce strict purification for usenames.
  30. $purification_option_for_usernames = false;
  31. $inserted_in_course = array();
  32. global $_configuration;
  33. if (isset($_POST['formSent']) && $_POST['formSent']) {
  34. if (isset($_FILES['import_file']['tmp_name']) && !empty($_FILES['import_file']['tmp_name'])) {
  35. $form_sent = $_POST['formSent'];
  36. $file_type = $_POST['file_type'];
  37. $send_mail = $_POST['sendMail'] ? 1 : 0;
  38. $isOverwrite = $_POST['overwrite'] ? true: false;
  39. $deleteUsersNotInList = isset($_POST['delete_users_not_in_list']) ? true : false;
  40. $sessions = array();
  41. $session_counter = 0;
  42. if ($file_type == 'xml') {
  43. // XML
  44. // SimpleXML for PHP5 deals with various encodings, but how many they are, what are version issues, do we need to waste time with configuration options?
  45. // For avoiding complications we go some sort of "PHP4 way" - we convert the input xml-file into UTF-8 before passing it to the parser.
  46. // Instead of:
  47. // $root = @simplexml_load_file($_FILES['import_file']['tmp_name']);
  48. // we may use the following construct:
  49. // $root = @simplexml_load_string(api_utf8_encode_xml(file_get_contents($_FILES['import_file']['tmp_name'])));
  50. // To ease debugging let us use:
  51. $content = file_get_contents($_FILES['import_file']['tmp_name']);
  52. $content = api_utf8_encode_xml($content);
  53. $root = @simplexml_load_string($content);
  54. unset($content);
  55. if (is_object($root)) {
  56. if (count($root->Users->User) > 0) {
  57. // Creating/updating users from <Sessions> <Users> base node.
  58. foreach ($root->Users->User as $node_user) {
  59. $username = $username_old = trim(api_utf8_decode($node_user->Username));
  60. if (UserManager::is_username_available($username)) {
  61. $password = api_utf8_decode($node_user->Password);
  62. if (empty($password)) {
  63. $password = api_generate_password();
  64. }
  65. switch ($node_user->Status) {
  66. case 'student' :
  67. $status = 5;
  68. break;
  69. case 'teacher' :
  70. $status = 1;
  71. break;
  72. default :
  73. $status = 5;
  74. $error_message .= get_lang('StudentStatusWasGivenTo').' : '.$username.'<br />';
  75. }
  76. $result = UserManager::create_user(
  77. api_utf8_decode($node_user->Firstname),
  78. api_utf8_decode($node_user->Lastname),
  79. $status,
  80. api_utf8_decode($node_user->Email),
  81. $username,
  82. $password,
  83. api_utf8_decode($node_user->OfficialCode),
  84. null,
  85. api_utf8_decode($node_user->Phone),
  86. null,
  87. PLATFORM_AUTH_SOURCE,
  88. null,
  89. 1,
  90. 0,
  91. null,
  92. null,
  93. $send_mail
  94. );
  95. } else {
  96. $lastname = trim(api_utf8_decode($node_user->Lastname));
  97. $firstname = trim(api_utf8_decode($node_user->Firstname));
  98. $password = api_utf8_decode($node_user->Password);
  99. $email = trim(api_utf8_decode($node_user->Email));
  100. $official_code = trim(api_utf8_decode($node_user->OfficialCode));
  101. $phone = trim(api_utf8_decode($node_user->Phone));
  102. $status = trim(api_utf8_decode($node_user->Status));
  103. switch ($status) {
  104. case 'student' : $status = 5; break;
  105. case 'teacher' : $status = 1; break;
  106. default : $status = 5; $error_message .= get_lang('StudentStatusWasGivenTo').' : '.$username.'<br />';
  107. }
  108. $sql = "UPDATE $tbl_user SET
  109. lastname = '".Database::escape_string($lastname)."',
  110. firstname = '".Database::escape_string($firstname)."',
  111. ".(empty($password) ? "" : "password = '".(api_get_encrypted_password($password))."',")."
  112. email = '".Database::escape_string($email)."',
  113. official_code = '".Database::escape_string($official_code)."',
  114. phone = '".Database::escape_string($phone)."',
  115. status = '".Database::escape_string($status)."'
  116. WHERE username = '".Database::escape_string($username)."'";
  117. Database::query($sql);
  118. }
  119. }
  120. }
  121. // Creating courses from <Sessions> <Courses> base node.
  122. if (count($root->Courses->Course) > 0) {
  123. foreach ($root->Courses->Course as $courseNode) {
  124. $params = array();
  125. if (empty($courseNode->CourseTitle)) {
  126. $params['title'] = api_utf8_decode($courseNode->CourseCode);
  127. } else {
  128. $params['title'] = api_utf8_decode($courseNode->CourseTitle);
  129. }
  130. $params['wanted_code'] = api_utf8_decode($courseNode->CourseCode);
  131. $params['tutor_name'] = null;
  132. $params['course_category'] = null;
  133. $params['course_language'] = api_get_valid_language(api_utf8_decode($courseNode->CourseLanguage));
  134. $params['user_id'] = api_get_user_id();
  135. // Looking up for the teacher.
  136. $username = trim(api_utf8_decode($courseNode->CourseTeacher));
  137. $sql = "SELECT user_id, lastname, firstname FROM $tbl_user WHERE username='$username'";
  138. $rs = Database::query($sql);
  139. list($user_id, $lastname, $firstname) = Database::fetch_array($rs);
  140. $params['teachers'] = $user_id;
  141. CourseManager::create_course($params);
  142. }
  143. }
  144. // Creating sessions from <Sessions> base node.
  145. if (count($root->Session) > 0) {
  146. foreach ($root->Session as $node_session) {
  147. $course_counter = 0;
  148. $user_counter = 0;
  149. $session_name = trim(api_utf8_decode($node_session->SessionName));
  150. $coach = UserManager::purify_username(api_utf8_decode($node_session->Coach), $purification_option_for_usernames);
  151. if (!empty($coach)) {
  152. $coach_id = UserManager::get_user_id_from_username($coach);
  153. if ($coach_id === false) {
  154. $error_message .= get_lang('UserDoesNotExist').' : '.$coach.'<br />';
  155. // Forcing the coach id if user does not exist.
  156. $coach_id = api_get_user_id();
  157. }
  158. } else {
  159. // Forcing the coach id.
  160. $coach_id = api_get_user_id();
  161. }
  162. $date_start = trim(api_utf8_decode($node_session->DateStart)); // Just in case - encoding conversion.
  163. if (!empty($date_start)) {
  164. list($year_start, $month_start, $day_start) = explode('/', $date_start);
  165. if(empty($year_start) || empty($month_start) || empty($day_start)) {
  166. $error_message .= get_lang('WrongDate').' : '.$date_start.'<br />';
  167. break;
  168. } else {
  169. $time_start = mktime(0, 0, 0, $month_start, $day_start, $year_start);
  170. }
  171. $date_end = trim(api_utf8_decode($node_session->DateEnd));
  172. if (!empty($date_start)) {
  173. list($year_end, $month_end, $day_end) = explode('/', $date_end);
  174. if (empty($year_end) || empty($month_end) || empty($day_end)) {
  175. $error_message .= get_lang('Error').' : '.$date_end.'<br />';
  176. break;
  177. } else {
  178. $time_end = mktime(0, 0, 0, $month_end, $day_end, $year_end);
  179. }
  180. }
  181. if ($time_end - $time_start < 0) {
  182. $error_message .= get_lang('StartDateShouldBeBeforeEndDate').' : '.$date_end.'<br />';
  183. }
  184. }
  185. $visibility = trim(api_utf8_decode($node_session->Visibility));
  186. $session_category_id = trim(api_utf8_decode($node_session->SessionCategory));
  187. if (!$updatesession) {
  188. // Always create a session.
  189. $unique_name = false; // This MUST be initializead.
  190. $i = 0;
  191. // Change session name, verify that session doesn't exist.
  192. while (!$unique_name) {
  193. if ($i > 1) {
  194. $suffix = ' - '.$i;
  195. }
  196. $sql = 'SELECT 1 FROM '.$tbl_session.' WHERE name="'.Database::escape_string($session_name.$suffix).'"';
  197. $rs = Database::query($sql);
  198. if (Database::result($rs, 0, 0)) {
  199. $i++;
  200. } else {
  201. $unique_name = true;
  202. $session_name .= $suffix;
  203. }
  204. }
  205. // Creating the session.
  206. $sql_session = "INSERT IGNORE INTO $tbl_session SET
  207. name = '".Database::escape_string($session_name)."',
  208. id_coach = '$coach_id',
  209. date_start = '$date_start',
  210. date_end = '$date_end',
  211. visibility = '$visibility',
  212. session_category_id = '$session_category_id',
  213. session_admin_id=".intval($_user['user_id']);
  214. $rs_session = Database::query($sql_session);
  215. $session_id = Database::insert_id();
  216. $session_counter++;
  217. } else {
  218. // Update the session if it is needed.
  219. $my_session_result = SessionManager::get_session_by_name($session_name);
  220. if ($my_session_result === false) {
  221. // Creating the session.
  222. $sql_session = "INSERT IGNORE INTO $tbl_session SET
  223. name = '".Database::escape_string($session_name)."',
  224. id_coach = '$coach_id',
  225. date_start = '$date_start',
  226. date_end = '$date_end',
  227. visibility = '$visibility',
  228. session_category_id = '$session_category_id',
  229. session_admin_id=".intval($_user['user_id']);
  230. $rs_session = Database::query($sql_session);
  231. $session_id = Database::insert_id();
  232. $session_counter++;
  233. } else {
  234. // if the session already exists - update it.
  235. $sql_session = "UPDATE $tbl_session SET
  236. id_coach = '$coach_id',
  237. date_start = '$date_start',
  238. date_end = '$date_end',
  239. visibility = '$visibility',
  240. session_category_id = '$session_category_id'
  241. WHERE name = '$session_name'";
  242. $rs_session = Database::query($sql_session);
  243. $session_id = Database::query("SELECT id FROM $tbl_session WHERE name='$session_name'");
  244. list($session_id) = Database::fetch_array($session_id);
  245. Database::query("DELETE FROM $tbl_session_user WHERE id_session='$session_id'");
  246. Database::query("DELETE FROM $tbl_session_course WHERE id_session='$session_id'");
  247. Database::query("DELETE FROM $tbl_session_course_user WHERE id_session='$session_id'");
  248. }
  249. }
  250. // Associate the session with access_url.
  251. global $_configuration;
  252. if ($_configuration['multiple_access_urls']) {
  253. $access_url_id = api_get_current_access_url_id();
  254. UrlManager::add_session_to_url($session_id, $access_url_id);
  255. } else {
  256. // We fill by default the access_url_rel_session table.
  257. UrlManager::add_session_to_url($session_id, 1);
  258. }
  259. // Adding users to the new session.
  260. foreach ($node_session->User as $node_user) {
  261. $username = UserManager::purify_username(api_utf8_decode($node_user), $purification_option_for_usernames);
  262. $user_id = UserManager::get_user_id_from_username($username);
  263. if ($user_id !== false) {
  264. $sql = "INSERT IGNORE INTO $tbl_session_user SET
  265. id_user='$user_id',
  266. id_session = '$session_id'";
  267. $rs_user = Database::query($sql);
  268. $user_counter++;
  269. }
  270. }
  271. // Adding courses to a session.
  272. foreach ($node_session->Course as $node_course) {
  273. $course_code = Database::escape_string(trim(api_utf8_decode($node_course->CourseCode)));
  274. // Verify that the course pointed by the course code node exists.
  275. if (CourseManager::course_exists($course_code)) {
  276. // If the course exists we continue.
  277. $course_info = CourseManager::get_course_information($course_code);
  278. $session_course_relation = SessionManager::relation_session_course_exist($session_id, $course_code);
  279. if (!$session_course_relation) {
  280. $sql_course = "INSERT INTO $tbl_session_course SET
  281. course_code = '$course_code',
  282. id_session='$session_id'";
  283. $rs_course = Database::query($sql_course);
  284. $course_info = api_get_course_info($course['code']);
  285. SessionManager::installCourse($id_session, $course_info['real_id']);
  286. }
  287. $course_coaches = explode(',', $node_course->Coach);
  288. // Adding coachs to session course user
  289. foreach ($course_coaches as $course_coach) {
  290. $coach_id = UserManager::purify_username(api_utf8_decode($course_coach), $purification_option_for_usernames);
  291. $coach_id = UserManager::get_user_id_from_username($course_coach);
  292. if ($coach_id !== false) {
  293. $sql = "INSERT IGNORE INTO $tbl_session_course_user SET
  294. id_user='$coach_id',
  295. course_code='$course_code',
  296. id_session = '$session_id',
  297. status = 2 ";
  298. $rs_coachs = Database::query($sql);
  299. } else {
  300. $error_message .= get_lang('UserDoesNotExist').' : '.$user.'<br />';
  301. }
  302. }
  303. // Adding users.
  304. $course_counter++;
  305. $users_in_course_counter = 0;
  306. foreach ($node_course->User as $node_user) {
  307. $username = UserManager::purify_username(api_utf8_decode($node_user), $purification_option_for_usernames);
  308. $user_id = UserManager::get_user_id_from_username($username);
  309. if ($user_id !== false) {
  310. // Adding to session_rel_user table.
  311. $sql = "INSERT IGNORE INTO $tbl_session_user SET
  312. id_user='$user_id',
  313. id_session = '$session_id'";
  314. $rs_user = Database::query($sql);
  315. $user_counter++;
  316. // Adding to session_rel_user_rel_course table.
  317. $sql = "INSERT IGNORE INTO $tbl_session_course_user SET
  318. id_user='$user_id',
  319. course_code='$course_code',
  320. id_session = '$session_id'";
  321. $rs_users = Database::query($sql);
  322. $users_in_course_counter++;
  323. } else {
  324. $error_message .= get_lang('UserDoesNotExist').' : '.$username.'<br />';
  325. }
  326. }
  327. $update_session_course = "UPDATE $tbl_session_course SET nbr_users='$users_in_course_counter' WHERE course_code='$course_code'";
  328. Database::query($update_session_course);
  329. $inserted_in_course[$course_code] = $course_info['title'];
  330. }
  331. if (CourseManager::course_exists($course_code, true)) {
  332. // If the course exists we continue.
  333. // Also subscribe to virtual courses through check on visual code.
  334. $list = CourseManager :: get_courses_info_from_visual_code($course_code);
  335. foreach ($list as $vcourse) {
  336. if ($vcourse['code'] == $course_code) {
  337. // Ignore, this has already been inserted.
  338. } else {
  339. $sql_course = "INSERT INTO $tbl_session_course SET
  340. course_code = '".$vcourse['code']."',
  341. id_session='$session_id'";
  342. $rs_course = Database::query($sql_course);
  343. $course_info = api_get_course_info($course['code']);
  344. SessionManager::installCourse($id_session, $course_info['real_id']);
  345. $course_coaches = explode(",",$node_course->Coach);
  346. // adding coachs to session course user
  347. foreach ($course_coaches as $course_coach) {
  348. $coach_id = UserManager::purify_username(api_utf8_decode($course_coach), $purification_option_for_usernames);
  349. $coach_id = UserManager::get_user_id_from_username($course_coach);
  350. if ($coach_id !== false) {
  351. $sql = "INSERT IGNORE INTO $tbl_session_course_user SET
  352. id_user='$coach_id',
  353. course_code='{$vcourse['code']}',
  354. id_session = '$session_id',
  355. status = 2 ";
  356. $rs_coachs = Database::query($sql);
  357. } else {
  358. $error_message .= get_lang('UserDoesNotExist').' : '.$user.'<br />';
  359. }
  360. }
  361. // adding users
  362. $course_counter++;
  363. $users_in_course_counter = 0;
  364. foreach ($node_course->User as $node_user) {
  365. $username = UserManager::purify_username(api_utf8_decode($node_user), $purification_option_for_usernames);
  366. $user_id = UserManager::get_user_id_from_username($username);
  367. if ($user_id !== false) {
  368. // Adding to session_rel_user table.
  369. $sql = "INSERT IGNORE INTO $tbl_session_user SET
  370. id_user='$user_id',
  371. id_session = '$session_id'";
  372. $rs_user = Database::query($sql);
  373. $user_counter++;
  374. // Adding to session_rel_user_rel_course table.
  375. $sql = "INSERT IGNORE INTO $tbl_session_course_user SET
  376. id_user='$user_id',
  377. course_code='{$vcourse['code']}',
  378. id_session = '$session_id'";
  379. $rs_users = Database::query($sql);
  380. $users_in_course_counter++;
  381. } else {
  382. $error_message .= get_lang('UserDoesNotExist').' : '.$username.'<br />';
  383. }
  384. }
  385. $update_session_course = "UPDATE $tbl_session_course SET nbr_users='$users_in_course_counter' WHERE course_code='$course_code'";
  386. Database::query($update_session_course);
  387. $inserted_in_course[$course_code] = $course_info['title'];
  388. }
  389. $inserted_in_course[$vcourse['code']] = $vcourse['title'];
  390. }
  391. } else {
  392. // The course does not exist.
  393. $error_message .= get_lang('CourseDoesNotExist').' : '.$course_code.'<br />';
  394. }
  395. }
  396. Database::query("UPDATE $tbl_session SET nbr_users='$user_counter', nbr_courses='$course_counter' WHERE id='$session_id'");
  397. }
  398. }
  399. if (empty($root->Users->User) && empty($root->Courses->Course) && empty($root->Session)) {
  400. $error_message = get_lang('NoNeededData');
  401. }
  402. } else {
  403. $error_message .= get_lang('XMLNotValid');
  404. }
  405. } else {
  406. // CSV
  407. $updateCourseCoaches = isset($_POST['update_course_coaches']) ? true : false;
  408. $result = SessionManager::importCSV(
  409. $_FILES['import_file']['tmp_name'],
  410. $isOverwrite,
  411. api_get_user_id(),
  412. null,
  413. array(),
  414. null,
  415. null,
  416. null,
  417. 1,
  418. array(),
  419. $deleteUsersNotInList,
  420. $updateCourseCoaches
  421. );
  422. $sessionList = $result['session_list'];
  423. $error_message = $result['error_message'];
  424. $session_counter = $result['session_counter'];
  425. }
  426. if (!empty($error_message)) {
  427. $error_message = get_lang('ButProblemsOccured').' :<br />'.$error_message;
  428. }
  429. if (count($inserted_in_course) > 1) {
  430. $warn = get_lang('SeveralCoursesSubscribedToSessionBecauseOfSameVisualCode').': ';
  431. foreach ($inserted_in_course as $code => $title) {
  432. $warn .= ' '.$title.' ('.$code.'),';
  433. }
  434. $warn = substr($warn, 0, -1);
  435. }
  436. if ($session_counter == 1) {
  437. if ($file_type == 'csv') {
  438. $session_id = current($sessionList);
  439. }
  440. header('Location: resume_session.php?id_session='.$session_id.'&warn='.urlencode($warn));
  441. exit;
  442. } else {
  443. header('Location: session_list.php?action=show_message&message='.urlencode(get_lang('FileImported').' '.$error_message).'&warn='.urlencode($warn));
  444. exit;
  445. }
  446. } else {
  447. $error_message = get_lang('NoInputFile');
  448. }
  449. }
  450. // Display the header.
  451. Display::display_header($tool_name);
  452. if (count($inserted_in_course) > 1) {
  453. $msg = get_lang('SeveralCoursesSubscribedToSessionBecauseOfSameVisualCode').': ';
  454. foreach ($inserted_in_course as $code => $title) {
  455. $msg .= ' '.$title.' ('.$title.'),';
  456. }
  457. $msg = substr($msg, 0, -1);
  458. Display::display_warning_message($msg);
  459. }
  460. echo '<div class="actions">';
  461. echo '<a href="../admin/index.php">'.Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('PlatformAdmin'),'',ICON_SIZE_MEDIUM).'</a>';
  462. echo '</div>';
  463. if (!empty($error_message)) {
  464. Display::display_normal_message($error_message, false);
  465. }
  466. $form = new FormValidator('import_sessions', 'post', api_get_self(), null, array('enctype' => 'multipart/form-data'));
  467. $form->addElement('hidden', 'formSent', 1);
  468. $form->addElement('file', 'import_file', get_lang('ImportFileLocation'));
  469. $form->addElement('radio', 'file_type', array(get_lang('FileType'), '<a href="example_session.csv" target="_blank">'.get_lang('ExampleCSVFile').'</a>'), 'CSV', 'csv');
  470. $form->addElement('radio', 'file_type', array(null, '<a href="example_session.xml" target="_blank">'.get_lang('ExampleXMLFile').'</a>'), 'XML', 'xml');
  471. $form->addElement('checkbox', 'overwrite', null, get_lang('IfSessionExistsUpdate'));
  472. $form->addElement('checkbox', 'delete_users_not_in_list', null, get_lang('DeleteUsersNotInList'));
  473. $form->addElement('checkbox', 'update_course_coaches', null, get_lang('CleanAndUpdateCourseCoaches'));
  474. $form->addElement('checkbox', 'sendMail', null, get_lang('SendMailToUsers'));
  475. $form->addElement('button', 'submit', get_lang('ImportSession'));
  476. $defaults = array('sendMail' => 'true','file_type' => 'csv');
  477. $form->setDefaults($defaults);
  478. Display::display_normal_message(get_lang('TheXMLImportLetYouAddMoreInfoAndCreateResources'));
  479. $form->display();
  480. ?>
  481. <font color="gray">
  482. <p><?php echo get_lang('CSVMustLookLike').' ('.get_lang('MandatoryFields').')'; ?> :</p>
  483. <blockquote>
  484. <pre>
  485. <strong>SessionName</strong>;Coach;<strong>DateStart</strong>;<strong>DateEnd</strong>;Users;Courses
  486. <strong>xxx1</strong>;xxx;<strong>xxx;xxx</strong>;username1|username2;course1[coach1][username1,username2,...]|course2[coach1][username1,username2,...]
  487. <strong>xxx2</strong>;xxx;<strong>xxx;xxx</strong>;username1|username2;course1[coach1][username1,username2,...]|course2[coach1][username1,username2,...]
  488. </pre>
  489. </blockquote>
  490. <p><?php echo get_lang('XMLMustLookLike').' ('.get_lang('MandatoryFields').')'; ?> :</p>
  491. <blockquote>
  492. <pre>
  493. &lt;?xml version=&quot;1.0&quot; encoding=&quot;<?php echo api_refine_encoding_id(api_get_system_encoding()); ?>&quot;?&gt;
  494. &lt;Sessions&gt;
  495. &lt;Users&gt;
  496. &lt;User&gt;
  497. &lt;Username&gt;<strong>username1</strong>&lt;/Username&gt;
  498. &lt;Lastname&gt;xxx&lt;/Lastname&gt;
  499. &lt;Firstname&gt;xxx&lt;/Firstname&gt;
  500. &lt;Password&gt;xxx&lt;/Password&gt;
  501. &lt;Email&gt;xxx@xx.xx&lt;/Email&gt;
  502. &lt;OfficialCode&gt;xxx&lt;/OfficialCode&gt;
  503. &lt;Phone&gt;xxx&lt;/Phone&gt;
  504. &lt;Status&gt;student|teacher&lt;/Status&gt;
  505. &lt;/User&gt;
  506. &lt;/Users&gt;
  507. &lt;Courses&gt;
  508. &lt;Course&gt;
  509. &lt;CourseCode&gt;<strong>xxx</strong>&lt;/CourseCode&gt;
  510. &lt;CourseTeacher&gt;<strong>teacher_username</strong>&lt;/CourseTeacher&gt;
  511. &lt;CourseLanguage&gt;xxx&lt;/CourseLanguage&gt;
  512. &lt;CourseTitle&gt;xxx&lt;/CourseTitle&gt;
  513. &lt;CourseDescription&gt;xxx&lt;/CourseDescription&gt;
  514. &lt;/Course&gt;
  515. &lt;/Courses&gt;
  516. &lt;Session&gt;
  517. <strong>&lt;SessionName&gt;xxx&lt;/SessionName&gt;</strong>
  518. &lt;Coach&gt;xxx&lt;/Coach&gt;
  519. <strong>&lt;DateStart&gt;xxx&lt;/DateStart&gt;</strong>
  520. <strong>&lt;DateEnd&gt;xxx&lt;/DateEnd&gt;</strong>
  521. &lt;User&gt;xxx&lt;/User&gt;
  522. &lt;User&gt;xxx&lt;/User&gt;
  523. &lt;Course&gt;
  524. &lt;CourseCode&gt;coursecode1&lt;/CourseCode&gt;
  525. &lt;Coach&gt;coach1&lt;/Coach&gt;
  526. &lt;User&gt;username1&lt;/User&gt;
  527. &lt;User&gt;username2&lt;/User&gt;
  528. &lt;/Course&gt;
  529. &lt;/Session&gt;
  530. &lt;Session&gt;
  531. <strong>&lt;SessionName&gt;xxx&lt;/SessionName&gt;</strong>
  532. &lt;Coach&gt;xxx&lt;/Coach&gt;
  533. <strong>&lt;DateStart&gt;xxx&lt;/DateStart&gt;</strong>
  534. <strong>&lt;DateEnd&gt;xxx&lt;/DateEnd&gt;</strong>
  535. &lt;User&gt;xxx&lt;/User&gt;
  536. &lt;User&gt;xxx&lt;/User&gt;
  537. &lt;Course&gt;
  538. &lt;CourseCode&gt;coursecode1&lt;/CourseCode&gt;
  539. &lt;Coach&gt;coach1&lt;/Coach&gt;
  540. &lt;User&gt;username1&lt;/User&gt;
  541. &lt;User&gt;username2&lt;/User&gt;
  542. &lt;/Course&gt;
  543. &lt;/Session&gt;
  544. &lt;/Sessions&gt;
  545. </pre>
  546. </blockquote>
  547. </font>
  548. <?php
  549. /* FOOTER */
  550. Display::display_footer();