Minor - format code

pull/3418/head
Julio Montoya 5 years ago
parent 7492a20bb3
commit 5b86004e73
  1. 20
      main/admin/grade_models.php
  2. 19
      main/inc/lib/grade_model.lib.php

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
$cidReset = true;
@ -8,11 +9,11 @@ $this_section = SECTION_PLATFORM_ADMIN;
api_protect_admin_script();
if (api_get_setting('gradebook_enable_grade_model') != 'true') {
if (api_get_setting('gradebook_enable_grade_model') !== 'true') {
api_not_allowed(true);
}
//Add the JS needed to use the jqgrid
// Add the JS needed to use the jqgrid
$htmlHeadXtra[] = api_get_jqgrid_js();
// setting breadcrumbs
@ -26,7 +27,7 @@ $token = Security::get_token();
if ($action === 'add') {
$interbreadcrumb[] = ['url' => 'grade_models.php', 'name' => get_lang('GradeModel')];
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Add')];
} elseif ($action == 'edit') {
} elseif ($action === 'edit') {
$interbreadcrumb[] = ['url' => 'grade_models.php', 'name' => get_lang('GradeModel')];
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Edit')];
} else {
@ -50,11 +51,8 @@ function plusItem(item) {
function minItem(item) {
if (item != 1) {
document.getElementById(item).style.display = "none";
//document.getElementById("txta-"+item).value = "";
//document.getElementById("txtb-"+item).value = "";
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) {
@ -66,7 +64,7 @@ function minItem(item) {
Display::display_header();
//jqgrid will use this URL to do the selects
// jqgrid will use this URL to do the selects
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_grade_models';
//The order is important you need to check the the $column variable in the model.ajax.php file
@ -201,9 +199,9 @@ switch ($action) {
$obj->display();
break;
}
echo '<script>
$(function () {
$("input").removeClass("form-control");
});
echo '<script>
$(function () {
$("input").removeClass("form-control");
});
</script>';
Display::display_footer();

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**
@ -79,10 +80,10 @@ class GradeModel extends Model
// Setting the form elements
$header = get_lang('Add');
if ($action == 'edit') {
if ($action === 'edit') {
$header = get_lang('Modify');
}
$id = isset($_GET['id']) ? intval($_GET['id']) : '';
$id = isset($_GET['id']) ? (int) $_GET['id'] : '';
$form->addHeader($header);
$form->addHidden('id', $id);
@ -104,14 +105,13 @@ class GradeModel extends Model
// Get components
$nr_items = 2;
$max = 10;
// Setting the defaults
$defaults = $this->get($id);
if ($defaults) {
$components = $this->get_components($defaults['id']);
}
if ('edit' == $action) {
if ('edit' === $action) {
if (!empty($components)) {
$nr_items = count($components);
}
@ -122,7 +122,6 @@ class GradeModel extends Model
$renderer = &$form->defaultRenderer();
$component_array = [];
for ($i = 0; $i <= $max; $i++) {
$counter = $i;
$form->addElement('text', 'components['.$i.'][percentage]', null);
@ -131,7 +130,7 @@ class GradeModel extends Model
$form->addElement('hidden', 'components['.$i.'][id]', null);
$template_percentage =
'<div id='.$i.' style="display: '.(($i <= $nr_items) ? 'inline' : 'none').';" class="form-group">
'<div id='.$i.' style="display: '.(($i <= $nr_items) ? 'inline' : 'none').';" class="form-group">
<label for="" class="col-sm-2 control-label">
{label}
</label>
@ -168,11 +167,11 @@ class GradeModel extends Model
$component_array[] = 'components['.$i.'][percentage]';
}
//New rule added in the formvalidator compare_fields that filters a group of fields in order to compare with the wanted value
// New rule added in the formvalidator compare_fields that filters a group of fields in order to compare with the wanted value
$form->addRule($component_array, get_lang('AllMustWeight100'), 'compare_fields', '==@100');
$form->addElement('label', '', get_lang('AllMustWeight100'));
if ($action == 'edit') {
if ($action === 'edit') {
$form->addButtonUpdate(get_lang('Modify'));
} else {
$form->addButtonCreate(get_lang('Add'));
@ -326,8 +325,6 @@ class GradeModelComponents extends Model
*/
public function save($params, $showQuery = false)
{
$id = parent::save($params, $showQuery);
return $id;
return parent::save($params, $showQuery);
}
}

Loading…
Cancel
Save