diff --git a/main/exercise/exercise_submit.php b/main/exercise/exercise_submit.php index f1a1c11c72..1474cf0e4d 100755 --- a/main/exercise/exercise_submit.php +++ b/main/exercise/exercise_submit.php @@ -792,46 +792,9 @@ if ($question_count != 0) { exit; } else { // Certainty grade question - // We send un email to the student before redirection to the result page - $userInfo = api_get_user_info($user_id); - $recipient_name = api_get_person_name($userInfo['firstname'], - $userInfo['lastname'], - null, - PERSON_NAME_EMAIL_ADDRESS - ); - $emailTo = $userInfo['email']; - $senderName = api_get_person_name(api_get_setting('administratorName'), - api_get_setting('administratorSurname'), - null, - PERSON_NAME_EMAIL_ADDRESS - ); - $senderEmail = api_get_setting('emailAdministrator'); - - $subject = "[".get_lang('DoNotReply')."] " - .html_entity_decode(get_lang('ResultAccomplishedTest')." \"".$objExercise->title."\""); - - // message sent to the student - $message = get_lang('Dear').' '.$recipient_name.",

"; - $exerciseLink = ""; - $titleExercise = ''.$objExercise->title.''; - $message .= sprintf(get_lang('QuestionDegreeCertaintyHTMLMail'), $titleExercise, api_get_path(WEB_PATH), $exerciseLink); - - // show histogram - require_once api_get_path(SYS_CODE_PATH) - ."exercise/multipleAnswerTrueFalseDegreeCertainty.php"; - $message .= MultipleAnswerTrueFalseDegreeCertainty::displayStudentsChartResults($exe_id, $objExercise); - $message .= get_lang('KindRegards').'
'; - - $message = api_preg_replace("/\\\n/", "", $message); - api_mail_html($recipient_name, - $emailTo, - $subject, - $message, - $senderName, - $senderEmail, - ['content-type' => 'html'] + // We send an email to the student before redirection to the result page + MultipleAnswerTrueFalseDegreeCertainty::sendQuestionCertaintyNotification( + $user_id, $objExercise, $exe_id ); header("Location: exercise_result.php?" @@ -1243,6 +1206,9 @@ if (!empty($error)) { //3. Hotspots var hotspot = $(\'*[name*="hotspot[\'+question_id+\']"]\').serialize(); + //4. choice for degree of certainty + var my_choiceDc = $(\'*[name*="choiceDegreeCertainty[\'+question_id+\']"]\').serialize(); + // Checking FCK if (question_id) { if (CKEDITOR.instances["choice["+question_id+"]"]) { @@ -1265,33 +1231,39 @@ if (!empty($error)) { type:"post", async: false, url: "'.api_get_path(WEB_AJAX_PATH).'exercise.ajax.php?'.api_get_cidreq().'&a=save_exercise_by_now", - data: "'.$params.'&type=simple&question_id="+question_id+"&"+my_choice+"&"+hotspot+"&"+remind_list, + data: "'.$params.'&type=simple&question_id="+question_id+"&"+my_choice+"&"+hotspot+"&"+remind_list+"&"+my_choiceDc, success: function(return_value) { if (return_value == "ok") { - $("#save_for_now_"+question_id).html(\''.Display::return_icon('save.png', get_lang('Saved'), [], ICON_SIZE_SMALL).'\'); + $("#save_for_now_"+question_id).html(\''. + Display::return_icon('save.png', get_lang('Saved'), [], ICON_SIZE_SMALL).'\'); } else if (return_value == "error") { - $("#save_for_now_"+question_id).html(\''.Display::return_icon('error.png', get_lang('Error'), [], ICON_SIZE_SMALL).'\'); + $("#save_for_now_"+question_id).html(\''. + Display::return_icon('error.png', get_lang('Error'), [], ICON_SIZE_SMALL).'\'); } else if (return_value == "one_per_page") { var url = ""; if ('.$reminder.' == 1 ) { url = "exercise_reminder.php?'.$params.'&num='.$current_question.'"; } else if ('.$reminder.' == 2 ) { - url = "exercise_submit.php?'.$params.'&num='.$current_question.'&remind_question_id='.$remind_question_id.'&reminder=2"; + url = "exercise_submit.php?'.$params.'&num='.$current_question. + '&remind_question_id='.$remind_question_id.'&reminder=2"; } else { - url = "exercise_submit.php?'.$params.'&num='.$current_question.'&remind_question_id='.$remind_question_id.'"; + url = "exercise_submit.php?'.$params.'&num='.$current_question. + '&remind_question_id='.$remind_question_id.'"; } if (url_extra) { url = url_extra; } - $("#save_for_now_"+question_id).html(\''.Display::return_icon('save.png', get_lang('Saved'), [], ICON_SIZE_SMALL).'\'); + $("#save_for_now_"+question_id).html(\''. + Display::return_icon('save.png', get_lang('Saved'), [], ICON_SIZE_SMALL).'\'); window.location = url; } }, error: function() { - $("#save_for_now_"+question_id).html(\''.Display::return_icon('error.png', get_lang('Error'), [], ICON_SIZE_SMALL).'\'); + $("#save_for_now_"+question_id).html(\''. + Display::return_icon('error.png', get_lang('Error'), [], ICON_SIZE_SMALL).'\'); } }); } @@ -1348,7 +1320,9 @@ if (!empty($error)) { } '; - echo '
+ echo ' diff --git a/main/exercise/multipleAnswerTrueFalseDegreeCertainty.php b/main/exercise/multipleAnswerTrueFalseDegreeCertainty.php index 38d853a161..6253295a73 100644 --- a/main/exercise/multipleAnswerTrueFalseDegreeCertainty.php +++ b/main/exercise/multipleAnswerTrueFalseDegreeCertainty.php @@ -44,9 +44,10 @@ class MultipleAnswerTrueFalseDegreeCertainty extends Question /** * Redefines Question::createAnswersForm: creates the HTML form to answer the question - * @param FormValidator $form - * @throws \Exception * @uses globals $text and $class, defined in the calling script + * @param FormValidator $form + * @throws Exception + * @throws HTML_QuickForm_Error */ public function createAnswersForm($form) { @@ -100,20 +101,20 @@ class MultipleAnswerTrueFalseDegreeCertainty extends Question for ($i = 1; $i <= $nbAnswers; ++$i) { $renderer->setElementTemplate( - '{error}
{element}', - 'correct['.$i.']' + '{error}
{element}', + 'correct['.$i.']' ); $renderer->setElementTemplate( - '{error}
{element}', - 'counter['.$i.']' + '{error}
{element}', + 'counter['.$i.']' ); $renderer->setElementTemplate( - '{error}
{element}', - 'answer['.$i.']' + '{error}
{element}', + 'answer['.$i.']' ); $renderer->setElementTemplate( - '{error}
{element}', - 'comment['.$i.']' + '{error}
{element}', + 'comment['.$i.']' ); $answerNumber = $form->addElement('text', 'counter['.$i.']', null, 'value="'.$i.'"'); @@ -270,7 +271,8 @@ class MultipleAnswerTrueFalseDegreeCertainty extends Question $comment = trim($form->getSubmitValue('comment['.$i.']')); $goodAnswer = trim($form->getSubmitValue('correct['.$i.']')); if (empty($options)) { - //If this is the first time that the question is created when change the default values from the form 1 and 2 by the correct "option id" registered + // If this is the first time that the question is created then change + // the default values from the form 1 and 2 by the correct "option id" registered $goodAnswer = $sortedByPosition[$goodAnswer]['id']; } $questionWeighting += $extraValues[0]; //By default 0 has the correct answers @@ -973,7 +975,11 @@ class MultipleAnswerTrueFalseDegreeCertainty extends Question * [ * (categoryId=)5 => [LEVEL_DARKGREEN => 3, LEVEL_WHITE => 5, LEVEL_LIGHTRED => 12] * (categoryId=)2 => [LEVEL_DARKGREEN => 8, LEVEL_LIGHTRED => 2, LEVEL_DARKTRED => 8] - * (categoryId=)0 => [LEVEL_DARKGREEN => 1, LEVEL_LIGHTGREEN => 2, LEVEL_WHITE => 6, LEVEL_LIGHTRED => 1, LEVEL_DARKTRED => 9] + * (categoryId=)0 => [LEVEL_DARKGREEN => 1, + * LEVEL_LIGHTGREEN => 2, + * LEVEL_WHITE => 6, + * LEVEL_LIGHTRED => 1, + * LEVEL_DARKTRED => 9] * ] * * @param $exeId @@ -1227,4 +1233,59 @@ class MultipleAnswerTrueFalseDegreeCertainty extends Question return $html; } + + + /** + * send mail to student with degre certainty result test + * @param $userId + * @param $objExercise + * @param $exeId + */ + public static function sendQuestionCertaintyNotification($userId, $objExercise, $exeId) + { + $userInfo = api_get_user_info($userId); + $recipient_name = api_get_person_name($userInfo['firstname'], + $userInfo['lastname'], + null, + PERSON_NAME_EMAIL_ADDRESS + ); + $emailTo = $userInfo['email']; + $senderName = api_get_person_name(api_get_setting('administratorName'), + api_get_setting('administratorSurname'), + null, + PERSON_NAME_EMAIL_ADDRESS + ); + $genericEmail = api_get_setting('emailAdministrator'); + + $subject = "[".get_lang('DoNotReply')."] " + .html_entity_decode(get_lang('ResultAccomplishedTest')." \"".$objExercise->title."\""); + + // message sended to the student + $message = get_lang('Dear').' '.$recipient_name.",

"; + $message .= get_lang('MessageQuestionCertainty'); + $exerciseLink = "
"; + $titleExercice = $objExercise->title; + $message = str_replace('%exerTitle', $titleExercice, $message); + $message = str_replace('%webPath', api_get_path(WEB_PATH), $message); + $message = str_replace('%s', $exerciseLink, $message); + + // show histogram + require_once api_get_path(SYS_CODE_PATH) + ."exercise/multipleAnswerTrueFalseDegreeCertainty.php"; + $message .= MultipleAnswerTrueFalseDegreeCertainty::displayStudentsChartResults($exeId, $objExercise); + $message .= get_lang('KindRegards'); + + $message = api_preg_replace("/\\\n/", "", $message); + api_mail_html($recipient_name, + $emailTo, + $subject, + $message, + $senderName, + $genericEmail, + ['content-type' => 'html'] + ); + } + } diff --git a/main/inc/ajax/exercise.ajax.php b/main/inc/ajax/exercise.ajax.php index e51e94e75c..ce358573e4 100755 --- a/main/inc/ajax/exercise.ajax.php +++ b/main/inc/ajax/exercise.ajax.php @@ -396,7 +396,7 @@ switch ($action) { // Questions choices. $choice = isset($_REQUEST['choice']) ? $_REQUEST['choice'] : null; - // cretainty degree choice + // certainty degree choice $choiceDegreeCertainty = isset($_REQUEST['choiceDegreeCertainty']) ? $_REQUEST['choiceDegreeCertainty'] : null; // Hot spot coordinates from all questions. @@ -522,7 +522,7 @@ switch ($action) { $objQuestionTmp = Question::read($my_question_id, $course_id); if ($objQuestionTmp->type == MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY) { - // LQ debug + $myChoiceDegreeCertainty = isset($choiceDegreeCertainty[$my_question_id]) ? $choiceDegreeCertainty[$my_question_id] : null; } diff --git a/main/inc/lib/exercise.lib.php b/main/inc/lib/exercise.lib.php index 1fc4ccb166..ee054cbeb4 100644 --- a/main/inc/lib/exercise.lib.php +++ b/main/inc/lib/exercise.lib.php @@ -250,101 +250,89 @@ class ExerciseLib ['style' => 'text-align:left;'] ); } elseif ($answerType == MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY) { - echo ""; - $header = Display::tag('th', get_lang('Options'), ['width' => '50%']); foreach ($objQuestionTmp->optionsTitle as $item) { if (in_array($item, $objQuestionTmp->optionsTitle)) { @@ -681,7 +669,8 @@ class ExerciseLib $attributes = []; } $attributes['onChange'] = 'RadioValidator('.$questionId.', '.$numAnswer.')'; - // gère la séletion des radio button du degré de certitude + + // radio button selection if (isset($myChoiceDegreeCertainty[$numAnswer]) && $id == $myChoiceDegreeCertainty[$numAnswer] ) { @@ -981,7 +970,8 @@ class ExerciseLib } } - // If display preview of answer in test view for exemple, set the student answer to the correct answers + // If display preview of answer in test view for exemple, + // set the student answer to the correct answers if ($debug_mark_answer) { // contain the rights answers surronded with brackets $studentAnswerList = $correctAnswerList[0]; diff --git a/main/inc/lib/exercise_show_functions.lib.php b/main/inc/lib/exercise_show_functions.lib.php index 2893a195ad..43a479d694 100755 --- a/main/inc/lib/exercise_show_functions.lib.php +++ b/main/inc/lib/exercise_show_functions.lib.php @@ -265,7 +265,8 @@ class ExerciseShowFunctions ]; echo ''; echo ''; echo 'getColorResponse( - $studentChoice, - $answerCorrect, - $newOptions[$studentChoiceDegree]['position'] - ); - if ($degreeCertaintyColor == "#088A08" || $degreeCertaintyColor == "#FE2E2E") { - $color = "#FFFFFF"; - } else { - $color = "#000000"; - } - $responseCode = $question->getCodeResponse( - $studentChoice, - $answerCorrect, - $newOptions[$studentChoiceDegree]['position'] - ); + $degreeCertaintyColor = $question->getColorResponse( + $studentChoice, + $answerCorrect, + $newOptions[$studentChoiceDegree]['position'] + ); + if ($degreeCertaintyColor == "#088A08" || $degreeCertaintyColor == "#FE2E2E") { + $color = "#FFFFFF"; + } else { + $color = "#000000"; + } + $responseCode = $question->getCodeResponse( + $studentChoice, + $answerCorrect, + $newOptions[$studentChoiceDegree]['position'] + ); ?>
'; - echo ''; + echo ''; echo ''; echo "$answerId - $answer"; @@ -552,31 +553,31 @@ class ExerciseShowFunctions
'.nl2br($answerComment).''; - } + $color = "black"; + if (isset($newOptions[$studentChoice])) { + echo ''.nl2br($answerComment).''; + } ?>