Exercises: option is_block_by_percentage

In setting exercise_finished_notification_settings BT#18068
pull/3565/head^2
Julio Montoya 5 years ago
parent 823e5eb9b1
commit f6bd3f5765
  1. 31
      main/inc/lib/exercise.lib.php
  2. 1
      main/install/configuration.dist.php

@ -5030,6 +5030,11 @@ EOT;
$total_weight $total_weight
); );
$percentage = 0;
if (!empty($total_weight)) {
$percentage = ($total_score / $total_weight) * 100;
}
return [ return [
'category_list' => $category_list, 'category_list' => $category_list,
'attempts_result_list' => $attemptResult, // array of results 'attempts_result_list' => $attemptResult, // array of results
@ -5040,6 +5045,7 @@ EOT;
'all_answers_html' => $all, 'all_answers_html' => $all,
'total_score' => $total_score, 'total_score' => $total_score,
'total_weight' => $total_weight, 'total_weight' => $total_weight,
'total_percentage' => $percentage,
'count_pending_questions' => $countPendingQuestions, 'count_pending_questions' => $countPendingQuestions,
]; ];
} }
@ -5957,16 +5963,26 @@ EOT;
MessageManager::send_message($currentUserId, $subject, $content); MessageManager::send_message($currentUserId, $subject, $content);
} }
// Notifications.
$extraFieldData = $exerciseExtraFieldValue->get_values_by_handler_and_field_variable( $extraFieldData = $exerciseExtraFieldValue->get_values_by_handler_and_field_variable(
$objExercise->iId, $objExercise->iId,
'notifications' 'notifications'
); );
$exerciseNotification = ''; $exerciseNotification = '';
if ($extraFieldData && isset($extraFieldData['value'])) { if ($extraFieldData && isset($extraFieldData['value'])) {
$exerciseNotification = $extraFieldData['value']; $exerciseNotification = $extraFieldData['value'];
} }
// Blocking exercise.
$extraFieldData = $exerciseExtraFieldValue->get_values_by_handler_and_field_variable(
$objExercise->iId,
'blocking_percentage'
);
$blockPercentage = false;
if ($extraFieldData && isset($extraFieldData['value']) && $extraFieldData['value']) {
$blockPercentage = $extraFieldData['value'];
}
$extraFieldValueUser = new ExtraFieldValue('user'); $extraFieldValueUser = new ExtraFieldValue('user');
if (!empty($exerciseNotification) && !empty($notifications)) { if (!empty($exerciseNotification) && !empty($notifications)) {
@ -6012,6 +6028,19 @@ EOT;
continue; continue;
} }
if ($blockPercentage && isset($attempt['is_block_by_percentage'])) {
$passBlock = $stats['total_percentage'] > $blockPercentage;
if ($attempt['is_block_by_percentage']) {
if ($passBlock) {
continue;
}
} else {
if (false === $passBlock) {
continue;
}
}
}
switch ($attempt['status']) { switch ($attempt['status']) {
case 'passed': case 'passed':
if ($exercisePassed) { if ($exercisePassed) {

@ -1650,6 +1650,7 @@ $_configuration['auth_password_links'] = [
'email' => 'teacher1@example.com,teacher2@example.com', // multiple emails allowed 'email' => 'teacher1@example.com,teacher2@example.com', // multiple emails allowed
'attempts' => [ 'attempts' => [
[ [
'is_block_by_percentage' => true,
'status' => 'passed', // passed/failed/all (depends in the exercise pass %) 'status' => 'passed', // passed/failed/all (depends in the exercise pass %)
'content' => 'MailAttemptPassed', // exercise extra field 'content' => 'MailAttemptPassed', // exercise extra field
'content_default' => 'Hi, ((user_lastname)) ', // value if MailAttemptPassed is empty 'content_default' => 'Hi, ((user_lastname)) ', // value if MailAttemptPassed is empty

Loading…
Cancel
Save