diff --git a/public/legacy.php b/public/legacy.php
index 7e0e69ee74..7ff53cc93b 100644
--- a/public/legacy.php
+++ b/public/legacy.php
@@ -17,4 +17,3 @@ require_once __DIR__.'/main/inc/lib/fileDisplay.lib.php';
require_once __DIR__.'/main/inc/lib/specific_fields_manager.lib.php';
require_once __DIR__.'/main/forum/forumfunction.inc.php';
require_once __DIR__.'/main/work/work.lib.php';
-
diff --git a/public/main/exercise/exercise.class.php b/public/main/exercise/exercise.class.php
index aa0086d88b..f6bcaf166f 100644
--- a/public/main/exercise/exercise.class.php
+++ b/public/main/exercise/exercise.class.php
@@ -3630,7 +3630,7 @@ class Exercise
if (ORAL_EXPRESSION == $answerType) {
$exe_info = Event::get_exercise_results_by_attempt($exeId);
$exe_info = isset($exe_info[$exeId]) ? $exe_info[$exeId] : null;
-
+ /** @var OralExpression $objQuestionTmp */
$objQuestionTmp->initFile(
api_get_session_id(),
isset($exe_info['exe_user_id']) ? $exe_info['exe_user_id'] : api_get_user_id(),
@@ -5058,13 +5058,13 @@ class Exercise
$showTotalScoreAndUserChoicesInLastAttempt
);
} elseif (HOT_SPOT_ORDER == $answerType) {
- ExerciseShowFunctions::display_hotspot_order_answer(
+ /*ExerciseShowFunctions::display_hotspot_order_answer(
$feedback_type,
$answerId,
$answer,
$studentChoice,
$answerComment
- );
+ );*/
} elseif (HOT_SPOT_DELINEATION == $answerType) {
$user_answer = $_SESSION['exerciseResultCoordinates'][$questionId];
@@ -5422,6 +5422,7 @@ class Exercise
break;
case ORAL_EXPRESSION:
+ /** @var OralExpression $objQuestionTmp */
echo '
'.
ExerciseShowFunctions::display_oral_expression_answer(
@@ -5588,13 +5589,13 @@ class Exercise
break;
case HOT_SPOT_ORDER:
- ExerciseShowFunctions::display_hotspot_order_answer(
+ /*ExerciseShowFunctions::display_hotspot_order_answer(
$feedback_type,
$answerId,
$answer,
$studentChoice,
$answerComment
- );
+ );*/
break;
case DRAGGABLE:
@@ -5755,8 +5756,7 @@ class Exercise
echo $message;
$_SESSION['hotspot_delineation_result'][$this->getId()][$questionId][0] = $message;
- $_SESSION['hotspot_delineation_result'][$this->selgetIdectId(
- )][$questionId][1] = $_SESSION['exerciseResultCoordinates'][$questionId];
+ $_SESSION['hotspot_delineation_result'][$this->getId()][$questionId][1] = $_SESSION['exerciseResultCoordinates'][$questionId];
} else {
echo $hotspot_delineation_result[0];
}
@@ -9504,7 +9504,7 @@ class Exercise
$currentRow['id'] = $exercise->id;
$currentRow['url'] = $webPath.'exercise/overview.php?'
.api_get_cidreq_params($courseInfo['code'], $sessionId).'&'
- ."$mylpid$mylpitemid&exerciseId={$row['id']}";
+ ."$mylpid$mylpitemid&exerciseId={$exercise->id}";
$currentRow['name'] = $currentRow[0];
}
}
diff --git a/public/main/gradebook/gradebook_flatview.php b/public/main/gradebook/gradebook_flatview.php
index 3ae409a72a..708f532253 100644
--- a/public/main/gradebook/gradebook_flatview.php
+++ b/public/main/gradebook/gradebook_flatview.php
@@ -3,7 +3,7 @@
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../inc/global.inc.php';
-require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/fe/exportgradebook.php';
+require_once __DIR__.'/lib/fe/exportgradebook.php';
$current_course_tool = TOOL_GRADEBOOK;
@@ -51,7 +51,7 @@ if ($showlink) {
$alllinks = $cat[0]->get_links($userId, true);
}
-global $file_type;
+/*global $file_type;
if (isset($export_flatview_form) && 'pdf' === !$file_type) {
Display::addFlash(
Display::return_message(
@@ -60,7 +60,7 @@ if (isset($export_flatview_form) && 'pdf' === !$file_type) {
false
)
);
-}
+}*/
$category_id = 0;
if (isset($_GET['selectcat'])) {
$category_id = (int) $_GET['selectcat'];
diff --git a/public/main/gradebook/gradebook_view_result.php b/public/main/gradebook/gradebook_view_result.php
index 3aa743cd0c..12e6acc8e3 100644
--- a/public/main/gradebook/gradebook_view_result.php
+++ b/public/main/gradebook/gradebook_view_result.php
@@ -3,7 +3,7 @@
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../inc/global.inc.php';
-require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/fe/exportgradebook.php';
+require_once __DIR__.'/lib/fe/exportgradebook.php';
api_block_anonymous_users();
$isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
@@ -23,9 +23,11 @@ $interbreadcrumb[] = [
//load the evaluation & category
$select_eval = (int) $_GET['selecteval'];
if (empty($select_eval)) {
- api_not_allowed();
+ api_not_allowed(true);
}
+$_course = api_get_course_info();
+$_user = api_get_user_info();
$displayscore = ScoreDisplay::instance();
$eval = Evaluation::load($select_eval);
$overwritescore = 0;
@@ -360,7 +362,7 @@ if (isset($_GET['export'])) {
$filename = 'export_results_'.gmdate('Y-m-d_H-i-s');
$results = Result::load(null, null, $select_eval);
$data = []; //when file type is csv, add a header to the output file
- if ('csv' == $file_type) {
+ if ('csv' === $file_type) {
$alldata[] = [
'username',
'official_code',
@@ -372,7 +374,7 @@ if (isset($_GET['export'])) {
}
// export results to pdf file
- if ('pdf' == $file_type) {
+ if ('pdf' === $file_type) {
$number_decimals = api_get_setting('gradebook_number_decimals');
$datagen = new ResultsDataGenerator($eval[0], $allresults);
diff --git a/public/main/gradebook/lib/be/abstractlink.class.php b/public/main/gradebook/lib/be/abstractlink.class.php
index d6d71fb72b..175aa9213d 100644
--- a/public/main/gradebook/lib/be/abstractlink.class.php
+++ b/public/main/gradebook/lib/be/abstractlink.class.php
@@ -372,13 +372,11 @@ abstract class AbstractLink implements GradebookItem
public function add()
{
$this->add_linked_data();
- if (isset($this->type) &&
- isset($this->ref_id) &&
- isset($this->user_id) &&
- isset($this->course_code) &&
- isset($this->category) &&
- isset($this->weight) &&
- isset($this->visible)
+ if (!empty($this->type) &&
+ !empty($this->ref_id) &&
+ !empty($this->user_id) &&
+ !empty($this->course_code) &&
+ !empty($this->category)
) {
$table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
$sql = "SELECT count(*) count FROM $table
diff --git a/public/main/gradebook/lib/be/evaluation.class.php b/public/main/gradebook/lib/be/evaluation.class.php
index da5c553102..51ea1b8437 100644
--- a/public/main/gradebook/lib/be/evaluation.class.php
+++ b/public/main/gradebook/lib/be/evaluation.class.php
@@ -393,7 +393,7 @@ class Evaluation implements GradebookItem
$sql .= 'null';
}
$sql .= ', category_id = ';
- if (isset($this->category)) {
+ if (!empty($this->category)) {
$sql .= intval($this->get_category_id());
} else {
$sql .= 'null';
diff --git a/public/main/gradebook/lib/fe/catform.class.php b/public/main/gradebook/lib/fe/catform.class.php
index c3dbd05470..deb9def6fe 100644
--- a/public/main/gradebook/lib/fe/catform.class.php
+++ b/public/main/gradebook/lib/fe/catform.class.php
@@ -153,7 +153,7 @@ class CatForm extends FormValidator
$category_name = $this->category_object->get_name();
// The main course category:
- if (isset($this->category_object) && 0 == $this->category_object->get_parent_id()) {
+ if (!empty($this->category_object) && 0 == $this->category_object->get_parent_id()) {
if (empty($category_name)) {
$category_name = $course_code;
}
@@ -219,9 +219,7 @@ class CatForm extends FormValidator
);
$this->addRule('name', get_lang('Required field'), 'required');
- if (isset($this->category_object) &&
- 0 == $this->category_object->get_parent_id()
- ) {
+ if (!empty($this->category_object) && 0 == $this->category_object->get_parent_id()) {
// we can't change the root category
$this->freeze('name');
}
diff --git a/public/main/gradebook/lib/fe/exportgradebook.php b/public/main/gradebook/lib/fe/exportgradebook.php
index f035becab6..51acf9724d 100644
--- a/public/main/gradebook/lib/fe/exportgradebook.php
+++ b/public/main/gradebook/lib/fe/exportgradebook.php
@@ -1,8 +1,6 @@
get_id();
}
- if (isset($this->category) && !empty($this->category)) {
+ if (!empty($this->category)) {
$categories = Category::load(
null,
null,
diff --git a/public/main/inc/lib/SortableTableFromArrayConfig.php b/public/main/inc/lib/SortableTableFromArrayConfig.php
index cd2ee2f061..da8935a14a 100644
--- a/public/main/inc/lib/SortableTableFromArrayConfig.php
+++ b/public/main/inc/lib/SortableTableFromArrayConfig.php
@@ -97,7 +97,7 @@ class SortableTableFromArrayConfig extends SortableTable
*/
public function get_total_number_of_items()
{
- if (isset($this->total_number_of_items) && !empty($this->total_number_of_items)) {
+ if (!empty($this->total_number_of_items) && $this->total_number_of_items !== -1) {
return $this->total_number_of_items;
} else {
if (!empty($this->table_data)) {
diff --git a/public/main/inc/lib/api.lib.php b/public/main/inc/lib/api.lib.php
index db70903c8e..1995604258 100644
--- a/public/main/inc/lib/api.lib.php
+++ b/public/main/inc/lib/api.lib.php
@@ -1889,7 +1889,7 @@ function api_get_user_info_from_entity(
$result['user_is_online'] = true == $result['user_is_online'] ? 1 : 0;
}
if (isset($result['user_is_online_in_chat'])) {
- $result['user_is_online_in_chat'] = (int) $result['user_is_online_in_chat'];
+ $result['user_is_online_in_chat'] = $result['user_is_online_in_chat'];
}
$result['password'] = '';
diff --git a/public/main/inc/lib/career.lib.php b/public/main/inc/lib/career.lib.php
index 9aa4836f16..165d51b376 100644
--- a/public/main/inc/lib/career.lib.php
+++ b/public/main/inc/lib/career.lib.php
@@ -594,7 +594,7 @@ class Career extends Model
'',
$value
);
- $simpleSecondConnection = 'g'.(int) $groupValueId;
+ $simpleSecondConnection = 'g'.$groupValueId;
} else {
// Course block (row_123 id)
if (!empty($explode[0]) && isset($explode[1])) {
diff --git a/public/main/inc/lib/course.lib.php b/public/main/inc/lib/course.lib.php
index 5b5d4ab118..3dffcaecd1 100644
--- a/public/main/inc/lib/course.lib.php
+++ b/public/main/inc/lib/course.lib.php
@@ -289,7 +289,7 @@ class CourseManager
if (!in_array($orderdirection, ['ASC', 'DESC'])) {
$sql .= 'ASC';
} else {
- $sql .= ('ASC' == $orderdirection ? 'ASC' : 'DESC');
+ $sql .= ('ASC' === $orderdirection ? 'ASC' : 'DESC');
}
if (!empty($howmany) && is_int($howmany) and $howmany > 0) {
@@ -299,7 +299,7 @@ class CourseManager
}
if (!empty($from)) {
$from = (int) $from;
- $sql .= ' OFFSET '.(int) $from;
+ $sql .= ' OFFSET '.$from;
} else {
$sql .= ' OFFSET 0';
}
@@ -476,7 +476,6 @@ class CourseManager
// Erase user student publications (works) in the course - by André Boivin
if (!empty($userList)) {
- require_once api_get_path(SYS_CODE_PATH).'work/work.lib.php';
foreach ($userList as $userId) {
// Getting all work from user
$workList = getWorkPerUser($userId);
@@ -891,7 +890,7 @@ class CourseManager
'status' => $status,
'sort' => $maxSort + 1,
'relation_type' => 0,
- 'user_course_cat' => (int) $userCourseCategoryId,
+ 'user_course_cat' => $userCourseCategoryId,
];
$insertId = Database::insert($courseUserTable, $params);
@@ -924,11 +923,9 @@ class CourseManager
$subscribe = (int) api_get_course_setting('subscribe_users_to_forum_notifications', $courseInfo);
if (1 === $subscribe) {
- require_once api_get_path(SYS_CODE_PATH).'forum/forumfunction.inc.php';
$forums = get_forums(0, $courseCode, true, $sessionId);
foreach ($forums as $forum) {
- $forumId = $forum['iid'];
- set_notification('forum', $forumId, false, $userInfo, $courseInfo);
+ set_notification('forum', $forum->getIid(), false, $userInfo, $courseInfo);
}
}
@@ -2926,8 +2923,9 @@ class CourseManager
// Restriction by user id
$currentUserRestriction = '';
+
+ $byUserId = (int) $byUserId;
if ($byUserId > 0) {
- $byUserId = (int) $byUserId;
$currentUserRestriction = " AND tcruc.user_id = $byUserId ";
}
diff --git a/public/main/inc/lib/dashboard.lib.php b/public/main/inc/lib/dashboard.lib.php
index f5b8e59d85..86956a4dbc 100644
--- a/public/main/inc/lib/dashboard.lib.php
+++ b/public/main/inc/lib/dashboard.lib.php
@@ -47,13 +47,13 @@ class DashboardManager
// change index to lower case
$plugin_info = array_change_key_case($plugin_info);
-
echo ' |