From 007d9dcbe90074ca67f10e440b040d97f8b740b6 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Sat, 22 Jan 2011 13:58:49 +0100 Subject: [PATCH] Fixing exercise layout, fixing links, fixing query --- main/exercice/exercice.php | 18 +++++++++-------- main/exercice/exercise.lib.php | 36 ++++++++++++++++----------------- main/exercice/exercise_show.php | 7 ++++--- main/inc/lib/events.lib.inc.php | 12 ++++++----- 4 files changed, 39 insertions(+), 34 deletions(-) diff --git a/main/exercice/exercice.php b/main/exercice/exercice.php index fd285e05f7..a9527447f6 100755 --- a/main/exercice/exercice.php +++ b/main/exercice/exercice.php @@ -615,7 +615,7 @@ if ($is_allowedToEdit && $origin != 'learnpath') { echo '' . Display :: return_icon('hotpotatoes_s.png', get_lang('ImportHotPotatoesQuiz')) . get_lang('ImportHotPotatoesQuiz') . ''; // link to import qti2 ... echo '' . Display :: return_icon('import_db.png', get_lang('ImportQtiQuiz')) . get_lang('ImportQtiQuiz') . ''; - echo '' . Display :: return_icon('show_test_results.gif', get_lang('Results')) . get_lang('Results') . ''; + //echo '' . Display :: return_icon('show_test_results.gif', get_lang('Results')) . get_lang('Results') . ''; } // the actions for the statistics @@ -684,9 +684,9 @@ if ($show == 'result') { null; } if ($_GET['filter'] == '1' or !isset ($_GET['filter']) or $_GET['filter'] == 0 ) { - $view_result = ''.Display :: return_icon('check.gif', get_lang('ShowCorrectedOnly')).get_lang('ShowCorrectedOnly').''; + $view_result = ''.Display :: return_icon('check.gif', get_lang('ShowCorrectedOnly')).get_lang('ShowCorrectedOnly').''; } else { - $view_result = ''.Display :: return_icon('un_check.gif', get_lang('ShowUnCorrectedOnly')).get_lang('ShowUnCorrectedOnly').''; + $view_result = ''.Display :: return_icon('un_check.gif', get_lang('ShowUnCorrectedOnly')).get_lang('ShowUnCorrectedOnly').''; } echo $view_result; } @@ -816,6 +816,8 @@ if ($show == 'test') { $actions = Display::url(Display::return_icon('wizard_small.gif',get_lang('Edit'), array('width'=>'22px')), 'admin.php?'.api_get_cidreq().'&exerciseId='.$row['id']); + $actions .='' . Display :: return_icon('show_test_results.gif', get_lang('Results')).''; + //Export $actions .= Display::url(Display::return_icon('cd.gif', get_lang('CopyExercise')), '', array('onclick'=>"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('AreYouSureToCopy'),ENT_QUOTES,$charset))." ".addslashes($row['title'])."?"."')) return false;",'href'=>'exercice.php?'.api_get_cidreq().'&choice=copy_exercise&sec_token='.$token.'&exerciseId='.$row['id'])); //Clean exercise @@ -865,6 +867,7 @@ if ($show == 'test') { echo '';*/ echo Display::tag('tr',$item); } else { + // Student only $row['title']=text_filter($row['title']); @@ -878,8 +881,7 @@ if ($show == 'test') { } } else { $url = ''.$row['title'].''; - } - + } $item = Display::tag('td',$url.' '.$session_img); @@ -931,7 +933,7 @@ if ($show == 'test') { $percentage = ($row['exe_result'] / $row['exe_weighting']) * 100; } $attempt_text = get_lang('Attempted') . ' (' . get_lang('Score') . ': '; - $attempt_text .= printf("%1.2f\n", $percentage); + $attempt_text .= sprintf("%1.2f\n", $percentage); $attempt_text .= " %)"; } else { //echo get_lang('WillBeActivated' .' '. $row['start_time']); @@ -964,7 +966,7 @@ if ($show == 'test') { /* Exercise Results (uses tracking tool) */ // if tracking is enabled -if ($_configuration['tracking_enabled'] && ($show == 'result')) { +if ($show == 'result') { $parameters=array('cidReq'=>Security::remove_XSS($_GET['cidReq']),'show'=>Security::remove_XSS($_GET['show']),'filter' => Security::remove_XSS($_GET['filter']),'gradebook' =>Security::remove_XSS($_GET['gradebook'])); $exercise_id = intval($_GET['exercise_id']); if (!empty($exercise_id)) @@ -988,7 +990,7 @@ if ($_configuration['tracking_enabled'] && ($show == 'result')) { $table->set_header(-$secuence + 3, get_lang('Duration'),false); $table->set_header(-$secuence + 4, get_lang('Date')); $table->set_header(-$secuence + 5, get_lang('Result'),false); - $table->set_header(-$secuence + 6, (($is_allowedToEdit||$is_tutor) ? get_lang('CorrectTest') : get_lang('ViewTest')), false); + $table->set_header(-$secuence + 6, (($is_allowedToEdit||$is_tutor) ? get_lang('CorrectTest') : get_lang('ViewTest')), false); $table->display(); } diff --git a/main/exercice/exercise.lib.php b/main/exercice/exercise.lib.php index e901a36a34..47cf927c8a 100755 --- a/main/exercice/exercise.lib.php +++ b/main/exercice/exercise.lib.php @@ -1075,25 +1075,25 @@ function get_exam_results_data($from, $number_of_items, $column, $direction) { */ function show_score($score, $weight, $show_porcentage = true) { $html = ''; - $score_rounded = $score; - if ($score != '' && $weight != '') { - $max_note = api_get_setting('exercise_max_score'); - $min_note = api_get_setting('exercise_min_score'); - if ($max_note != '' && $min_note != '') { - if (!empty($weight) && intval($weight) != 0) { - $score = $min_note + ($max_note - $min_note) * $score /$weight; - } else { - $score = $min_note; - } - $score_rounded = round($score, 2); - $weight = $max_note; + $score_rounded = $score; + + $max_note = api_get_setting('exercise_max_score'); + $min_note = api_get_setting('exercise_min_score'); + + if ($max_note != '' && $min_note != '') { + if (!empty($weight) && intval($weight) != 0) { + $score = $min_note + ($max_note - $min_note) * $score /$weight; + } else { + $score = $min_note; } - if ($show_porcentage) { - $html = round(($score / ($weight != 0 ? $weight : 1)) * 100, 2) . '% (' . $score_rounded . ' / ' . $weight . ')'; - } else { - $html = $score_rounded . ' / ' . $weight; - } - } + $score_rounded = round($score, 2); + $weight = $max_note; + } + if ($show_porcentage) { + $html = round(($score / ($weight != 0 ? $weight : 1)) * 100, 2) . '% (' . $score_rounded . ' / ' . $weight . ')'; + } else { + $html = $score_rounded . ' / ' . $weight; + } return $html; } diff --git a/main/exercice/exercise_show.php b/main/exercice/exercise_show.php index e4265139c8..b821437039 100755 --- a/main/exercice/exercise_show.php +++ b/main/exercice/exercise_show.php @@ -248,7 +248,7 @@ if ($show_results) { - : + : - : + : '.get_lang('YourTotalScore').": "; + //@todo $dsp_percent who do that and why? if ($dsp_percent) { $my_result = number_format(($totalScore/$totalWeighting)*100,1,'.',''); $my_result = float_format($my_result,1); echo $my_result."%"; - } else { + } else { echo show_score($totalScore,$totalWeighting,false); } echo ''; diff --git a/main/inc/lib/events.lib.inc.php b/main/inc/lib/events.lib.inc.php index 4caa1bc26a..001d24235f 100755 --- a/main/inc/lib/events.lib.inc.php +++ b/main/inc/lib/events.lib.inc.php @@ -602,17 +602,20 @@ function get_last_attempt_date_of_exercise($exe_id) { return $last_attempt_date; } - -function get_attempt_count($user_id, $exerciseId, $lp_id, $lp_item_id) { +/** + * Gets how many attempts exists + */ +function get_attempt_count($user_id, $exerciseId, $lp_id, $lp_item_id,$lp_item_view_id) { $stat_table = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES); $user_id = intval($user_id); $exerciseId = intval($exerciseId); $lp_id = intval($lp_id); $lp_item_id = intval($lp_item_id); + $lp_item_view_id = intval($lp_item_view_id); $sql = "SELECT count(*) as count FROM $stat_table WHERE exe_exo_id = '$exerciseId' AND exe_user_id = '$user_id' AND status != 'incomplete' - AND orig_lp_id = $lp_id AND orig_lp_item_id = $lp_item_id AND exe_cours_id = '".api_get_course_id()."' AND session_id = '" . api_get_session_id() . "'"; + AND orig_lp_id = $lp_id AND orig_lp_item_id = $lp_item_id AND orig_lp_item_view_id = $lp_item_view_id AND exe_cours_id = '".api_get_course_id()."' AND session_id = '" . api_get_session_id() . "'"; $query = Database::query($sql); if (Database::num_rows($query) > 0 ) { @@ -801,8 +804,7 @@ function get_all_exercises_from_lp($lp_id, $course_db) { * @param int $question_id * @return str the comment */ -function get_comments($id,$question_id) -{ +function get_comments($id,$question_id) { $TBL_TRACK_ATTEMPT = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT); $sql = "SELECT teacher_comment FROM ".$TBL_TRACK_ATTEMPT." where exe_id='".Database::escape_string($id)."' and question_id = '".Database::escape_string($question_id)."' ORDER by question_id"; $sqlres = Database::query($sql);