@ -26,7 +26,7 @@ if (empty($origin)) {
}
if ($origin == 'learnpath')
api_protect_course_script();
api_protect_course_script();
else
api_protect_course_script(true);
@ -81,301 +81,7 @@ if ($show_headers) {
Display::display_reduced_header();
}
$show_results = true;
$show_only_total_score = false;
$display_category_name = 1;
// Avoiding the "Score 0/0" message when the exe_id is not set
if (!empty($track_exercise_info)) {
// if the results_disabled of the Quiz is 1 when block the script
$result_disabled = $track_exercise_info['results_disabled'];
$display_category_name = $track_exercise_info['display_category_name'];
if (!(api_is_platform_admin() || api_is_course_admin()) ) {
if ($result_disabled == EXERCISE_FEEDBACK_TYPE_DIRECT) {
$show_results = false;
Display::display_warning_message(get_lang('CantViewResults'));
} elseif ($result_disabled == EXERCISE_FEEDBACK_TYPE_EXAM) {
$show_results = false;
$show_only_total_score = true;
}
}
}
if ($show_results || $show_only_total_score) {
$user_info = api_get_user_info($student_id);
//Shows exercise header
$objExercise->description = '';
echo $objExercise->show_exercise_result_header(api_get_person_name($user_info['firstName'], $user_info['lastName']), api_convert_and_format_date($exercise_date, DATE_TIME_FORMAT_LONG));
}
$i = $totalScore = $totalWeighting = 0;
$result = get_exercise_results_by_attempt($id);
$question_list = $result[$id]['question_list'];
// for each question
$total_weighting = 0;
$counter = 1;
if (!empty($question_list)) {
foreach ($question_list as $question_item) {
$objQuestionTmp = Question::read($question_item['question_id'], api_get_course_int_id());
$total_weighting += $objQuestionTmp->selectWeighting();
}
//Needed in the manage_answer function
$feedback_type = $objExercise->feedback_type;
foreach ($question_list as $question_item) {
$choice = $question_item['answer'];
// creates a temporary Question object
$questionId = $question_item['question_id'];
$objQuestionTmp = Question::read($questionId, api_get_course_int_id());
$questionWeighting = $objQuestionTmp->selectWeighting();
$answerType = $objQuestionTmp->selectType();
if ($show_results) {
// display question category, if any
Testcategory::displayCategoryAndTitle($questionId, $display_category_name );
echo $objQuestionTmp->return_header($objExercise->feedback_type, $counter);
}
$counter++;
if ($answerType == MULTIPLE_ANSWER || $answerType == MULTIPLE_ANSWER_TRUE_FALSE) {
$question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg());
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
} elseif ($answerType == GLOBAL_MULTIPLE_ANSWER) {
$question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg());
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
} elseif ($answerType == MULTIPLE_ANSWER_COMBINATION || $answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
$choice = array();
$question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg());
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
} elseif ($answerType == UNIQUE_ANSWER || $answerType == UNIQUE_ANSWER_NO_OPTION) {
$question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg());
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
} elseif ($answerType == FILL_IN_BLANKS) {
$question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg());
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
} elseif ($answerType == FREE_ANSWER) {
$question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg());
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
} elseif ($answerType == MATCHING) {
$question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg());
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
} elseif ($answerType == HOT_SPOT) {
//@todo move this in the manage_answer function
if ($show_results) {
echo '< table width = "500" border = "0" > < tr >
< td valign = "top" align = "center" style = "padding-left:0px;" >
< table border = "1" bordercolor = "#A4A4A4" style = "border-collapse: collapse;" width = "552" > ';
}
$question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg());
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
if ($show_results) {
echo '< / table > < / td > < / tr > ';
echo '< tr >
< td colspan = "2" > '.
'< object type = "application/x-shockwave-flash" data = "'.api_get_path(WEB_CODE_PATH).'plugin/hotspot/hotspot_solution.swf?modifyAnswers='.Security::remove_XSS($questionId).'&exe_id='.$id.'&from_db=1" width = "552" height = "352" >
< param name = "movie" value = "../plugin/hotspot/hotspot_solution.swf?modifyAnswers='.Security::remove_XSS($questionId).'&exe_id='.$id.'&from_db=1" / >
< / object >
< / td >
< / tr >
< / table > < br / > ';
}
} else if($answerType == HOT_SPOT_DELINEATION) {
$question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg(), 'database');
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
$final_overlap = $question_result['extra']['final_overlap'];
$final_missing = $question_result['extra']['final_missing'];
$final_excess = $question_result['extra']['final_excess'];
$overlap_color = $question_result['extra']['overlap_color'];
$missing_color = $question_result['extra']['missing_color'];
$excess_color = $question_result['extra']['excess_color'];
$threadhold1 = $question_result['extra']['threadhold1'];
$threadhold2 = $question_result['extra']['threadhold2'];
$threadhold3 = $question_result['extra']['threadhold3'];
if ($show_results) {
if ($overlap_color) {
$overlap_color='green';
} else {
$overlap_color='red';
}
if ($missing_color) {
$missing_color='green';
} else {
$missing_color='red';
}
if ($excess_color) {
$excess_color='green';
} else {
$excess_color='red';
}
if (!is_numeric($final_overlap)) {
$final_overlap = 0;
}
if (!is_numeric($final_missing)) {
$final_missing = 0;
}
if (!is_numeric($final_excess)) {
$final_excess = 0;
}
if ($final_excess>100) {
$final_excess = 100;
}
$table_resume='< table class = "data_table" >
< tr class = "row_odd" >
< td > < / td >
< td > < b > '.get_lang('Requirements').'< / b > < / td >
< td > < b > '.get_lang('YourAnswer').'< / b > < / td >
< / tr >
< tr class = "row_even" >
< td > < b > '.get_lang('Overlap').'< / b > < / td >
< td > '.get_lang('Min').' '.$threadhold1.'< / td >
< td > < div style = "color:'.$overlap_color.'" > '.(($final_overlap < 0 ) ? 0:intval ( $ final_overlap ) ) . ' < / div > < / td >
< / tr >
< tr >
< td > < b > '.get_lang('Excess').'< / b > < / td >
< td > '.get_lang('Max').' '.$threadhold2.'< / td >
< td > < div style = "color:'.$excess_color.'" > '.(($final_excess < 0 ) ? 0:intval ( $ final_excess ) ) . ' < / div > < / td >
< / tr >
< tr class = "row_even" >
< td > < b > '.get_lang('Missing').'< / b > < / td >
< td > '.get_lang('Max').' '.$threadhold3.'< / td >
< td > < div style = "color:'.$missing_color.'" > '.(($final_missing < 0 ) ? 0:intval ( $ final_missing ) ) . ' < / div > < / td >
< / tr > < / table > ';
if ($answerType!= HOT_SPOT_DELINEATION) {
$item_list=explode('@@',$destination);
//print_R($item_list);
$try = $item_list[0];
$lp = $item_list[1];
$destinationid= $item_list[2];
$url=$item_list[3];
$table_resume='';
} else {
if ($next==0) {
$try = $try_hotspot;
$lp = $lp_hotspot;
$destinationid= $select_question_hotspot;
$url=$url_hotspot;
} else {
//show if no error
//echo 'no error';
$comment=$answerComment=$objAnswerTmp->selectComment($nbrAnswers);
$answerDestination=$objAnswerTmp->selectDestination($nbrAnswers);
}
}
echo '< h1 > < div style = "color:#333;" > '.get_lang('Feedback').'< / div > < / h1 > ';
if ($answerType == HOT_SPOT_DELINEATION) {
if ($organs_at_risk_hit>0) {
$message='< br / > '.get_lang('ResultIs').' < b > '.$result_comment.'< / b > < br / > ';
$message.='< p style = "color:#DC0A0A;" > < b > '.get_lang('OARHit').'< / b > < / p > ';
} else {
$message='< p > '.get_lang('YourDelineation').'< / p > ';
$message.=$table_resume;
$message.='< br / > '.get_lang('ResultIs').' < b > '.$result_comment.'< / b > < br / > ';
}
$message.='< p > '.$comment.'< / p > ';
echo $message;
} else {
echo '< p > '.$comment.'< / p > ';
}
//showing the score
/*
$queryfree = "select marks from ".$TBL_TRACK_ATTEMPT." where exe_id = '".Database::escape_string($id)."' and question_id= '".Database::escape_string($questionId)."'";
$resfree = Database::query($queryfree);
$questionScore= Database::result($resfree,0,"marks");
$totalScore+=$questionScore;*/
?>
< / table >
< / td > < / tr >
<?php
echo '< tr >
< td colspan = "2" >
< object type = "application/x-shockwave-flash" data = "../plugin/hotspot/hotspot_solution.swf?modifyAnswers='.$questionId.'&exe_id='.$id.'&from_db=1" width = "556" height = "350" >
< param name = "movie" value = "../plugin/hotspot/hotspot_solution.swf?modifyAnswers='.$questionId.'&exe_id='.$id.'&from_db=1" / >
< / object >
< / td >
< / tr >
< / table > ';
}
}
if ($show_results) {
if ($answerType != HOT_SPOT) {
echo '< / table > ';
}
}
if ($show_results) {
$comnt = get_comments($id, $questionId);
if (!empty($comnt)) {
echo '< b > '.get_lang('Feedback').'< / b > ';
echo '< div id = "question_feedback" > '.$comnt.'< / div > ';
}
}
$my_total_score = $questionScore;
$my_total_weight = $questionWeighting;
if ($objExercise->selectPropagateNeg() == 0 & & $my_total_score < 0 ) {
$my_total_score = 0;
}
if ($show_results) {
echo '< div id = "question_score" > ';
echo get_lang('Score')." : ".show_score($my_total_score, $my_total_weight, false, false);
echo '< / div > ';
}
unset($objAnswerTmp);
unset($objQuestionTmp);
$i++;
$totalWeighting += $questionWeighting;
} // end of large foreach on questions
}
//Total score
if ($show_results || $show_only_total_score) {
echo '< div id = "question_score" > '.get_lang('YourTotalScore').": ";
$my_total_score_temp = $totalScore;
if ($objExercise->selectPropagateNeg() == 0 & & $my_total_score_temp < 0 ) {
$my_total_score_temp = 0;
}
echo show_score($my_total_score_temp, $totalWeighting, false, true, true, $objExercise->selectPassPercentage());
echo '< / div > ';
}
display_question_list_by_attempt($objExercise, $id, false);
if ($show_headers) {
Display::display_footer();