Adding show_score function to use the new max and min platform scores

skala
Julio Montoya 15 years ago
parent e693e38325
commit 23fcfae9cb
  1. 10
      main/exercice/exercice.php
  2. 24
      main/exercice/exercise.lib.php
  3. 9
      main/exercice/exercise_show.php
  4. 20
      main/newscorm/lp_stats.php

@ -778,7 +778,13 @@ if ($show == 'test') {
//Showing exercise title
$row['title']=text_filter($row['title']);
echo Display::tag('h1',$row['title']);
echo Display::tag('h1',$row['title']);
if ($session_id == $row['session_id']) {
//Settings
//echo Display::url(Display::return_icon('settings.png',get_lang('Edit'), array('width'=>'22px'))." ".get_lang('Edit'), 'exercise_admin.php?'.api_get_cidreq().'&modifyExercise=yes&exerciseId='.$row['id']);
}
echo '<p>';
echo $session_img;
$exid = $row['id'];
@ -800,7 +806,7 @@ if ($show == 'test') {
if ($session_id == $row['session_id']) {
//Settings
echo Display::url(Display::return_icon('settings.png',get_lang('Edit'), array('width'=>'22px'))." ".get_lang('Edit'), 'exercise_admin.php?'.api_get_cidreq().'&modifyExercise=yes&exerciseId='.$row['id']);
echo Display::url(Display::return_icon('edit.gif',get_lang('Edit'), array('width'=>'20px')), 'exercise_admin.php?'.api_get_cidreq().'&modifyExercise=yes&exerciseId='.$row['id']);
//Export
echo 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']));

@ -1015,7 +1015,8 @@ function get_exam_results_data($from, $number_of_items, $column, $direction) {
$ex = show_score($my_res, $my_total);
$result_list = round(($my_res / ($my_total != 0 ? $my_total : 1)) * 100, 2) . '% (' . $my_res . ' / ' . $my_total . ') --> '.$ex;
//$result_list = round(($my_res / ($my_total != 0 ? $my_total : 1)) * 100, 2) . '% (' . $my_res . ' / ' . $my_total . ')';
$result_list = $ex;
$html_link = '';
if ($is_allowedToEdit || $is_tutor) {
@ -1105,5 +1106,26 @@ function show_score($score, $weight, $show_porcentage = true) {
}
function convert_score($score, $weight) {
$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)) {
$score = $min_note + ($max_note - $min_note) * $score /$weight;
} else {
$score = $min_note;
}
$score_rounded = round($score, 2);
}
}
return $score_rounded;
}

@ -578,12 +578,13 @@ if ($show_results) {
</tr>
</table>
<?php
$my_total_score = float_format($questionScore,1);
$my_total_weight = float_format($questionWeighting,1);
$my_total_score = convert_score($questionScore, $total_weighting);
$my_total_weight = convert_score($questionWeighting, $total_weighting);
echo '<div id="question_score">';
//echo get_lang('Score')." : $my_total_score/$my_total_weight";
echo get_lang('Score')." : ".show_score($my_total_score,$total_weighting,false);
echo get_lang('Score')." : $my_total_score/$my_total_weight";
//echo get_lang('Score')." : ".show_score($my_total_score, $total_weighting, false);
echo '</div>';
unset($objAnswerTmp);

@ -14,6 +14,7 @@ require_once 'learnpath.class.php';
require_once 'resourcelinker.inc.php';
require_once api_get_path(LIBRARY_PATH).'tracking.lib.php';
require_once api_get_path(LIBRARY_PATH).'course.lib.php';
require_once '../exercice/exercise.lib.php';
if (empty($_SESSION['_course']['id']) && isset($_GET['course'])) {
$course_code = Security::remove_XSS($_GET['course']);
@ -285,7 +286,9 @@ 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 {
$view_score = ($score == 0 ? '/' : ($maxscore === 0 ? $score : $score . '/' . float_format($maxscore, 1)));
//$view_score = ($score == 0 ? '/' : ($maxscore === 0 ? $score : $score . '/' . float_format($maxscore, 1)));
$view_score = show_score($score,$maxscore, false);
}
$output .= "<tr class='$oddclass'>\n" . "<td></td>\n" . "<td>$extend_attempt_link</td>\n" . '<td colspan="3">' . get_lang('Attempt') . ' ' . $row['iv_view_count'] . "</td>\n"
. '<td colspan="2"><font color="' . $color . '"><div class="mystatus">' . $my_lesson_status . "</div></font></td>\n" . '<td colspan="2"><div class="mystatus" align="center">' . $view_score . "</div></td>\n" . '<td colspan="2"><div class="mystatus">'.$time.'</div></td><td></td></tr>';
@ -296,7 +299,6 @@ if (is_array($list) && count($list) > 0) {
$temp[] = Security::remove_XSS($my_lesson_status);
if ($row['item_type'] == 'quiz') {
if (!$is_allowed_to_edit && $result_disabled_ext_all) {
$temp[] = '/';
} else {
@ -546,13 +548,12 @@ if (is_array($list) && count($list) > 0) {
$output .= "<td>$extend_link</td>\n" . '<td colspan="4"><div class="mystatus">' .$title. '</div></td>' . "\n";
$output .= '<td colspan="2"><font color="' . $color . '"><div class="mystatus">' . $my_lesson_status . "</div></font></td>\n" . '<td colspan="2"><div class="mystatus" align="center">';
if ($row['item_type'] == 'quiz') {
if (!$is_allowed_to_edit && $result_disabled_ext_all) {
$output .= Display::return_icon('invisible.gif', get_lang('ResultsHiddenByExerciseSetting'));
} else {
$output .= ($score == 0 ? '0/'.float_format($maxscore, 1) : ($maxscore == 0 ? $score : float_format($score, 1) . '/' . float_format($maxscore, 1)));
// $output .= ($score == 0 ? '0/'.float_format($maxscore, 1) : ($maxscore == 0 ? $score : float_format($score, 1) . '/' . float_format($maxscore, 1)));
$output .= show_score($score, $maxscore, false);
}
} else {
$output .= ($score == 0 ? '/' : ($maxscore == 0 ? $score : $score . '/' . $maxscore));
}
@ -642,10 +643,13 @@ if (is_array($list) && count($list) > 0) {
if ($my_score == 0 ) {
$view_score = '0/'.$my_maxscore;
} else {
if ($my_maxscore == 0)
if ($my_maxscore == 0) {
$view_score = $my_score;
else
$view_score = $my_score . '/' . $my_maxscore;
} else {
//$view_score = $my_score . '/' . $my_maxscore;
$view_score = show_score($my_score, $my_maxscore, false);
}
}
//$view_score = ($my_score == 0 ? '0.00/'.$my_maxscore : ($my_maxscore == 0 ? $my_score : $my_score . '/' . $my_maxscore));
}

Loading…
Cancel
Save