Skip to content

Commit 213ded4

Browse files
committed
Minor: Format code - refs BT#22403
1 parent df715cb commit 213ded4

File tree

4 files changed

+46
-46
lines changed

4 files changed

+46
-46
lines changed

main/exercise/exercise.class.php

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,8 @@ public function updateTextWhenFinished($text)
460460
}
461461

462462
/**
463-
* Get the text to display when the user has failed the test
463+
* Get the text to display when the user has failed the test.
464+
*
464465
* @return string html text : the text to display ay the end of the test
465466
*/
466467
public function getTextWhenFinishedFailure(): string
@@ -473,8 +474,7 @@ public function getTextWhenFinishedFailure(): string
473474
}
474475

475476
/**
476-
* Set the text to display when the user has succeeded in the test
477-
* @param string $text
477+
* Set the text to display when the user has succeeded in the test.
478478
*/
479479
public function setTextWhenFinishedFailure(string $text): void
480480
{
@@ -11837,6 +11837,34 @@ public static function getFeedbackTypeLiteral(int $feedbackType): string
1183711837
return $result;
1183811838
}
1183911839

11840+
/**
11841+
* Return the text to display, based on the score and the max score.
11842+
*
11843+
* @param int|float $score
11844+
* @param int|float $maxScore
11845+
*/
11846+
public function getFinishText($score, $maxScore): string
11847+
{
11848+
if (true !== api_get_configuration_value('exercise_text_when_finished_failure')) {
11849+
return $this->getTextWhenFinished();
11850+
}
11851+
11852+
$passPercentage = $this->selectPassPercentage();
11853+
11854+
if (!empty($passPercentage)) {
11855+
$percentage = float_format(
11856+
($score / (0 != $maxScore ? $maxScore : 1)) * 100,
11857+
1
11858+
);
11859+
11860+
if ($percentage < $passPercentage) {
11861+
return $this->getTextWhenFinishedFailure();
11862+
}
11863+
}
11864+
11865+
return $this->getTextWhenFinished();
11866+
}
11867+
1184011868
/**
1184111869
* Get number of questions in exercise by user attempt.
1184211870
*
@@ -12322,32 +12350,4 @@ private function setResultDisabledGroup(FormValidator $form)
1232212350
get_lang('ShowResultsToStudents')
1232312351
);
1232412352
}
12325-
12326-
/**
12327-
* Return the text to display, based on the score and the max score.
12328-
* @param int|float $score
12329-
* @param int|float $maxScore
12330-
* @return string
12331-
*/
12332-
public function getFinishText($score, $maxScore): string
12333-
{
12334-
if (true !== api_get_configuration_value('exercise_text_when_finished_failure')) {
12335-
return $this->getTextWhenFinished();
12336-
}
12337-
12338-
$passPercentage = $this->selectPassPercentage();
12339-
12340-
if (!empty($passPercentage)) {
12341-
$percentage = float_format(
12342-
($score / (0 != $maxScore ? $maxScore : 1)) * 100,
12343-
1
12344-
);
12345-
12346-
if ($percentage < $passPercentage) {
12347-
return $this->getTextWhenFinishedFailure();
12348-
}
12349-
}
12350-
12351-
return $this->getTextWhenFinished();
12352-
}
1235312353
}

main/exercise/exercise_show.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,6 @@ function getFCK(vals, marksid) {
379379
$questionList = $question_list_from_database;
380380
}
381381

382-
383382
// for each question
384383
$total_weighting = 0;
385384
foreach ($questionList as $questionId) {

main/inc/lib/exercise.lib.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5840,20 +5840,6 @@ public static function getSessionWhenFinishedFailure(int $exerciseId): ?SessionE
58405840
return null;
58415841
}
58425842

5843-
private static function subscribeSessionWhenFinishedFailure(int $exerciseId): void
5844-
{
5845-
$failureSession = self::getSessionWhenFinishedFailure($exerciseId);
5846-
5847-
if ($failureSession) {
5848-
SessionManager::subscribeUsersToSession(
5849-
$failureSession->getId(),
5850-
[api_get_user_id()],
5851-
SESSION_VISIBLE_READ_ONLY,
5852-
false
5853-
);
5854-
}
5855-
}
5856-
58575843
/**
58585844
* It validates unique score when all user answers are correct by question.
58595845
* It is used for global questions.
@@ -7416,4 +7402,18 @@ public static function exportExerciseAllResultsZip(
74167402

74177403
return false;
74187404
}
7405+
7406+
private static function subscribeSessionWhenFinishedFailure(int $exerciseId): void
7407+
{
7408+
$failureSession = self::getSessionWhenFinishedFailure($exerciseId);
7409+
7410+
if ($failureSession) {
7411+
SessionManager::subscribeUsersToSession(
7412+
$failureSession->getId(),
7413+
[api_get_user_id()],
7414+
SESSION_VISIBLE_READ_ONLY,
7415+
false
7416+
);
7417+
}
7418+
}
74197419
}

src/Chamilo/CourseBundle/Entity/CQuiz.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,7 @@ public function getTextWhenFinishedFailure(): ?string
853853
public function setTextWhenFinishedFailure(?string $textWhenFinishedFailure): CQuiz
854854
{
855855
$this->textWhenFinishedFailure = $textWhenFinishedFailure;
856+
856857
return $this;
857858
}
858859
}

0 commit comments

Comments
 (0)