diff --git a/main/admin/grade_models.php b/main/admin/grade_models.php index 32bfe79452..9098b05a6c 100755 --- a/main/admin/grade_models.php +++ b/main/admin/grade_models.php @@ -48,6 +48,7 @@ function plusItem(item) { document.getElementById("plus-"+(item+1)).style.display = "inline"; //document.getElementById("txta-"+(item)).value = "100"; //document.getElementById("txta-"+(item-1)).value = ""; + $("input").removeClass("form-control"); } } @@ -59,15 +60,17 @@ function minItem(item) { document.getElementById("plus-"+item).style.display = "inline"; document.getElementById("min-"+(item-1)).style.display = "inline"; //document.getElementById("txta-"+(item-1)).value = "100"; + $("input").removeClass("form-control"); } if (item = 1) { document.getElementById("min-"+(item)).style.display = "none"; + $("input").removeClass("form-control"); } } '; // The header. -Display::display_header($tool_name); +Display::display_header(); //jqgrid will use this URL to do the selects $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_grade_models'; @@ -168,4 +171,5 @@ switch ($action) { $obj->display(); break; } +echo ''; Display :: display_footer(); diff --git a/main/inc/lib/formvalidator/Rule/CompareFields.php b/main/inc/lib/formvalidator/Rule/CompareFields.php index f36669f045..967039379c 100755 --- a/main/inc/lib/formvalidator/Rule/CompareFields.php +++ b/main/inc/lib/formvalidator/Rule/CompareFields.php @@ -13,7 +13,7 @@ class HTML_QuickForm_Compare_Fields extends HTML_QuickForm_Rule_Compare * @param string the value to compare * @return boolean True if date is valid */ - function validate($values, $operator_and_max_value) { + function validate($values = [], $operator_and_max_value = null) { if (is_array($values) && !empty($values) && !empty($operator_and_max_value)) { $final_value = 0; foreach ($values as $value) { diff --git a/main/inc/lib/grade_model.lib.php b/main/inc/lib/grade_model.lib.php index 1f5ac7c654..2fe1c89221 100755 --- a/main/inc/lib/grade_model.lib.php +++ b/main/inc/lib/grade_model.lib.php @@ -106,8 +106,9 @@ class GradeModel extends Model // Setting the defaults $defaults = $this->get($id); - - $components = $this->get_components($defaults['id']); + if ($defaults) { + $components = $this->get_components($defaults['id']); + } if ($action == 'edit') { if (!empty($components)) { @@ -143,21 +144,20 @@ class GradeModel extends Model $template_title = ' {element} {error} - '.get_lang('Add').' + '.Display::return_icon('add.png', get_lang('Add'), ['id' => 'plus-' . ($counter+1), 'style' => 'display: '.(($counter>=$nr_items) ? 'inline':'none') ]).' - '.get_lang('Delete').' + '.Display::return_icon('delete.png', get_lang('Delete'), ['id' => 'min-' . ($counter), 'style' => 'display: '.(($counter>=$nr_items) ? 'inline':'none') ]).'

'; - $renderer->setElementTemplate($template_title, 'components['.$i.'][title]'); $renderer->setElementTemplate($template_percentage, 'components['.$i.'][percentage]'); $renderer->setElementTemplate($template_acronym, 'components['.$i.'][acronym]'); if ($i == 0) { $form->addRule('components['.$i.'][percentage]', get_lang('ThisFieldIsRequired'), 'required'); - $form->addRule('components['.$i.'][title]', get_lang('ThisFieldIsRequired'), 'required'); $form->addRule('components['.$i.'][acronym]', get_lang('ThisFieldIsRequired'), 'required'); + $form->addRule('components['.$i.'][title]', get_lang('ThisFieldIsRequired'), 'required'); } $form->addRule('components['.$i.'][percentage]', get_lang('OnlyNumbers'), 'numeric'); @@ -187,7 +187,6 @@ class GradeModel extends Model $counter++; } } - $form->setDefaults($defaults); // Setting the rules