chamilo/chamilo-lms

View on GitHub
public/main/exercise/export/qti2/qti2_export.php

Summary

Maintainability
A
0 mins
Test Coverage

Missing class import via use statement (line '435', column '16').
Open

    $ims = new ImsSection($exercise);

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 '469', column '16').
Open

    $ims = new ImsAssessmentItem($question);

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 '53', column '29').
Open

            $category = new TestCategory();

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 '450', column '21').
Open

    $question = new Ims2Question();

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 '431', column '21').
Open

    $exercise = new Exercise();

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 export_duration uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            return '';
        }

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 assigning values to variables in if clauses and the like (line '181', column '13').
Open

    public function export_duration()
    {
        if ($max_time = $this->exercise->selectTimeLimit()) {
            // return exercise duration in ISO8601 format.
            $minutes = floor($max_time / 60);

IfStatementAssignment

Since: 2.7.0

Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

Example

class Foo
{
    public function bar($flag)
    {
        if ($foo = 'bar') { // possible typo
            // ...
        }
        if ($baz = 0) { // always false
            // ...
        }
    }
}

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

Avoid assigning values to variables in if clauses and the like (line '213', column '13').
Open

    public function export_ordering()
    {
        $out = '';
        if ($n = $this->exercise->getShuffle()) {
            $out .= '<selection_ordering>'

IfStatementAssignment

Since: 2.7.0

Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

Example

class Foo
{
    public function bar($flag)
    {
        if ($foo = 'bar') { // possible typo
            // ...
        }
        if ($baz = 0) { // always false
            // ...
        }
    }
}

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

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

        } else {
            $out .= '<selection_ordering sequence_type="Normal">'."\n"
                 ."  <selection />\n"
                 ."</selection_ordering>\n";
        }

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

Each class must be in a file by itself
Open

class ImsItem

Each class must be in a file by itself
Open

class ImsSection

Method name "ImsSection::export_duration" is not in camel caps format
Open

    public function export_duration()

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

            $seconds = $max_time % 60;

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

function export_question_qti($questionId, $standalone = true)

Method name "ImsSection::end_section" is not in camel caps format
Open

    public function end_section()

Method name "ImsAssessmentItem::end_item" is not in camel caps format
Open

    public function end_item()

Missing function doc comment
Open

    public function start_section()

Method name "ImsSection::export_ordering" is not in camel caps format
Open

    public function export_ordering()

Method name "ImsItem::start_presentation" is not in camel caps format
Open

    public function start_presentation()

Method name "ImsItem::end_processing" is not in camel caps format
Open

    public function end_processing()

Method name "ImsAssessmentItem::end_item_body" is not in camel caps format
Open

    public function end_item_body()

Method name "ImsSection::export_presentation" is not in camel caps format
Open

    public function export_presentation()

Multiple classes defined in a single file
Open

class ImsItem

Method name "ImsAssessmentItem::start_item" is not in camel caps format
Open

    public function start_item()

Missing parameter name
Open

 * @param $text

Method name "ImsSection::start_section" is not in camel caps format
Open

    public function start_section()

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

function formatExerciseQtiText($text)

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

function cleanAttribute($text)

Method name "ImsAssessmentItem::start_item_body" is not in camel caps format
Open

    public function start_item_body()

Method name "ImsAssessmentItem::add_response_processing" is not in camel caps format
Open

    public function add_response_processing()

Method name "ImsItem::end_presentation" is not in camel caps format
Open

    public function end_presentation()

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

function formatExerciseQtiDescription($text)

Method name "ImsItem::start_item" is not in camel caps format
Open

    public function start_item()

Missing function doc comment
Open

    public function end_section()

Method name "ImsItem::start_processing" is not in camel caps format
Open

    public function start_processing()

Multiple classes defined in a single file
Open

class ImsSection

Missing function doc comment
Open

    public function export_duration()

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

            $minutes = floor($max_time / 60);

Method name "ImsItem::end_item" is not in camel caps format
Open

    public function end_item()

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

        if ($max_time = $this->exercise->selectTimeLimit()) {

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

function export_exercise_to_qti($exerciseId, $standalone = true)

The variable $max_time is not named in camelCase.
Open

    public function export_duration()
    {
        if ($max_time = $this->exercise->selectTimeLimit()) {
            // return exercise duration in ISO8601 format.
            $minutes = floor($max_time / 60);

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

    public function export_duration()
    {
        if ($max_time = $this->exercise->selectTimeLimit()) {
            // return exercise duration in ISO8601 format.
            $minutes = floor($max_time / 60);

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

    public function export_duration()
    {
        if ($max_time = $this->exercise->selectTimeLimit()) {
            // return exercise duration in ISO8601 format.
            $minutes = floor($max_time / 60);

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

    public function add_response_processing()
    {
        return '  <responseProcessing template="http://www.imsglobal.org/question/qti_v2p1/rptemplates/map_correct"/>'."\n";
    }

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

    public function end_item()
    {
        return "</item>\n";
    }

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

    public function start_item_body()
    {
        return '  <itemBody>'."\n";
    }

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

    public function end_item_body()
    {
        return "  </itemBody>\n";
    }

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

    public function start_section()
    {
        return '<section
            ident = "EXO_'.$this->exercise->getId().'"
            title = "'.cleanAttribute(formatExerciseQtiDescription($this->exercise->selectTitle())).'"

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

    public function end_section()
    {
        return "</section>\n";
    }

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

    public function end_presentation()
    {
        return "</flow></presentation>\n";
    }

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

    public function export_ordering()
    {
        $out = '';
        if ($n = $this->exercise->getShuffle()) {
            $out .= '<selection_ordering>'

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

    public function start_item()
    {
        return '<item title="'.cleanAttribute(formatExerciseQtiDescription($this->question->selectTitle())).'" ident="'.$this->questionIdent.'">'."\n";
    }

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

    public function start_presentation()
    {
        return '<presentation label="'.$this->questionIdent.'"><flow>'."\n"
            .'<material><mattext>'.formatExerciseQtiDescription($this->question->selectDescription())."</mattext></material>\n";
    }

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

    public function export_duration()
    {
        if ($max_time = $this->exercise->selectTimeLimit()) {
            // return exercise duration in ISO8601 format.
            $minutes = floor($max_time / 60);

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

    public function end_processing()
    {
        return "</resprocessing>\n";
    }

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

    public function start_item()
    {
        $categoryTitle = '';
        if (!empty($this->question->category)) {
            $category = new TestCategory();

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

    public function export_presentation()
    {
        return "<presentation_material><flow_mat><material>\n"
             .'  <mattext><![CDATA['.formatExerciseQtiDescription($this->exercise->selectDescription())."]]></mattext>\n"
             ."</material></flow_mat></presentation_material>\n";

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

    public function start_processing()
    {
        return '<resprocessing><outcomes><decvar vartype="Integer" defaultval="0" /></outcomes>'."\n";
    }

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

    public function end_item()
    {
        return "</assessmentItem>\n";
    }

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