diff --git a/main/exercice/exercise_show.php b/main/exercice/exercise_show.php index debb1eabdc..030b5d0d3f 100755 --- a/main/exercice/exercise_show.php +++ b/main/exercice/exercise_show.php @@ -21,8 +21,9 @@ require_once '../inc/lib/course.lib.php'; require_once 'exercise.class.php'; require_once 'question.class.php'; //also defines answer type constants require_once 'answer.class.php'; -require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'); -require_once(api_get_path(LIBRARY_PATH).'mail.lib.inc.php'); +require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'; +require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php'; +require_once api_get_path(LIBRARY_PATH).'exercise_show_functions.lib.php'; if ( empty ( $origin ) ) { $origin = $_REQUEST['origin']; @@ -227,200 +228,12 @@ function getFCK(vals,marksid) - - - - - -  - - - - - - - '.nl2br(make_clickable($answerComment)).''; - } - else{ - echo ''.nl2br(make_clickable($answerComment)).''; - } - } - else - { - echo ' '; - } - ?> - - - -   - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
- -
-
-
- - - - - - - - - '.nl2br(make_clickable($answerComment)).''; - } else { - echo ''.nl2br(make_clickable($answerComment)).''; - } - ?> - - -   - - - - '; if ($answerId==1) { - display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,$id,$questionId,$answerId); + ExerciseShowFunctions::display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,$id,$questionId,$answerId); } else { - display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,$id,$questionId,""); + ExerciseShowFunctions::display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,$id,$questionId,""); } echo ''; $i++; @@ -711,9 +524,9 @@ if ($show_results) { echo ''; if ($answerId==1) { - display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,$id,$questionId,$answerId); + ExerciseShowFunctions::display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,$id,$questionId,$answerId); } else { - display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,$id,$questionId,""); + ExerciseShowFunctions::display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,$id,$questionId,""); } echo ''; $i++; @@ -775,9 +588,9 @@ if ($show_results) { } echo ''; if ($answerId==1) { - display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,$id,$questionId,$answerId); + ExerciseShowFunctions::display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,$id,$questionId,$answerId); } else { - display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,$id,$questionId,""); + ExerciseShowFunctions::display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect,$id,$questionId,""); } echo ''; $i++; @@ -941,7 +754,7 @@ if ($show_results) { } //echo $questionScore."-".$totalScore; echo ''; - display_fill_in_blanks_answer($answer,$id,$questionId); + ExerciseShowFunctions::display_fill_in_blanks_answer($answer,$id,$questionId); echo ''; $i++; } @@ -980,7 +793,7 @@ if ($show_results) { $arrans[] = $choice; echo ' - '.display_free_answer($choice, $id, $questionId).' + '.ExerciseShowFunctions::display_free_answer($choice, $id, $questionId).' '; @@ -1068,7 +881,7 @@ if ($show_results) { $query = "select hotspot_correct from ".$TBL_TRACK_HOTSPOT." where hotspot_exe_id = '".Database::escape_string($id)."' and hotspot_question_id= '".Database::escape_string($questionId)."' AND hotspot_answer_id='".Database::escape_string($answerId)."'"; $resq=Database::query($query); $choice = Database::result($resq,0,"hotspot_correct"); - display_hotspot_answer($answerId,$answer,$choice,$answerComment); + ExerciseShowFunctions::display_hotspot_answer($answerId,$answer,$choice,$answerComment); $i++; } @@ -1108,7 +921,7 @@ if ($show_results) { } } echo '
'; - $comnt = trim(get_comments($id,$questionId)); + $comnt = trim(ExerciseShowFunctions::get_comments($id,$questionId)); if (empty($comnt)) { echo '
'; } else { @@ -1122,7 +935,7 @@ if ($show_results) { $renderer =& $feedback_form->defaultRenderer(); $renderer->setFormTemplate('
{content}
'); $renderer->setElementTemplate('
{element}
'); - $comnt = get_comments($id,$questionId); + $comnt = ExerciseShowFunctions::get_comments($id,$questionId); ${user.$questionId}['comments_'.$questionId] = $comnt; $feedback_form->addElement('html_editor', 'comments_'.$questionId, null, null, array('ToolbarSet' => 'TestAnswerFeedback', 'Width' => '100%', 'Height' => '120')); $feedback_form->addElement('html','
'); @@ -1131,7 +944,7 @@ if ($show_results) { $feedback_form->display(); echo '
'; } else { - $comnt = get_comments($id,$questionId); + $comnt = ExerciseShowFunctions::get_comments($id,$questionId); echo '
'; if (!empty($comnt)) { echo ''.get_lang('Feedback').''; @@ -1266,7 +1079,7 @@ if ($origin != 'learnpath') { echo ''; } else { if (!$is_allowedToEdit) { - send_notification($arrques, $arrans, $to); + ExerciseShowFunctions::send_notification($arrques, $arrans, $to); } Display::display_normal_message(get_lang('ExerciseFinished').' '.get_lang('ToContinueUseMenu')); } @@ -1274,7 +1087,7 @@ if ($origin != 'learnpath') { if (!$is_allowedToEdit) { if ($origin != 'learnpath') { - send_notification($arrques, $arrans, $to); + ExerciseShowFunctions::send_notification($arrques, $arrans, $to); } } @@ -1283,120 +1096,4 @@ api_session_unregister('questionList'); unset ($questionList); api_session_unregister('exerciseResult'); -unset ($exerciseResult); - -function send_notification($arrques, $arrans, $to) { - global $courseName, $exerciseTitle, $url_email; - require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php'; - $user_info = UserManager::get_user_info_by_id(api_get_user_id()); - - if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1 ) { - return ''; - } - - $mycharset = api_get_system_encoding(); - $msg = ' - - '; - if(count($arrques)>0) { - $msg .= ' -

'.get_lang('OpenQuestionsAttempted').' : -

-

'.get_lang('AttemptDetails').' :
-

- - - - - - - - - - - - - - - - -

  '.get_lang('CourseName').'

#course#

  '.get_lang('TestAttempted').'#exercise#
  '.get_lang('StudentName').'#firstName# #lastName#
  '.get_lang('StudentEmail').' #mail#
-


'.get_lang('OpenQuestionsAttemptedAre').' :

- '; - - for($i=0;$i - - - - - - '; - - $msg1= str_replace("#exercise#",$exerciseTitle,$msg); - $msg= str_replace("#firstName#",$user_info['firstname'],$msg1); - $msg1= str_replace("#lastName#",$user_info['lastname'],$msg); - $msg= str_replace("#mail#",$user_info['email'],$msg1); - $msg1= str_replace("#questionName#",$arrques[$i],$msg); - $msg= str_replace("#answer#",$arrans[$i],$msg1); - $msg1= str_replace("#i#",$i,$msg); - $msg= str_replace("#course#",$courseName,$msg1); - } - $msg.='
#questionName#
  '.get_lang('Answer').' #answer#

- '.get_lang('ClickToCommentAndGiveFeedback').',
- #url#
'; - - $msg1= str_replace("#url#",$url_email,$msg); - $mail_content = $msg1; - - $subject = get_lang('OpenQuestionsAttempted'); - - - $sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS); - $email_admin = api_get_setting('emailAdministrator'); - $result = @api_mail_html('', $to, $subject, $mail_content, $sender_name, $email_admin, array('charset'=>$mycharset)); - } else { - - $msg .= ' -

'.get_lang('ExerciseAttempted').'
-

- - - - - - - - - - - - '.(api_is_western_name_order() ? '' : '').' - - - - -

  '.get_lang('CourseName').'

#course#

  '.get_lang('TestAttempted').'#exercise#
  '.get_lang('StudentName').'#firstName# #lastName##lastName# #firstName#
  '.get_lang('StudentEmail').' #mail#
'; - - $msg= str_replace("#exercise#",$exerciseTitle,$msg); - $msg= str_replace("#firstName#",$user_info['firstname'],$msg); - $msg= str_replace("#lastName#",$user_info['lastname'],$msg); - $msg= str_replace("#mail#",$user_info['email'],$msg); - $msg= str_replace("#course#",$courseName,$msg); - - $msg.='
- '.get_lang('ClickToCommentAndGiveFeedback').',
- #url#
'; - - $msg= str_replace("#url#",$url_email,$msg); - $mail_content = $msg; - - $sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS); - $email_admin = api_get_setting('emailAdministrator'); - - $subject = get_lang('ExerciseAttempted'); - $result = @api_mail_html('', $to, $subject, $mail_content, $sender_name, $email_admin, array('charset'=>$mycharset)); - } -} +unset ($exerciseResult); \ No newline at end of file