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. 211
      main/exercice/exercise.class.php
  3. 32
      main/exercice/exercise.lib.php
  4. 6
      main/exercice/exercise_result.php
  5. 20
      main/exercice/exercise_show.php
  6. 13
      main/exercice/exercise_submit.php
  7. 12
      main/inc/lib/events.lib.inc.php
  8. 43
      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; font-size: 12px !important;
color: #111 ! 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;
}

@ -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;

@ -146,31 +146,7 @@ function showQuestion($questionId, $only_questions = false, $origin = false, $cu
?> ?>
<style> <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> </style>
<script> <script>
$(function() { $(function() {
@ -239,8 +215,6 @@ function showQuestion($questionId, $only_questions = false, $origin = false, $cu
// splits text and weightings that are joined with the character '::' // splits text and weightings that are joined with the character '::'
list($answer) = explode('::',$answer); list($answer) = explode('::',$answer);
// because [] is parsed here we follow this procedure:
$answer = text_filter($answer);
//getting the matches //getting the matches
$answer = api_ereg_replace('\[[^]]+\]','<input type="text" name="choice['.$questionId.'][]" size="10" />',($answer)); $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) { } elseif ($answerType == MULTIPLE_ANSWER_TRUE_FALSE) {
$options = array('type'=>'radio','name'=>'choice['.$questionId.']['.$numAnswer.']', 'class'=>'checkbox'); $options = array('type'=>'radio','name'=>'choice['.$questionId.']['.$numAnswer.']', 'class'=>'checkbox');
$s .= '<input type="hidden" name="choice2['.$questionId.']" value="0" />';
$s .='<tr>'; $s .='<tr>';
$s .= Display::tag('td', $answer); $s .= Display::tag('td', $answer);
if (!empty($quiz_question_options)) { if (!empty($quiz_question_options)) {
@ -334,6 +309,8 @@ function showQuestion($questionId, $only_questions = false, $origin = false, $cu
// multiple answers // multiple answers
// set $debug_mark_answer to true at function start to // set $debug_mark_answer to true at function start to
// show the correct answer with a suffix '-x' // show the correct answer with a suffix '-x'
$s .= '<input type="hidden" name="choice2['.$questionId.']" value="0" />';
$help = $selected = ''; $help = $selected = '';
if ($debug_mark_answer) { if ($debug_mark_answer) {
if ($answerCorrect) { if ($answerCorrect) {
@ -960,10 +937,9 @@ function get_exam_results_data($from, $number_of_items, $column, $direction) {
$teacher_list = CourseManager::get_teacher_list_from_course_code(api_get_course_id()); $teacher_list = CourseManager::get_teacher_list_from_course_code(api_get_course_id());
$teacher_id_list = array(); $teacher_id_list = array();
foreach ($teacher_list as $teacher) { foreach ($teacher_list as $teacher) {
$teacher_id_list[] =$teacher['user_id']; $teacher_id_list[] = $teacher['user_id'];
} }
if (empty($hotpotatoe_where)) { if (empty($hotpotatoe_where)) {
$column = intval($column); $column = intval($column);
$from = intval($from); $from = intval($from);

@ -108,7 +108,7 @@ if (!empty($gradebook) && $gradebook=='view') {
$interbreadcrumb[]= array ('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('ToolGradebook')); $interbreadcrumb[]= array ('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('ToolGradebook'));
} }
$nameTools=get_lang('Exercice'); $nameTools = get_lang('Exercice');
$interbreadcrumb[]=array("url" => "exercice.php?gradebook=$gradebook","name" => get_lang('Exercices')); $interbreadcrumb[]=array("url" => "exercice.php?gradebook=$gradebook","name" => get_lang('Exercices'));
//$htmlHeadXtra[] = $objExercise->show_lp_javascript(); //$htmlHeadXtra[] = $objExercise->show_lp_javascript();
@ -155,7 +155,7 @@ if (api_is_course_admin() && $origin != 'learnpath') {
echo '</div>'; echo '</div>';
} }
$exerciseTitle=text_filter($objExercise->selectTitle()); $exerciseTitle = $objExercise->selectTitle();
$feedback_type = $objExercise->feedbacktype; $feedback_type = $objExercise->feedbacktype;
//show exercise title //show exercise title
@ -275,7 +275,7 @@ if ($show_results || $show_only_score) {
$quizDuration = (!empty($_SESSION['quizStartTime']) ? time() - $_SESSION['quizStartTime'] : 0); $quizDuration = (!empty($_SESSION['quizStartTime']) ? time() - $_SESSION['quizStartTime'] : 0);
if (api_is_allowed_to_session_edit() ) { 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') { 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 //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); $track_exercise_info = get_exercise_track_exercise_info($id);
//No track info //No track info
if (empty($track_exercise_info)) { if (empty($track_exercise_info)) {
api_not_allowed(); 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" => "../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")); $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') { } 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" => 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" => "../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")); $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 { } else {
Display::display_reduced_header(); 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"> <script language="javascript">
function showfck(sid,marksid) { function showfck(sid,marksid) {
document.getElementById(sid).style.display='block'; document.getElementById(sid).style.display='block';
@ -270,7 +256,7 @@ $query = "SELECT attempts.question_id, answer from ".$TBL_TRACK_ATTEMPT." as at
GROUP BY quizz_rel_questions.question_order, attempts.question_id"; GROUP BY quizz_rel_questions.question_order, attempts.question_id";
//GROUP BY questions.position, attempts.question_id"; //GROUP BY questions.position, attempts.question_id";
$result =Database::query($query); $result = Database::query($query);
$questionList = array(); $questionList = array();
$exerciseResult = array(); $exerciseResult = array();
@ -609,7 +595,7 @@ foreach ($questionList as $questionId) {
unset($objAnswerTmp); unset($objAnswerTmp);
$i++; $i++;
$totalWeighting+=$questionWeighting; $totalWeighting += $questionWeighting;
} // end of large foreach on questions } // end of large foreach on questions

@ -91,10 +91,10 @@ if (empty ($exerciseType)) {
if (empty ($exerciseId)) { if (empty ($exerciseId)) {
$exerciseId = intval($_REQUEST['exerciseId']); $exerciseId = intval($_REQUEST['exerciseId']);
} }
if (empty ($choice)) { if (empty($choice)) {
$choice = $_REQUEST['choice']; $choice = $_REQUEST['choice'];
} }
if (empty ($_REQUEST['choice'])) { if (empty($_REQUEST['choice'])) {
$choice = $_REQUEST['choice2']; $choice = $_REQUEST['choice2'];
} }
if (empty ($questionNum)) { if (empty ($questionNum)) {
@ -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_id = ($learnpath_item_id == '') ? 0 : $learnpath_item_id;
$safe_lp_item_view_id = ($learnpath_item_view_id == '') ? 0 : $learnpath_item_view_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 * 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 in the exercise
@ -304,6 +303,7 @@ if ($formSent && isset($_POST)) {
} }
// if the user has answered at least one question // if the user has answered at least one question
if (is_array($choice)) { if (is_array($choice)) {
if ($debug) { error_log('$choice is an array '.print_r($choice, 1)); } if ($debug) { error_log('$choice is an array '.print_r($choice, 1)); }
// Also store hotspot spots in the session ($exerciseResultCoordinates // Also store hotspot spots in the session ($exerciseResultCoordinates
// will be stored in the session at the end of this script) // will be stored in the session at the end of this script)
@ -334,7 +334,7 @@ if ($formSent && isset($_POST)) {
if (isset($exe_id)) { if (isset($exe_id)) {
//Manage the question and answer attempts //Manage the question and answer attempts
if ($debug > 0) { error_log('manage_answer exe_id: '.$exe_id.' - $questionId: '.$questionId.' Choice'.print_r($choice,1)); } 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 //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>'; 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) { 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 '<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 { } else {
echo '<a href="#">'.Display::return_icon('settings_na.png', get_lang('ModifyExercise'),'','32').'</a>'; echo '<a href="#">'.Display::return_icon('settings_na.png', get_lang('ModifyExercise'),'','32').'</a>';
} }
echo '</div>'; echo '</div>';
} }
$exerciseTitle = text_filter($objExercise->selectTitle()); $exerciseTitle = $objExercise->selectTitle();
echo Display::tag('h2', $exerciseTitle); echo Display::tag('h2', $exerciseTitle);
$show_clock = true; $show_clock = true;
$user_id = api_get_user_id(); $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']); $score = show_score($last_attempt_info['exe_result'], $last_attempt_info['exe_weighting']);
echo Display::div(get_lang('YourTotalScore').' '.$score, array('id'=>'question_score')); echo Display::div(get_lang('YourTotalScore').' '.$score, array('id'=>'question_score'));
} else { } else {
Display :: display_warning_message(sprintf(get_lang('ReachedMaxAttempts'), $exerciseTitle, $objExercise->selectAttempts()), false); 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 * @author Julio Montoya Armas <gugli100@gmail.com> Reworked 2010
* @desc Record result of user when an exercice was done * @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'; require_once api_get_path(SYS_CODE_PATH).'exercice/exercise.lib.php';
if ($exeid!='') { if ($exeid!='') {
// Validation in case of fraud with actived control time // 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); $TABLETRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
array_map('intval', $question_list);
$sql = "UPDATE $TABLETRACK_EXERCICES SET $sql = "UPDATE $TABLETRACK_EXERCICES SET
exe_exo_id = '".Database::escape_string($exo_id)."', exe_exo_id = '".Database::escape_string($exo_id)."',
@ -335,18 +336,17 @@ function update_event_exercice($exeid, $exo_id, $score, $weighting,$session_id,$
exe_duration = '".Database::escape_string($duration)."', exe_duration = '".Database::escape_string($duration)."',
exe_date = '".api_get_utc_datetime()."', exe_date = '".api_get_utc_datetime()."',
status = '', 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)."'"; WHERE exe_id = '".Database::escape_string($exeid)."'";
$res = @Database::query($sql); $res = @Database::query($sql);
//Deleting control time session track //Deleting control time session track
exercise_time_control_delete($exo_id); exercise_time_control_delete($exo_id);
//error_log('update_event_exercice');
//error_log($sql);
return $res; return $res;
} else {
} else
return false; return false;
}
} }
/** /**

@ -171,11 +171,15 @@ foreach($list as $toc) {
} }
} }
$debug = 0;
$autostart = 'true'; $autostart = 'true';
// Update status, total_time from lp_item_view table when you finish the exercises in learning path. // 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'])) { if ($type_quiz && !empty($_REQUEST['exeId']) && isset($lp_id) && isset($_GET['lp_item_id'])) {
global $src; global $src;
$_SESSION['oLP']->items[$_SESSION['oLP']->current]->write_to_db(); $_SESSION['oLP']->items[$_SESSION['oLP']->current]->write_to_db();
$TBL_TRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES); $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_ITEM_VIEW = Database::get_course_table(TABLE_LP_ITEM_VIEW);
$TBL_LP_VIEW = Database::get_course_table(TABLE_LP_VIEW); $TBL_LP_VIEW = Database::get_course_table(TABLE_LP_VIEW);
@ -186,7 +190,7 @@ if ($type_quiz && !empty($_REQUEST['exeId']) && isset($lp_id) && isset($_GET['lp
if ($safe_id == strval(intval($safe_id)) && $safe_item_id == strval(intval($safe_item_id))) { if ($safe_id == strval(intval($safe_id)) && $safe_item_id == strval(intval($safe_item_id))) {
$sql = 'SELECT start_date,exe_date,exe_result,exe_weighting FROM ' . $TBL_TRACK_EXERCICES . ' WHERE exe_id = '.$safe_exe_id; $sql = 'SELECT start_date, exe_date, exe_result, exe_weighting FROM ' . $TBL_TRACK_EXERCICES . ' WHERE exe_id = '.$safe_exe_id;
$res = Database::query($sql); $res = Database::query($sql);
$row_dates = Database::fetch_array($res); $row_dates = Database::fetch_array($res);
@ -197,7 +201,17 @@ if ($type_quiz && !empty($_REQUEST['exeId']) && isset($lp_id) && isset($_GET['lp
$score = (float)$row_dates['exe_result']; $score = (float)$row_dates['exe_result'];
$max_score = (float)$row_dates['exe_weighting']; $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."'"; $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); 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"; $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";
@ -206,7 +220,8 @@ if ($type_quiz && !empty($_REQUEST['exeId']) && isset($lp_id) && isset($_GET['lp
$lp_item_view_id = $row_last_attempt[0]; $lp_item_view_id = $row_last_attempt[0];
if (Database::num_rows($res_last_attempt) > 0) { 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."'"; $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); 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; $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) { if (intval($_GET['fb_type']) > 0) {
$src = 'blank.php?msg=exerciseFinished'; $src = 'blank.php?msg=exerciseFinished';
} else { } 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'; $autostart = 'false';
} }
@ -235,18 +251,19 @@ if ($_SESSION['oLP']->mode == 'fullscreen') {
$htmlHeadXtra[] = "<script>window.open('$src','content_id','toolbar=0,location=0,status=0,scrollbars=1,resizable=1');</script>"; $htmlHeadXtra[] = "<script>window.open('$src','content_id','toolbar=0,location=0,status=0,scrollbars=1,resizable=1');</script>";
} }
// Not in fullscreen mode. // Not in fullscreen mode.
require_once '../inc/reduced_header.inc.php'; require_once '../inc/reduced_header.inc.php';
//$displayAudioRecorder = (api_get_setting('service_visio', 'active') == 'true') ? true : false; //$displayAudioRecorder = (api_get_setting('service_visio', 'active') == 'true') ? true : false;
// Check if audio recorder needs to be in studentview. // Check if audio recorder needs to be in studentview.
$course_id = $_SESSION['_course']['id']; $course_id = $_SESSION['_course']['id'];
if ($_SESSION['status'][$course_id] == 5) { if ($_SESSION['status'][$course_id] == 5) {
$audio_recorder_studentview = true; $audio_recorder_studentview = true;
} else { } else {
$audio_recorder_studentview = false; $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; // Set flag to ensure lp_header.php is loaded by this script (flag is unset in lp_header.php).
$_SESSION['loaded_lp_view'] = true;
$display_none = ''; $display_none = '';
$margin_left = '290px'; $margin_left = '290px';

@ -142,9 +142,9 @@ class TestEvents extends UnitTestCase {
$weighting=''; $weighting='';
$session_id=''; $session_id='';
$duration=''; $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)); $this->assertTrue(is_bool($res));
//var_dump($res); //var_dump($res);
} }
} }
?>

Loading…
Cancel
Save