diff --git a/main/gradebook/gradebook_scoring_system.php b/main/gradebook/gradebook_scoring_system.php index c1475205a8..1fc85bbcd8 100644 --- a/main/gradebook/gradebook_scoring_system.php +++ b/main/gradebook/gradebook_scoring_system.php @@ -91,10 +91,11 @@ if ($scoreform->validate()) { } $scorecolpercent = 0; - if ($displayscore->is_coloring_enabled()) { + + if ($displayscore->is_coloring_enabled()) { $scorecolpercent = $values['scorecolpercent']; } - + if ($displayscore->is_custom() && !empty($scoringdisplay)) { $displayscore->update_custom_score_display_settings($scoringdisplay, $scorecolpercent); } diff --git a/main/gradebook/lib/fe/displaygradebook.php b/main/gradebook/lib/fe/displaygradebook.php index 2e1c73be67..85cda3815f 100644 --- a/main/gradebook/lib/fe/displaygradebook.php +++ b/main/gradebook/lib/fe/displaygradebook.php @@ -528,7 +528,7 @@ class DisplayGradebook if (empty($categories)) { $modify_icons .= ''.Display::return_icon('percentage.png', get_lang('EditAllWeights'),'',ICON_SIZE_MEDIUM).''; - } + } if (api_get_setting('teachers_can_change_score_settings') == 'true') { $modify_icons .= ''.Display::return_icon('ranking.png', get_lang('ScoreEdit'),'',ICON_SIZE_MEDIUM).''; } diff --git a/main/gradebook/lib/fe/scoredisplayform.class.php b/main/gradebook/lib/fe/scoredisplayform.class.php index e9e242069d..82df7094aa 100644 --- a/main/gradebook/lib/fe/scoredisplayform.class.php +++ b/main/gradebook/lib/fe/scoredisplayform.class.php @@ -9,8 +9,7 @@ */ require_once dirname(__FILE__).'/../../../inc/global.inc.php'; require_once dirname(__FILE__).'/../gradebook_functions.inc.php'; -require_once api_get_path(LIBRARY_PATH) . 'groupmanager.lib.php'; -require_once api_get_path(LIBRARY_PATH) . 'formvalidator/FormValidator.class.php'; + /** * Form for the score display dialog * @author Stijn Konings @@ -22,11 +21,15 @@ class ScoreDisplayForm extends FormValidator function ScoreDisplayForm($form_name, $action= null) { parent :: __construct($form_name, 'post', $action); $displayscore= ScoreDisplay :: instance(); - $customdisplays= $displayscore->get_custom_score_display_settings(); + $customdisplays = $displayscore->get_custom_score_display_settings(); + $nr_items =(count($customdisplays)!='0')?count($customdisplays):'1'; $this->setDefaults(array ( 'scorecolpercent' => $displayscore->get_color_split_value() )); + + //var_dump($displayscore->get_color_split_value() ); + $this->addElement('hidden', 'maxvalue', '100'); $this->addElement('hidden', 'minvalue', '0'); $counter= 1; @@ -42,27 +45,37 @@ class ScoreDisplayForm extends FormValidator $counter++; } } - $scorecol= array (); + $scorecol = array (); //settings for the colored score - $this->addElement('header', '', get_lang('ScoreEdit')); - $this->addElement('html', '' . get_lang('ScoreColor') . ''); - $this->addElement('text', 'scorecolpercent', array(get_lang('Below'), get_lang('WillColorRed'), '%'), array ( - 'size' => 5, - 'maxlength' => 5, - 'class'=>'span1', + $this->addElement('header', get_lang('ScoreEdit')); + + if ($displayscore->is_coloring_enabled()) { - )); - $this->addRule('scorecolpercent', get_lang('OnlyNumbers'), 'numeric'); - $this->addRule(array('scorecolpercent','maxvalue'), get_lang('Over100'), 'compare', '<='); - $this->addRule(array('scorecolpercent','minvalue'), get_lang('UnderMin'), 'compare', '>'); - - //settings for the scoring system + $this->addElement('html', '' . get_lang('ScoreColor') . ''); + + $this->addElement('text', 'scorecolpercent', array(get_lang('Below'), get_lang('WillColorRed'), '%'), array ( + 'size' => 5, + 'maxlength' => 5, + 'class'=>'span1', + )); + + if (api_get_setting('teachers_can_change_score_settings') != 'true') { + $this->freeze('scorecolpercent'); + } + + $this->addRule('scorecolpercent', get_lang('OnlyNumbers'), 'numeric'); + $this->addRule(array('scorecolpercent','maxvalue'), get_lang('Over100'), 'compare', '<='); + $this->addRule(array('scorecolpercent','minvalue'), get_lang('UnderMin'), 'compare', '>'); + } - $this->addElement('html', '
' . get_lang('ScoringSystem') . ''); - //$this->addElement('checkbox', 'enablescore', null, get_lang('EnableScoringSystem'), null); + //Settings for the scoring system - if ($displayscore->is_custom()) { + if ($displayscore->is_custom()) { + + $this->addElement('html', '
' . get_lang('ScoringSystem') . ''); + //$this->addElement('checkbox', 'enablescore', null, get_lang('EnableScoringSystem'), null); + //$this->addElement('checkbox', 'includeupperlimit', null, get_lang('IncludeUpperLimit'), null); $this->addElement('static', null, null, get_lang('ScoreInfo')); $scorenull[]= & $this->CreateElement('static', null, null, get_lang('Between')); @@ -110,9 +123,12 @@ class ScoreDisplayForm extends FormValidator $this->addRule(array ('endscore[' . $counter . ']', 'maxvalue'), get_lang('Over100'), 'compare', '<='); $this->addRule(array ('endscore[' . $counter . ']', 'minvalue'), get_lang('UnderMin'), 'compare', '>'); } - } - $this->addElement('style_submit_button', 'submit', get_lang('Ok'),'class="save"'); + } + + if ($displayscore->is_custom()) + $this->addElement('style_submit_button', 'submit', get_lang('Ok'),'class="save"'); } + function validate() { return parent :: validate(); } diff --git a/main/gradebook/lib/gradebook_functions.inc.php b/main/gradebook/lib/gradebook_functions.inc.php index 4b32150cbf..8bb7a50f6a 100644 --- a/main/gradebook/lib/gradebook_functions.inc.php +++ b/main/gradebook/lib/gradebook_functions.inc.php @@ -695,7 +695,8 @@ function load_gradebook_select_in_tool($form) { /** * PDF report creation */ -function export_pdf_flatview($cat, $users, $alleval, $alllinks, $params = array()) { +function export_pdf_flatview($cat, $users, $alleval, $alllinks, $params = array()) { + global $flatviewtable; //Getting data $printable_data = get_printable_data($cat[0], $users, $alleval, $alllinks, $params); diff --git a/main/gradebook/lib/scoredisplay.class.php b/main/gradebook/lib/scoredisplay.class.php index 8021395889..244c8d8345 100644 --- a/main/gradebook/lib/scoredisplay.class.php +++ b/main/gradebook/lib/scoredisplay.class.php @@ -107,9 +107,9 @@ class ScoreDisplay } //Setting custom enabled - $value = api_get_setting('gradebook_score_display_custom'); + $value = api_get_setting('gradebook_score_display_custom'); $value = $value['my_display_custom']; - $this->custom_enabled = $value; + $this->custom_enabled = $value == 'true' ? true : false; if ($this->custom_enabled) { @@ -143,6 +143,7 @@ class ScoreDisplay $this->custom_display_conv = $this->convert_displays($this->custom_display); } } + if ($this->coloring_enabled) { $this->color_split_value = $this->get_score_color_percent(); } @@ -155,17 +156,18 @@ class ScoreDisplay public function is_coloring_enabled () { return $this->coloring_enabled; } + /** * Is custom score display enabled ? */ public function is_custom() { return $this->custom_enabled; } + /** * Is upperlimit included ? */ - public function is_upperlimit_included () - { + public function is_upperlimit_included () { return $this->upperlimit_included; } @@ -193,8 +195,8 @@ class ScoreDisplay private function get_current_gradebook_category_id() { $tbl_gradebook_category = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY); - $curr_course_code = api_get_course_id(); - $curr_session_id = api_get_session_id(); + $curr_course_code = api_get_course_id(); + $curr_session_id = api_get_session_id(); $session_condition = ''; if (empty($curr_session_id)) { @@ -244,6 +246,7 @@ class ScoreDisplay $sql .= "(NULL, '".$display['score']."', '".Database::escape_string($display['display'])."', ".$category_id.", ".intval($scorecolpercent).")"; $count++; } + Database::query($sql); } @@ -291,11 +294,13 @@ class ScoreDisplay } else { // if no custom display set, use default display $display = $this->display_default($my_score, $type); - } + } + if ($this->coloring_enabled && $no_color == false) { $my_score_denom = ($score[1]==0)?1:$score[1]; if (($score[0] / $my_score_denom) < ($this->color_split_value / 100)) { - $display = Display::tag('font', $display, array('color'=>'red')); + $display = Display::tag('font', $display, array('color'=>'red')); + //$display = Display::label($display, 'important'); } } return $display; @@ -328,19 +333,22 @@ class ScoreDisplay return $this->display_simple_score($score).$custom; break; case SCORE_DIV_SIMPLE_WITH_CUSTOM_LETTERS: - $custom = $this->display_custom($score); + $custom = $this->display_custom($score); if (!empty($custom)) { $custom = ' - '.$custom; - } + } + $score = $this->display_simple_score($score); + //needs sudo apt-get install php5-intl if (class_exists(NumberFormatter)) { - $iso = api_get_language_isocode(); + $iso = api_get_language_isocode(); $f = new NumberFormatter($iso, NumberFormatter::SPELLOUT); - $letters = $f->format($score[0]); + $letters = $f->format($score); $letters = api_strtoupper($letters); $letters = " ($letters) "; } - return $this->display_simple_score($score).$letters.$custom; + + return $score.$letters.$custom; break; case SCORE_CUSTOM: // Good! return $this->display_custom($score); diff --git a/main/inc/lib/display.lib.php b/main/inc/lib/display.lib.php index 6256ac3f8b..77be3c31bc 100644 --- a/main/inc/lib/display.lib.php +++ b/main/inc/lib/display.lib.php @@ -1515,6 +1515,6 @@ class Display { if (empty($tip)) { return $text; } - return self::span($text, array('class' => 'boot-tooltip', 'title' => $tip)); + return self::span($text, array('class' => 'boot-tooltip', 'title' => strip_tags($tip))); } } //end class Display