Fixing LP when doing an exercise

skala
Julio Montoya 13 years ago
parent 5e806196e9
commit 0b7d468d38
  1. 821
      main/exercice/exercise.class.php
  2. 1003
      main/exercice/exercise.lib.php
  3. 3
      main/exercice/exercise_result.php
  4. 226
      main/exercice/exercise_show.php
  5. 6
      main/exercice/savescores.php
  6. 181
      main/inc/lib/internationalization.lib.php
  7. 208
      main/newscorm/lp_stats.php
  8. 30
      main/newscorm/scorm_api.php

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -148,6 +148,7 @@ if (isset($session_control_key) && !exercise_time_control_is_valid($objExercise-
exercise_time_control_delete($objExercise->id, $learnpath_id, $learnpath_item_id);
delete_chat_exercise_session($exe_id);
if ($origin != 'learnpath') {
echo '<hr>';
echo Display::url(get_lang('ReturnToCourseHomepage'), api_get_course_url(), array('class' => 'btn btn-large'));
@ -168,7 +169,7 @@ if ($origin != 'learnpath') {
Session::erase('exe_id');
}
//record the results in the learning path, using the SCORM interface (API)
echo '<script>window.parent.API.void_save_asset('.$total_score.', '.$total_weight.');</script>';
echo "<script>window.parent.API.void_save_asset('$total_score', '$total_weight', 0, 'completed');</script>";
echo '<script type="text/javascript">'.$href.'</script>';
echo '</body></html>';
}

@ -1,14 +1,14 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Shows the exercise results
* Shows the exercise results
*
* @author Julio Montoya Armas Added switchable fill in blank option added
* @version $Id: exercise_show.php 22256 2009-07-20 17:40:20Z ivantcholakov $
* @package chamilo.exercise
* @todo remove the debug code and use the general debug library
* @todo small letters for table variables
*
*
*/
/**
* Code
@ -78,7 +78,7 @@ $exercise_id = $track_exercise_info['id'];
$exercise_date = $track_exercise_info['start_date'];
$student_id = $track_exercise_info['exe_user_id'];
$learnpath_id = $track_exercise_info['orig_lp_id'];
$learnpath_item_id = $track_exercise_info['orig_lp_item_id'];
$learnpath_item_id = $track_exercise_info['orig_lp_item_id'];
$lp_item_view_id = $track_exercise_info['orig_lp_item_view_id'];
$current_user_id = api_get_user_id();
@ -97,7 +97,7 @@ if (isset($session_control_key) && !exercise_time_control_is_valid($exercise_id,
Database::query($sql_fraud);
}
//Only users can see their own results
//Only users can see their own results
if (!$is_allowedToEdit) {
if ($student_id != $current_user_id) {
api_not_allowed();
@ -169,9 +169,9 @@ $show_only_total_score = false;
if (!empty($track_exercise_info)) {
// if the results_disabled of the Quiz is 1 when block the script
$result_disabled = $track_exercise_info['results_disabled'];
if (!(api_is_platform_admin() || api_is_course_admin()) ) {
if ($result_disabled == 1) {
if (!(api_is_platform_admin() || api_is_course_admin()) ) {
if ($result_disabled == 1) {
//api_not_allowed();
$show_results = false;
//Display::display_warning_message(get_lang('CantViewResults'));
@ -186,7 +186,7 @@ if (!empty($track_exercise_info)) {
}
} elseif ($result_disabled == 2) {
$show_results = false;
$show_only_total_score = true;
$show_only_total_score = true;
if ($origin != 'learnpath') {
echo '<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
@ -195,8 +195,8 @@ if (!empty($track_exercise_info)) {
echo '</td>
</tr>
</table>';
}
}
}
}
}
} else {
Display::display_warning_message(get_lang('CantViewResults'));
@ -223,17 +223,17 @@ $arrans = array();
$user_restriction = $is_allowedToEdit ? '' : "AND user_id=".intval($student_id)." ";
$query = "SELECT attempts.question_id, answer FROM ".$TBL_TRACK_ATTEMPT." as attempts
INNER JOIN ".$TBL_TRACK_EXERCICES." AS stats_exercices ON stats_exercices.exe_id=attempts.exe_id
INNER JOIN ".$TBL_EXERCICE_QUESTION." AS quizz_rel_questions
ON quizz_rel_questions.exercice_id=stats_exercices.exe_exo_id
INNER JOIN ".$TBL_EXERCICE_QUESTION." AS quizz_rel_questions
ON quizz_rel_questions.exercice_id=stats_exercices.exe_exo_id
AND quizz_rel_questions.question_id = attempts.question_id
AND quizz_rel_questions.c_id=".api_get_course_int_id()."
INNER JOIN ".$TBL_QUESTIONS." AS questions
INNER JOIN ".$TBL_QUESTIONS." AS questions
ON questions.id=quizz_rel_questions.question_id
AND questions.c_id = ".api_get_course_int_id()."
WHERE attempts.exe_id='".Database::escape_string($id)."' $user_restriction
GROUP BY quizz_rel_questions.question_order, attempts.question_id";
//GROUP BY questions.position, attempts.question_id";
$result = Database::query($query);
$result = Database::query($query);
$questionList = array();
$exerciseResult = array();
@ -245,9 +245,9 @@ while ($row = Database::fetch_array($result)) {
//Fixing #2073 Fixing order of questions
if (!empty($track_exercise_info['data_tracking']) && !empty($track_exercise_info['random']) ) {
$tempquestionList = explode(',', $track_exercise_info['data_tracking']);
if (is_array($tempquestionList) && count($tempquestionList) == count($questionList)) {
$questionList = $tempquestionList;
}
if (is_array($tempquestionList) && count($tempquestionList) == count($questionList)) {
$questionList = $tempquestionList;
}
}
// Display the text when finished message if we are on a LP #4227
@ -261,7 +261,7 @@ if (!empty($end_of_message) && ($origin == 'learnpath')) {
$total_weighting = 0;
foreach ($questionList as $questionId) {
$objQuestionTmp = Question::read($questionId);
$total_weighting +=$objQuestionTmp->selectWeighting();
$total_weighting +=$objQuestionTmp->selectWeighting();
}
$counter = 1;
@ -270,37 +270,37 @@ $exercise_content = null;
$category_list = array();
foreach ($questionList as $questionId) {
$choice = $exerciseResult[$questionId];
// destruction of the Question object
unset($objQuestionTmp);
// creates a temporary Question object
$objQuestionTmp = Question::read($questionId);
$objQuestionTmp = Question::read($questionId);
$questionWeighting = $objQuestionTmp->selectWeighting();
$answerType = $objQuestionTmp->selectType();
// Start buffer
ob_start();
/* Use switch
switch ($answerType) {
switch ($answerType) {
}*/
if ($answerType == MULTIPLE_ANSWER || $answerType == MULTIPLE_ANSWER_TRUE_FALSE) {
$question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg());
$question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg());
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
$totalScore += $question_result['score'];
} elseif ($answerType == MULTIPLE_ANSWER_COMBINATION || $answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
$choice = array();
$question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg());
$question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg());
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
} elseif ($answerType == UNIQUE_ANSWER || $answerType == UNIQUE_ANSWER_NO_OPTION) {
$totalScore += $question_result['score'];
} elseif ($answerType == UNIQUE_ANSWER || $answerType == UNIQUE_ANSWER_NO_OPTION) {
$question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg());
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
$totalScore += $question_result['score'];
echo '</table>';
} elseif ($answerType == FILL_IN_BLANKS) {
$question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg());
@ -311,8 +311,8 @@ foreach ($questionList as $questionId) {
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
} elseif ($answerType == FREE_ANSWER) {
$answer = $str;
$question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg());
$answer = $str;
$question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg());
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
} elseif ($answerType == ORAL_EXPRESSION) {
@ -320,22 +320,22 @@ foreach ($questionList as $questionId) {
$question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg());
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
} elseif ($answerType == MATCHING) {
$question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg());
} elseif ($answerType == MATCHING) {
$question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg());
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
} elseif ($answerType == HOT_SPOT) {
$totalScore += $question_result['score'];
} elseif ($answerType == HOT_SPOT) {
if ($show_results) {
echo '<table width="500" border="0"><tr>
<td valign="top" align="center" style="padding-left:0px;" >
<table border="1" bordercolor="#A4A4A4" style="border-collapse: collapse;" width="552">';
}
$question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg());
}
$question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg());
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
if ($show_results) {
echo '</table></td></tr>';
if ($show_results) {
echo '</table></td></tr>';
echo '<tr>
<td colspan="2">'.
'<object type="application/x-shockwave-flash" data="'.api_get_path(WEB_CODE_PATH).'plugin/hotspot/hotspot_solution.swf?modifyAnswers='.Security::remove_XSS($questionId).'&exe_id='.$id.'&from_db=1" width="552" height="352">
@ -346,7 +346,7 @@ foreach ($questionList as $questionId) {
</table><br/>';
}
} else if($answerType == HOT_SPOT_DELINEATION) {
$question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg(), 'database');
$questionScore = $question_result['score'];
@ -360,9 +360,9 @@ foreach ($questionList as $questionId) {
$missing_color = $question_result['extra']['missing_color'];
$excess_color = $question_result['extra']['excess_color'];
$threadhold1 = $question_result['extra']['threadhold1'];
$threadhold1 = $question_result['extra']['threadhold1'];
$threadhold2 = $question_result['extra']['threadhold2'];
$threadhold3 = $question_result['extra']['threadhold3'];
$threadhold3 = $question_result['extra']['threadhold3'];
if ($show_results) {
@ -381,7 +381,7 @@ foreach ($questionList as $questionId) {
$excess_color='green';
} else {
$excess_color='red';
}
}
if (!is_numeric($final_overlap)) {
$final_overlap = 0;
@ -396,9 +396,9 @@ foreach ($questionList as $questionId) {
if ($final_excess>100) {
$final_excess = 100;
}
}
$table_resume='<table class="data_table">
$table_resume='<table class="data_table">
<tr class="row_odd" >
<td></td>
<td ><b>'.get_lang('Requirements').'</b></td>
@ -440,33 +440,33 @@ foreach ($questionList as $questionId) {
} else {
//show if no error
//echo 'no error';
$comment=$answerComment=$objAnswerTmp->selectComment($nbrAnswers);
$comment=$answerComment=$objAnswerTmp->selectComment($nbrAnswers);
$answerDestination=$objAnswerTmp->selectDestination($nbrAnswers);
}
}
}
echo '<h1><div style="color:#333;">'.get_lang('Feedback').'</div></h1>';
if ($answerType == HOT_SPOT_DELINEATION) {
if ($answerType == HOT_SPOT_DELINEATION) {
if ($organs_at_risk_hit>0) {
$message='<br />'.get_lang('ResultIs').' <b>'.$result_comment.'</b><br />';
$message='<br />'.get_lang('ResultIs').' <b>'.$result_comment.'</b><br />';
$message.='<p style="color:#DC0A0A;"><b>'.get_lang('OARHit').'</b></p>';
} else {
$message='<p>'.get_lang('YourDelineation').'</p>';
$message.=$table_resume;
$message.=$table_resume;
$message.='<br />'.get_lang('ResultIs').' <b>'.$result_comment.'</b><br />';
}
$message.='<p>'.$comment.'</p>';
echo $message;
$message.='<p>'.$comment.'</p>';
echo $message;
} else {
echo '<p>'.$comment.'</p>';
}
//showing the score
//showing the score
$queryfree = "select marks from ".$TBL_TRACK_ATTEMPT." WHERE exe_id = '".Database::escape_string($id)."' and question_id= '".Database::escape_string($questionId)."'";
$resfree = Database::query($queryfree);
$questionScore= Database::result($resfree,0,"marks");
$totalScore+=$questionScore;
echo '</table></td></tr>';
$totalScore+=$questionScore;
echo '</table></td></tr>';
echo '<tr>
<td colspan="2">
<object type="application/x-shockwave-flash" data="../plugin/hotspot/hotspot_solution.swf?modifyAnswers='.$questionId.'&exe_id='.$id.'&from_db=1" width="556" height="350">
@ -483,13 +483,13 @@ foreach ($questionList as $questionId) {
echo '</table>';
}
}
$comnt = null;
if ($show_results) {
if ($is_allowedToEdit && $locked == false && !api_is_drh()) {
if ($show_results) {
if ($is_allowedToEdit && $locked == false && !api_is_drh()) {
$name = "fckdiv".$questionId;
$marksname = "marksName".$questionId;
$marksname = "marksName".$questionId;
if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION))) {
$url_name = get_lang('EditCommentsAndMarks');
} else {
@ -500,9 +500,9 @@ foreach ($questionList as $questionId) {
}
}
echo '<br />';
echo Display::url($url_name, 'javascript://', array('class' => 'btn', 'onclick'=>"showfck('".$name."', '".$marksname."');"));
echo Display::url($url_name, 'javascript://', array('class' => 'btn', 'onclick'=>"showfck('".$name."', '".$marksname."');"));
echo '<br />';
echo '<div id="feedback_'.$name.'" style="width:100%">';
$comnt = trim(get_comments($id, $questionId));
if (empty($comnt)) {
@ -511,8 +511,8 @@ foreach ($questionList as $questionId) {
echo '<div id="question_feedback">'.$comnt.'</div>';
}
echo '</div>';
echo '<div id="'.$name.'" style="display:none">';
echo '<div id="'.$name.'" style="display:none">';
$arrid[] = $questionId;
$feedback_form = new FormValidator('frmcomments'.$questionId,'post','');
$feedback_form->addElement('html','<br>');
@ -522,25 +522,25 @@ foreach ($questionList as $questionId) {
$comnt = get_comments($id, $questionId);
$default = array('comments_'.$questionId => $comnt);
$feedback_form->addElement('html_editor', 'comments_'.$questionId, null, null, array('ToolbarSet' => 'TestAnswerFeedback', 'Width' => '100%', 'Height' => '120'));
$feedback_form->addElement('html','<br>');
$feedback_form->addElement('html','<br>');
$feedback_form->setDefaults($default);
$feedback_form->display();
echo '</div>';
} else {
$comnt = get_comments($id, $questionId);
echo '<br />';
if (!empty($comnt)) {
echo '<b>'.get_lang('Feedback').'</b>';
echo '<div id="question_feedback">'.$comnt.'</div>';
}
}
}
if ($is_allowedToEdit) {
if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION))) {
$marksname = "marksName".$questionId;
echo '<div id="'.$marksname.'" style="display:none">';
echo '<form name="marksform_'.$questionId.'" method="post" action="">';
echo '<form name="marksform_'.$questionId.'" method="post" action="">';
$arrmarks[] = $questionId;
echo get_lang("AssignMarks");
echo "&nbsp;<select name='marks' id='marks'>";
@ -549,7 +549,7 @@ foreach ($questionList as $questionId) {
}
echo '</select>';
echo '</form><br /></div>';
if ($questionScore == -1 ) {
$questionScore = 0;
echo Display::return_message(get_lang('notCorrectedYet'));
@ -563,20 +563,20 @@ foreach ($questionList as $questionId) {
if ($questionScore == -1) {
$questionScore = 0;
}
}
}
}
}
$my_total_score = $questionScore;
$my_total_weight = $questionWeighting;
$totalWeighting += $questionWeighting;
$category_was_added_for_this_test = false;
if (isset($objQuestionTmp->category) && !empty($objQuestionTmp->category)) {
$category_list[$objQuestionTmp->category]['score'] += $my_total_score;
$category_list[$objQuestionTmp->category]['total'] += $my_total_weight;
$category_was_added_for_this_test = true;
}
}
if (isset($objQuestionTmp->category_list) && !empty($objQuestionTmp->category_list)) {
foreach($objQuestionTmp->category_list as $category_id) {
@ -585,41 +585,41 @@ foreach ($questionList as $questionId) {
$category_was_added_for_this_test = true;
}
}
//No category for this question!
if ($category_was_added_for_this_test == false) {
$category_list['none']['score'] += $my_total_score;
$category_list['none']['total'] += $my_total_weight;
}
}
if ($objExercise->selectPropagateNeg() == 0 && $my_total_score < 0) {
$my_total_score = 0;
}
$score = array();
if ($show_results) {
$score = array();
if ($show_results) {
$score['result'] = get_lang('Score')." : ".show_score($my_total_score, $my_total_weight, false, false);
$score['pass'] = $my_total_score >= $my_total_weight ? true : false;
$score['type'] = $answerType;
$score['pass'] = $my_total_score >= $my_total_weight ? true : false;
$score['type'] = $answerType;
$score['score'] = $my_total_score;
$score['weight'] = $my_total_weight;
$score['comments'] = isset($comnt) ? $comnt : null;
$score['weight'] = $my_total_weight;
$score['comments'] = isset($comnt) ? $comnt : null;
}
unset($objAnswerTmp);
$i++;
$contents = ob_get_clean();
$question_content = '<div class="question_row">';
if ($show_results) {
if ($show_results) {
//Shows question title an description
$question_content .= $objQuestionTmp->return_header(null, $counter, $score);
}
$counter++;
$question_content .= $objQuestionTmp->return_header(null, $counter, $score);
}
$counter++;
$question_content .= $contents;
$question_content .= '</div>';
$question_content .= '</div>';
$exercise_content .= $question_content;
} // end of large foreach on questions
@ -629,22 +629,22 @@ $total_score_text = null;
//Total score
if ($origin!='learnpath' || ($origin == 'learnpath' && isset($_GET['fb_type']))) {
if ($show_results || $show_only_total_score) {
$total_score_text .= '<div class="question_row">';
$my_total_score_temp = $totalScore;
$total_score_text .= '<div class="question_row">';
$my_total_score_temp = $totalScore;
if ($objExercise->selectPropagateNeg() == 0 && $my_total_score_temp < 0) {
$my_total_score_temp = 0;
}
$total_score_text .= get_question_ribbon($objExercise, $my_total_score_temp, $totalWeighting, true);
}
$total_score_text .= get_question_ribbon($objExercise, $my_total_score_temp, $totalWeighting, true);
$total_score_text .= '</div>';
}
}
if (!empty($category_list) && ($show_results || $show_only_total_score)) {
//Adding total
//Adding total
$category_list['total'] = array('score' => $my_total_score_temp, 'total' => $totalWeighting);
echo Testcategory::get_stats_table_by_attempt($objExercise->id, $category_list);
}
}
echo $total_score_text;
echo $exercise_content;
@ -656,18 +656,18 @@ if (is_array($arrid) && is_array($arrmarks)) {
}
if ($is_allowedToEdit && $locked == false && !api_is_drh()) {
if (in_array($origin, array('tracking_course','user_course','correct_exercise_in_lp'))) {
echo ' <form name="myform" id="myform" action="exercise_report.php?exerciseId='.$exercise_id.'&filter=2&comments=update&exeid='.$id.'&origin='.$origin.'&details=true&course='.Security::remove_XSS($_GET['cidReq']).$fromlink.'" method="post">';
if (in_array($origin, array('tracking_course','user_course','correct_exercise_in_lp'))) {
echo ' <form name="myform" id="myform" action="exercise_report.php?exerciseId='.$exercise_id.'&filter=2&comments=update&exeid='.$id.'&origin='.$origin.'&details=true&course='.Security::remove_XSS($_GET['cidReq']).$fromlink.'" method="post">';
echo '<input type = "hidden" name="lp_item_id" value="'.$learnpath_id.'">';
echo '<input type = "hidden" name="lp_item_view_id" value="'.$lp_item_view_id.'">';
echo '<input type = "hidden" name="student_id" value="'.$student_id.'">';
echo '<input type = "hidden" name="total_score" value="'.$totalScore.'"> ';
echo '<input type = "hidden" name="my_exe_exo_id" value="'.$exercise_id.'"> ';
echo '<input type = "hidden" name="my_exe_exo_id" value="'.$exercise_id.'"> ';
} else {
echo ' <form name="myform" id="myform" action="exercise_report.php?exerciseId='.$exercise_id.'&filter=1&comments=update&exeid='.$id.'" method="post">';
}
if ($origin !='learnpath' && $origin!='student_progress') {
echo '<label><input type= "checkbox" name="send_notification"> '.get_lang('SendEmail').'</label>';
?>
<button type="submit" class="btn btn-primary" value="<?php echo get_lang('Ok'); ?>" onclick="getFCK('<?php echo $strids; ?>','<?php echo $marksid; ?>');">
@ -698,10 +698,10 @@ if ($origin != 'learnpath') {
$lp_mode = $_SESSION['lp_mode'];
$url = '../newscorm/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$learnpath_id.'&lp_item_id='.$learnpath_item_id.'&exeId='.$exeId.'&fb_type='.$feedback_type;
$href = ($lp_mode == 'fullscreen')?' window.opener.location.href="'.$url.'" ':' top.location.href="'.$url.'" ';
echo '<script type="text/javascript">'.$href.'</script>';
//Record the results in the learning path, using the SCORM interface (API)
echo '<script type="text/javascript">window.parent.API.void_save_asset('.$totalScore.','.$totalWeighting.');</script>'."\n";
echo '<script type="text/javascript">'.$href.'</script>';
//Record the results in the learning path, using the SCORM interface (API)
echo "<script>window.parent.API.void_save_asset('$totalScore', '$totalWeighting'); </script>";
echo '</body></html>';
} else {
Display::display_normal_message(get_lang('ExerciseFinished').' '.get_lang('ToContinueUseMenu'));

@ -54,7 +54,7 @@ function save_scores($file, $score) {
global $origin, $_user, $_cid,
$TABLETRACK_HOTPOTATOES;
// if tracking is disabled record nothing
$weighting = 100; // 100%
$weighting = 100; // 100%
$date = api_get_utc_datetime();
if ($_user['user_id']) {
@ -80,7 +80,7 @@ function save_scores($file, $score) {
//table to get tracking in there as well
global $jscript2run;
//record the results in the learning path, using the SCORM interface (API)
$jscript2run .= '<script>window.parent.API.void_save_asset('.$score.','.$weighting.');</script>';
$jscript2run .= "<script>window.parent.API.void_save_asset('$score', '$weighting', 0, 'completed');</script>";
}
}
@ -88,7 +88,7 @@ function save_scores($file, $score) {
save_scores($test, $score);
// Back
if ($origin != 'learnpath') {
if ($origin != 'learnpath') {
$url = "exercice.php"; // back to exercices
$jscript2run .= '<script>'."window.open('$url', '_top', '')".'</script>';
echo $jscript2run;

@ -24,14 +24,14 @@ define('SPECIAL_CLOSING_TAG', '=]');
// To be used as a parameter for the function api_format_date()
define('TIME_NO_SEC_FORMAT', 0); // 15:23
define('DATE_FORMAT_SHORT', 1); // Aug 25, 09
define('DATE_FORMAT_LONG', 2); // Monday August 25, 09
define('DATE_FORMAT_SHORT', 1); // Aug 25, 09
define('DATE_FORMAT_LONG', 2); // Monday August 25, 09
define('DATE_FORMAT_LONG_NO_DAY', 10); // August 25, 2009
define('DATE_TIME_FORMAT_LONG', 3); // Monday August 25, 2009 at 03:28 PM
define('DATE_TIME_FORMAT_LONG', 3); // Monday August 25, 2009 at 03:28 PM
define('DATE_FORMAT_NUMBER', 4); // 25.08.09
define('DATE_TIME_FORMAT_LONG_24H', 5); // August 25, 2009 at 15:28
define('DATE_TIME_FORMAT_SHORT', 6); // Aug 25, 2009 at 03:28 PM
define('DATE_TIME_FORMAT_SHORT', 6); // Aug 25, 2009 at 03:28 PM
define('DATE_TIME_FORMAT_SHORT_TIME_FIRST', 7); // 03:28 PM, Aug 25 2009
define('DATE_FORMAT_NUMBER_NO_YEAR', 8); // 25.08 dd-mm
define('DATE_FORMAT_ONLY_DAYNAME', 9); // Monday, Sunday, etc
@ -130,7 +130,7 @@ function get_lang($variable, $reserved = null, $language = null) {
$language_interface_initial_value,
// For serving the function is_translated()
$_api_is_translated, $_api_is_translated_call;
global $used_lang_vars, $_configuration;
// add language_measure_frequency to your main/inc/conf/configuration.php in order to generate language
// variables frequency measurements (you can then see them trhough main/cron/lang/langstats.php)
@ -143,7 +143,7 @@ function get_lang($variable, $reserved = null, $language = null) {
if (!isset ($used_lang_vars)) {
$used_lang_vars = array();
}
// Caching results from some API functions, for speed.
static $initialized, $encoding, $is_utf8_encoding, $langpath, $test_server_mode, $show_special_markup;
if (!isset($initialized)) {
@ -160,7 +160,7 @@ function get_lang($variable, $reserved = null, $language = null) {
$language = $language_interface;
}
$lang_postfix = isset($is_interface_language) && $is_interface_language ? '' : '('.$language.')';
$is_interface_language = $language == $language_interface_initial_value;
// This is a cache for already translated language variables. By using it, we avoid repetitive translations, gaining speed.
@ -235,7 +235,7 @@ function get_lang($variable, $reserved = null, $language = null) {
$langvar = $show_special_markup ? SPECIAL_OPENING_TAG.$variable.SPECIAL_CLOSING_TAG : $variable;
}
//return $cache[$language][$variable] = $is_utf8_encoding ? $langvar : api_utf8_decode($langvar, $encoding);
$ret = $cache[$language][$variable] = $is_utf8_encoding ? $langvar : api_utf8_decode($langvar, $encoding);
$ret = $cache[$language][$variable] = $is_utf8_encoding ? $langvar : api_utf8_decode($langvar, $encoding);
$used_lang_vars[$variable.$lang_postfix] = $ret;
return $ret;
}
@ -243,7 +243,7 @@ function get_lang($variable, $reserved = null, $language = null) {
// Translation mode for test/development servers.
if (!is_string($variable)) {
//return $cache[$language][$variable] = SPECIAL_OPENING_TAG.'get_lang(?)'.SPECIAL_CLOSING_TAG;
$ret = $cache[$language][$variable] = SPECIAL_OPENING_TAG.'get_lang(?)'.SPECIAL_CLOSING_TAG;
$ret = $cache[$language][$variable] = SPECIAL_OPENING_TAG.'get_lang(?)'.SPECIAL_CLOSING_TAG;
$used_lang_vars[$variable.$lang_postfix] = $ret;
return $ret;
}
@ -258,11 +258,11 @@ function get_lang($variable, $reserved = null, $language = null) {
}
if (empty($langvar) || !is_string($langvar)) {
$_api_is_translated = false;
$langvar = $show_special_markup ? SPECIAL_OPENING_TAG.$variable.SPECIAL_CLOSING_TAG : $variable;
$langvar = $show_special_markup ? SPECIAL_OPENING_TAG.$variable.SPECIAL_CLOSING_TAG : $variable;
}
//return $cache[$language][$variable] = $is_utf8_encoding ? $langvar : api_utf8_decode($langvar, $encoding);
$ret = $cache[$language][$variable] = $is_utf8_encoding ? $langvar : api_utf8_decode($langvar, $encoding);
$used_lang_vars[$variable.$lang_postfix] = $ret;
$ret = $cache[$language][$variable] = $is_utf8_encoding ? $langvar : api_utf8_decode($langvar, $encoding);
$used_lang_vars[$variable.$lang_postfix] = $ret;
return $ret;
}
@ -288,21 +288,21 @@ function api_is_translated($variable, $language = null) {
*/
function api_get_interface_language($purified = false, $check_sub_language = false) {
global $language_interface;
if (empty($language_interface)) {
return 'english';
}
}
//1. Checking if current language is supported
$language_is_supported = api_is_language_supported($language_interface);
$language_is_supported = api_is_language_supported($language_interface);
if ($check_sub_language && !$language_is_supported) {
static $parent_language_name = null;
if (!isset($parent_language_name)) {
//2. The current language is a sub language so we grab the father's setting according to the internalization_database/name_order_convetions.php file
$language_id = api_get_language_id($language_interface);
$language_info = api_get_language_info($language_id);
$language_id = api_get_language_id($language_interface);
$language_info = api_get_language_info($language_id);
if (!empty($language_id) && !empty($language_info)) {
$language_info = api_get_language_info($language_info['parent_id']);
$parent_language_name = $language_info['english_name'];
@ -313,9 +313,9 @@ function api_get_interface_language($purified = false, $check_sub_language = fal
return 'english';
} else {
return $parent_language_name;
}
}
} else {
//2. Normal way
//2. Normal way
$interface_language = $purified ? api_purify_language_id($language_interface) : $language_interface;
}
return $interface_language;
@ -328,7 +328,7 @@ function api_get_interface_language($purified = false, $check_sub_language = fal
*/
function api_is_language_supported($language) {
static $supported = array();
if (!isset($supported[$language])) {
if (!isset($supported[$language])) {
$supported[$language] = in_array(api_purify_language_id($language), array_keys(_api_non_utf8_encodings()));
}
return $supported[$language];
@ -405,9 +405,9 @@ function api_get_language_isocode($language = null, $default_code = 'en') {
/**
* Gets language isocode column from the language table
*
*
* @return array An array with the current isocodes
*
*
* */
function api_get_platform_isocodes() {
$iso_code = array();
@ -416,7 +416,7 @@ function api_get_platform_isocodes() {
while ($row = Database::fetch_array($sql_result)) {;
$iso_code[] = trim($row['isocode']);
}
}
}
return $iso_code;
}
@ -429,34 +429,34 @@ function api_get_platform_isocodes() {
*/
function api_get_text_direction($language = null) {
static $text_direction = array();
/*
* Not necessary to validate the language because the list if rtl/ltr is harcoded
*
/*
$language_is_supported = api_is_language_supported($language);
*
/*
$language_is_supported = api_is_language_supported($language);
if (!$language_is_supported || empty($language)) {
$language = api_get_interface_language(false, true);
}*/
$language = api_get_interface_language(false, true);
}*/
if (empty($language)) {
$language = api_get_interface_language();
}
}
if (!isset($text_direction[$language])) {
$text_direction[$language] = in_array(api_purify_language_id($language),
array(
'arabic',
'arabic',
'ar',
'dari',
'dari',
'prs',
'hebrew',
'hebrew',
'he',
'iw',
'pashto',
'pashto',
'ps',
'persian',
'persian',
'fa',
'ur',
'yiddish',
'yiddish',
'yid'
)
) ? 'rtl' : 'ltr';
@ -550,7 +550,7 @@ function _api_get_timezone() {
// If allowed by the administrator
$use_users_timezone = api_get_setting('use_users_timezone', 'timezones');
if ($use_users_timezone == 'true') {
// Get the timezone based on user preference, if it exists
// Get the timezone based on user preference, if it exists
$timezone_user = UserManager::get_extra_user_data_by_field($_user['user_id'],'timezone');
if ($timezone_user['timezone'] != null) {
$to_timezone = $timezone_user['timezone'];
@ -567,10 +567,13 @@ function _api_get_timezone() {
*
* @author Guillaume Viguier <guillaume.viguier@beeznest.com>
*/
function api_get_utc_datetime($time = null) {
function api_get_utc_datetime($time = null, $return_null_if_invalid_date = false) {
$from_timezone = _api_get_timezone();
$to_timezone = 'UTC';
if (is_null($time)) {
if (is_null($time) || empty($time) || $time == '0000-00-00 00:00:00') {
if ($return_null_if_invalid_date) {
return null;
}
return gmdate('Y-m-d H:i:s');
}
// If time is a timestamp, return directly in utc
@ -699,14 +702,14 @@ function api_format_date($time, $format = null, $language = null) {
}
break;
case DATE_FORMAT_NUMBER_NO_YEAR:
$date_format = get_lang('dateFormatShortNumberNoYear', '', $language);
$date_format = get_lang('dateFormatShortNumberNoYear', '', $language);
if (IS_PHP_53 && INTL_INSTALLED) {
$datetype = IntlDateFormatter::SHORT;
$timetype = IntlDateFormatter::NONE;
}
break;
case DATE_FORMAT_NUMBER:
$date_format = get_lang('dateFormatShortNumber', '', $language);
case DATE_FORMAT_NUMBER:
$date_format = get_lang('dateFormatShortNumber', '', $language);
if (IS_PHP_53 && INTL_INSTALLED) {
$datetype = IntlDateFormatter::SHORT;
$timetype = IntlDateFormatter::NONE;
@ -739,14 +742,14 @@ function api_format_date($time, $format = null, $language = null) {
$datetype = IntlDateFormatter::FULL;
$timetype = IntlDateFormatter::SHORT;
}
break;
break;
case DATE_FORMAT_LONG_NO_DAY:
$date_format = get_lang('dateFormatLongNoDay', '', $language);
if (IS_PHP_53 && INTL_INSTALLED) {
$datetype = IntlDateFormatter::FULL;
$timetype = IntlDateFormatter::SHORT;
}
break;
break;
case DATE_TIME_FORMAT_SHORT:
$date_format = get_lang('dateTimeFormatShort', '', $language);
if (IS_PHP_53 && INTL_INSTALLED) {
@ -778,8 +781,8 @@ function api_format_date($time, $format = null, $language = null) {
} else {
$date_format = $format;
}
//if (IS_PHP_53 && INTL_INSTALLED && $datetype !== null && $timetype !== null) {
//if (IS_PHP_53 && INTL_INSTALLED && $datetype !== null && $timetype !== null) {
if (0) {
//if using PHP 5.3 format dates like: $dateFormatShortNumber, can't be used
//
@ -787,9 +790,9 @@ function api_format_date($time, $format = null, $language = null) {
if (is_null($language)) {
$language = api_get_language_isocode();
}
/*$date_formatter = datefmt_create($language, $datetype, $timetype, date_default_timezone_get());
$formatted_date = api_to_system_encoding(datefmt_format($date_formatter, $time), 'UTF-8');*/
/*$date_formatter = datefmt_create($language, $datetype, $timetype, date_default_timezone_get());
$formatted_date = api_to_system_encoding(datefmt_format($date_formatter, $time), 'UTF-8');*/
$date_formatter = new IntlDateFormatter($language, $datetype, $timetype, date_default_timezone_get());
//$date_formatter->setPattern($date_format);
$formatted_date = api_to_system_encoding($date_formatter->format($time), 'UTF-8');
@ -1027,11 +1030,11 @@ function api_get_person_name($first_name, $last_name, $title = null, $format = n
$format = PERSON_NAME_COMMON_CONVENTION;
}
//We check if the language is supported, otherwise we check the interface language of the parent language of sublanguage
$language_is_supported = api_is_language_supported($language);
$language_is_supported = api_is_language_supported($language);
if (!$language_is_supported || empty($language)) {
$language = api_get_interface_language(false, true);
}
$language = api_get_interface_language(false, true);
}
if (empty($encoding)) {
$encoding = _api_mb_internal_encoding();
}
@ -1079,10 +1082,10 @@ function api_is_western_name_order($format = null, $language = null) {
if (empty($format)) {
$format = PERSON_NAME_COMMON_CONVENTION;
}
$language_is_supported = api_is_language_supported($language);
$language_is_supported = api_is_language_supported($language);
if (!$language_is_supported || empty($language)) {
$language = api_get_interface_language(false, true);
$language = api_get_interface_language(false, true);
}
if (!isset($order[$format][$language])) {
$test_name = api_get_person_name('%f', '%l', '%t', $format, $language);
@ -1102,10 +1105,10 @@ function api_is_western_name_order($format = null, $language = null) {
*/
function api_sort_by_first_name($language = null) {
static $sort_by_first_name = array();
$language_is_supported = api_is_language_supported($language);
$language_is_supported = api_is_language_supported($language);
if (!$language_is_supported || empty($language)) {
$language = api_get_interface_language(false, true);
$language = api_get_interface_language(false, true);
}
if (!isset($sort_by_first_name[$language])) {
$sort_by_first_name[$language] = _api_get_person_name_convention($language, 'sort_by');
@ -2038,7 +2041,7 @@ function api_strripos($haystack, $needle, $offset = 0, $encoding = null) {
* @link http://php.net/manual/en/function.mb-strrpos
*/
function api_strrpos($haystack, $needle, $offset = 0, $encoding = null) {
if (empty($encoding)) {
$encoding = _api_mb_internal_encoding();
}
@ -2055,25 +2058,25 @@ function api_strrpos($haystack, $needle, $offset = 0, $encoding = null) {
}
if (_api_is_single_byte_encoding($encoding)) {
return strrpos($haystack, $needle, $offset);
}
}
if (_api_mb_supports($encoding) && IS_PHP_52) {
return @mb_strrpos($haystack, $needle, $offset, $encoding);
} elseif (api_is_encoding_supported($encoding)) {
if (!api_is_utf8($encoding)) {
$haystack = api_utf8_encode($haystack, $encoding);
$needle = api_utf8_encode($needle, $encoding);
}
// In PHP 5.1 the $offset parameter didn't exist see http://php.net/manual/en/function.mb-strrpos.php
if (MBSTRING_INSTALLED && IS_PHP_SUP_OR_EQ_51) {
if (MBSTRING_INSTALLED && IS_PHP_SUP_OR_EQ_51) {
//return @mb_strrpos($haystack, $needle, $offset, 'UTF-8');
//@todo fix the missing $offset parameter
return @mb_strrpos($haystack, $needle, 'UTF-8');
}
}
if (MBSTRING_INSTALLED && IS_PHP_SUP_OR_EQ_52) {
return @mb_strrpos($haystack, $needle, $offset, 'UTF-8');
}
// This branch (this fragment of code) is an adaptation from the CakePHP(tm) Project, http://www.cakefoundation.org
$found = false;
$haystack = _api_utf8_to_unicode($haystack);
@ -3602,12 +3605,12 @@ function api_is_encoding_supported($encoding) {
* if you wish to revise the leading non-UTF-8 encoding for your language.
*/
function api_get_non_utf8_encoding($language = null) {
$language_is_supported = api_is_language_supported($language);
$language_is_supported = api_is_language_supported($language);
if (!$language_is_supported || empty($language)) {
$language = api_get_interface_language(false, true);
$language = api_get_interface_language(false, true);
}
$language = api_purify_language_id($language);
$encodings = & _api_non_utf8_encodings();
if (is_array($encodings[$language])) {
@ -3712,7 +3715,7 @@ function api_detect_encoding($string, $language = null) {
/**
* Checks a string for UTF-8 validity.
*
*
* @deprecated Use Encoding::utf8()->is_valid() instead
*/
function api_is_valid_utf8(&$string) {
@ -3732,37 +3735,37 @@ function api_is_valid_ascii(&$string) {
}
/**
*
*
* Experimental translation feature for Chamilo
*
*
* Install this in Ubuntu
*
*
* sudo locale-gen es_ES
* sudo apt-get install php-gettext
*
*
* Install Spanish locale: $ sudo locale-gen es_ES
* Install English locale: $ sudo locale-gen en_US
*
*
* To view the list of locales installed in ubuntu
* locale -a
*
*
* In Debian check this file More info: http://algorytmy.pl/doc/php/ref.gettext.php
* sudo vim /etc/locale.gen
*
* Translate po files using this GUI
* sudo apt-get install poedit
*
* sudo vim /etc/locale.gen
*
* Translate po files using this GUI
* sudo apt-get install poedit
*
* Some help here:
*
*
* Config getext
* http://zez.org/article/articleview/42/3/
* *
* *
* Using getext in ubuntu
* http://www.sourcerally.net/regin/49-How-to-get-PHP-and-gettext-working-%28ubuntu,-debian%29
*
*
* Getext tutorial
* http://mel.melaxis.com/devblog/2005/08/06/localizing-php-web-sites-using-gettext/
*
*
*/
function setting_gettext() {
$domain = 'default';
@ -3771,7 +3774,7 @@ function setting_gettext() {
putenv("LC_ALL=$locale");
setlocale(LC_ALL, $locale);
bindtextdomain($domain, api_get_path(SYS_LANG_PATH));
bind_textdomain_codeset($domain, 'UTF-8');
bind_textdomain_codeset($domain, 'UTF-8');
textdomain($domain);
}

@ -149,23 +149,23 @@ if (isset($_GET['lp_id']) && isset($_GET['lp_item_id'])) {
if (Database::num_rows($res_path) > 0) {
if ($origin != 'tracking') {
$sql_attempts = 'SELECT * FROM ' . $tbl_stats_exercices . '
WHERE exe_exo_id="' . (int) $row_path['path'] . '" AND
status <> "incomplete" AND
exe_user_id="' . api_get_user_id() . '" AND
orig_lp_id = "' . (int) $clean_lp_id . '" AND
orig_lp_item_id = "' . (int) $clean_lp_item_id . '" AND
exe_cours_id="' . $clean_course_code . '" AND
session_id = ' . $session_id . '
WHERE exe_exo_id="' . (int) $row_path['path'] . '" AND
status <> "incomplete" AND
exe_user_id="' . api_get_user_id() . '" AND
orig_lp_id = "' . (int) $clean_lp_id . '" AND
orig_lp_item_id = "' . (int) $clean_lp_item_id . '" AND
exe_cours_id="' . $clean_course_code . '" AND
session_id = ' . $session_id . '
ORDER BY exe_date';
} else {
$sql_attempts = 'SELECT * FROM ' . $tbl_stats_exercices . '
WHERE exe_exo_id="' . (int) $row_path['path'] . '" AND
status <> "incomplete" AND
exe_user_id="' . $student_id . '" AND
orig_lp_id = "' . (int) $clean_lp_id . '" AND
orig_lp_item_id = "' . (int) $clean_lp_item_id . '" AND
exe_cours_id="' . $clean_course_code . '" AND
session_id = ' . $session_id . '
WHERE exe_exo_id="' . (int) $row_path['path'] . '" AND
status <> "incomplete" AND
exe_user_id="' . $student_id . '" AND
orig_lp_id = "' . (int) $clean_lp_id . '" AND
orig_lp_item_id = "' . (int) $clean_lp_item_id . '" AND
exe_cours_id="' . $clean_course_code . '" AND
session_id = ' . $session_id . '
ORDER BY exe_date';
}
}
@ -184,54 +184,54 @@ if (is_array($list) && count($list) > 0) {
// Prepare statement to go through each attempt.
if (!empty($view)) {
$sql = "SELECT iv.status as mystatus,
v.view_count as mycount,
iv.score as myscore,
iv.total_time as mytime,
$sql = "SELECT iv.status as mystatus,
v.view_count as mycount,
iv.score as myscore,
iv.total_time as mytime,
i.id as myid,
i.lp_id as mylpid,
iv.lp_view_id as mylpviewid,
i.title as mytitle,
i.lp_id as mylpid,
iv.lp_view_id as mylpviewid,
i.title as mytitle,
i.max_score as mymaxscore,
iv.max_score as myviewmaxscore,
i.item_type as item_type,
iv.view_count as iv_view_count,
iv.id as iv_id,
iv.max_score as myviewmaxscore,
i.item_type as item_type,
iv.view_count as iv_view_count,
iv.id as iv_id,
path
FROM $TBL_LP_ITEM as i
FROM $TBL_LP_ITEM as i
INNER JOIN $TBL_LP_ITEM_VIEW as iv ON (i.id = iv.lp_item_id AND i.c_id = $course_id AND iv.c_id = $course_id)
INNER JOIN $TBL_LP_VIEW as v ON (iv.lp_view_id = v.id AND v.c_id = $course_id)
WHERE
i.id = $my_item_id AND
i.lp_id = $lp_id AND
v.user_id = $user_id AND
v.view_count = $view AND
v.view_count = $view AND
v.session_id = $session_id
ORDER BY iv.view_count $qry_order ";
//var_dump($sql);
} else {
$sql = "SELECT iv.status as mystatus,
v.view_count as mycount,
iv.score as myscore,
iv.total_time as mytime,
i.id as myid,
i.lp_id as mylpid,
$sql = "SELECT iv.status as mystatus,
v.view_count as mycount,
iv.score as myscore,
iv.total_time as mytime,
i.id as myid,
i.lp_id as mylpid,
iv.lp_view_id as mylpviewid,
i.title as mytitle,
i.max_score as mymaxscore,
iv.max_score as myviewmaxscore,
i.item_type as item_type,
i.title as mytitle,
i.max_score as mymaxscore,
iv.max_score as myviewmaxscore,
i.item_type as item_type,
iv.view_count as iv_view_count,
iv.id as iv_id,
iv.id as iv_id,
path
FROM $TBL_LP_ITEM as i
FROM $TBL_LP_ITEM as i
INNER JOIN $TBL_LP_ITEM_VIEW as iv ON (i.id = iv.lp_item_id AND i.c_id = $course_id AND iv.c_id = $course_id)
INNER JOIN $TBL_LP_VIEW as v ON (iv.lp_view_id = v.id AND v.c_id = $course_id)
WHERE
i.id = $my_item_id AND
i.lp_id = $lp_id AND
v.user_id = $user_id AND
v.session_id = $session_id
WHERE
i.id = $my_item_id AND
i.lp_id = $lp_id AND
v.user_id = $user_id AND
v.session_id = $session_id
ORDER BY iv.view_count $qry_order ";
}
$result = Database::query($sql);
@ -254,7 +254,7 @@ if (is_array($list) && count($list) > 0) {
$result_disabled_ext_all = true;
}
}
// If there are several attempts, and the link to extend has been clicked, show each attempt...
if (($counter % 2) == 0) {
$oddclass = 'row_odd';
@ -274,7 +274,7 @@ if (is_array($list) && count($list) > 0) {
if ($row['item_type'] != 'dokeos_chapter') {
$correct_test_link = '-';
$title = Security::remove_XSS($title);
$title = Security::remove_XSS($title);
$output .= '<tr class="'.$oddclass.'">
<td>'.$extend_link.'</td>
<td colspan="4">
@ -292,7 +292,7 @@ if (is_array($list) && count($list) > 0) {
// Check if there are interactions below.
$extend_attempt_link = '';
$extend_this_attempt = 0;
if ((learnpath :: get_interactions_count_from_db($row['iv_id'], $course_id) > 0 || learnpath :: get_objectives_count_from_db($row['iv_id'], $course_id) > 0) && !$extend_all) {
if (!empty($_GET['extend_attempt_id']) && $_GET['extend_attempt_id'] == $row['iv_id']) {
// The extend button for this attempt has been clicked.
@ -317,7 +317,7 @@ if (is_array($list) && count($list) > 0) {
$time = learnpathItem :: get_scorm_time('js', $row['mytime']);
$scoIdentifier = $row['myid'];
if ($score == 0) {
$maxscore = $row['mymaxscore'];
} else {
@ -335,7 +335,7 @@ if (is_array($list) && count($list) > 0) {
}
// Remove "NaN" if any (@todo: locate the source of these NaN)
$time = str_replace('NaN', '00' . $h . '00\'00"', $time);
$time = str_replace('NaN', '00' . $h . '00\'00"', $time);
if ($row['item_type'] != 'dokeos_chapter') {
if (!$is_allowed_to_edit && $result_disabled_ext_all) {
@ -390,7 +390,7 @@ if (is_array($list) && count($list) > 0) {
if ($extend_this_attempt OR $extend_all) {
$list1 = learnpath :: get_iv_interactions_array($row['iv_id']);
foreach ($list1 as $id => $interaction) {
if (($counter % 2) == 0) {
$oddclass = 'row_odd';
@ -421,9 +421,9 @@ if (is_array($list) && count($list) > 0) {
<td></td>
</tr>';
$counter++;
}
}
$list2 = learnpath :: get_iv_objectives_array($row['iv_id']);
foreach ($list2 as $id => $interaction) {
if (($counter % 2) == 0) {
$oddclass = 'row_odd';
@ -511,24 +511,24 @@ if (is_array($list) && count($list) > 0) {
// Selecting the exe_id from stats attempts tables in order to look the max score value.
if ($origin != 'tracking') {
$sql_last_attempt = 'SELECT * FROM ' . $tbl_stats_exercices . '
WHERE exe_exo_id="' . $row['path'] . '" AND
exe_user_id="' . api_get_user_id() . '" AND
orig_lp_id = "' . $lp_id . '" AND
orig_lp_item_id = "' . $row['myid'] . '" AND
exe_cours_id="' . $course_code . '" AND
status <> "incomplete" AND
session_id = ' . $session_id . '
$sql_last_attempt = 'SELECT * FROM ' . $tbl_stats_exercices . '
WHERE exe_exo_id="' . $row['path'] . '" AND
exe_user_id="' . api_get_user_id() . '" AND
orig_lp_id = "' . $lp_id . '" AND
orig_lp_item_id = "' . $row['myid'] . '" AND
exe_cours_id="' . $course_code . '" AND
status <> "incomplete" AND
session_id = ' . $session_id . '
ORDER BY exe_date DESC limit 1';
} else {
$sql_last_attempt = 'SELECT * FROM ' . $tbl_stats_exercices . '
WHERE exe_exo_id="' . $row['path'] . '" AND
exe_user_id="' . $student_id . '" AND
orig_lp_id = "' . $lp_id . '" AND
orig_lp_item_id = "' . $row['myid'] . '" AND
exe_cours_id="' . $course_code . '" AND
status <> "incomplete" AND
session_id = ' . $session_id . '
$sql_last_attempt = 'SELECT * FROM ' . $tbl_stats_exercices . '
WHERE exe_exo_id="' . $row['path'] . '" AND
exe_user_id="' . $student_id . '" AND
orig_lp_id = "' . $lp_id . '" AND
orig_lp_item_id = "' . $row['myid'] . '" AND
exe_cours_id="' . $course_code . '" AND
status <> "incomplete" AND
session_id = ' . $session_id . '
ORDER BY exe_date DESC limit 1';
}
@ -576,11 +576,11 @@ if (is_array($list) && count($list) > 0) {
//echo $subtotal_time ;
//$time = learnpathItem :: get_scorm_time('js', $subtotal_time);
// Selecting the max score from an attempt.
$sql = "SELECT SUM(t.ponderation) as maxscore
$sql = "SELECT SUM(t.ponderation) as maxscore
FROM (
SELECT distinct question_id, marks, ponderation
SELECT distinct question_id, marks, ponderation
FROM $tbl_stats_attempts as at INNER JOIN $tbl_quiz_questions as q
ON (q.id = at.question_id AND q.c_id = $course_id
ON (q.id = at.question_id AND q.c_id = $course_id
)
WHERE exe_id ='$id_last_attempt' ) as t";
@ -608,25 +608,25 @@ if (is_array($list) && count($list) > 0) {
if ($origin != 'tracking' && $origin != 'tracking_course') {
$my_url_suffix = '&course=' . api_get_course_id() . '&student_id=' . api_get_user_id() . '&lp_id=' . Security::remove_XSS($row['mylpid']);
$sql_last_attempt = 'SELECT * FROM ' . $tbl_stats_exercices . '
WHERE exe_exo_id="' . $row['path'] . '" AND
exe_user_id="' . api_get_user_id() . '" AND
orig_lp_id = "' . $lp_id . '" AND
orig_lp_item_id = "' . $row['myid'] . '" AND
exe_cours_id="' . $course_code . '" AND
status <> "incomplete" AND
session_id = ' . $session_id . '
$sql_last_attempt = 'SELECT * FROM ' . $tbl_stats_exercices . '
WHERE exe_exo_id="' . $row['path'] . '" AND
exe_user_id="' . api_get_user_id() . '" AND
orig_lp_id = "' . $lp_id . '" AND
orig_lp_item_id = "' . $row['myid'] . '" AND
exe_cours_id="' . $course_code . '" AND
status <> "incomplete" AND
session_id = ' . $session_id . '
ORDER BY exe_date DESC ';
} else {
$my_url_suffix = '&course=' . Security::remove_XSS($_GET['course']) . '&student_id=' . $student_id . '&lp_id=' . Security::remove_XSS($row['mylpid']) . '&origin=' . Security::remove_XSS($_GET['origin'] . $from_link);
$sql_last_attempt = 'SELECT * FROM ' . $tbl_stats_exercices . '
WHERE exe_exo_id="' . $row['path'] . '" AND
exe_user_id="' . $student_id . '" AND
orig_lp_id = "' . $lp_id . '" AND
orig_lp_item_id = "' . $row['myid'] . '" AND
exe_cours_id="' . Database :: escape_string($_GET['course']) . '" AND
status <> "incomplete" AND
session_id = ' . $session_id . '
$sql_last_attempt = 'SELECT * FROM ' . $tbl_stats_exercices . '
WHERE exe_exo_id="' . $row['path'] . '" AND
exe_user_id="' . $student_id . '" AND
orig_lp_id = "' . $lp_id . '" AND
orig_lp_item_id = "' . $row['myid'] . '" AND
exe_cours_id="' . Database :: escape_string($_GET['course']) . '" AND
status <> "incomplete" AND
session_id = ' . $session_id . '
ORDER BY exe_date DESC ';
}
@ -634,7 +634,7 @@ if (is_array($list) && count($list) > 0) {
$num = Database :: num_rows($resultLastAttempt);
if ($num > 0) {
if (isset($_GET['extend_attempt']) && $_GET['extend_attempt'] == 1 && (isset($_GET['lp_id']) && $_GET['lp_id'] == $my_lp_id) && (isset($_GET['lp_item_id']) && $_GET['lp_item_id'] == $my_id)) {
$correct_test_link = '<a href="' . api_get_self() . '?action=stats' . $my_url_suffix . '&session_id=' . api_get_session_id() . '&lp_item_id=' . $my_id . '"><img src="../img/view_less_stats.gif" alt="fold_view" border="0" title="' . get_lang('HideAllAttempts') . '"></a>';
$correct_test_link = '<a href="' . api_get_self() . '?action=stats' . $my_url_suffix . '&session_id=' . api_get_session_id() . '&lp_item_id=' . $my_id . '"><img src="../img/view_less_stats.gif" alt="fold_view" border="0" title="' . get_lang('HideAllAttempts') . '"></a>';
} else {
$correct_test_link = '<a href="' . api_get_self() . '?action=stats&extend_attempt=1' . $my_url_suffix . '&session_id=' . api_get_session_id() . '&lp_item_id=' . $my_id . '"><img src="../img/view_more_stats.gif" alt="extend_view" border="0" title="' . get_lang('ShowAllAttemptsByExercise') . '"></a>';
}
@ -648,7 +648,7 @@ if (is_array($list) && count($list) > 0) {
$title = Security::remove_XSS($title);
if ((isset($_GET['lp_id']) && $_GET['lp_id'] == $my_lp_id && false)) {
$output .= '<tr class =' . $oddclass . '>
<td>' . $extend_link . '</td>
<td colspan="4">' . $title . '</td>
@ -664,15 +664,15 @@ if (is_array($list) && count($list) > 0) {
} else {
$output .= "<tr class='$oddclass'>";
}
if (($is_allowed_to_edit || api_is_drh()) && isset($_GET['lp_id']) && isset($course_code)) {
$lp = new learnpath($course_code, $_GET['lp_id'], api_get_user_id());
if (($is_allowed_to_edit || api_is_drh()) && isset($_GET['lp_id']) && isset($course_code)) {
$lp = new learnpath($course_code, $_GET['lp_id'], api_get_user_id());
$lp->set_course_int_id($course_id);
$item_path_url = $lp->get_link('http', $my_id, false);
$item_path_url = $lp->get_link('http', $my_id, false);
$item_path_url .= "&width=600";
$title = Display::url($title, $item_path_url, array('class' => 'ajax'));
}
$output .= '<td>'.$extend_link.'</td>
<td colspan="4">' . $title . '</td>
<td colspan="2">' . learnpathitem::humanize_status($lesson_status) .'</td>
@ -680,7 +680,7 @@ if (is_array($list) && count($list) > 0) {
if ($row['item_type'] == 'quiz') {
if (!$is_allowed_to_edit && $result_disabled_ext_all) {
$output .= Display::return_icon('invisible.gif', get_lang('ResultsHiddenByExerciseSetting'));
} else {
} else {
$output .= show_score($score, $maxscore, false);
}
} else {
@ -787,16 +787,16 @@ if (is_array($list) && count($list) > 0) {
if (!$is_allowed_to_edit && $result_disabled_ext_all) {
$view_score = Display::return_icon('invisible.gif', get_lang('ResultsHiddenByExerciseSetting'));
} else {
// Show only float when need it
if ($my_score == 0) {
// Show only float when need it
if ($my_score == 0) {
$view_score = show_score(0, $my_maxscore, false);
} else {
if ($my_maxscore == 0) {
$view_score = $my_score;
} else {
} else {
$view_score = show_score($my_score, $my_maxscore, false);
}
}
}
}
$my_lesson_status = $row_attempts['status'];
@ -809,14 +809,10 @@ if (is_array($list) && count($list) > 0) {
$output .= '<tr class="' . $oddclass . '" >
<td></td>
<td>' . $extend_attempt_link . '</td>
<td colspan="3">' . get_lang('Attempt') . ' ' . $n . '</td>
<td colspan="3">' . get_lang('Attempt').' '. $n.'</td>
<td colspan="2">' . $my_lesson_status . '</td>
<td colspan="2">
' . $view_score . '
</td>
<td colspan="2">
' . $time_attemp . '
</td>';
<td colspan="2">'.$view_score . '</td>
<td colspan="2">'.$time_attemp . '</td>';
if ($origin != 'tracking') {
if (!$is_allowed_to_edit && $result_disabled_ext_all) {
$output .= '<td><img src="' . api_get_path(WEB_IMG_PATH) . 'quiz_na.gif" alt="' . get_lang('ShowAttempt') . '" title="' . get_lang('ShowAttempt') . '"></td>';

@ -301,6 +301,10 @@ function LMSInitialize() {
xajax_start_timer();
}
if (olms.lms_item_type == 'quiz') {
update_toc(olms.lesson_status, olms.lms_item_id);
}
<?php if (api_get_setting('show_glossary_in_documents') == 'ismanual') { ?>
if (olms.lms_item_type == 'sco') {
attach_glossary_into_scorm('automatic');
@ -1074,14 +1078,19 @@ function lms_save_asset() {
* Also save the score locally because it hasn't been done through SetValue().
* Saving the status will be dealt with by the XAJAX function.
*/
function chamilo_void_save_asset(myscore, mymax) {
function chamilo_void_save_asset(score, max, min, status) {
logit_lms('chamilo_void_save_asset',2);
olms.score = myscore;
if ((mymax == null) || (mymax == '')){
mymax = 100;
olms.score = score;
if ((max == null) || (max == '')){
max = 100;
}
if ((min == null) || (min == '')){
min = 0;
}
//assume a default of 100, otherwise the score will not get saved (see lpi->set_score())
xajax_save_item(olms.lms_lp_id, olms.lms_user_id, olms.lms_view_id, olms.lms_item_id, myscore, mymax);
xajax_save_item(olms.lms_lp_id, olms.lms_user_id, olms.lms_view_id, olms.lms_item_id, score, max, min, status);
}
/**
@ -1340,10 +1349,8 @@ function switch_item(current_item, next_item){
if (next_item_type != 'sco' ) {
//case 1
logit_lms('Case 1');
logit_lms('timer' + olms.asset_timer);
xajax_save_item(olms.lms_lp_id, olms.lms_user_id, olms.lms_view_id, olms.lms_item_id, olms.score, olms.max, olms.min, olms.lesson_status, olms.asset_timer, olms.suspend_data, olms.lesson_location,olms.interactions, olms.lms_item_core_exit);
xajax_switch_item_details(olms.lms_lp_id,olms.lms_user_id,olms.lms_view_id,olms.lms_item_id,next_item);
xajax_switch_item_details(olms.lms_lp_id, olms.lms_user_id, olms.lms_view_id, olms.lms_item_id, next_item);
} else {
logit_lms('Case 2');
//case 2
@ -1503,7 +1510,7 @@ function xajax_save_item(lms_lp_id, lms_user_id, lms_view_id, lms_item_id, score
params += '&status='+lesson_status+'&t='+session_time;
params += '&suspend='+suspend_data+'&loc='+lesson_location;
params += '&core_exit='+lms_item_core_exit;
//console.info(session_time);
if (olms.lms_lp_type == 1) {
logit_lms('xajax_save_item with params:' + params);
$.ajax({
@ -1618,7 +1625,10 @@ function xajax_start_timer() {
success: function(time) {
olms.asset_timer = time;
olms.asset_timer_total = 0;
logit_lms('xajax_start_timer result:' + time);
logit_lms('xajax_start_timer result: ' + time);
var date = new Date(time * 1000);
logit_lms('xajax_start_timer result: ' + date.toString());
}
});
}

Loading…
Cancel
Save