Add new configuration parameter "send_score_in_exam_notification_mail_to_manager"

See BT#11918
pull/2487/head
jmontoyaa 9 years ago
parent 79f8dee67a
commit 03a24ebd34
  1. 64
      main/exercise/exercise.class.php
  2. 26
      main/inc/lib/exercise.lib.php
  3. 2
      main/install/configuration.dist.php

@ -5241,13 +5241,19 @@ class Exercise
/** /**
* Sends a notification when a user ends an examn * Sends a notification when a user ends an examn
* *
* @param integer $exe_id * @param array $question_list_answers
* @param string $origin
* @param int $exe_id
* @param float $score
* @param float $weight
* @return bool
*/ */
public function send_mail_notification_for_exam($question_list_answers, $origin, $exe_id) public function send_mail_notification_for_exam($question_list_answers, $origin, $exe_id, $score, $weight)
{ {
if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1 ) { if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1) {
return null; return false;
} }
// Email configuration settings // Email configuration settings
$courseCode = api_get_course_id(); $courseCode = api_get_course_id();
$courseInfo = api_get_course_info($courseCode); $courseInfo = api_get_course_info($courseCode);
@ -5267,26 +5273,36 @@ class Exercise
. '&action=qualify'; . '&action=qualify';
$user_info = api_get_user_info(api_get_user_id()); $user_info = api_get_user_info(api_get_user_id());
$scoreLabel = '';
if (api_get_configuration_value('send_score_in_exam_notification_mail_to_manager') == true) {
$scoreLabel = ExerciseLib::show_score($score, $weight, false, true);
$scoreLabel = "<tr>
<td>".get_lang('Score')."</td>
<td>&nbsp;$scoreLabel</td>
</tr>";
}
$msg = get_lang('ExerciseAttempted').'<br /><br />' $msg = get_lang('ExerciseAttempted').'<br /><br />'
.get_lang('AttemptDetails').' : <br /><br />'. .get_lang('AttemptDetails').' : <br /><br />
'<table>' <table>
.'<tr>' <tr>
.'<td><em>'.get_lang('CourseName').'</em></td>' <td><em>'.get_lang('CourseName').'</em></td>
.'<td>&nbsp;<b>#course#</b></td>' <td>&nbsp;<b>#course#</b></td>
.'</tr>' </tr>
.'<tr>' <tr>
.'<td>'.get_lang('TestAttempted').'</td>' <td>'.get_lang('TestAttempted').'</td>
.'<td>&nbsp;#exercise#</td>' <td>&nbsp;#exercise#</td>
.'</tr>' </tr>
.'<tr>' <tr>
.'<td>'.get_lang('StudentName').'</td>' <td>'.get_lang('StudentName').'</td>
.'<td>&nbsp;#firstName# #lastName#</td>' <td>&nbsp;#firstName# #lastName#</td>
.'</tr>' </tr>
.'<tr>' <tr>
.'<td>'.get_lang('StudentEmail').'</td>' <td>'.get_lang('StudentEmail').'</td>
.'<td>&nbsp;#email#</td>' <td>&nbsp;#email#</td>
.'</tr>' </tr>
.'</table>'; '.$scoreLabel.'
</table>';
$open_question_list = null; $open_question_list = null;
$msg = str_replace("#email#", $user_info['email'], $msg); $msg = str_replace("#email#", $user_info['email'], $msg);
@ -5333,7 +5349,7 @@ class Exercise
* *
* @param integer $exe_id * @param integer $exe_id
*/ */
function send_notification_for_open_questions($question_list_answers, $origin, $exe_id) public function send_notification_for_open_questions($question_list_answers, $origin, $exe_id)
{ {
if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1 ) { if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1 ) {
return null; return null;

@ -3771,19 +3771,18 @@ HOTSPOT;
); );
} }
// Send notification .. // Send notification
if (!api_is_allowed_to_edit(null, true) && !api_is_excluded_user_type() if (!api_is_allowed_to_edit(null, true) &&
!api_is_excluded_user_type()
) { ) {
if (api_get_course_setting( $objExercise->send_mail_notification_for_exam(
'email_alert_manager_on_new_quiz' $question_list_answers,
) == 1 $origin,
) { $exe_id,
$objExercise->send_mail_notification_for_exam( $total_score,
$question_list_answers, $total_weight
$origin, );
$exe_id
);
}
$objExercise->send_notification_for_open_questions( $objExercise->send_notification_for_open_questions(
$question_list_answers, $question_list_answers,
$origin, $origin,
@ -3810,8 +3809,7 @@ HOTSPOT;
$score, $score,
$weight, $weight,
$check_pass_percentage = false $check_pass_percentage = false
) ) {
{
$ribbon = '<div class="title-score">'; $ribbon = '<div class="title-score">';
if ($check_pass_percentage) { if ($check_pass_percentage) {
$is_success = self::is_success_exercise_result( $is_success = self::is_success_exercise_result(

@ -261,4 +261,6 @@ $_configuration['system_stable'] = NEW_VERSION_STABLE;
//$_configuration['user_portal_load_notification_by_ajax'] = false; //$_configuration['user_portal_load_notification_by_ajax'] = false;
// When exporting a LP, all files and folders in the same path of an html will be exported too. // When exporting a LP, all files and folders in the same path of an html will be exported too.
//$_configuration['add_all_files_in_lp_export'] = false; //$_configuration['add_all_files_in_lp_export'] = false;
// Send exercise student score to manager in email notification
//$_configuration['send_score_in_exam_notification_mail_to_manager'] = false;

Loading…
Cancel
Save