@ -1858,7 +1858,9 @@ class Exercise {
if ($debug) error_log('manage_answer $learnpath_id: '.$learnpath_id);
if ($debug) error_log('manage_answer $learnpath_item_id: '.$learnpath_item_id);
$extra_data = array();
$extra_data = array();
$arrques = null;
$arrans = null;
$questionId = intval($questionId);
$exeId = intval($exeId);
@ -2300,8 +2302,8 @@ class Exercise {
} else {
$totalScore+=$questionScore;
}
$arrques[] = $questionName;
$arrans[] = $choice;
$arrques = $questionName;
$arrans = $choice;
} else {
$studentChoice = $choice;
if ($studentChoice) {
@ -2324,8 +2326,8 @@ class Exercise {
} else {
$totalScore+=$questionScore;
}
$arrques[] = $questionName;
$arrans[] = $choice;
$arrques = $questionName;
$arrans = $choice;
} else {
$studentChoice = $choice;
if ($studentChoice) {
@ -2495,18 +2497,13 @@ class Exercise {
if ($origin!='learnpath') {
ExerciseShowFunctions::display_fill_in_blanks_answer($answer,0,0);
}
} elseif($answerType == FREE_ANSWER) {
// to store the details of open questions in an array to be used in mail
$arrques[] = $questionName;
$arrans[] = $choice;
} elseif($answerType == FREE_ANSWER) {
if($origin != 'learnpath') {
ExerciseShowFunctions::display_free_answer($choice,0,0);
}
} elseif($answerType == ORAL_EXPRESSION) {
// to store the details of open questions in an array to be used in mail
$arrques[] = $questionName;
$arrans[] = $choice;
if($origin != 'learnpath') {
// to store the details of open questions in an array to be used in mail
if ($origin != 'learnpath') {
ExerciseShowFunctions::display_oral_expression_answer($choice, 0, 0, $nano);
}
} elseif($answerType == HOT_SPOT) {
@ -2744,8 +2741,7 @@ class Exercise {
$max_coord = poly_get_max($poly_user,$poly_answer);
$poly_user_compiled = poly_compile($poly_user,$max_coord);
$poly_answer_compiled = poly_compile($poly_answer,$max_coord);
$poly_results = poly_result($poly_answer_compiled,$poly_user_compiled,$max_coord);
$poly_results = poly_result($poly_answer_compiled,$poly_user_compiled,$max_coord);
$overlap = $poly_results['both'];
$poly_answer_area = $poly_results['s1'];
@ -3187,7 +3183,13 @@ class Exercise {
if ($debug) error_log($sql_update);
Database::query($sql_update);
}
$return_array = array('score'=>$questionScore, 'weight'=>$questionWeighting,'extra'=>$extra_data);
$return_array = array( 'score' => $questionScore,
'weight' => $questionWeighting,
'extra' => $extra_data,
'open_question' => $arrques,
'open_answer' => $arrans
);
return $return_array;
} //End function
@ -3195,148 +3197,88 @@ class Exercise {
* Sends a notification when a user ends an examn
*
*/
function send_notification($arrques, $arrans, $origin) {
function send_notification_for_open_questions($question_list_answers, $origin, $exe_id) {
if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1 ) {
return '';
}
return null;
}
// Email configuration settings
$coursecode = api_get_course_id();
$course_info = api_get_course_info(api_get_course_id());
$to = '';
$teachers = array();
if (api_get_session_id()) {
$teachers = CourseManager::get_coach_list_from_course_code($coursecode, api_get_session_id());
} 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)
}
$url_email = api_get_path(WEB_CODE_PATH).'exercice/exercise_report.php?'.api_get_cidreq().'&id_session='.api_get_session_id().'&exerciseId='.$this->id;
$url_email = api_get_path(WEB_CODE_PATH).'exercice/exercise_show.php?'.api_get_cidreq().'&id_session='.api_get_session_id().'&id='.$exe_id.'&action=qualify';
$user_info = UserManager::get_user_info_by_id(api_get_user_id());
$mycharset = api_get_system_encoding();
$msg = '< html > < head >
< link rel = "stylesheet" href = "'.api_get_path(WEB_CODE_PATH).'css/'.api_get_setting('stylesheets').'/default.css" type = "text/css" >
< meta content = "text/html; charset='.$mycharset.'" http-equiv = "content-type" > < / head > ';
if (count($arrques) > 0) {
$msg .= '< body >
< p > '.get_lang('OpenQuestionsAttempted').' :
< / p >
< p > '.get_lang('AttemptDetails').' : < br / >
< / p >
< table width = "730" height = "136" border = "0" cellpadding = "3" cellspacing = "3" >
< tr >
< td width = "229" valign = "top" > < h2 > '.get_lang('CourseName').'< / h2 > < / td >
< td width = "469" valign = "top" > < h2 > #course#< / h2 > < / td >
< / tr >
< tr >
< td width = "229" valign = "top" class = "outerframe" > '.get_lang('TestAttempted').'< / span > < / td >
< td width = "469" valign = "top" class = "outerframe" > #exercise#< / td >
< / tr >
< tr >
< td valign = "top" > < span class = "style10" > '.get_lang('StudentName').'< / span > < / td >
< td valign = "top" > #firstName# #lastName#< / td >
< / tr >
< tr >
< td valign = "top" > '.get_lang('StudentEmail').' < / td >
< td valign = "top" > #mail#< / td >
< / tr > < / table >
< p > < br / > '.get_lang('OpenQuestionsAttemptedAre').' :< / p >
< table width = "730" height = "136" border = "0" cellpadding = "3" cellspacing = "3" > ';
for($i=0;$i< sizeof ( $ arrques ) ; $ i + + ) {
$msg.='
$msg = '< p > '.get_lang('OpenQuestionsAttempted').' :< / p >
< p > '.get_lang('AttemptDetails').' : < / p >
< table class = "data_table" >
< tr >
< td width = "220" valign = "top" bgcolor = "#E5EDF8" > < span class = "style10" > '.get_lang('Question').'< / span > < / td >
< td width = "473" valign = "top" bgcolor = "#F3F3F3" > < span class = "style16" > #questionName#< / span > < / td >
< td > < h3 > '.get_lang('CourseName').'< / h3 > < / td >
< td > < h3 > #course#< / h3 > < / td >
< / tr >
< tr >
< td width = "220" valign = "top" bgcolor = "#E5EDF8" > < span class = "style10" > '.get_lang('Answer').' < / span > < / td >
< td valign = "top" bgcolor = "#F3F3F3" > < span class = "style16" > #answer#< / span > < / td >
< / tr > ';
$msg1 = str_replace("#exercise#", $this->exercise, $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#", $course_info['name'],$msg1);
}
$msg.='< / table > < br / > ';
if ($origin != 'learnpath') {
$msg.= '< span class = "style16" > '.get_lang('ClickToCommentAndGiveFeedback').',< br / >
< a href = "#url#" > #url#< / a > < / span > ';
< td > '.get_lang('TestAttempted').'< / span > < / td >
< td > #exercise#< / td >
< / tr >
< tr >
< td > '.get_lang('StudentName').'< / td >
< td > #firstName# #lastName#< / td >
< / tr >
< tr >
< td > '.get_lang('StudentEmail').'< / td >
< td > #mail#< / td >
< / tr >
< / table > ';
$open_question_list = null;
foreach ($question_list_answers as $item) {
$question = $item['question'];
$answer = $item['answer'];
if (!empty($question) & & !empty($answer)) {
$open_question_list.='< tr >
< td width = "220" valign = "top" bgcolor = "#E5EDF8" > '.get_lang('Question').'< / td >
< td width = "473" valign = "top" bgcolor = "#F3F3F3" > '.$question.'< / td >
< / tr >
< tr >
< td width = "220" valign = "top" bgcolor = "#E5EDF8" > '.get_lang('Answer').'< / td >
< td valign = "top" bgcolor = "#F3F3F3" > '.$answer.'< / td >
< / tr > ';
}
}
$msg.= '< / body > < / html > ';
$msg1 = str_replace("#url#", $url_email, $msg);
$mail_content = $msg1;
$subject = get_lang('OpenQuestionsAttempted');
if (!empty($open_question_list)) {
$msg .= '< p > < br / > '.get_lang('OpenQuestionsAttemptedAre').' :< / p >
< table width = "730" height = "136" border = "0" cellpadding = "3" cellspacing = "3" > ';
$msg .= $open_question_list;
$msg.='< / table > < br / > ';
$msg1 = str_replace("#exercise#", $this->exercise, $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);
$msg = str_replace("#course#", $course_info['name'],$msg1);
if ($origin != 'learnpath') {
$msg.= get_lang('ClickToCommentAndGiveFeedback').', < br / >
< a href = "#url#" > #url#< / a > ';
}
$msg1 = str_replace("#url#", $url_email, $msg);
$mail_content = $msg1;
$subject = get_lang('OpenQuestionsAttempted');
$teachers = array();
if (api_get_session_id()) {
$teachers = CourseManager::get_coach_list_from_course_code($coursecode, api_get_session_id());
} else {
$teachers = CourseManager::get_teacher_list_from_course_code($coursecode);
}
$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 .= '< body >
< p > '.get_lang('ExerciseAttempted').'< / p >
< table width = "730" height = "136" border = "0" cellpadding = "3" cellspacing = "3" >
< tr >
< td width = "229" valign = "top" > < h2 > '.get_lang('CourseName').'< / h2 > < / td >
< td width = "469" valign = "top" > < h2 > #course#< / h2 > < / td >
< / tr >
< tr >
< td width = "229" valign = "top" class = "outerframe" > '.get_lang('TestAttempted').'< / span > < / td >
< td width = "469" valign = "top" class = "outerframe" > #exercise#< / td >
< / tr >
< tr >
< td valign = "top" > < span class = "style10" > '.get_lang('StudentName').'< / span > < / td >
'.(api_is_western_name_order() ? '< td valign = "top" > #firstName# #lastName#< / td > ' : '< td valign = "top" > #lastName# #firstName#< / td > ').'
< / tr >
< tr >
< td valign = "top" > '.get_lang('StudentEmail').' < / td >
< td valign = "top" > #mail#< / td >
< / tr > < / table > ';
$msg= str_replace("#exercise#", $this->exercise,$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#", $course_info['name'], $msg);
if ($origin != 'learnpath') {
$msg.='< br / >
< span class = "style16" > '.get_lang('ClickToCommentAndGiveFeedback').',< br / >
< a href = "#url#" > #url#< / a > < / span > ';
}
$msg .= '< / body > < / html > ';
$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));
}
foreach ($teachers as $user_id => $teacher_data) {
MessageManager::send_message_simple($user_id, $subject, $mail_content);
}
}
}
function show_exercise_result_header($user_data, $date = null) {