get_custom_score_display_settings(); $nr_items = (count($customdisplays) != '0') ? count($customdisplays) : '1'; $this->setDefaults(array( 'scorecolpercent' => $displayscore->get_color_split_value() )); $this->addElement('hidden', 'maxvalue', '100'); $this->addElement('hidden', 'minvalue', '0'); $counter = 1; //setting the default values if (is_array($customdisplays)) { foreach ($customdisplays as $customdisplay) { $this->setDefaults(array( 'endscore['.$counter.']' => $customdisplay['score'], 'displaytext['.$counter.']' => $customdisplay['display'] )); $counter++; } } $scorecol = array(); //settings for the colored score $this->addElement('header', get_lang('ScoreEdit')); if ($displayscore->is_coloring_enabled()) { $this->addElement('html', ''.get_lang('ScoreColor').''); $this->addElement( 'text', 'scorecolpercent', array(get_lang('Below'), get_lang('WillColorRed'), '%'), array( 'size' => 5, 'maxlength' => 5, 'input-size' => 2, ) ); 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', '>'); } //Settings for the scoring system if ($displayscore->is_custom()) { $this->addElement('html', '
'.get_lang('ScoringSystem').''); $this->addElement('static', null, null, get_lang('ScoreInfo')); $this->setDefaults(array( 'beginscore' => '0' )); $this->addElement('text', 'beginscore', array(get_lang('Between'), null, '%'), array( 'size' => 5, 'maxlength' => 5, 'disabled' => 'disabled', 'input-size' => 2 )); for ($counter = 1; $counter <= 20; $counter++) { $renderer = & $this->defaultRenderer(); $elementTemplateTwoLabel = '
*
{error}
 '.get_lang('And').'
{element}
=
'; $elementTemplateTwoLabel2 = '
{error} {element}
'; $scorebetw = array(); $this->addElement('text', 'endscore['.$counter.']', null, array( 'size' => 5, 'maxlength' => 5, 'id' => 'txta-'.$counter, 'input-size' => 2 )); $this->addElement( 'text', 'displaytext['.$counter.']', null, array( 'size' => 40, 'maxlength' => 40, 'id' => 'txtb-'.$counter, ) ); $renderer->setElementTemplate($elementTemplateTwoLabel, 'endscore['.$counter.']'); $renderer->setElementTemplate($elementTemplateTwoLabel2, 'displaytext['.$counter.']'); $this->addRule('endscore['.$counter.']', get_lang('OnlyNumbers'), 'numeric'); $this->addRule(array('endscore['.$counter.']', 'maxvalue'), get_lang('Over100'), 'compare', '<='); $this->addRule(array('endscore['.$counter.']', 'minvalue'), get_lang('UnderMin'), 'compare', '>'); } } if ($displayscore->is_custom()) { $this->addButtonSave(get_lang('Ok')); } } public function validate() { return parent::validate(); } }