chamilo/chamilo-lms

View on GitHub
public/main/inc/lib/grade_model.lib.php

Summary

Maintainability
A
0 mins
Test Coverage

The method return_form() has an NPath complexity of 3264. The configured NPath complexity threshold is 200.
Open

    public function return_form($url, $action)
    {
        $form = new FormValidator('grades', 'post', $url);

        // Setting the form elements

NPathComplexity

Since: 0.1

The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

Example

class Foo {
    function bar() {
        // lots of complicated code
    }
}

Source https://phpmd.org/rules/codesize.html#npathcomplexity

Missing class import via use statement (line '242', column '28').
Open

                $obj = new GradeModelComponents();

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '74', column '21').
Open

        $form = new FormValidator('grades', 'post', $url);

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '222', column '32').
Open

                    $obj = new GradeModelComponents();

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '202', column '20').
Open

        $obj = new GradeModelComponents();

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

The method update uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

                } else {
                    $obj->update($component);
                }

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

The method return_form uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $form->addButtonCreate(get_lang('Add'));
        }

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

The method fill_grade_model_select_in_form uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                $default = $default_platform_setting;
            }

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

The parameter $default_value is not named in camelCase.
Open

    public function fill_grade_model_select_in_form(&$form, $name = 'gradebook_model_id', ?int $default_value = null)
    {
        if ('false' === api_get_setting('gradebook_enable_grade_model')) {
            return false;
        }

CamelCaseParameterName

Since: 0.2

It is considered best practice to use the camelCase notation to name parameters.

Example

class ClassName {
    public function doSomething($user_name) {
    }
}

Source

Each class must be in a file by itself
Open

class GradeModelComponents extends Model

Method name "GradeModel::get_count" is not in camel caps format
Open

    public function get_count()

Variable "nr_items" is not in valid camel caps format
Open

        $nr_items = 2;

Method name "GradeModel::return_form" is not in camel caps format
Open

    public function return_form($url, $action)

Method name "GradeModel::get_all" is not in camel caps format
Open

    public function get_all(array $options = []): array

Missing function doc comment
Open

    public function get_all(array $options = []): array

Variable "nr_items" is not in valid camel caps format
Open

                $nr_items = count($components);

Method name "GradeModel::get_components" is not in camel caps format
Open

    public function get_components($id)

Variable "default_value" is not in valid camel caps format
Open

                if (!empty($default_value)) {

Expected 1 spaces after parameter type; 3 found
Open

     * @param int|null   $default_value

Variable "grade_model_options" is not in valid camel caps format
Open

            $grade_model_options = ['-1' => get_lang('none')];

Variable "component_array" is not in valid camel caps format
Open

        $component_array = [];

Variable "template_acronym" is not in valid camel caps format
Open

            $template_acronym = '

Variable "template_acronym" is not in valid camel caps format
Open

            $renderer->setElementTemplate($template_acronym, 'components['.$i.'][acronym]');

Variable "grade_models" is not in valid camel caps format
Open

                foreach ($grade_models as $item) {

Variable "component_array" is not in valid camel caps format
Open

        $form->addRule($component_array, get_lang('The sum of all values must be 100'), 'compare_fields', '==@100');

Variable "default_value" is not in valid camel caps format
Open

    public function fill_grade_model_select_in_form(&$form, $name = 'gradebook_model_id', ?int $default_value = null)

Variable "grade_models" is not in valid camel caps format
Open

            if (!empty($grade_models)) {

Variable "default_value" is not in valid camel caps format
Open

                    $default = $default_value;

Variable "grade_model_options" is not in valid camel caps format
Open

                    $grade_model_options[$item['id']] = $item['title'];

Variable "default_platform_setting" is not in valid camel caps format
Open

                $default = $default_platform_setting;

Variable "template_title" is not in valid camel caps format
Open

            $template_title =

Variable "nr_items" is not in valid camel caps format
Open

                '.Display::return_icon('delete.png', get_lang('Delete'), ['id' => 'min-'.($counter), 'style' => 'display: '.(($counter >= $nr_items) ? 'inline' : 'none')]).'

Missing parameter name
Open

     * @param $form

Variable "nr_items" is not in valid camel caps format
Open

                '.Display::return_icon('add.png', get_lang('Add'), ['id' => 'plus-'.($counter + 1), 'style' => 'display: '.(($counter >= $nr_items) ? 'inline' : 'none')]).'

Expected 3 spaces after parameter type; 1 found
Open

     * @param string $name

Variable "grade_models" is not in valid camel caps format
Open

            $grade_models = $this->get_all();

Variable "template_percentage" is not in valid camel caps format
Open

            $template_percentage =

Method name "GradeModel::fill_grade_model_select_in_form" is not in camel caps format
Open

    public function fill_grade_model_select_in_form(&$form, $name = 'gradebook_model_id', ?int $default_value = null)

Variable "template_percentage" is not in valid camel caps format
Open

            $renderer->setElementTemplate($template_percentage, 'components['.$i.'][percentage]');

Missing parameter name
Open

     * @param $id

Variable "default_platform_setting" is not in valid camel caps format
Open

            $default_platform_setting = api_get_setting('gradebook_default_grade_model_id');

Variable "nr_items" is not in valid camel caps format
Open

            '<div id='.$i.' style="display: '.(($i <= $nr_items) ? 'inline' : 'none').';" class="form-group">

Variable "template_title" is not in valid camel caps format
Open

            $renderer->setElementTemplate($template_title, 'components['.$i.'][title]');

Multiple classes defined in a single file
Open

class GradeModelComponents extends Model

Variable "component_array" is not in valid camel caps format
Open

            $component_array[] = 'components['.$i.'][percentage]';

Variable "grade_model_options" is not in valid camel caps format
Open

            $form->addSelect($name, get_lang('Grading model'), $grade_model_options);

Variable "default_platform_setting" is not in valid camel caps format
Open

            if (-1 == $default_platform_setting) {

The variable $component_array is not named in camelCase.
Open

    public function return_form($url, $action)
    {
        $form = new FormValidator('grades', 'post', $url);

        // Setting the form elements

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $template_percentage is not named in camelCase.
Open

    public function return_form($url, $action)
    {
        $form = new FormValidator('grades', 'post', $url);

        // Setting the form elements

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $component_array is not named in camelCase.
Open

    public function return_form($url, $action)
    {
        $form = new FormValidator('grades', 'post', $url);

        // Setting the form elements

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $default_platform_setting is not named in camelCase.
Open

    public function fill_grade_model_select_in_form(&$form, $name = 'gradebook_model_id', ?int $default_value = null)
    {
        if ('false' === api_get_setting('gradebook_enable_grade_model')) {
            return false;
        }

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $grade_models is not named in camelCase.
Open

    public function fill_grade_model_select_in_form(&$form, $name = 'gradebook_model_id', ?int $default_value = null)
    {
        if ('false' === api_get_setting('gradebook_enable_grade_model')) {
            return false;
        }

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $default_value is not named in camelCase.
Open

    public function fill_grade_model_select_in_form(&$form, $name = 'gradebook_model_id', ?int $default_value = null)
    {
        if ('false' === api_get_setting('gradebook_enable_grade_model')) {
            return false;
        }

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $component_array is not named in camelCase.
Open

    public function return_form($url, $action)
    {
        $form = new FormValidator('grades', 'post', $url);

        // Setting the form elements

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $grade_models is not named in camelCase.
Open

    public function fill_grade_model_select_in_form(&$form, $name = 'gradebook_model_id', ?int $default_value = null)
    {
        if ('false' === api_get_setting('gradebook_enable_grade_model')) {
            return false;
        }

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $grade_model_options is not named in camelCase.
Open

    public function fill_grade_model_select_in_form(&$form, $name = 'gradebook_model_id', ?int $default_value = null)
    {
        if ('false' === api_get_setting('gradebook_enable_grade_model')) {
            return false;
        }

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $default_platform_setting is not named in camelCase.
Open

    public function fill_grade_model_select_in_form(&$form, $name = 'gradebook_model_id', ?int $default_value = null)
    {
        if ('false' === api_get_setting('gradebook_enable_grade_model')) {
            return false;
        }

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $nr_items is not named in camelCase.
Open

    public function return_form($url, $action)
    {
        $form = new FormValidator('grades', 'post', $url);

        // Setting the form elements

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $default_value is not named in camelCase.
Open

    public function fill_grade_model_select_in_form(&$form, $name = 'gradebook_model_id', ?int $default_value = null)
    {
        if ('false' === api_get_setting('gradebook_enable_grade_model')) {
            return false;
        }

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $default_platform_setting is not named in camelCase.
Open

    public function fill_grade_model_select_in_form(&$form, $name = 'gradebook_model_id', ?int $default_value = null)
    {
        if ('false' === api_get_setting('gradebook_enable_grade_model')) {
            return false;
        }

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $grade_model_options is not named in camelCase.
Open

    public function fill_grade_model_select_in_form(&$form, $name = 'gradebook_model_id', ?int $default_value = null)
    {
        if ('false' === api_get_setting('gradebook_enable_grade_model')) {
            return false;
        }

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $nr_items is not named in camelCase.
Open

    public function return_form($url, $action)
    {
        $form = new FormValidator('grades', 'post', $url);

        // Setting the form elements

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $nr_items is not named in camelCase.
Open

    public function return_form($url, $action)
    {
        $form = new FormValidator('grades', 'post', $url);

        // Setting the form elements

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $template_acronym is not named in camelCase.
Open

    public function return_form($url, $action)
    {
        $form = new FormValidator('grades', 'post', $url);

        // Setting the form elements

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $template_acronym is not named in camelCase.
Open

    public function return_form($url, $action)
    {
        $form = new FormValidator('grades', 'post', $url);

        // Setting the form elements

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $grade_models is not named in camelCase.
Open

    public function fill_grade_model_select_in_form(&$form, $name = 'gradebook_model_id', ?int $default_value = null)
    {
        if ('false' === api_get_setting('gradebook_enable_grade_model')) {
            return false;
        }

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $nr_items is not named in camelCase.
Open

    public function return_form($url, $action)
    {
        $form = new FormValidator('grades', 'post', $url);

        // Setting the form elements

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $nr_items is not named in camelCase.
Open

    public function return_form($url, $action)
    {
        $form = new FormValidator('grades', 'post', $url);

        // Setting the form elements

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $template_percentage is not named in camelCase.
Open

    public function return_form($url, $action)
    {
        $form = new FormValidator('grades', 'post', $url);

        // Setting the form elements

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $template_title is not named in camelCase.
Open

    public function return_form($url, $action)
    {
        $form = new FormValidator('grades', 'post', $url);

        // Setting the form elements

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $template_title is not named in camelCase.
Open

    public function return_form($url, $action)
    {
        $form = new FormValidator('grades', 'post', $url);

        // Setting the form elements

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $grade_model_options is not named in camelCase.
Open

    public function fill_grade_model_select_in_form(&$form, $name = 'gradebook_model_id', ?int $default_value = null)
    {
        if ('false' === api_get_setting('gradebook_enable_grade_model')) {
            return false;
        }

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The method get_all is not named in camelCase.
Open

    public function get_all(array $options = []): array
    {
        return Database::select(
            '*',
            $this->table,

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method fill_grade_model_select_in_form is not named in camelCase.
Open

    public function fill_grade_model_select_in_form(&$form, $name = 'gradebook_model_id', ?int $default_value = null)
    {
        if ('false' === api_get_setting('gradebook_enable_grade_model')) {
            return false;
        }

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method get_components is not named in camelCase.
Open

    public function get_components($id)
    {
        $obj = new GradeModelComponents();
        if (!empty($id)) {
            return $obj->get_all(['where' => ['grade_model_id = ?' => $id]]);

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method get_count is not named in camelCase.
Open

    public function get_count()
    {
        $row = Database::select(
            'count(*) as count',
            $this->table,

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method return_form is not named in camelCase.
Open

    public function return_form($url, $action)
    {
        $form = new FormValidator('grades', 'post', $url);

        // Setting the form elements

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

There are no issues that match your filters.

Category
Status