chamilo/chamilo-lms

View on GitHub
public/main/exercise/question_create.php

Summary

Maintainability
A
0 mins
Test Coverage

Avoid using undefined variables such as '$valid_question_types' which will lead to PHP notices.
Open

        $valid_question_types[] = $key;

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

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

Avoid using undefined variables such as '$valid_question_types' which will lead to PHP notices.
Open

    if (in_array($parameter, $valid_question_types)) {

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

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

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

    } else {
        return false;
    }

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

Avoid unused local variables such as '$value'.
Open

    foreach ($question_list as $key => $value) {

UnusedLocalVariable

Since: 0.2

Detects when a local variable is declared and/or assigned, but not used.

Example

class Foo {
    public function doSomething()
    {
        $i = 5; // Unused
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

Consider putting global function "check_question_type" in a static class
Open

function check_question_type($parameter)

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

    $question_list_options,

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

    $exercise_id = (int) ($values['exercise']);

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

    $row_feedback_type = Database::fetch_row($rs_feedback_type);

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

    $row_feedback_type = Database::fetch_row($rs_feedback_type);

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

    $feedback_type = $row_feedback_type[0];

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

    if ((HOT_SPOT_DELINEATION == $answer_type && 1 != $feedback_type) ||

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

        (1 == $feedback_type && (HOT_SPOT_DELINEATION != $answer_type && UNIQUE_ANSWER != $answer_type))) {

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

    foreach ($question_list as $key => $value) {

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

    $rs_feedback_type = Database::query($sql);

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

    $sql = "SELECT feedback_type FROM $tbl_exercises

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

        (1 == $feedback_type && (HOT_SPOT_DELINEATION != $answer_type && UNIQUE_ANSWER != $answer_type))) {

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

        (1 == $feedback_type && (HOT_SPOT_DELINEATION != $answer_type && UNIQUE_ANSWER != $answer_type))) {

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

    $question_list = Question::getQuestionTypeList();

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

$question_list_options = [];

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

    $question_list_options[$key] = addslashes(get_lang($value[1]));

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

$session_id = api_get_session_id();

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

    $feedback_type = $row_feedback_type[0];

Missing function doc comment
Open

function check_question_type($parameter)

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

    $answer_type = $values['question_type_hidden'];

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

            WHERE iid = '$exercise_id'";

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

foreach ($question_list as $key => $value) {

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

$course_id = api_get_course_int_id();

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

$this_section = SECTION_COURSES;

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

    if ((HOT_SPOT_DELINEATION == $answer_type && 1 != $feedback_type) ||

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

    header('Location: admin.php?exerciseId='.$values['exercise'].'&newQuestion=yes&isContent='.$values['is_content'].'&answerType='.$answer_type);

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

        $valid_question_types[] = $key;

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

$question_list = Question::getQuestionTypeList();

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

$tbl_exercises = Database::get_course_table(TABLE_QUIZ_TEST);

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

    if (in_array($parameter, $valid_question_types)) {

The variable $question_list is not named in camelCase.
Open

function check_question_type($parameter)
{
    $question_list = Question::getQuestionTypeList();
    foreach ($question_list as $key => $value) {
        $valid_question_types[] = $key;

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 $valid_question_types is not named in camelCase.
Open

function check_question_type($parameter)
{
    $question_list = Question::getQuestionTypeList();
    foreach ($question_list as $key => $value) {
        $valid_question_types[] = $key;

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 $question_list is not named in camelCase.
Open

function check_question_type($parameter)
{
    $question_list = Question::getQuestionTypeList();
    foreach ($question_list as $key => $value) {
        $valid_question_types[] = $key;

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 $valid_question_types is not named in camelCase.
Open

function check_question_type($parameter)
{
    $question_list = Question::getQuestionTypeList();
    foreach ($question_list as $key => $value) {
        $valid_question_types[] = $key;

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

There are no issues that match your filters.

Category
Status