[svn r17605] Logic Changes - Fixed bug founded in learning path score and when you display a exercise item should show check icon when the exercise is over see FS#3427
//this query might be improved later on by ordering by the new "tms" field rather than by exe_id
$qry = "SELECT * FROM $TBL_TRACK_EXERCICES " .
"WHERE exe_exo_id = '".Database::escape_string($eid)."' and exe_user_id = '".Database::escape_string($uid)."' AND exe_cours_id = '".api_get_course_id()."' AND orig_lp_id = 0 AND orig_lp_item_id = 0 AND session_id = '".api_get_session_id()."' ORDER BY exe_id DESC";
"WHERE exe_exo_id = '".Database::escape_string($eid)."' and exe_user_id = '".Database::escape_string($uid)."' AND exe_cours_id = '".api_get_course_id()."' AND status <>'incomplete' AND orig_lp_id = 0 AND orig_lp_item_id = 0 AND session_id = '".api_get_session_id()."' ORDER BY exe_id DESC";
@ -251,7 +252,7 @@ function display_fill_in_blanks_answer($answer,$id,$questionId)
<td>
<?phpechonl2br($answer);?>
</td><?php
if(!$is_allowedToEdit) {?>
if(!api_is_allowed_to_edit()) {?>
<td>
<?php
$comm = get_comments($id,$questionId);
@ -274,7 +275,7 @@ function display_free_answer($answer,$id,$questionId)
<tr>
<td>
<?phpechonl2br(stripslashes($answer));?>
</td><?phpif(!$is_allowedToEdit){?>
</td><?phpif(!api_is_allowed_to_edit()){?>
<td>
<?php
@ -344,9 +345,9 @@ function display_hotspot_answer($answerId, $answer, $studentChoice, $answerComme
<?php
$sql_test_name='SELECT title, description FROM '.$TBL_EXERCICES.' as exercises, '.$TBL_TRACK_EXERCICES.' as track_exercises WHERE exercises.id=track_exercises.exe_exo_id AND track_exercises.exe_id="'.Database::escape_string($id).'"';
@ -161,7 +163,7 @@ foreach ($list as $my_item_id) {
if (!empty ($view)) {
$sql = "SELECT iv.status as mystatus, v.view_count as mycount, " .
"iv.score as myscore, iv.total_time as mytime, i.id as myid, " .
"iv.score as myscore, iv.total_time as mytime, i.id as myid, i.lp_id as mylpid, " .
"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, " .
@ -176,7 +178,7 @@ foreach ($list as $my_item_id) {
" ORDER BY iv.view_count $qry_order ";
} 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, " .
"iv.score as myscore, iv.total_time as mytime, i.id as myid, i.lp_id as mylpid, " .
"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, " .
@ -219,9 +221,9 @@ foreach ($list as $my_item_id) {
if ($row['item_type'] == 'quiz')
{
if ($origin != 'tracking') {
$sql_last_attempt = 'SELECT exe_id 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 . '" ORDER BY exe_date DESC limit 1';
$sql_last_attempt = 'SELECT exe_id 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" ORDER BY exe_date DESC limit 1';
} else {
$sql_last_attempt = 'SELECT exe_id FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="' . $row['path'] . '" AND exe_user_id="' . $_GET['student_id'] . '" AND orig_lp_id = "'.$lp_id.'" AND orig_lp_item_id = "'.$row['myid'].'" AND exe_cours_id="' . $course_code . '" ORDER BY exe_date DESC limit 1';
$sql_last_attempt = 'SELECT exe_id FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="' . $row['path'] . '" AND exe_user_id="' . $_GET['student_id'] . '" AND orig_lp_id = "'.$lp_id.'" AND orig_lp_item_id = "'.$row['myid'].'" AND exe_cours_id="' . $course_code . '" AND status <> "incomplete" ORDER BY exe_date DESC limit 1';
@ -283,7 +285,7 @@ foreach ($list as $my_item_id) {
$type;
$scoIdentifier = $row['myid'];
if ($score == 0) {
$maxscore = 0;
$maxscore = $row['mymaxscore'];
} else {
if ($row['item_type'] == 'sco') {
@ -420,9 +422,9 @@ foreach ($list as $my_item_id) {
// selecting the exe_id from stats attempts tables in order to look the max score value
if ($origin != 'tracking') {
$sql_last_attempt = 'SELECT exe_id 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 . '" ORDER BY exe_date DESC limit 1';
$sql_last_attempt = 'SELECT exe_id 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" ORDER BY exe_date DESC limit 1';
} else {
$sql_last_attempt = 'SELECT exe_id FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="' . $row['path'] . '" AND exe_user_id="' . $_GET['student_id'] . '" AND orig_lp_id = "'.$lp_id.'" AND orig_lp_item_id = "'.$row['myid'].'" AND exe_cours_id="' . $course_code . '" ORDER BY exe_date DESC limit 1';
$sql_last_attempt = 'SELECT exe_id FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="' . $row['path'] . '" AND exe_user_id="' . $_GET['student_id'] . '" AND orig_lp_id = "'.$lp_id.'" AND orig_lp_item_id = "'.$row['myid'].'" AND exe_cours_id="' . $course_code . '" AND status <> "incomplete" ORDER BY exe_date DESC limit 1';
@ -439,7 +441,7 @@ foreach ($list as $my_item_id) {
if ($score == 0)
{
$maxscore = 0;
$maxscore = $row['mymaxscore'];
}
else
{
@ -500,14 +502,16 @@ foreach ($list as $my_item_id) {
$correct_test_link = '';
if ($origin != 'tracking' && $origin != 'tracking_course') {
$sql_last_attempt = 'SELECT exe_id 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 . '" ORDER BY exe_date ASC';
$sql_last_attempt = 'SELECT exe_id 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" ORDER BY exe_date ASC';
} else {
$sql_last_attempt = 'SELECT exe_id FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="' . $row['path'] . '" AND exe_user_id="' . Database :: escape_string($_GET['student_id']) . '" AND orig_lp_id = "'.$lp_id.'" AND orig_lp_item_id = "'.$row['myid'].'" AND exe_cours_id="' . Database :: escape_string($_GET['course']) . '" ORDER BY exe_date';
$sql_last_attempt = 'SELECT exe_id FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="' . $row['path'] . '" AND exe_user_id="' . Database :: escape_string($_GET['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" ORDER BY exe_date';
$sql = "UPDATE $TBL_LP_ITEM_VIEW SET status = 'completed' WHERE lp_item_id = '".Database::escape_string($learnpath_item_id)."'
AND lp_view_id = (SELECT lp_view.id FROM $TBL_LP_VIEW lp_view WHERE user_id = '".Database::escape_string($user_id)."' AND lp_id='".Database::escape_string($learnpath_id)."')";