[svn r20087] UI improvements changing the format of the results in a Test tool 10.00 instead of 10 see FS#4034

skala
Julio Montoya 17 years ago
parent c475631b42
commit b2c2ae6be2
  1. 1773
      main/exercice/exercice.php
  2. 27
      main/exercice/exercise.class.php
  3. 14
      main/exercice/exercise_admin.php
  4. 25
      main/exercice/exercise_show.php
  5. 82
      main/inc/lib/text.lib.php

File diff suppressed because it is too large Load Diff

@ -25,7 +25,7 @@
* Exercise class: This class allows to instantiate an object of type Exercise
* @package dokeos.exercise
* @author Olivier Brouckaert
* @version $Id: exercise.class.php 19959 2009-04-21 22:29:46Z cvargas1 $
* @version $Id: exercise.class.php 20087 2009-04-24 20:44:55Z juliomontoya $
*/
@ -851,25 +851,32 @@ class Exercise
$type='full';
}
// form title
if (!empty($_GET['exerciseId']))
{
if (!empty($_GET['exerciseId'])) {
$form_title = get_lang('ModifyExercise');
}
else
{
} else {
$form_title = get_lang('NewEx');
}
$form->addElement('header', '', $form_title);
// title
$form -> addElement('text', 'exerciseTitle', get_lang('ExerciseName'),'class="input_titles"');
// fck editor
global $fck_attribute;
$fck_attribute = array();
$fck_attribute['Width'] = '100%';
$fck_attribute['Height'] = '200px';
$fck_attribute['ToolbarSet'] = 'TestDescription';
$form -> addElement ('html_editor', 'exerciseDescription', get_lang('ExerciseDescription'));
$fck_attribute['ToolbarSet'] = 'TestDescription';
$form -> addElement('html','<div class="row">
<div class="label">&nbsp;</div>
<div class="formw">
<a href="javascript://" onclick=" return show_media()"><img src="../img/looknfeel.png" alt="" />&nbsp;'.get_lang('EnrichQuestion').'</a>
</div>
</div>');
$form -> addElement ('html','<div id="media" style="display:none;">');
$form -> addElement ('html_editor', 'exerciseDescription');
$form -> addElement ('html','</div>');
$form -> addElement('html','<div class="row">
<div class="label">&nbsp;</div>
@ -881,7 +888,7 @@ class Exercise
// Random questions
$form -> addElement('html','<div id="options" style="display:none">');
if($type=='full') {
if($type=='full') {
// feedback type
$radios_feedback = array();
$radios_feedback[] = FormValidator :: createElement ('radio', 'exerciseFeedbackType', null, get_lang('Feedback'),'0');

@ -55,8 +55,18 @@ $htmlHeadXtra[] = '<script>
document.getElementById(\'options\').style.display = \'none\';
document.getElementById(\'img_plus_and_minus\').innerHTML=\'&nbsp;<img src="../img/div_show.gif" alt="" />&nbsp;'.get_lang('AdvancedParameters').'\';
}
}
}
function show_media() {
if(document.getElementById(\'media\').style.display == \'none\') {
document.getElementById(\'media\').style.display = \'block\';
} else {
document.getElementById(\'media\').style.display = \'none\';
}
}
function timelimit() {
if(document.getElementById(\'options2\').style.display == \'none\') {
document.getElementById(\'options2\').style.display = \'block\';

@ -4,7 +4,7 @@
*
* @package dokeos.exercise
* @author Julio Montoya Armas Added switchable fill in blank option added
* @version $Id: exercise_show.php 20081 2009-04-24 17:57:27Z juliomontoya $
* @version $Id: exercise_show.php 20087 2009-04-24 20:44:55Z juliomontoya $
*
* @todo remove the debug code and use the general debug library
* @todo use the Database:: functions
@ -372,15 +372,12 @@ function display_hotspot_answer($answerId, $answer, $studentChoice, $answerComme
//api_not_allowed();
$show_results = false;
//Display::display_warning_message(get_lang('CantViewResults'));
if ($origin!='learnpath')
if ($origin!='learnpath') {
Display::display_warning_message(get_lang('ThankYouForPassingTheTest').'<br /><br /><a href="exercice.php">'.(get_lang('BackToExercisesList')).'</a>', false);
else {
Display::display_warning_message(get_lang('ThankYouForPassingTheTest'));
}
echo '</td>
echo '</td>
</tr>
</table>';
}
}
}
$user_restriction = $is_allowedToEdit ? '' : "AND user_id=".intval($_user['user_id'])." ";
@ -1008,7 +1005,11 @@ if($is_allowedToEdit) {
</table>
<div id="question_score">
<?php echo get_lang('Score')." : $questionScore/$questionWeighting"; ?>
<?php
$my_total_score = float_format($questionScore,1);
$my_total_weight = float_format($questionWeighting,1);
echo get_lang('Score')." : $my_total_score/$my_total_weight";
?>
</div>
<?php
@ -1023,9 +1024,13 @@ if($origin!='learnpath') {
if ($show_results) {
echo '<div id="question_score">'.get_lang('YourTotalScore')." ";
if($dsp_percent == true) {
echo number_format(($totalScore/$totalWeighting)*100,1,'.','')."%";
$my_result = number_format(($totalScore/$totalWeighting)*100,1,'.','');
$my_result = float_format($my_result,1);
echo $my_result."%";
} else {
echo $totalScore."/".$totalWeighting;
$my_total_score = float_format($totalScore,1);
$my_total_weight = float_format($totalWeighting,1);
echo $my_total_score."/".$my_total_weight;
}
echo '!</div>';
}

@ -1,9 +1,9 @@
<?php // $Id: text.lib.php 17946 2009-01-22 20:52:23Z juliomontoya $
<?php // $Id: text.lib.php 20087 2009-04-24 20:44:55Z juliomontoya $
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004-2008 Dokeos S.A.
Copyright (c) 2004-2009 Dokeos S.A.
Copyright (c) 2003 Ghent University (UGent)
Copyright (c) 2001 Universite catholique de Louvain (UCL)
Copyright (c) various contributors
@ -289,11 +289,11 @@ function latex_gif_renderer($latex_code)
/**
* This function returns the difference between the current date (date(now)) with the parameter $date in a string format like "2 days, 1 hour"
* Returns the difference between the current date (date(now)) with the parameter $date in a string format like "2 days, 1 hour"
* Example: $date="2008-03-07 15:44:08";
* date_to_str($date) it will return 3 days, 20 hours
*
* @param string This string has to be the result of a date function in this format -> date("Y-m-d H:i:s",time());
* @param string The string has to be the result of a date function in this format -> date("Y-m-d H:i:s",time());
* @return string The difference between the current date and the parameter in a literal way "3 days, 2 hour" *
* @author Julio Montoya
*/
@ -306,8 +306,7 @@ function date_to_str_ago($date)
static $min_decades, $min_years, $min_months, $min_weeks, $min_days, $min_hours, $min_minutes;
static $sec_time_time, $sec_time_sing, $sec_time_plu;
if (!$initialized)
{
if (!$initialized) {
$today = ucfirst(get_lang('Today'));
$yesterday = ucfirst(get_lang('Yesterday'));
@ -333,7 +332,6 @@ function date_to_str_ago($date)
$sec_time_time=array(315569260,31556926,2629743.83,604800,86400,3600,60);
$sec_time_sing=array($min_decade,$min_year,$min_month,$min_week,$min_day,$min_hour,$min_minute);
$sec_time_plu =array($min_decades,$min_years,$min_months,$min_weeks,$min_days,$min_hours,$min_minutes);
$initialized = true;
}
@ -357,16 +355,13 @@ function date_to_str_ago($date)
$act_mth=date('n');
$act_yr = date('Y');
if ($dst_day==$act_day && $dst_mth==$act_mth && $dst_yr == $act_yr )
{
if ($dst_day==$act_day && $dst_mth==$act_mth && $dst_yr == $act_yr ) {
return $today;
}
if ($dst_day==$act_day-1 && $dst_mth==$act_mth && $dst_yr == $act_yr )
{
if ($dst_day==$act_day-1 && $dst_mth==$act_mth && $dst_yr == $act_yr ) {
return $yesterday;
}
}
$str_result=array();
$time_result=array();
@ -374,22 +369,16 @@ function date_to_str_ago($date)
$str='';
$i=0;
for ($i=0;$i<count($sec_time_time);$i++)
{
$seconds=$sec_time_time[$i];
for ($i=0;$i<count($sec_time_time);$i++) {
$seconds=$sec_time_time[$i];
if($seconds > $time) {
continue;
}
}
$current_value=intval($time/$seconds);
if ($current_value != 1)
{
if ($current_value != 1) {
$date_str= $sec_time_plu[$i];
}
else
{
} else {
$date_str= $sec_time_sing[$i];
}
@ -399,32 +388,25 @@ function date_to_str_ago($date)
$time_result[]= $current_value;
$str.=$current_value.$date_str;
$time%=$seconds;
}
if ($key_result[0]== $min_day && $key_result[1]== $min_minute)
{
}
if ($key_result[0]== $min_day && $key_result[1]== $min_minute) {
$key_result[1]=' 0 '.$min_hours;
$str_result[0]=$time_result[0].' '.$key_result[0];
$str_result[1]=$key_result[1];
}
if ($key_result[0]== $min_year && ($key_result[1]== $min_day || $key_result[1]== $min_week))
{
if ($key_result[0]== $min_year && ($key_result[1]== $min_day || $key_result[1]== $min_week)) {
$key_result[1]=' 0 '.$min_months;
$str_result[0]=$time_result[0].' '.$key_result[0];
$str_result[1]=$key_result[1];
}
if (!empty($str_result[1]))
{
if (!empty($str_result[1])) {
$str=$str_result[0].', '.$str_result[1];
}
else
{
} else {
$str=$str_result[0];
}
}
return $str;
}
/**
@ -442,5 +424,27 @@ function cut($text,$maxchar)
return $text;
}
}
/**
* Show a number as only integers if no decimals, but will show 2 decimals if exist.
*
* @param mixed number to convert
* @param int decimal points 0=never, 1=if needed, 2=always
* @return mixed an integer or a float depends on the parameter
*/
function float_format($number, $flag = 1)
{
if (is_numeric($number)) { // a number
if (!$number) { // zero
$result = ($flag == 2 ? '0.00' : '0'); // output zero
} else { // value
if (floor($number) == $number) { // whole number
$result = number_format($number, ($flag == 2 ? 2 : 0)); // format
} else { // cents
$result = number_format(round($number, 2), ($flag == 0 ? 0 : 2)); // format
} // integer or decimal
} // value
return $result;
}
}
?>
?>
Loading…
Cancel
Save