Skip to content

Commit

Permalink
Minor: Format code - refs BT#22403
Browse files Browse the repository at this point in the history
  • Loading branch information
AngelFQC committed Feb 18, 2025
1 parent 272af46 commit f6c7005
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 46 deletions.
62 changes: 31 additions & 31 deletions main/exercise/exercise.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,8 @@ public function updateTextWhenFinished($text)
}

/**
* Get the text to display when the user has failed the test
* Get the text to display when the user has failed the test.
*
* @return string html text : the text to display ay the end of the test
*/
public function getTextWhenFinishedFailure(): string
Expand All @@ -473,8 +474,7 @@ public function getTextWhenFinishedFailure(): string
}

/**
* Set the text to display when the user has succeeded in the test
* @param string $text
* Set the text to display when the user has succeeded in the test.
*/
public function setTextWhenFinishedFailure(string $text): void
{
Expand Down Expand Up @@ -11837,6 +11837,34 @@ public static function getFeedbackTypeLiteral(int $feedbackType): string
return $result;
}

/**
* Return the text to display, based on the score and the max score.
*
* @param int|float $score
* @param int|float $maxScore
*/
public function getFinishText($score, $maxScore): string
{
if (true !== api_get_configuration_value('exercise_text_when_finished_failure')) {
return $this->getTextWhenFinished();
}

$passPercentage = $this->selectPassPercentage();

if (!empty($passPercentage)) {
$percentage = float_format(
($score / (0 != $maxScore ? $maxScore : 1)) * 100,
1
);

if ($percentage < $passPercentage) {
return $this->getTextWhenFinishedFailure();
}
}

return $this->getTextWhenFinished();
}

/**
* Get number of questions in exercise by user attempt.
*
Expand Down Expand Up @@ -12322,32 +12350,4 @@ private function setResultDisabledGroup(FormValidator $form)
get_lang('ShowResultsToStudents')
);
}

/**
* Return the text to display, based on the score and the max score.
* @param int|float $score
* @param int|float $maxScore
* @return string
*/
public function getFinishText($score, $maxScore): string
{
if (true !== api_get_configuration_value('exercise_text_when_finished_failure')) {
return $this->getTextWhenFinished();
}

$passPercentage = $this->selectPassPercentage();

if (!empty($passPercentage)) {
$percentage = float_format(
($score / (0 != $maxScore ? $maxScore : 1)) * 100,
1
);

if ($percentage < $passPercentage) {
return $this->getTextWhenFinishedFailure();
}
}

return $this->getTextWhenFinished();
}
}
1 change: 0 additions & 1 deletion main/exercise/exercise_show.php
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,6 @@ function getFCK(vals, marksid) {
$questionList = $question_list_from_database;
}


// for each question
$total_weighting = 0;
foreach ($questionList as $questionId) {
Expand Down
28 changes: 14 additions & 14 deletions main/inc/lib/exercise.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -5840,20 +5840,6 @@ public static function getSessionWhenFinishedFailure(int $exerciseId): ?SessionE
return null;
}

private static function subscribeSessionWhenFinishedFailure(int $exerciseId): void
{
$failureSession = self::getSessionWhenFinishedFailure($exerciseId);

if ($failureSession) {
SessionManager::subscribeUsersToSession(
$failureSession->getId(),
[api_get_user_id()],
SESSION_VISIBLE_READ_ONLY,
false
);
}
}

/**
* It validates unique score when all user answers are correct by question.
* It is used for global questions.
Expand Down Expand Up @@ -7416,4 +7402,18 @@ public static function exportExerciseAllResultsZip(

return false;
}

private static function subscribeSessionWhenFinishedFailure(int $exerciseId): void
{
$failureSession = self::getSessionWhenFinishedFailure($exerciseId);

if ($failureSession) {
SessionManager::subscribeUsersToSession(
$failureSession->getId(),
[api_get_user_id()],
SESSION_VISIBLE_READ_ONLY,
false
);
}
}
}
1 change: 1 addition & 0 deletions src/Chamilo/CourseBundle/Entity/CQuiz.php
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,7 @@ public function getTextWhenFinishedFailure(): ?string
public function setTextWhenFinishedFailure(?string $textWhenFinishedFailure): CQuiz
{
$this->textWhenFinishedFailure = $textWhenFinishedFailure;

return $this;
}
}

0 comments on commit f6c7005

Please sign in to comment.