Excercise: Subscribe to remedial or advance course - refs BT#18165

pull/3729/head
Carlos Alvarado 5 years ago
parent 9c440a0647
commit b8a6caba5c
No known key found for this signature in database
GPG Key ID: B612DB1EE6658FBB
  1. 56
      main/exercise/exercise.class.php
  2. 11
      main/exercise/overview.php

@ -6795,7 +6795,6 @@ class Exercise
} }
// 4. We check if the student have attempts // 4. We check if the student have attempts
$extraMessage = ''; // extra mensaje
if ($isVisible) { if ($isVisible) {
$exerciseAttempts = $this->selectAttempts(); $exerciseAttempts = $this->selectAttempts();
@ -6808,16 +6807,12 @@ class Exercise
$lpItemViewId $lpItemViewId
); );
// BT#18165
$extraMessage .= $this->advanceCourseList();
if ($attemptCount >= $exerciseAttempts) { if ($attemptCount >= $exerciseAttempts) {
$message = sprintf( $message = sprintf(
get_lang('ReachedMaxAttempts'), get_lang('ReachedMaxAttempts'),
$this->name, $this->name,
$exerciseAttempts $exerciseAttempts
); );
// BT#18165
$message .= $this->remedialCourseList(api_get_user_id());
$isVisible = false; $isVisible = false;
} else { } else {
// Check blocking exercise. // Check blocking exercise.
@ -6852,7 +6847,34 @@ class Exercise
} }
} }
// BT#18165 // BT#18165
$message .= $extraMessage; $field = new ExtraField('exercise');
$advancedCourseField = $field->get_handler_field_info_by_field_variable('advancedcourselist');
$field = new ExtraField('exercise');
$remedialField = $field->get_handler_field_info_by_field_variable('remedialcourselist');
if (
($remedialField != false && isset($remedialField['default_value']) && $remedialField['default_value'] == 1 // if the plugin is activated
) || (
$advancedCourseField != false && isset($advancedCourseField['default_value']) && $advancedCourseField['default_value'] == 1 // if the plugin is activated
)
) {
$exerciseAttempts = $this->selectAttempts();
if ($exerciseAttempts > 0) {
$attemptCount = Event::get_attempt_count_not_finished(
api_get_user_id(),
$this->id,
$lpId,
$lpItemId,
$lpItemViewId
);
$message .= $this->advanceCourseList(api_get_user_id());
if ($attemptCount >= $exerciseAttempts) {
$message .= $this->remedialCourseList(api_get_user_id());
}
}
}
$rawMessage = ''; $rawMessage = '';
if (!empty($message)) { if (!empty($message)) {
$rawMessage = $message; $rawMessage = $message;
@ -10853,21 +10875,17 @@ class Exercise
|| !isset($bestAttempt['exe_weighting']) || !isset($bestAttempt['exe_weighting'])
) { ) {
// Sin intentos, sin id de ejercicio y sin total definido // Sin intentos, sin id de ejercicio y sin total definido
return ''; return null;
} }
$resultado = $bestAttempt['exe_result']; $percentSuccess = (float) $this->selectPassPercentage();
$total = $bestAttempt['exe_weighting'];
$objExercise = new Exercise();
$objExercise->read($bestAttempt['exe_id']);
$percentSuccess = (float) $objExercise->selectPassPercentage();
$pass = ExerciseLib::isPassPercentageAttemptPassed( $pass = ExerciseLib::isPassPercentageAttemptPassed(
$objExercise, $this,
$resultado, $bestAttempt['exe_result'],
$total $bestAttempt['exe_weighting']
); );
if ($percentSuccess == 0 && $pass == false) { if ($percentSuccess == 0 && $pass == false) {
return ''; return null;
} }
$canRemedial = ($pass == false) ? true : false; $canRemedial = ($pass == false) ? true : false;
//Examen de siguiente nivel //Examen de siguiente nivel
@ -10962,11 +10980,9 @@ class Exercise
} }
} }
} }
$objExercise = new Exercise(); $percentSuccess = (float) $this->selectPassPercentage();
$objExercise->read($bestAttempt['exe_id']);
$percentSuccess = (float) $objExercise->selectPassPercentage();
$pass = ExerciseLib::isPassPercentageAttemptPassed( $pass = ExerciseLib::isPassPercentageAttemptPassed(
$objExercise, $this,
$bestAttempt['exe_result'], $bestAttempt['exe_result'],
$bestAttempt['exe_weighting'] $bestAttempt['exe_weighting']
); );

@ -195,8 +195,19 @@ if ($visible_return['value'] == false) {
$message = $visible_return['message']; $message = $visible_return['message'];
$exercise_url_button = null; $exercise_url_button = null;
} }
}else{
$text = $objExercise->advanceCourseList(api_get_user_id());
if(!empty($text)){
$message = Display::return_message(
$text,
'info',
false
);
} }
}
if (!api_is_allowed_to_session_edit()) { if (!api_is_allowed_to_session_edit()) {
$exercise_url_button = null; $exercise_url_button = null;
} }

Loading…
Cancel
Save