Plugin: Remedial Course: Fix conditions to inscription in remedial course - refs BT#18165

pull/3860/head
Angel Fernando Quiroz Campos 5 years ago
parent b7be4688e1
commit c58798ec30
  1. 40
      plugin/remedial_course/RemedialCoursePlugin.php

@ -181,28 +181,23 @@ class RemedialCoursePlugin extends Plugin
return null;
}
$canRemedial = false;
$bestAttempt['exe_result'] = (int) $bestAttempt['exe_result'];
if (isset($bestAttempt['exe_result'])) {
$bestAttempt['exe_result'] = (int) $bestAttempt['exe_result'];
$canRemedial = $objExercise->isBlockedByPercentage($bestAttempt);
if (false == $canRemedial) {
$pass = ExerciseLib::isPassPercentageAttemptPassed(
$objExercise,
$bestAttempt['exe_result'],
$bestAttempt['exe_weighting']
);
$canRemedial = !$pass;
$isPassedPercentage = ExerciseLib::isPassPercentageAttemptPassed(
$objExercise,
$bestAttempt['exe_result'],
$bestAttempt['exe_weighting']
);
if (false == $canRemedial) {
return null;
}
}
if ($isPassedPercentage) {
return null;
}
// Remedial course
if (!$canRemedial) {
$hasAttempts = count($exerciseStatInfo) < $objExercise->selectAttempts();
$doSubscriptionToRemedial = !$hasAttempts || $objExercise->isBlockedByPercentage($bestAttempt);
if (!$doSubscriptionToRemedial) {
return null;
}
@ -233,13 +228,10 @@ class RemedialCoursePlugin extends Plugin
}
}
if (0 != count($courses)) {
return sprintf(
$this->get_lang('SubscriptionToXRemedialCourses'),
implode(' - ', $courses)
);
if (empty($courses)) {
return null;
}
return null;
return sprintf($this->get_lang('SubscriptionToXRemedialCourses'), implode(' - ', $courses));
}
}

Loading…
Cancel
Save