Skip to content

Commit adad61f

Browse files
committed
Minor: Format code
1 parent 16fbd41 commit adad61f

34 files changed

+748
-708
lines changed

main/admin/user_import.php

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,11 @@ function complete_missing_data(array $user): array
256256
* Save the imported data.
257257
*
258258
* @uses global $inserted_in_course, which returns the list of courses the user was inserted in
259-
* @param array $users
260-
* @param bool $sendMail
261-
* @param string|null $targetFolder
262-
* @return array The $users array, with 'message' and (for reused users) 'id' set
259+
*
260+
* @return array The $users array, with 'message' and (for reused users) 'id' set
263261
*/
264-
function save_data(array $users, bool $sendMail = false, ?string $targetFolder = null): array {
262+
function save_data(array $users, bool $sendMail = false, ?string $targetFolder = null): array
263+
{
265264
global $inserted_in_course, $extra_fields;
266265

267266
// Not all scripts declare the $inserted_in_course array (although they should).
@@ -290,15 +289,15 @@ function save_data(array $users, bool $sendMail = false, ?string $targetFolder =
290289
}
291290

292291
$returnMessage = '';
293-
$user_id = null;
292+
$user_id = null;
294293

295294
// 1) If the CSV row has that unique extra‑field, try to look up an existing user
296295
if (!empty($uniqueField) && !empty($user[$uniqueField])) {
297296
// pass true to getUserId mode
298297
$existing = UserManager::isExtraFieldValueUniquePerUrl($user[$uniqueField], true);
299298
if ($existing !== null) {
300299
// existing user found → reuse
301-
$user_id = $existing;
300+
$user_id = $existing;
302301
$returnMessage = Display::return_message(
303302
sprintf(
304303
get_lang('ExistingUserWithSameExtraFieldValue'),
@@ -315,7 +314,7 @@ function save_data(array $users, bool $sendMail = false, ?string $targetFolder =
315314
// fill in missing fields, generate password, etc.
316315
$user = complete_missing_data($user);
317316
$user['Status'] = api_status_key($user['Status']);
318-
$redirection = $user['Redirection'] ?? '';
317+
$redirection = $user['Redirection'] ?? '';
319318

320319
$user_id = UserManager::create_user(
321320
$user['FirstName'],
@@ -421,9 +420,9 @@ function save_data(array $users, bool $sendMail = false, ?string $targetFolder =
421420
}
422421

423422
// 7) Record success
424-
$user['id'] = $user_id;
423+
$user['id'] = $user_id;
425424
$user['message'] = $returnMessage;
426-
$userSaved[] = $user;
425+
$userSaved[] = $user;
427426
}
428427

429428
// Save with success, error and warning users
@@ -764,7 +763,7 @@ function processUsers(array &$users, bool $sendMail, ?string $targetFolder = nul
764763
'error'
765764
)
766765
);
767-
header('Location: ' . api_get_self());
766+
header('Location: '.api_get_self());
768767
exit;
769768
}
770769
}

main/attendance/attendance_sheet.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ function UpdateTableHeaders() {
286286
if ($allowSignature) {
287287
$iconFullScreen = Display::url(
288288
Display::return_icon('view_fullscreen.png', get_lang('SeeForTablet'), [], ICON_SIZE_SMALL),
289-
api_get_self().'?'.api_get_cidreq().'&action=attendance_sheet_list&func=fullscreen&attendance_id='.$attendance_id.'&calendar_id='.$calendar['id'] . (!empty($groupId) ? '&group_id=' . $groupId : '')
289+
api_get_self().'?'.api_get_cidreq().'&action=attendance_sheet_list&func=fullscreen&attendance_id='.$attendance_id.'&calendar_id='.$calendar['id'].(!empty($groupId) ? '&group_id='.$groupId : '')
290290
);
291291
$isBlocked = 0;
292292
$iconBlockName = 'eyes.png';

main/auth/sort_my_courses.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
if ($getMove = $httpRequest->query->get('move')) {
9797
$getCourse = Security::remove_XSS($httpRequest->query->get('course'));
9898
$getMove = Security::remove_XSS($getMove);
99-
$getCategory = Security::remove_XSS($httpRequest->query->get('category'));;
99+
$getCategory = Security::remove_XSS($httpRequest->query->get('category'));
100100
if (!empty($getCourse)) {
101101
$result = $auth->move_course($getMove, $getCourse, $getCategory);
102102
if ($result) {

main/cron/import_users_from_xlsx.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ function normalizeName($name)
147147
function removeAccents($str)
148148
{
149149
$str = str_replace(
150-
['à', 'á', 'â', 'ã', 'ä', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ù', 'ú', 'û', 'ü', 'ý', 'ÿ', 'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ù', 'Ú', 'Û', 'Ü', 'Ý',"'"],
151-
['a', 'a', 'a', 'a', 'a', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', 'n', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'u', 'y', 'y', 'A', 'A', 'A', 'A', 'A', 'A', 'C', 'E', 'E', 'E', 'E', 'I', 'I', 'I', 'I', 'N', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'Y',''],
150+
['à', 'á', 'â', 'ã', 'ä', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ù', 'ú', 'û', 'ü', 'ý', 'ÿ', 'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', "'"],
151+
['a', 'a', 'a', 'a', 'a', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', 'n', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'u', 'y', 'y', 'A', 'A', 'A', 'A', 'A', 'A', 'C', 'E', 'E', 'E', 'E', 'I', 'I', 'I', 'I', 'N', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'Y', ''],
152152
$str
153153
);
154154

@@ -186,15 +186,15 @@ function generateProposedLogin($xlsxLastname, $xlsxFirstname, $isActive, &$usedL
186186
if ($letterCount > strlen($lastPartLetters) - 1) {
187187
break; // No more letters available. Will append a number below
188188
}
189-
$login = $baseLogin . substr($lastPartLetters, 1, $letterCount);
189+
$login = $baseLogin.substr($lastPartLetters, 1, $letterCount);
190190
}
191191
}
192192

193193
// Ensure uniqueness by appending a number if still conflicting
194194
$suffix = 1;
195195
$originalLogin = $login;
196196
while (isset($usedLogins['logins'][$login]) && $usedLogins['logins'][$login]['active']) {
197-
$login = $originalLogin . $suffix;
197+
$login = $originalLogin.$suffix;
198198
$suffix++;
199199
}
200200

@@ -236,14 +236,15 @@ function createMissingFieldFile($filename, $rows, $columns)
236236
}
237237

238238
/**
239-
* Generate a tentative e-mail address from firstname and lastname
239+
* Generate a tentative e-mail address from firstname and lastname.
240240
*/
241241
function generateMailFromFirstAndLastNames(string $firstname, string $lastname, string $domain): string
242242
{
243243
$emailLastnameParts = preg_split('/[\s-]+/', trim(removeAccents($lastname)), -1, PREG_SPLIT_NO_EMPTY);
244244
$emailLastname = !empty($emailLastnameParts[0]) ? strtolower($emailLastnameParts[0]) : '';
245245
$emailFirstnameParts = preg_split('/[\s-]+/', trim(removeAccents($firstname)), -1, PREG_SPLIT_NO_EMPTY);
246246
$emailFirstname = !empty($emailFirstnameParts[0]) ? strtolower($emailFirstnameParts[0]) : '';
247+
247248
return "$emailLastname.$emailFirstname@$domain";
248249
}
249250

@@ -363,7 +364,7 @@ function generateMailFromFirstAndLastNames(string $firstname, string $lastname,
363364
'Username' => $dbUser['username'],
364365
'User ID' => $dbUser['id'],
365366
'E-mail' => $dbUser['email'],
366-
'Active' => $dbUser['active']?'Yes':'No',
367+
'Active' => $dbUser['active'] ? 'Yes' : 'No',
367368
];
368369
}
369370
}
@@ -408,8 +409,7 @@ function generateMailFromFirstAndLastNames(string $firstname, string $lastname,
408409
$xlsxUserData['username'] = generateProposedLogin($xlsxUserData['lastname'], $xlsxUserData['firstname'], $isActive, $usedLogins);
409410
$dbUsername = Database::escape_string($xlsxUserData['username']);
410411

411-
if (!empty($xlsxUserData['official_code']) && !empty($generatedEmails[$xlsxUserData['official_code']]))
412-
{
412+
if (!empty($xlsxUserData['official_code']) && !empty($generatedEmails[$xlsxUserData['official_code']])) {
413413
$emailSource = 'E-mail generated during import';
414414
$xlsxUserData['email'] = $generatedEmails[$xlsxUserData['official_code']];
415415
} elseif (!empty($rowData['emailSource'])) {
@@ -553,7 +553,7 @@ function generateMailFromFirstAndLastNames(string $firstname, string $lastname,
553553
'E-mail' => $xlsxUserData['email'],
554554
'E-mail source' => $emailSource,
555555
'External User ID' => $xlsxMatricule,
556-
'Updated Fields' => implode(', ', array_map(function($update) { return trim(explode(':', $update)[0]); }, $updates)),
556+
'Updated Fields' => implode(', ', array_map(function ($update) { return trim(explode(':', $update)[0]); }, $updates)),
557557
];
558558
} else {
559559
echo " Error: Could not update user (username: $dbUsername)\n";
@@ -595,7 +595,7 @@ function generateMailFromFirstAndLastNames(string $firstname, string $lastname,
595595
'E-mail' => $xlsxUserData['email'],
596596
'E-mail source' => $emailSource,
597597
'External User ID' => $xlsxMatricule,
598-
'Updated Fields' => implode(', ', array_map(function($update) { return trim(explode(':', $update)[0]); }, $updates)),
598+
'Updated Fields' => implode(', ', array_map(function ($update) { return trim(explode(':', $update)[0]); }, $updates)),
599599
];
600600
}
601601
} else {

main/exercise/exercise.class.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4528,11 +4528,11 @@ function ($answerId) use ($objAnswerTmp) {
45284528
// Works with cyrillic alphabet and when using ">" chars see #7718 #7610 #7618
45294529
// ENT_QUOTES is used in order to transform ' to '
45304530
//if (!$from_database) {
4531-
$studentAnswer = FillBlanks::clearStudentAnswer($studentAnswer);
4532-
if ($debug) {
4533-
error_log('Student answer cleaned:');
4534-
error_log($studentAnswer);
4535-
}
4531+
$studentAnswer = FillBlanks::clearStudentAnswer($studentAnswer);
4532+
if ($debug) {
4533+
error_log('Student answer cleaned:');
4534+
error_log($studentAnswer);
4535+
}
45364536
//}
45374537

45384538
$isAnswerCorrect = 0;

main/exercise/fill_blanks.class.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,8 +1257,6 @@ public static function getHtmlDisplayForAnswer(
12571257
* @param int $feedbackType
12581258
* @param bool $resultsDisabled
12591259
* @param bool $showTotalScoreAndUserChoices
1260-
*
1261-
* @return string
12621260
*/
12631261
public static function getHtmlAnswer(
12641262
$answer,
@@ -1268,8 +1266,7 @@ public static function getHtmlAnswer(
12681266
$resultsDisabled = false,
12691267
$showTotalScoreAndUserChoices = false,
12701268
$exercise
1271-
): string
1272-
{
1269+
): string {
12731270
$hideExpectedAnswer = false;
12741271
$hideUserSelection = false;
12751272
if (!$exercise->showExpectedChoiceColumn()) {
@@ -1411,8 +1408,6 @@ public static function getHtmlWrongAnswer(
14111408
* Check if a answer is correct by its text.
14121409
*
14131410
* @param string $answerText
1414-
*
1415-
* @return bool
14161411
*/
14171412
public static function isCorrect($answerText): bool
14181413
{
@@ -1433,8 +1428,6 @@ public static function isCorrect($answerText): bool
14331428
* Clear the answer entered by student.
14341429
*
14351430
* @param string $answer
1436-
*
1437-
* @return string
14381431
*/
14391432
public static function clearStudentAnswer($answer): string
14401433
{

main/exercise/hotspot_admin.inc.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* @author Toon Keppens
1414
*/
1515
$modifyAnswers = (int) $_GET['hotspotadmin'];
16-
if (!is_object($objQuestion) || empty($objQuestion->iid) || (int)$objQuestion->iid !== $modifyAnswers) {
16+
if (!is_object($objQuestion) || empty($objQuestion->iid) || (int) $objQuestion->iid !== $modifyAnswers) {
1717
$objQuestion = Question::read($modifyAnswers);
1818
if (!$objQuestion) {
1919
api_not_allowed();
@@ -334,9 +334,9 @@
334334
);
335335
$objAnswer->save();
336336

337-
$objQuestion->iid = (int)$modifyAnswers;
337+
$objQuestion->iid = (int) $modifyAnswers;
338338
$objQuestion->course = api_get_course_info();
339-
$objQuestion->updateWeighting((float)$questionWeighting);
339+
$objQuestion->updateWeighting((float) $questionWeighting);
340340

341341
$objQuestion->save($objExercise);
342342

main/gradebook/gradebook_add_result.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
api_protect_course_script(true);
99
api_block_anonymous_users();
1010
GradebookUtils::block_students();
11-
11+
1212
if (isset($_GET['import'])) {
1313
$queryString = $_SERVER['QUERY_STRING'];
1414
$webPath = api_get_path(WEB_CODE_PATH);
15-
$newUrl = $webPath . 'gradebook/gradebook_view_result.php';
15+
$newUrl = $webPath.'gradebook/gradebook_view_result.php';
1616
if (!empty($queryString)) {
17-
$newUrl .= '?' . $queryString;
17+
$newUrl .= '?'.$queryString;
1818
}
1919
header("Location: $newUrl");
2020
exit;

main/inc/ajax/document.ajax.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@
236236
'uploaded' => 0,
237237
'error' => [
238238
'message' => $e->getMessage(),
239-
]
239+
],
240240
]);
241241

242242
exit;

main/inc/lib/PortfolioController.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4309,10 +4309,7 @@ private function getCommentsInHtmlFormatted(array $comments): array
43094309
}
43104310

43114311
/**
4312-
* @param string $htmlContent
43134312
* @param array $imagePaths Relative paths found in $htmlContent
4314-
*
4315-
* @return string
43164313
*/
43174314
private function fixMediaSourcesToHtml(string $htmlContent, array &$imagePaths): string
43184315
{
@@ -4343,7 +4340,7 @@ private function fixMediaSourcesToHtml(string $htmlContent, array &$imagePaths):
43434340

43444341
$paths = [
43454342
'/app/upload/' => $sysPath,
4346-
'/courses/' => $sysPath.'/app'
4343+
'/courses/' => $sysPath.'/app',
43474344
];
43484345

43494346
foreach ($elements as $element) {

0 commit comments

Comments
 (0)