0){error_log('Entered exercise_result.php: '.print_r($_POST,1));} // general parameters passed via POST/GET if ( empty ( $origin ) ) { $origin = Security::remove_XSS($_REQUEST['origin']);} if ( empty ( $learnpath_id ) ) { $learnpath_id = intval($_REQUEST['learnpath_id']);} if ( empty ( $learnpath_item_id ) ) { $learnpath_item_id = intval($_REQUEST['learnpath_item_id']);} if ( empty ( $learnpath_item_view_id ) ) { $learnpath_item_view_id = intval($_REQUEST['learnpath_item_view_id']);} if ( empty ( $formSent ) ) { $formSent = $_REQUEST['formSent'];} if ( empty ( $exerciseResult ) ) { $exerciseResult = $_SESSION['exerciseResult'];} if ( empty ( $exerciseResultCoordinates)){ $exerciseResultCoordinates = $_SESSION['exerciseResultCoordinates'];} if ( empty ( $questionId ) ) { $questionId = $_REQUEST['questionId'];} if ( empty ( $choice ) ) { $choice = $_REQUEST['choice'];} if ( empty ( $questionNum ) ) { $questionNum = $_REQUEST['questionNum'];} if ( empty ( $nbrQuestions ) ) { $nbrQuestions = $_REQUEST['nbrQuestions'];} if ( empty ( $questionList ) ) { $questionList = $_SESSION['questionList'];} if ( empty ( $objExercise ) ) { $objExercise = $_SESSION['objExercise'];} if ( empty ( $exerciseType ) ) { $exerciseType = $_REQUEST['exerciseType'];} //@todo There should be some doc about this settings $_configuration['live_exercise_tracking'] = false; if ($_configuration['live_exercise_tracking']) define('ENABLED_LIVE_EXERCISE_TRACKING',1); if ($_configuration['live_exercise_tracking'] && $exerciseType == 1){ $_configuration['live_exercise_tracking'] = false; } $arrques = array(); $arrans = array(); // set admin name as person who sends the results e-mail (lacks policy about whom should really send the results) $query = "SELECT user_id FROM $main_admin_table LIMIT 1"; //get all admins from admin table $admin_id = Database::result(Database::query($query),0,"user_id"); $uinfo = api_get_user_info($admin_id); $from = $uinfo['mail']; $from_name = api_get_person_name($uinfo['firstname'], $uinfo['lastname'], null, PERSON_NAME_EMAIL_ADDRESS); $str = $_SERVER['REQUEST_URI']; $url = api_get_path(WEB_CODE_PATH).'exercice/exercice.php?'.api_get_cidreq().'&show=result'; // if the above variables are empty or incorrect, we don't have any result to show, so stop the script if(!is_array($exerciseResult) || !is_array($questionList) || !is_object($objExercise)) { if ($debug) {error_log('Exit exercise result'); error_log('$exerciseResult: '.print_r($exerciseResult,1)); error_log('$questionList:'.print_r($questionList,1));error_log('$objExercise:'.print_r($objExercise,1));} header('Location: exercice.php'); exit(); } $gradebook = ''; if (isset($_SESSION['gradebook'])) { $gradebook= $_SESSION['gradebook']; } if (!empty($gradebook) && $gradebook=='view') { $interbreadcrumb[]= array ('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('ToolGradebook')); } $nameTools=get_lang('Exercice'); $interbreadcrumb[]=array("url" => "exercice.php?gradebook=$gradebook","name" => get_lang('Exercices')); //$htmlHeadXtra[] = $objExercise->show_lp_javascript(); if ($origin != 'learnpath') { //so we are not in learnpath tool Display::display_header($nameTools,get_lang('Exercise')); } else { header('Content-Type: text/html; charset='.api_get_system_encoding()); $document_language = api_get_language_isocode(); /* HTML HEADER */ ?> results_disabled == 0) { $show_results = true; } if ($objExercise->results_disabled == 2) { $show_only_score = true; } /* DISPLAY AND MAIN PROCESS */ // I'm in a preview mode as course admin. Display the action menu. if (api_is_course_admin() && $origin != 'learnpath') { echo '
'; echo ''.Display::return_icon('back.png', get_lang('GoBackToQuestionList'), array(), 32).''; echo ''.Display::return_icon('edit.png', get_lang('ModifyExercise'), array(), 32).''; echo '
'; } $exerciseTitle=text_filter($objExercise->selectTitle()); $feedback_type = $objExercise->feedbacktype; //show exercise title if($origin == 'learnpath') { ?>
0){error_log ("ExerciseResult: ".print_r($exerciseResult,1)); error_log("QuestionList: ".print_r($questionList,1));} // Create an empty exercise if (api_is_allowed_to_session_edit()) { $exeId= create_event_exercice($objExercise->selectId()); } $counter=0; $user_info = api_get_user_info(api_get_user_id()); if ($show_results || $show_only_score) { echo $exercise_header = $objExercise->show_exercise_result_header(api_get_person_name($user_info['firstName'], $user_info['lastName'])); } // Loop over all question to show results for each of them, one by one foreach ($questionList as $questionId) { // destruction of the Question object unset($objQuestionTmp); $counter++; // gets the student choice for this question $choice = $exerciseResult[$questionId]; // creates a temporary Question object $objQuestionTmp = Question :: read($questionId); // initialize question information $questionName = $objQuestionTmp->selectTitle(); $questionDescription = $objQuestionTmp->selectDescription(); $questionWeighting = $objQuestionTmp->selectWeighting(); $answerType = $objQuestionTmp->selectType(); $quesId = $objQuestionTmp->selectId(); //this variable commes from exercise_submit_modal.php $hotspot_delineation_result = $_SESSION['hotspot_delineation_result'][$objExercise->selectId()][$quesId]; if ($show_results) { // show titles if ($origin != 'learnpath') { echo $objQuestionTmp->return_header($objExercise->feedbacktype); if ($answerType == HOT_SPOT) { ?> feedbacktype != EXERCISE_FEEDBACK_TYPE_EXAM) { ?> manage_answer($exeId, $questionId, $choice,'exercise_result', $exerciseResultCoordinates, true, false, $show_results, $objExercise->selectPropagateNeg(), $hotspot_delineation_result); $totalScore += $result['score']; $totalWeighting += $result['weight']; } // end foreach() block that loops over all questions if ($origin != 'learnpath') { if ($show_results || $show_only_score) { echo '
'; echo get_lang('YourTotalScore')." "; if ($objExercise->selectPropagateNeg() == 0 && $totalScore < 0) { $totalScore = 0; } echo show_score($totalScore, $totalWeighting, false); echo '
'; } /* */ } // Tracking of results // Updates the empty exercise $safe_lp_id = $learnpath_id==''?0:(int)$learnpath_id; $safe_lp_item_id = $learnpath_item_id==''?0:(int)$learnpath_item_id; $safe_lp_item_view_id = $learnpath_item_view_id==''?0:(int)$learnpath_item_view_id; $quizDuration = (!empty($_SESSION['quizStartTime']) ? time() - $_SESSION['quizStartTime'] : 0); if (api_is_allowed_to_session_edit() ) { update_event_exercice($exeId, $objExercise->selectId(), $totalScore, $totalWeighting, api_get_session_id(),$safe_lp_id,$safe_lp_item_id,$safe_lp_item_view_id, $quizDuration); } if ($origin != 'learnpath') { Display :: display_normal_message(get_lang('ExerciseFinished').'
'.get_lang('Back').'',false); } else { Display :: display_normal_message(get_lang('ExerciseFinished').'

',false); $lp_mode = $_SESSION['lp_mode']; $url = '../newscorm/lp_controller.php?cidReq='.api_get_course_id().'&action=view&lp_id='.$learnpath_id.'&lp_item_id='.$learnpath_item_id.'&exeId='.$exeId.'&fb_type='.$objExercise->feedbacktype; $href = ($lp_mode == 'fullscreen')?' window.opener.location.href="'.$url.'" ':' top.location.href="'.$url.'" '; echo ''."\n"; //record the results in the learning path, using the SCORM interface (API) echo ''."\n"; echo ''; } if ($origin != 'learnpath') { //we are not in learnpath tool Display::display_footer(); } // Email configuration settings require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php'; $user_info = UserManager::get_user_info_by_id(api_get_user_id()); $firstName = $user_info['firstname']; $lastName = $user_info['lastname']; $mail = $user_info['email']; $coursecode = api_get_course_id(); $courseName = $_SESSION['_course']['name']; $to = ''; $teachers = array(); if(api_get_setting('use_session_mode')=='true' && !empty($_SESSION['id_session'])) { $teachers = CourseManager::get_coach_list_from_course_code($coursecode,$_SESSION['id_session']); } else { $teachers = CourseManager::get_teacher_list_from_course_code($coursecode); } $num = count($teachers); if($num>1) { $to = array(); foreach($teachers as $teacher) { $to[] = $teacher['email']; } }elseif($num>0){ foreach($teachers as $teacher) { $to = $teacher['email']; } } else { //this is a problem (it means that there is no admin for this course) } // we are able to send emails to the teachers? if (api_get_course_setting('email_alert_manager_on_new_quiz') == 1 ) { // only for "simple tests" if ($origin != 'learnpath') { //has a unique answer? $mycharset = api_get_system_encoding(); $msg = ''; if (count($arrques)>0) { $msg .= '

'.get_lang('OpenQuestionsAttempted').' :

'.get_lang('AttemptDetails').' :







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

  '.get_lang('CourseName').'

#course#

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


'.get_lang('OpenQuestionsAttemptedAre').' :

'; for($i=0;$i '; $msg1= str_replace("#exercise#",$exerciseTitle,$msg); $msg= str_replace("#firstName#",$firstName,$msg1); $msg1= str_replace("#lastName#",$lastName,$msg); $msg= str_replace("#mail#",$mail,$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,$msg); $mail_content = $msg1; $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('OpenQuestionsAttempted'); $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#",$firstName,$msg); $msg= str_replace("#lastName#",$lastName,$msg); $msg= str_replace("#mail#",$mail,$msg); $msg= str_replace("#course#",$courseName,$msg); $msg.='
'.get_lang('ClickToCommentAndGiveFeedback').',
#url#
'; $msg= str_replace("#url#",$url,$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)); } } }