File tree Expand file tree Collapse file tree 3 files changed +16
-9
lines changed
Expand file tree Collapse file tree 3 files changed +16
-9
lines changed Original file line number Diff line number Diff line change @@ -5084,7 +5084,7 @@ public static function importCSV(
50845084 }
50855085 }
50865086
5087- $ session_name = $ enreg ['SessionName ' ];
5087+ $ session_name = trim ( trim ( api_utf8_decode ( $ enreg ['SessionName ' ]), ' " ' )) ;
50885088
50895089 if ($ debug ) {
50905090 $ logger ->addInfo ('--------------------------------------- ' );
@@ -5536,6 +5536,7 @@ public static function importCSV(
55365536 }
55375537 }
55385538
5539+ $ position = 0 ;
55395540 foreach ($ courses as $ course ) {
55405541 $ courseArray = bracketsToArray ($ course );
55415542 $ course_code = $ courseArray [0 ];
@@ -5546,7 +5547,7 @@ public static function importCSV(
55465547
55475548 // Adding the course to a session.
55485549 $ sql = "INSERT IGNORE INTO $ tbl_session_course
5549- SET c_id = ' $ courseId', session_id=' $ session_id' " ;
5550+ SET c_id = ' $ courseId', session_id=' $ session_id', position = ' $ position ' " ;
55505551 Database::query ($ sql );
55515552
55525553 self ::installCourse ($ session_id , $ courseInfo ['real_id ' ]);
@@ -5934,6 +5935,7 @@ public static function importCSV(
59345935 }
59355936 }
59365937 $ inserted_in_course [$ course_code ] = $ courseInfo ['title ' ];
5938+ $ position ++;
59375939 }
59385940 }
59395941 $ access_url_id = api_get_current_access_url_id ();
Original file line number Diff line number Diff line change 162162 }
163163
164164 // Courses
165- $ sql = "SELECT DISTINCT c.code, sc.c_id
166- FROM $ tbl_course c
167- INNER JOIN $ tbl_session_course_user sc
168- ON c.id = sc.c_id AND sc.session_id = ' " .$ row ['id ' ]."' " ;
165+ $ sql = "SELECT DISTINCT c.code, sc.c_id, sr.position
166+ FROM $ tbl_course c
167+ INNER JOIN $ tbl_session_course_user sc
168+ ON c.id = sc.c_id AND sc.session_id = ' " .$ row ['id ' ]."'
169+ INNER JOIN $ tbl_session_course sr
170+ ON sc.session_id = sr.session_id AND sc.c_id = sr.c_id
171+ ORDER BY sr.position ASC " ;
169172
170173 $ rsCourses = Database::query ($ sql );
171174
Original file line number Diff line number Diff line change 188188 foreach ($ root ->Session as $ node_session ) {
189189 $ course_counter = 0 ;
190190 $ user_counter = 0 ;
191-
192- $ session_name = trim (api_utf8_decode ($ node_session ->SessionName ));
191+ $ session_name = trim (trim (api_utf8_decode ($ node_session ->SessionName ), '" ' ));
193192 $ coach = UserManager::purify_username (
194193 api_utf8_decode ($ node_session ->Coach ),
195194 $ purification_option_for_usernames
345344 }
346345
347346 // Adding courses to a session.
347+ $ position = 0 ;
348348 foreach ($ node_session ->Course as $ node_course ) {
349349 $ course_code = Database::escape_string (trim (api_utf8_decode ($ node_course ->CourseCode )));
350350 // Verify that the course pointed by the course code node exists.
357357 if (!$ session_course_relation ) {
358358 $ sql_course = "INSERT INTO $ tbl_session_course SET
359359 c_id = $ courseId,
360- session_id = $ session_id " ;
360+ session_id = $ session_id,
361+ position = $ position " ;
361362 $ rs_course = Database::query ($ sql_course );
362363 SessionManager::installCourse ($ session_id , $ courseId );
363364 }
408409 $ sql = "UPDATE $ tbl_session_course SET nbr_users=' $ users_in_course_counter' WHERE c_id=' $ courseId' " ;
409410 Database::query ($ sql );
410411 $ inserted_in_course [$ course_code ] = $ course_info ['title ' ];
412+ $ position ++;
411413 }
412414 }
413415 Database::query ("UPDATE $ tbl_session SET nbr_users=' $ user_counter', nbr_courses=' $ course_counter' WHERE id=' $ session_id' " );
You can’t perform that action at this time.
0 commit comments