RemedialCourse: Added validating for Blocking percentage- refs BT#18165

pull/3729/head
Carlos Alvarado 5 years ago
parent 10aad3e978
commit 003bb085b8
No known key found for this signature in database
GPG Key ID: B612DB1EE6658FBB
  1. 48
      main/exercise/exercise.class.php
  2. 2
      main/exercise/exercise_result.php

@ -10945,6 +10945,32 @@ class Exercise
return $extraMessage;
}
/**
* Returns true if the exercise is locked by percentage. an exercise attempt must be passed
*
* @param array $attemp
*
* @return bool
*/
public function isBlockedByPercentage($attemp = []){
if(empty($attemp)) return false;
$extraFieldValue = new ExtraFieldValue('exercise');
$blockExercise = $extraFieldValue->get_values_by_handler_and_field_variable(
$this->iId,
'blocking_percentage'
);
$blockPercentage= 0;
if ($blockExercise && isset($blockExercise['value']) && !empty($blockExercise['value'])) {
$blockPercentage = (int) $blockExercise['value'];
}
if ($attemp['exe_result'] <= $blockPercentage && $blockPercentage != 0) {
return true;
}
return false;
}
/**
* When a student completes the number of attempts and fails the exam, she is enrolled in a series of remedial
* courses BT#18165.
@ -11022,15 +11048,19 @@ class Exercise
return null;
}
$canRemedial = false;
if (isset($bestAttempt['exe_result']) && $bestAttempt['exe_result'] != 0) {
$pass = ExerciseLib::isPassPercentageAttemptPassed(
$this,
$bestAttempt['exe_result'],
$bestAttempt['exe_weighting']
);
$canRemedial = false === $pass;
if (false == $canRemedial) {
return null;
if (isset($bestAttempt['exe_result'])) {
$bestAttempt['exe_result'] = (int) $bestAttempt['exe_result'];
$canRemedial = $this->isBlockedByPercentage($bestAttempt);
if ($bestAttempt['exe_result'] != 0 && false == $canRemedial) {
$pass = ExerciseLib::isPassPercentageAttemptPassed(
$this,
$bestAttempt['exe_result'],
$bestAttempt['exe_weighting']
);
$canRemedial = false === $pass;
if (false == $canRemedial) {
return null;
}
}
}
$extraFieldValue = new ExtraFieldValue('exercise');

@ -290,7 +290,7 @@ if (null != $advanceCourseMessage) {
);
}
$remedialMessage = null;
if ($attempt_count >= $objExercise->selectAttempts()) {
if ($attempt_count >= $objExercise->selectAttempts() || $objExercise->isBlockedByPercentage($exercise_stat_info)) {
$remedialMessage = $objExercise->remedialCourseList(api_get_user_id(), api_get_session_id(), $exerciseStatInfo);
}
if (null != $remedialMessage) {

Loading…
Cancel
Save