@ -1,21 +1,20 @@
<?php
<?php
/* For licensing terms, see /license.txt */
/* For licensing terms, see /license.txt */
/**
/**
* Exercise class: This class allows to instantiate an object of type Exercise
* Exercise class: This class allows to instantiate an object of type Exercise
* @package chamilo.exercise
* @package chamilo.exercise
* @author Olivier Brouckaert
* @author Olivier Brouckaert
* @author Julio Montoya Cleaning exercises
* @author Julio Montoya Cleaning exercises
* @version $Id: exercise.class.php 22046 2009-07-14 01:45:19Z ivantcholakov $
*/
*/
/**
/**
* Code
* Code
*/
*/
define('ALL_ON_ONE_PAGE', 1);
define('ALL_ON_ONE_PAGE', 1);
define('ONE_PER_PAGE', 2);
define('ONE_PER_PAGE', 2);
//0=>Feedback , 1=>DirectFeedback, 2=>NoFeedback
define('EXERCISE_FEEDBACK_TYPE_END', 0);
define('EXERCISE_FEEDBACK_TYPE_END', 0); //Feedback
define('EXERCISE_FEEDBACK_TYPE_DIRECT', 1);
define('EXERCISE_FEEDBACK_TYPE_DIRECT', 1); //DirectFeedback
define('EXERCISE_FEEDBACK_TYPE_EXAM', 2);
define('EXERCISE_FEEDBACK_TYPE_EXAM', 2); //NoFeedback
define('EXERCISE_MAX_NAME_SIZE', 80);
define('EXERCISE_MAX_NAME_SIZE', 80);
@ -26,8 +25,8 @@ require_once dirname(__FILE__).'/../inc/lib/exercise_show_functions.lib.php';
if(!class_exists('Exercise')):
if(!class_exists('Exercise')):
/**
/**
* Exercise class
* Exercise class
* @package chamilo.exercise
* @package chamilo.exercise
*/
*/
class Exercise {
class Exercise {
public $id;
public $id;
@ -899,7 +898,7 @@ class Exercise {
/*$feedback_option[0]=get_lang('ExerciseAtTheEndOfTheTest');
/*$feedback_option[0]=get_lang('ExerciseAtTheEndOfTheTest');
$feedback_option[1]=get_lang('DirectFeedback');
$feedback_option[1]=get_lang('DirectFeedback');
$feedback_option[2]=get_lang('NoFeedback');
$feedback_option[2]=get_lang('NoFeedback');
*/
*/
//Can't modify a DirectFeedback question
//Can't modify a DirectFeedback question
if ($this->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_DIRECT ) {
if ($this->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_DIRECT ) {
// feedback type
// feedback type
@ -1528,6 +1527,7 @@ class Exercise {
$sql_fields = "";
$sql_fields = "";
$sql_fields_values = "";
$sql_fields_values = "";
}
}
array_map('intval', $questionList);
if ($this->type == ONE_PER_PAGE) {
if ($this->type == ONE_PER_PAGE) {
$sql = "INSERT INTO $track_exercises ($sql_fields exe_exo_id, exe_user_id, exe_cours_id, status,session_id, data_tracking, start_date, orig_lp_id, orig_lp_item_id, exe_weighting)
$sql = "INSERT INTO $track_exercises ($sql_fields exe_exo_id, exe_user_id, exe_cours_id, status,session_id, data_tracking, start_date, orig_lp_id, orig_lp_item_id, exe_weighting)
VALUES($sql_fields_values '".$this->id."','" . api_get_user_id() . "','" . api_get_course_id() . "','incomplete','" . api_get_session_id() . "','" . implode(',', $questionList) . "', '" . api_get_utc_datetime() . "', '$safe_lp_id', '$safe_lp_item_id', '$weight' )";
VALUES($sql_fields_values '".$this->id."','" . api_get_user_id() . "','" . api_get_course_id() . "','incomplete','" . api_get_session_id() . "','" . implode(',', $questionList) . "', '" . api_get_utc_datetime() . "', '$safe_lp_id', '$safe_lp_item_id', '$weight' )";
@ -1769,7 +1769,7 @@ class Exercise {
* @todo reduce parameters of this function
* @todo reduce parameters of this function
* @return string html code
* @return string html code
*/
*/
function manage_answer($exeId, $questionId, $choice, $from = 'exercise_show', $exerciseResultCoordinates = array(), $saved_results = true, $from_database = false, $show_result = true, $propagate_neg = 0, $hotspot_delineation_result = array()) {
public function manage_answer($exeId, $questionId, $choice, $from = 'exercise_show', $exerciseResultCoordinates = array(), $saved_results = true, $from_database = false, $show_result = true, $propagate_neg = 0, $hotspot_delineation_result = array()) {
global $_configuration, $feedback_type, $debug;
global $_configuration, $feedback_type, $debug;
require_once api_get_path(LIBRARY_PATH).'geometry.lib.php';
require_once api_get_path(LIBRARY_PATH).'geometry.lib.php';
@ -1804,9 +1804,11 @@ class Exercise {
//Extra information of the question
//Extra information of the question
if (!empty($extra)) {
if (!empty($extra)) {
$extra = explode(':', $extra);
$extra = explode(':', $extra);
$true_score = $extra[0];
if ($debug) error_log(print_r($extra, 1));
$false_score = $extra[1];
//Fixes problems with negatives values using intval
$doubt_score = $extra[2];
$true_score = intval($extra[0]);
$false_score = intval($extra[1]);
$doubt_score = intval($extra[2]);
}
}
$totalWeighting = 0;
$totalWeighting = 0;
@ -1822,7 +1824,7 @@ class Exercise {
if ($debug) error_log('Count of answers :'.$nbrAnswers);
if ($debug) error_log('Count of answers :'.$nbrAnswers);
if ($debug) error_log('$answerType : '.$answerType);
if ($debug) error_log('$answerType : '.$answerType);
$questionScore = 0;
if ($answerType == FREE_ANSWER) {
if ($answerType == FREE_ANSWER) {
$nbrAnswers = 1;
$nbrAnswers = 1;
}
}
@ -1838,8 +1840,11 @@ class Exercise {
$real_answers = array();
$real_answers = array();
$quiz_question_options = Question::readQuestionOption($questionId);
$quiz_question_options = Question::readQuestionOption($questionId);
$organs_at_risk_hit = 0;
$organs_at_risk_hit = 0;
$questionScore = 0;
for ($answerId = 1; $answerId < = $nbrAnswers; $answerId++) {
for ($answerId = 1; $answerId < = $nbrAnswers; $answerId++) {
$answer = $objAnswerTmp->selectAnswer($answerId);
$answer = $objAnswerTmp->selectAnswer($answerId);
$answerComment = $objAnswerTmp->selectComment($answerId);
$answerComment = $objAnswerTmp->selectComment($answerId);
@ -1893,17 +1898,18 @@ class Exercise {
} else {
} else {
$studentChoice =$choice[$numAnswer];
$studentChoice =$choice[$numAnswer];
}
}
if ($studentChoice == $answerCorrect ) {
if ($studentChoice == $answerCorrect ) {
$questionScore +=$true_score;
$questionScore += $true_score;
} else {
} else {
if ($quiz_question_options[$studentChoice]['name'] != 'DoubtScore' ) {
if ($quiz_question_options[$studentChoice]['name'] != "Don't know" ) {
$questionScore += $false_score;
$questionScore += $false_score;
} else {
} else {
$questionScore += $doubt_score;
$questionScore += $doubt_score;
}
}
}
}
$totalScore +=$true_score;
$totalScore = $questionScore;
/*error_log('$totalScore '.$totalScore);
error_log('$$questionScore '.$questionScore);*/
break;
break;
case MULTIPLE_ANSWER :
case MULTIPLE_ANSWER :
if ($from_database) {
if ($from_database) {
@ -1949,26 +1955,6 @@ class Exercise {
//$answerCorrect = 0;
//$answerCorrect = 0;
$real_answers[$answerId] = false;
$real_answers[$answerId] = false;
}
}
/*
if ($answerCorrect == 1) {
if ($studentChoice == 1) { //true value see MultipleAnswerCombinationTrueFalse class
$real_answers[$answerId] = true;
} elseif ($studentChoice == 2) { //false value
$real_answers[$answerId] = false;
} else {
$real_answers[$answerId] = false;
}
} else {
if ($studentChoice == 1) { //true value
$real_answers[$answerId] = false;
} elseif ($studentChoice == 2) { //false value see MultipleAnswerCombinationTrueFalse class
$real_answers[$answerId] = true;
} else {
$real_answers[$answerId] = true;
}
}*/
} else {
} else {
$studentChoice = $choice[$numAnswer];
$studentChoice = $choice[$numAnswer];
@ -1979,30 +1965,6 @@ class Exercise {
//$answerCorrect = 0;
//$answerCorrect = 0;
$real_answers[$answerId] = false;
$real_answers[$answerId] = false;
}
}
/*if ($answerCorrect == 1) {
if ($studentChoice == 1) { //true value see MultipleAnswerCombinationTrueFalse class
$real_answers[$answerId] = true;
} elseif ($studentChoice == 2) { //false value
$real_answers[$answerId] = false;
} else {
$real_answers[$answerId] = false;
}
} else {
if ($studentChoice == 1) { //true value
$real_answers[$answerId] = false;
} elseif ($studentChoice == 2) { //false value see MultipleAnswerCombinationTrueFalse class
$real_answers[$answerId] = true;
} else {
$real_answers[$answerId] = true;
}
} */
$final_answer = true;
foreach($real_answers as $my_answer) {
if (!$my_answer) {
$final_answer = false;
}
}
}
}
break;
break;
@ -2045,12 +2007,6 @@ class Exercise {
$real_answers[$answerId] = true;
$real_answers[$answerId] = true;
}
}
}
}
$final_answer = true;
foreach($real_answers as $my_answer) {
if (!$my_answer) {
$final_answer = false;
}
}
}
}
break;
break;
// for fill in the blanks
// for fill in the blanks
@ -2078,7 +2034,7 @@ class Exercise {
// we save the answer because it will be modified
// we save the answer because it will be modified
//$temp = $answer;
//$temp = $answer;
$temp = text_filter($answer) ;
$temp = $answer ;
$answer = '';
$answer = '';
$j = 0;
$j = 0;
@ -2342,7 +2298,6 @@ class Exercise {
if ($hotspot_delineation_result[1]==1) {
if ($hotspot_delineation_result[1]==1) {
$totalScore +=$answerWeighting; //adding the total
$totalScore +=$answerWeighting; //adding the total
}
}
//$totalScore +=$answerWeighting; we do not if the hotspot is right or not
}
}
}
}
$_SESSION['hotspot_coord'][1] = $delineation_cord;
$_SESSION['hotspot_coord'][1] = $delineation_cord;
@ -2430,7 +2385,8 @@ class Exercise {
$excess = $poly_results['s2Only'];
$excess = $poly_results['s2Only'];
//$overlap = round(polygons_overlap($poly_answer,$poly_user)); //this is an area in pixels
//$overlap = round(polygons_overlap($poly_answer,$poly_user)); //this is an area in pixels
if ($debug>0) { error_log(__LINE__.' - Polygons results are '.print_r($poly_results,1),0);}
if ($debug>0) error_log(__LINE__.' - Polygons results are '.print_r($poly_results,1),0);
if ($overlap < 1 ) {
if ($overlap < 1 ) {
//shortcut to avoid complicated calculations
//shortcut to avoid complicated calculations
$final_overlap = 0;
$final_overlap = 0;
@ -2439,13 +2395,17 @@ class Exercise {
} else {
} else {
// the final overlap is the percentage of the initial polygon that is overlapped by the user's polygon
// the final overlap is the percentage of the initial polygon that is overlapped by the user's polygon
$final_overlap = round(((float)$overlap / (float)$poly_answer_area)*100);
$final_overlap = round(((float)$overlap / (float)$poly_answer_area)*100);
if ($debug>1) { error_log(__LINE__.' - Final overlap is '.$final_overlap,0);}
if ($debug>1) error_log(__LINE__.' - Final overlap is '.$final_overlap,0);
// the final missing area is the percentage of the initial polygon that is not overlapped by the user's polygon
// the final missing area is the percentage of the initial polygon that is not overlapped by the user's polygon
$final_missing = 100 - $final_overlap;
$final_missing = 100 - $final_overlap;
if ($debug>1) { error_log(__LINE__.' - Final missing is '.$final_missing,0);}
if ($debug>1) {
error_log(__LINE__.' - Final missing is '.$final_missing,0);
}
// the final excess area is the percentage of the initial polygon's size that is covered by the user's polygon outside of the initial polygon
// the final excess area is the percentage of the initial polygon's size that is covered by the user's polygon outside of the initial polygon
$final_excess = round((((float)$poly_user_area-(float)$overlap)/(float)$poly_answer_area)*100);
$final_excess = round((((float)$poly_user_area-(float)$overlap)/(float)$poly_answer_area)*100);
if ($debug>1) { error_log(__LINE__.' - Final excess is '.$final_excess,0);}
if ($debug>1) {
error_log(__LINE__.' - Final excess is '.$final_excess,0);
}
}
}
//checking the destination parameters parsing the "@@"
//checking the destination parameters parsing the "@@"
@ -2486,12 +2446,16 @@ class Exercise {
}
}
} elseif($answerId>1) {
} elseif($answerId>1) {
if ($objAnswerTmp->selectHotspotType($answerId) == 'noerror') {
if ($objAnswerTmp->selectHotspotType($answerId) == 'noerror') {
if ($debug>0) { error_log(__LINE__.' - answerId is of type noerror',0);}
if ($debug>0) {
error_log(__LINE__.' - answerId is of type noerror',0);
}
//type no error shouldn't be treated
//type no error shouldn't be treated
$next = 1;
$next = 1;
continue;
continue;
}
}
if ($debug>0) { error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR',0);}
if ($debug>0) {
error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR',0);
}
//check the intersection between the oar and the user
//check the intersection between the oar and the user
//echo 'user'; print_r($x_user_list); print_r($y_user_list);
//echo 'user'; print_r($x_user_list); print_r($y_user_list);
//echo 'official';print_r($x_list);print_r($y_list);
//echo 'official';print_r($x_list);print_r($y_list);
@ -2511,7 +2475,9 @@ class Exercise {
$next = 1;
$next = 1;
continue;
continue;
} else {
} else {
if ($debug>0) { error_log(__LINE__.' - Overlap is '.$overlap.': OAR hit',0);}
if ($debug>0) {
error_log(__LINE__.' - Overlap is '.$overlap.': OAR hit',0);
}
$organs_at_risk_hit++;
$organs_at_risk_hit++;
//show the feedback
//show the feedback
$next=0;
$next=0;
@ -2526,7 +2492,9 @@ class Exercise {
}
}
}
}
} else { // the first delineation feedback
} else { // the first delineation feedback
if ($debug>0) { error_log(__LINE__.' first',0);}
if ($debug>0) {
error_log(__LINE__.' first',0);
}
}
}
@ -2611,7 +2579,9 @@ class Exercise {
$excess = $poly_results['s2Only'];
$excess = $poly_results['s2Only'];
//$overlap = round(polygons_overlap($poly_answer,$poly_user)); //this is an area in pixels
//$overlap = round(polygons_overlap($poly_answer,$poly_user)); //this is an area in pixels
if ($debug>0) { error_log(__LINE__.' - Polygons results are '.print_r($poly_results,1),0);}
if ($debug>0) {
error_log(__LINE__.' - Polygons results are '.print_r($poly_results,1),0);
}
if ($overlap < 1 ) {
if ($overlap < 1 ) {
//shortcut to avoid complicated calculations
//shortcut to avoid complicated calculations
$final_overlap = 0;
$final_overlap = 0;
@ -2620,13 +2590,19 @@ class Exercise {
} else {
} else {
// the final overlap is the percentage of the initial polygon that is overlapped by the user's polygon
// the final overlap is the percentage of the initial polygon that is overlapped by the user's polygon
$final_overlap = round(((float)$overlap / (float)$poly_answer_area)*100);
$final_overlap = round(((float)$overlap / (float)$poly_answer_area)*100);
if ($debug>1) { error_log(__LINE__.' - Final overlap is '.$final_overlap,0);}
if ($debug>1) {
error_log(__LINE__.' - Final overlap is '.$final_overlap,0);
}
// the final missing area is the percentage of the initial polygon that is not overlapped by the user's polygon
// the final missing area is the percentage of the initial polygon that is not overlapped by the user's polygon
$final_missing = 100 - $final_overlap;
$final_missing = 100 - $final_overlap;
if ($debug>1) { error_log(__LINE__.' - Final missing is '.$final_missing,0);}
if ($debug>1) {
error_log(__LINE__.' - Final missing is '.$final_missing,0);
}
// the final excess area is the percentage of the initial polygon's size that is covered by the user's polygon outside of the initial polygon
// the final excess area is the percentage of the initial polygon's size that is covered by the user's polygon outside of the initial polygon
$final_excess = round((((float)$poly_user_area-(float)$overlap)/(float)$poly_answer_area)*100);
$final_excess = round((((float)$poly_user_area-(float)$overlap)/(float)$poly_answer_area)*100);
if ($debug>1) { error_log(__LINE__.' - Final excess is '.$final_excess,0);}
if ($debug>1) {
error_log(__LINE__.' - Final excess is '.$final_excess,0);
}
}
}
//checking the destination parameters parsing the "@@"
//checking the destination parameters parsing the "@@"
@ -2667,12 +2643,16 @@ class Exercise {
}
}
} elseif($answerId>1) {
} elseif($answerId>1) {
if ($objAnswerTmp->selectHotspotType($answerId) == 'noerror') {
if ($objAnswerTmp->selectHotspotType($answerId) == 'noerror') {
if ($debug>0) { error_log(__LINE__.' - answerId is of type noerror',0);}
if ($debug>0) {
error_log(__LINE__.' - answerId is of type noerror',0);
}
//type no error shouldn't be treated
//type no error shouldn't be treated
$next = 1;
$next = 1;
continue;
continue;
}
}
if ($debug>0) { error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR',0);}
if ($debug>0) {
error_log(__LINE__.' - answerId is >1 so we\'re probably in OAR',0);
}
//check the intersection between the oar and the user
//check the intersection between the oar and the user
//echo 'user'; print_r($x_user_list); print_r($y_user_list);
//echo 'user'; print_r($x_user_list); print_r($y_user_list);
//echo 'official';print_r($x_list);print_r($y_list);
//echo 'official';print_r($x_list);print_r($y_list);
@ -2692,7 +2672,9 @@ class Exercise {
$next = 1;
$next = 1;
continue;
continue;
} else {
} else {
if ($debug>0) { error_log(__LINE__.' - Overlap is '.$overlap.': OAR hit',0);}
if ($debug>0) {
error_log(__LINE__.' - Overlap is '.$overlap.': OAR hit',0);
}
$organs_at_risk_hit++;
$organs_at_risk_hit++;
//show the feedback
//show the feedback
$next=0;
$next=0;
@ -2707,7 +2689,9 @@ class Exercise {
}
}
}
}
} else { // the first delineation feedback
} else { // the first delineation feedback
if ($debug>0) { error_log(__LINE__.' first',0);}
if ($debug>0) {
error_log(__LINE__.' first',0);
}
}
}
break;
break;
case HOT_SPOT_ORDER:
case HOT_SPOT_ORDER:
@ -2725,6 +2709,7 @@ class Exercise {
}
}
} // end for that loops over all answers of the current question
} // end for that loops over all answers of the current question
// destruction of Answer
// destruction of Answer
if (!$saved_results & & $answerType == HOT_SPOT) {
if (!$saved_results & & $answerType == HOT_SPOT) {
@ -2921,15 +2906,18 @@ class Exercise {
// stored by exercise_results.php (using the session)
// stored by exercise_results.php (using the session)
if ($saved_results) {
if ($saved_results) {
if (empty ($choice)) {
if (empty ($choice)) {
$choice = 0;
$choice = 0;
}
}
if ($answerType == MULTIPLE_ANSWER_TRUE_FALSE || $answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE ) {
if ($answerType == MULTIPLE_ANSWER_TRUE_FALSE || $answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE ) {
if ($debug) error_log(print_r($choice ,1 ));
if ($choice != 0) {
if ($choice != 0) {
$reply = array_keys($choice);
$reply = array_keys($choice);
for ($i = 0; $i < sizeof ( $ reply ) ; $ i + + ) {
for ($i = 0; $i < sizeof ( $ reply ) ; $ i + + ) {
$ans = $reply[$i];
$ans = $reply[$i];
exercise_attempt($questionScore, $ans.':'.$choice[$ans], $quesId, $exeId, $i, $this->id);
exercise_attempt($questionScore, $ans.':'.$choice[$ans], $quesId, $exeId, $i, $this->id);
if ($debug) error_log('result =>'.$questionScore.' '.$ans.':'.$choice[$ans]);
}
}
} else {
} else {
exercise_attempt($questionScore, 0, $quesId, $exeId, 0, $this->id);
exercise_attempt($questionScore, 0, $quesId, $exeId, 0, $this->id);
@ -2964,7 +2952,7 @@ class Exercise {
} elseif ($answerType == UNIQUE_ANSWER || $answerType == UNIQUE_ANSWER_NO_OPTION) {
} elseif ($answerType == UNIQUE_ANSWER || $answerType == UNIQUE_ANSWER_NO_OPTION) {
$answer = $choice;
$answer = $choice;
exercise_attempt($questionScore, $answer, $quesId, $exeId, 0, $this->id);
exercise_attempt($questionScore, $answer, $quesId, $exeId, 0, $this->id);
// } elseif ($answerType == HOT_SPOT || $answerType == HOT_SPOT_DELINEATION) {
// } elseif ($answerType == HOT_SPOT || $answerType == HOT_SPOT_DELINEATION) {
} elseif ($answerType == HOT_SPOT) {
} elseif ($answerType == HOT_SPOT) {
exercise_attempt($questionScore, $answer, $quesId, $exeId, 0, $this->id);
exercise_attempt($questionScore, $answer, $quesId, $exeId, 0, $this->id);
if (isset($exerciseResultCoordinates[$questionId]) & & !empty($exerciseResultCoordinates[$questionId])) {
if (isset($exerciseResultCoordinates[$questionId]) & & !empty($exerciseResultCoordinates[$questionId])) {
@ -2977,15 +2965,15 @@ class Exercise {
}
}
}
}
if ($propagate_neg == 0 & & $questionScore < 0 ) {
$questionScore = 0;
}
if ($saved_results) {
if ($saved_results) {
$stat_table = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$stat_table = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$sql_update = 'UPDATE ' . $stat_table . ' SET exe_result = exe_result + ' . floatval($totalScore) . ' WHERE exe_id = ' . $exeId;
$sql_update = 'UPDATE ' . $stat_table . ' SET exe_result = exe_result + ' . floatval($questionScore) . ' WHERE exe_id = ' . $exeId;
if ($debug) error_log($sql_update);
Database::query($sql_update);
Database::query($sql_update);
}
}
if ($propagate_neg == 0 & & $questionScore < 0 ) {
$questionScore = 0;
}
$return_array = array('score'=>$questionScore, 'weight'=>$questionWeighting,'extra'=>$extra_data);
$return_array = array('score'=>$questionScore, 'weight'=>$questionWeighting,'extra'=>$extra_data);
return $return_array;
return $return_array;
} //End function
} //End function
@ -3189,6 +3177,7 @@ class Exercise {
* @param int Whether the results are show to the user (0) or not (1)
* @param int Whether the results are show to the user (0) or not (1)
* @param int Maximum number of attempts (0 if no limit)
* @param int Maximum number of attempts (0 if no limit)
* @param int Feedback type
* @param int Feedback type
* @todo this was function was added due the import exercise via CSV
* @return int New exercise ID
* @return int New exercise ID
*/
*/
function create_quiz ($title, $expired_time = 0, $type = 2, $random = 0, $active = 1, $results_disabled = 0, $max_attempt = 0, $feedback = 3) {
function create_quiz ($title, $expired_time = 0, $type = 2, $random = 0, $active = 1, $results_disabled = 0, $max_attempt = 0, $feedback = 3) {
@ -3215,5 +3204,33 @@ class Exercise {
}
}
/**
* Returns the exercise result
* @param int attempt id
* @return float exercise result
*/
public function get_exercise_result($exe_id) {
$result = array();
$track_exercise_info = get_exercise_track_exercise_info($exe_id);
if (!empty($track_exercise_info)) {
$objExercise = new Exercise();
$objExercise->read($track_exercise_info['exe_exo_id']);
if (!empty($track_exercise_info['data_tracking'])) {
$question_list = explode(',', $track_exercise_info['data_tracking']);
}
foreach ($question_list as $questionId) {
$question_result = $objExercise->manage_answer($exe_id, $questionId, '','exercise_show', array(), false, true, false, $objExercise->selectPropagateNeg());
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
}
if ($objExercise->selectPropagateNeg() == 0 & & $totalScore < 0 ) {
$totalScore = 0;
}
$result = array('score' => $totalScore, 'weight' =>$track_exercise_info['exe_weighting']);
}
return $result;
}
}
}
endif;
endif;