Should fix most of the problems due negative values (using propagate quiz setting), should fix also some bugs with feedback.

skala
Julio Montoya 14 years ago
parent 743cc53d15
commit f3d0712bff
  1. 30
      main/css/base.css
  2. 189
      main/exercice/exercise.class.php
  3. 30
      main/exercice/exercise.lib.php
  4. 4
      main/exercice/exercise_result.php
  5. 16
      main/exercice/exercise_show.php
  6. 9
      main/exercice/exercise_submit.php
  7. 12
      main/inc/lib/events.lib.inc.php
  8. 19
      main/newscorm/lp_view.php
  9. 4
      tests/main/inc/lib/events.lib.inc.test.php

@ -2278,3 +2278,33 @@ div.admin_section h4 {
font-size: 12px !important;
color: #111 ! important;
}
/* Exercise comment*/
#comments {
position:absolute;
left:795px;
top:0px;
width:200px;
height:75px;
z-index:1;
}
#questions {
width:40%;
height:50px;
float:left;
padding:5px;
}
.question_item {
height:50px;
padding:5px;
margin:10px 0px 10px 0px;
}
.option_item {
width:150px;
padding:3px;
margin:10px;
}

@ -5,17 +5,16 @@
* @package chamilo.exercise
* @author Olivier Brouckaert
* @author Julio Montoya Cleaning exercises
* @version $Id: exercise.class.php 22046 2009-07-14 01:45:19Z ivantcholakov $
*/
/**
* Code
*/
define('ALL_ON_ONE_PAGE', 1);
define('ONE_PER_PAGE', 2);
//0=>Feedback , 1=>DirectFeedback, 2=>NoFeedback
define('EXERCISE_FEEDBACK_TYPE_END', 0);
define('EXERCISE_FEEDBACK_TYPE_DIRECT', 1);
define('EXERCISE_FEEDBACK_TYPE_EXAM', 2);
define('EXERCISE_FEEDBACK_TYPE_END', 0); //Feedback
define('EXERCISE_FEEDBACK_TYPE_DIRECT', 1); //DirectFeedback
define('EXERCISE_FEEDBACK_TYPE_EXAM', 2); //NoFeedback
define('EXERCISE_MAX_NAME_SIZE', 80);
@ -1528,6 +1527,7 @@ class Exercise {
$sql_fields = "";
$sql_fields_values = "";
}
array_map('intval', $questionList);
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)
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
* @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;
require_once api_get_path(LIBRARY_PATH).'geometry.lib.php';
@ -1804,9 +1804,11 @@ class Exercise {
//Extra information of the question
if (!empty($extra)) {
$extra = explode(':', $extra);
$true_score = $extra[0];
$false_score = $extra[1];
$doubt_score = $extra[2];
if ($debug) error_log(print_r($extra, 1));
//Fixes problems with negatives values using intval
$true_score = intval($extra[0]);
$false_score = intval($extra[1]);
$doubt_score = intval($extra[2]);
}
$totalWeighting = 0;
@ -1822,7 +1824,7 @@ class Exercise {
if ($debug) error_log('Count of answers :'.$nbrAnswers);
if ($debug) error_log('$answerType : '.$answerType);
$questionScore = 0;
if ($answerType == FREE_ANSWER) {
$nbrAnswers = 1;
}
@ -1838,8 +1840,11 @@ class Exercise {
$real_answers = array();
$quiz_question_options = Question::readQuestionOption($questionId);
$organs_at_risk_hit = 0;
$questionScore = 0;
for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
$answer = $objAnswerTmp->selectAnswer($answerId);
$answerComment = $objAnswerTmp->selectComment($answerId);
@ -1893,17 +1898,18 @@ class Exercise {
} else {
$studentChoice =$choice[$numAnswer];
}
if ($studentChoice == $answerCorrect ) {
$questionScore += $true_score;
} else {
if ($quiz_question_options[$studentChoice]['name'] != 'DoubtScore') {
if ($quiz_question_options[$studentChoice]['name'] != "Don't know") {
$questionScore += $false_score;
} else {
$questionScore += $doubt_score;
}
}
$totalScore +=$true_score;
$totalScore = $questionScore;
/*error_log('$totalScore '.$totalScore);
error_log('$$questionScore '.$questionScore);*/
break;
case MULTIPLE_ANSWER :
if ($from_database) {
@ -1949,26 +1955,6 @@ class Exercise {
//$answerCorrect = 0;
$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 {
$studentChoice = $choice[$numAnswer];
@ -1979,30 +1965,6 @@ class Exercise {
//$answerCorrect = 0;
$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;
@ -2045,12 +2007,6 @@ class Exercise {
$real_answers[$answerId] = true;
}
}
$final_answer = true;
foreach($real_answers as $my_answer) {
if (!$my_answer) {
$final_answer = false;
}
}
}
break;
// for fill in the blanks
@ -2078,7 +2034,7 @@ class Exercise {
// we save the answer because it will be modified
//$temp = $answer;
$temp = text_filter($answer);
$temp = $answer;
$answer = '';
$j = 0;
@ -2342,7 +2298,6 @@ class Exercise {
if ($hotspot_delineation_result[1]==1) {
$totalScore +=$answerWeighting; //adding the total
}
//$totalScore +=$answerWeighting; we do not if the hotspot is right or not
}
}
$_SESSION['hotspot_coord'][1] = $delineation_cord;
@ -2430,7 +2385,8 @@ class Exercise {
$excess = $poly_results['s2Only'];
//$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) {
//shortcut to avoid complicated calculations
$final_overlap = 0;
@ -2439,13 +2395,17 @@ class Exercise {
} else {
// 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);
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
$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
$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 "@@"
@ -2486,12 +2446,16 @@ class Exercise {
}
} elseif($answerId>1) {
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
$next = 1;
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
//echo 'user'; print_r($x_user_list); print_r($y_user_list);
//echo 'official';print_r($x_list);print_r($y_list);
@ -2511,7 +2475,9 @@ class Exercise {
$next = 1;
continue;
} 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++;
//show the feedback
$next=0;
@ -2526,7 +2492,9 @@ class Exercise {
}
}
} 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'];
//$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) {
//shortcut to avoid complicated calculations
$final_overlap = 0;
@ -2620,13 +2590,19 @@ class Exercise {
} else {
// 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);
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
$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
$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 "@@"
@ -2667,12 +2643,16 @@ class Exercise {
}
} elseif($answerId>1) {
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
$next = 1;
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
//echo 'user'; print_r($x_user_list); print_r($y_user_list);
//echo 'official';print_r($x_list);print_r($y_list);
@ -2692,7 +2672,9 @@ class Exercise {
$next = 1;
continue;
} 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++;
//show the feedback
$next=0;
@ -2707,7 +2689,9 @@ class Exercise {
}
}
} else { // the first delineation feedback
if ($debug>0) { error_log(__LINE__.' first',0);}
if ($debug>0) {
error_log(__LINE__.' first',0);
}
}
break;
case HOT_SPOT_ORDER:
@ -2725,6 +2709,7 @@ class Exercise {
}
} // end for that loops over all answers of the current question
// destruction of Answer
if (!$saved_results && $answerType == HOT_SPOT) {
@ -2925,11 +2910,14 @@ class Exercise {
$choice = 0;
}
if ($answerType == MULTIPLE_ANSWER_TRUE_FALSE || $answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE ) {
if ($debug) error_log(print_r($choice ,1 ));
if ($choice != 0) {
$reply = array_keys($choice);
for ($i = 0; $i < sizeof($reply); $i++) {
$ans = $reply[$i];
exercise_attempt($questionScore, $ans.':'.$choice[$ans], $quesId, $exeId, $i, $this->id);
if ($debug) error_log('result =>'.$questionScore.' '.$ans.':'.$choice[$ans]);
}
} else {
exercise_attempt($questionScore, 0, $quesId, $exeId, 0, $this->id);
@ -2977,15 +2965,15 @@ class Exercise {
}
}
if ($propagate_neg == 0 && $questionScore < 0) {
$questionScore = 0;
}
if ($saved_results) {
$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);
}
if ($propagate_neg == 0 && $questionScore < 0) {
$questionScore = 0;
}
$return_array = array('score'=>$questionScore, 'weight'=>$questionWeighting,'extra'=>$extra_data);
return $return_array;
} //End function
@ -3189,6 +3177,7 @@ class Exercise {
* @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 Feedback type
* @todo this was function was added due the import exercise via CSV
* @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) {
@ -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;

@ -146,31 +146,7 @@ function showQuestion($questionId, $only_questions = false, $origin = false, $cu
?>
<style>
#questions {
width:40%;
height:50px;
float:left;
padding:5px;
}
#options {
width:40%;
float:left;
padding:5px;
}
.question_item {
height:50px;
padding:5px;
margin:10px 0px 10px 0px;
}
.option_item {
width:150px;
padding:3px;
margin:10px;
}
</style>
<script>
$(function() {
@ -239,8 +215,6 @@ function showQuestion($questionId, $only_questions = false, $origin = false, $cu
// splits text and weightings that are joined with the character '::'
list($answer) = explode('::',$answer);
// because [] is parsed here we follow this procedure:
$answer = text_filter($answer);
//getting the matches
$answer = api_ereg_replace('\[[^]]+\]','<input type="text" name="choice['.$questionId.'][]" size="10" />',($answer));
}
@ -300,6 +274,7 @@ function showQuestion($questionId, $only_questions = false, $origin = false, $cu
} elseif ($answerType == MULTIPLE_ANSWER_TRUE_FALSE) {
$options = array('type'=>'radio','name'=>'choice['.$questionId.']['.$numAnswer.']', 'class'=>'checkbox');
$s .= '<input type="hidden" name="choice2['.$questionId.']" value="0" />';
$s .='<tr>';
$s .= Display::tag('td', $answer);
if (!empty($quiz_question_options)) {
@ -334,6 +309,8 @@ function showQuestion($questionId, $only_questions = false, $origin = false, $cu
// multiple answers
// set $debug_mark_answer to true at function start to
// show the correct answer with a suffix '-x'
$s .= '<input type="hidden" name="choice2['.$questionId.']" value="0" />';
$help = $selected = '';
if ($debug_mark_answer) {
if ($answerCorrect) {
@ -963,7 +940,6 @@ function get_exam_results_data($from, $number_of_items, $column, $direction) {
$teacher_id_list[] = $teacher['user_id'];
}
if (empty($hotpotatoe_where)) {
$column = intval($column);
$from = intval($from);

@ -155,7 +155,7 @@ if (api_is_course_admin() && $origin != 'learnpath') {
echo '</div>';
}
$exerciseTitle=text_filter($objExercise->selectTitle());
$exerciseTitle = $objExercise->selectTitle();
$feedback_type = $objExercise->feedbacktype;
//show exercise title
@ -275,7 +275,7 @@ if ($show_results || $show_only_score) {
$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);
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, $questionList);
}
if ($origin != 'learnpath') {

@ -74,6 +74,7 @@ $is_allowedToEdit = api_is_allowed_to_edit(null,true) || $is_courseTutor;
//Getting results from the exe_id. This variable also contain all the information about the exercise
$track_exercise_info = get_exercise_track_exercise_info($id);
//No track info
if (empty($track_exercise_info)) {
api_not_allowed();
@ -125,8 +126,6 @@ if($origin=='user_course') {
$interbreadcrumb[] = array ("url" => "../user/user.php?cidReq=".Security::remove_XSS($_GET['course']), "name" => get_lang("Users"));
$interbreadcrumb[] = array("url" => "../mySpace/myStudents.php?student=".$student_id."&course=".$_course['id']."&details=true&origin=".Security::remove_XSS($_GET['origin']) , "name" => get_lang("DetailsStudentInCourse"));
} else if($origin=='tracking_course') {
//$interbreadcrumb[] = array ("url" => "../mySpace/index.php", "name" => get_lang('MySpace'));
//$interbreadcrumb[] = array ("url" => "../mySpace/myStudents.php?student=".Security::remove_XSS($student_id).'&details=true&origin='.$origin.'&course='.Security::remove_XSS($_GET['cidReq']), "name" => get_lang("DetailsStudentInCourse"));
$interbreadcrumb[] = array ("url" => api_get_path(WEB_COURSE_PATH).$_course['directory'], 'name' => $_course['title']);
$interbreadcrumb[] = array ("url" => "../tracking/courseLog.php?cidReq=".$cidReq.'&studentlist=true&id_session='.$_SESSION['id_session'], "name" => get_lang("Tracking"));
$interbreadcrumb[] = array ("url" => "../mySpace/myStudents.php?student=".$student_id.'&details=true&origin='.$origin.'&course='.Security::remove_XSS($_GET['cidReq']), "name" => get_lang("DetailsStudentInCourse"));
@ -153,20 +152,7 @@ if ($origin != 'learnpath') {
} else {
Display::display_reduced_header();
}
?>
<style type="text/css">
<!--
#comments {
position:absolute;
left:795px;
top:0px;
width:200px;
height:75px;
z-index:1;
}
-->
</style>
<script language="javascript">
function showfck(sid,marksid) {
document.getElementById(sid).style.display='block';

@ -119,7 +119,6 @@ $safe_lp_id = ($learnpath_id == '') ? 0 : $learnpath_id;
$safe_lp_item_id = ($learnpath_item_id == '') ? 0 : $learnpath_item_id;
$safe_lp_item_view_id = ($learnpath_item_view_id == '') ? 0 : $learnpath_item_view_id;
/*
* Teacher takes an exam and want to see a preview, we delete the objExercise from the session in order to get the latest changes
in the exercise
@ -304,6 +303,7 @@ if ($formSent && isset($_POST)) {
}
// if the user has answered at least one question
if (is_array($choice)) {
if ($debug) { error_log('$choice is an array '.print_r($choice, 1)); }
// Also store hotspot spots in the session ($exerciseResultCoordinates
// will be stored in the session at the end of this script)
@ -334,7 +334,7 @@ if ($formSent && isset($_POST)) {
if (isset($exe_id)) {
//Manage the question and answer attempts
if ($debug > 0) { error_log('manage_answer exe_id: '.$exe_id.' - $questionId: '.$questionId.' Choice'.print_r($choice,1)); }
$objExercise->manage_answer($exe_id, $questionId, $choice,'exercise_show',$exerciseResultCoordinates, true, false,false);
$objExercise->manage_answer($exe_id, $questionId, $choice,'exercise_show',$exerciseResultCoordinates, true, false,false, $objExercise->propagate_neg);
}
//END of saving and qualifying
}
@ -475,14 +475,13 @@ if (api_is_course_admin() && $origin != 'learnpath') {
echo '<a href="exercice.php?show=test&id_session='.api_get_session_id().'">' . Display :: return_icon('back.png', get_lang('BackToExercisesList'),'','32').'</a>';
if ($show_quiz_edition) {
echo '<a href="exercise_admin.php?' . api_get_cidreq() . '&modifyExercise=yes&exerciseId=' . $objExercise->id . '">'.Display :: return_icon('settings.png', get_lang('ModifyExercise'),'','32').'</a>';
//echo Display :: return_icon('wizard.gif', get_lang('QuestionList')) . '<a href="exercice/admin.php?' . api_get_cidreq() . '&exerciseId=' . $objExercise->id . '">' . get_lang('QuestionList') . '</a>';
} else {
echo '<a href="#">'.Display::return_icon('settings_na.png', get_lang('ModifyExercise'),'','32').'</a>';
}
echo '</div>';
}
$exerciseTitle = text_filter($objExercise->selectTitle());
$exerciseTitle = $objExercise->selectTitle();
echo Display::tag('h2', $exerciseTitle);
$show_clock = true;
$user_id = api_get_user_id();
@ -518,8 +517,6 @@ if ($objExercise->selectAttempts() > 0) {
$score = show_score($last_attempt_info['exe_result'], $last_attempt_info['exe_weighting']);
echo Display::div(get_lang('YourTotalScore').' '.$score, array('id'=>'question_score'));
} else {
Display :: display_warning_message(sprintf(get_lang('ReachedMaxAttempts'), $exerciseTitle, $objExercise->selectAttempts()), false);
}

@ -305,7 +305,7 @@ function event_link($link_id) {
* @author Julio Montoya Armas <gugli100@gmail.com> Reworked 2010
* @desc Record result of user when an exercice was done
*/
function update_event_exercice($exeid, $exo_id, $score, $weighting,$session_id,$learnpath_id=0, $learnpath_item_id=0, $learnpath_item_view_id = 0, $duration) {
function update_event_exercice($exeid, $exo_id, $score, $weighting,$session_id,$learnpath_id=0, $learnpath_item_id=0, $learnpath_item_view_id = 0, $duration , $question_list) {
require_once api_get_path(SYS_CODE_PATH).'exercice/exercise.lib.php';
if ($exeid!='') {
// Validation in case of fraud with actived control time
@ -323,6 +323,7 @@ function update_event_exercice($exeid, $exo_id, $score, $weighting,$session_id,$
}
$TABLETRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
array_map('intval', $question_list);
$sql = "UPDATE $TABLETRACK_EXERCICES SET
exe_exo_id = '".Database::escape_string($exo_id)."',
@ -335,19 +336,18 @@ function update_event_exercice($exeid, $exo_id, $score, $weighting,$session_id,$
exe_duration = '".Database::escape_string($duration)."',
exe_date = '".api_get_utc_datetime()."',
status = '',
start_date = '".api_get_utc_datetime($start_date)."'
start_date = '".api_get_utc_datetime($start_date)."',
data_tracking = '".implode(',', $question_list)."'
WHERE exe_id = '".Database::escape_string($exeid)."'";
$res = @Database::query($sql);
//Deleting control time session track
exercise_time_control_delete($exo_id);
//error_log('update_event_exercice');
//error_log($sql);
return $res;
} else
} else {
return false;
}
}
/**
* This function creates an empty Exercise in STATISTIC_TRACK_E_EXERCICES table.

@ -171,11 +171,15 @@ foreach($list as $toc) {
}
}
$debug = 0;
$autostart = 'true';
// Update status, total_time from lp_item_view table when you finish the exercises in learning path.
if ($type_quiz && !empty($_REQUEST['exeId']) && isset($lp_id) && isset($_GET['lp_item_id'])) {
global $src;
$_SESSION['oLP']->items[$_SESSION['oLP']->current]->write_to_db();
$TBL_TRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$TBL_LP_ITEM_VIEW = Database::get_course_table(TABLE_LP_ITEM_VIEW);
$TBL_LP_VIEW = Database::get_course_table(TABLE_LP_VIEW);
@ -197,7 +201,17 @@ if ($type_quiz && !empty($_REQUEST['exeId']) && isset($lp_id) && isset($_GET['lp
$score = (float)$row_dates['exe_result'];
$max_score = (float)$row_dates['exe_weighting'];
/*require_once '../exercice/exercise.class.php';
require_once '../exercice/question.class.php';
require_once '../exercice/answer.class.php';
require_once '../exercice/exercise.lib.php';
$exercise_obj = new Exercise();
$score_result = $exercise_obj->get_exercise_result($safe_exe_id);
$score = (float)$score_result['score'];*/
$sql_upd_max_score = "UPDATE $TBL_LP_ITEM SET max_score = '$max_score' WHERE id = '".(int)$safe_item_id."'";
if ($debug) error_log($sql_upd_max_score);
Database::query($sql_upd_max_score);
$sql_last_attempt = "SELECT id FROM $TBL_LP_ITEM_VIEW WHERE lp_item_id = '$safe_item_id' AND lp_view_id = '".$_SESSION['oLP']->lp_view_id."' order by id desc limit 1";
@ -207,6 +221,7 @@ if ($type_quiz && !empty($_REQUEST['exeId']) && isset($lp_id) && isset($_GET['lp
if (Database::num_rows($res_last_attempt) > 0) {
$sql_upd_score = "UPDATE $TBL_LP_ITEM_VIEW SET status = 'completed' , score = $score, total_time = $mytime WHERE id='".$lp_item_view_id."'";
if ($debug) error_log($sql_upd_score);
Database::query($sql_upd_score);
$update_query = "UPDATE $TBL_TRACK_EXERCICES SET orig_lp_item_view_id = $lp_item_view_id WHERE exe_id = ".$safe_exe_id;
@ -217,7 +232,8 @@ if ($type_quiz && !empty($_REQUEST['exeId']) && isset($lp_id) && isset($_GET['lp
if (intval($_GET['fb_type']) > 0) {
$src = 'blank.php?msg=exerciseFinished';
} else {
$src = api_get_path(WEB_CODE_PATH).'exercice/exercise_show.php?id='.Security::remove_XSS($_REQUEST['exeId']).'&origin=learnpath&learnpath_id='.$lp_id.'&learnpath_item_id='.$lp_id.'&fb_type='.Security::remove_XSS($_GET['fb_type']);
$src = api_get_path(WEB_CODE_PATH).'exercice/exercise_show.php?id='.$safe_exe_id.'&origin=learnpath&learnpath_id='.$lp_id.'&learnpath_item_id='.$lp_id.'&fb_type='.Security::remove_XSS($_GET['fb_type']);
if ($debug) error_log('Calling URL'.$src);
}
$autostart = 'false';
}
@ -245,6 +261,7 @@ if ($_SESSION['oLP']->mode == 'fullscreen') {
} else {
$audio_recorder_studentview = false;
}
// Set flag to ensure lp_header.php is loaded by this script (flag is unset in lp_header.php).
$_SESSION['loaded_lp_view'] = true;

@ -142,9 +142,9 @@ class TestEvents extends UnitTestCase {
$weighting='';
$session_id='';
$duration='';
$res=update_event_exercice($exeid,$exo_id, $score, $weighting,$session_id,$learnpath_id=0,$learnpath_item_id=0, $duration);
$question_list = array();
$res=update_event_exercice($exeid,$exo_id, $score, $weighting,$session_id,$learnpath_id=0,$learnpath_item_id=0, $duration, $question_list);
$this->assertTrue(is_bool($res));
//var_dump($res);
}
}
?>

Loading…
Cancel
Save