diff --git a/main/gradebook/lib/fe/scoredisplayform.class.php b/main/gradebook/lib/fe/scoredisplayform.class.php index 87c5a80e5a..06158b8977 100755 --- a/main/gradebook/lib/fe/scoredisplayform.class.php +++ b/main/gradebook/lib/fe/scoredisplayform.class.php @@ -50,7 +50,7 @@ class ScoreDisplayForm extends FormValidator $this->addElement('text', 'scorecolpercent', array(get_lang('Below'), get_lang('WillColorRed'), '%'), array( 'size' => 5, 'maxlength' => 5, - 'class'=>'span1', + 'input-size' => 2 )); if (api_get_setting('teachers_can_change_score_settings') != 'true') { @@ -67,47 +67,72 @@ class ScoreDisplayForm extends FormValidator if ($displayscore->is_custom()) { $this->addElement('html', '
' . get_lang('ScoringSystem') . ''); $this->addElement('static', null, null, get_lang('ScoreInfo')); - $scorenull[]= & $this->createElement('static', null, null, get_lang('Between')); - $this->setDefaults(array ( + $this->setDefaults(array( 'beginscore' => '0' )); - $scorenull[]= & $this->createElement('text', 'beginscore', null, array ( + $this->addElement('text', 'beginscore', array(get_lang('Between'), null, '%'), array( 'size' => 5, 'maxlength' => 5, - 'disabled' => 'disabled' + 'disabled' => 'disabled', + 'input-size' => 2 )); - $scorenull[]= & $this->createElement('static', null, null, ' %'); - $this->addGroup($scorenull, '', '', ' '); + for ($counter= 1; $counter <= 20; $counter++) { $renderer =& $this->defaultRenderer(); $elementTemplateTwoLabel = - '
-

* + '

+ + * -
{error}

 '.get_lang('And').'     {element} %  ='; +
+ + +
+ {error}
+  '.get_lang('And').' +
+ +
+ {element} +
- $elementTemplateTwoLabel2 = - '{error}
 {element} +
+ = +
+ + + '; + + $elementTemplateTwoLabel2 =' +
+ {error} + + {element} +
+
'.get_lang('Add').' '.get_lang('Delete').' -

'; +
+
+
'; - $scorebetw= array (); + $scorebetw = array(); $this->addElement('text', 'endscore[' . $counter . ']', null, array ( 'size' => 5, 'maxlength' => 5, 'id' => 'txta-'.$counter, - 'class' => 'span1', + 'input-size' => 2 )); + $this->addElement('text', 'displaytext[' . $counter . ']', null,array ( 'size' => 40, 'maxlength' => 40, - 'id' => 'txtb-'.$counter, - 'class' => 'span', + 'id' => 'txtb-'.$counter )); - $renderer->setElementTemplate($elementTemplateTwoLabel,'endscore[' . $counter . ']'); - $renderer->setElementTemplate($elementTemplateTwoLabel2,'displaytext[' . $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', '>'); diff --git a/main/inc/lib/formvalidator/FormValidator.class.php b/main/inc/lib/formvalidator/FormValidator.class.php index 3c5b95e81b..9b689a1943 100755 --- a/main/inc/lib/formvalidator/FormValidator.class.php +++ b/main/inc/lib/formvalidator/FormValidator.class.php @@ -108,7 +108,7 @@ class FormValidator extends HTML_QuickForm $renderer->setHeaderTemplate('{header}'); //Set required field template - HTML_QuickForm::setRequiredNote('* ' . get_lang('ThisFieldIsRequired') . ''); + $this->setRequiredNote('* ' . get_lang('ThisFieldIsRequired') . ''); $noteTemplate = <<
@@ -143,13 +143,9 @@ EOT; * {label} -
+
{element} - - {label_3} - -

{label_2}

@@ -158,6 +154,11 @@ EOT; {error}
+
+ + {label_3} + +
'; } @@ -863,6 +864,16 @@ EOT; return $result; } + + /** + * @return null + */ + public static function getDefaultRenderer() + { + return + isset($GLOBALS['_HTML_QuickForm_default_renderer']) ? + $GLOBALS['_HTML_QuickForm_default_renderer'] : null; + } } /** diff --git a/main/inc/lib/pear/HTML/QuickForm/input.php b/main/inc/lib/pear/HTML/QuickForm/input.php index 04e53eaf45..c41786f511 100755 --- a/main/inc/lib/pear/HTML/QuickForm/input.php +++ b/main/inc/lib/pear/HTML/QuickForm/input.php @@ -141,7 +141,7 @@ class HTML_QuickForm_input extends HTML_QuickForm_element * @access public * @return string */ - function toHtml() + public function toHtml() { if ($this->_flagFrozen) { return $this->getFrozenHtml(); diff --git a/main/inc/lib/pear/HTML/QuickForm/text.php b/main/inc/lib/pear/HTML/QuickForm/text.php index c21a8f7236..9c1f44defa 100755 --- a/main/inc/lib/pear/HTML/QuickForm/text.php +++ b/main/inc/lib/pear/HTML/QuickForm/text.php @@ -34,6 +34,8 @@ */ class HTML_QuickForm_text extends HTML_QuickForm_input { + private $inputSize; + /** * Class constructor * @@ -53,11 +55,69 @@ class HTML_QuickForm_text extends HTML_QuickForm_input if (is_array($attributes) || empty($attributes)) { $attributes['class'] = 'form-control'; } + $inputSize = isset($attributes['input-size']) ? $attributes['input-size'] : null; + $this->setInputSize($inputSize); + if (!empty($inputSize)) { + unset($attributes['input-size']); + } - HTML_QuickForm_input::HTML_QuickForm_input($elementName, $elementLabel, $attributes); + parent::__construct($elementName, $elementLabel, $attributes); $this->_persistantFreeze = true; $this->setType('text'); + + $renderer = FormValidator::getDefaultRenderer(); + $renderer->setElementTemplate($this->getTemplate(), $elementName); + } + + /** + * @return string + */ + public function getTemplate() + { + $size = $this->getInputSize(); + $size = empty($size) ? '8' : $size; + + return ' +
+ +
+ {element} + + +

{label_2}

+ + + + {error} + +
+
+ + {label_3} + +
+
'; + } + + + /** + * @return null + */ + public function getInputSize() + { + return $this->inputSize; + } + + /** + * @param null $inputSize + */ + public function setInputSize($inputSize) + { + $this->inputSize = $inputSize; } /** @@ -68,9 +128,9 @@ class HTML_QuickForm_text extends HTML_QuickForm_input * @access public * @return void */ - function setSize($size) + public function setSize($size) { - $this->updateAttributes(array('size'=>$size)); + $this->updateAttributes(array('size' => $size)); } /** @@ -81,8 +141,20 @@ class HTML_QuickForm_text extends HTML_QuickForm_input * @access public * @return void */ - function setMaxlength($maxlength) + public function setMaxlength($maxlength) { - $this->updateAttributes(array('maxlength'=>$maxlength)); - } //end func setMaxlength + $this->updateAttributes(array('maxlength' => $maxlength)); + } + + /** + * @return string + */ + public function toHtml() + { + if ($this->_flagFrozen) { + return $this->getFrozenHtml(); + } else { + return '_getAttrString($this->_attributes) . ' />'; + } + } }