Skip to content

Commit c1ef468

Browse files
committed
Merge branch '1.11.x' of github.com:chamilo/chamilo-lms into 1.11.x
2 parents 822ae55 + b21a8a2 commit c1ef468

File tree

6 files changed

+48
-24
lines changed

6 files changed

+48
-24
lines changed

main/exercise/exercise_report.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
$sessionId = api_get_session_id();
6161
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
6262

63-
if ('export_all_exercises_results' !== $action) {
63+
if ('export_all_exercises_results' !== $action && !(isset($_GET['delete']) && $_GET['delete'] === 'delete')) {
6464
if (empty($exercise_id)) {
6565
api_not_allowed(true);
6666
}
@@ -523,6 +523,10 @@
523523
if (!empty($exe_id)) {
524524
ExerciseLib::deleteExerciseAttempt($exe_id);
525525

526+
if (empty($exercise_id)) {
527+
header('Location: pending.php');
528+
exit;
529+
}
526530
header('Location: exercise_report.php?'.api_get_cidreq().'&exerciseId='.$exercise_id);
527531
exit;
528532
}

main/inc/lib/glossary.lib.php

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ public static function get_glossary_term_by_glossary_name($name)
8282
$table = Database::get_course_table(TABLE_GLOSSARY);
8383
$session_id = api_get_session_id();
8484
$course_id = api_get_course_int_id();
85-
$sessionCondition = api_get_session_condition($session_id);
86-
8785
$glossaryName = Security::remove_XSS($name);
8886
$glossaryName = api_convert_encoding($glossaryName, 'UTF-8', 'UTF-8');
8987
$glossaryName = trim($glossaryName);
@@ -95,16 +93,31 @@ public static function get_glossary_term_by_glossary_name($name)
9593
}
9694

9795
$sql = "SELECT * FROM $table
98-
WHERE
99-
c_id = $course_id AND
100-
(
101-
name LIKE '".Database::escape_string($glossaryName)."'
102-
OR
103-
name LIKE '".Database::escape_string($parsed)."'
104-
)
105-
$sessionCondition
106-
LIMIT 1
107-
";
96+
WHERE
97+
c_id = $course_id AND
98+
(
99+
name LIKE '".Database::escape_string($glossaryName)."' OR
100+
name LIKE '".Database::escape_string($parsed)."'
101+
) AND
102+
session_id = $session_id
103+
LIMIT 1";
104+
105+
$rs = Database::query($sql);
106+
107+
if (Database::num_rows($rs) > 0) {
108+
return Database::fetch_array($rs, 'ASSOC');
109+
}
110+
111+
$sql = "SELECT * FROM $table
112+
WHERE
113+
c_id = $course_id AND
114+
(
115+
name LIKE '".Database::escape_string($glossaryName)."' OR
116+
name LIKE '".Database::escape_string($parsed)."'
117+
) AND
118+
session_id IS NULL
119+
LIMIT 1";
120+
108121
$rs = Database::query($sql);
109122

110123
if (Database::num_rows($rs) > 0) {

main/inc/lib/internationalization.lib.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,7 +1156,7 @@ function api_utf8_encode($string, $from_encoding = 'UTF-8')
11561156
*
11571157
* @see http://php.net/manual/en/function.utf8-decode
11581158
*/
1159-
function api_utf8_decode($string, $to_encoding = null)
1159+
function api_utf8_decode($string, $to_encoding = 'UTF-8')
11601160
{
11611161
return mb_convert_encoding($string, $to_encoding, 'UTF-8');
11621162
}
@@ -1176,7 +1176,7 @@ function api_utf8_decode($string, $to_encoding = null)
11761176
*
11771177
* @return string returns the converted string
11781178
*/
1179-
function api_to_system_encoding($string, $from_encoding = null, $check_utf8_validity = false)
1179+
function api_to_system_encoding($string, $from_encoding = 'UTF-8', $check_utf8_validity = false)
11801180
{
11811181
$system_encoding = api_get_system_encoding();
11821182

main/inc/lib/sessionmanager.lib.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff 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();

main/session/session_export.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,13 @@
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

main/session/session_import.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,7 @@
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
@@ -345,6 +344,7 @@
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.
@@ -357,7 +357,8 @@
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
}
@@ -408,6 +409,7 @@
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'");

0 commit comments

Comments
 (0)