Minor: code climate

pull/4037/head
Angel Fernando Quiroz Campos 4 years ago
parent 5b619c43f0
commit aa20546a81
  1. 2
      public/main/exercise/Draggable.php
  2. 2
      public/main/exercise/MatchingDraggable.php
  3. 2
      public/main/exercise/MultipleAnswerTrueFalseDegreeCertainty.php
  4. 2
      public/main/exercise/calculated_answer.class.php
  5. 10
      public/main/exercise/exercise_show.php
  6. 2
      public/main/exercise/fill_blanks.class.php
  7. 2
      public/main/exercise/freeanswer.class.php
  8. 2
      public/main/exercise/global_multiple_answer.class.php
  9. 2
      public/main/exercise/matching.class.php
  10. 2
      public/main/exercise/multiple_answer.class.php
  11. 2
      public/main/exercise/multiple_answer_combination.class.php
  12. 2
      public/main/exercise/multiple_answer_true_false.class.php
  13. 2
      public/main/exercise/oral_expression.class.php
  14. 2
      public/main/exercise/question.class.php
  15. 2
      public/main/exercise/unique_answer.class.php
  16. 2
      public/main/exercise/unique_answer_no_option.class.php
  17. 6
      public/main/gradebook/lib/GradebookUtils.php
  18. 2
      public/main/gradebook/lib/fe/flatviewtable.class.php
  19. 46
      public/main/gradebook/lib/fe/gradebooktable.class.php
  20. 2
      public/main/gradebook/lib/fe/resulttable.class.php
  21. 2
      public/main/gradebook/lib/fe/usertable.class.php
  22. 2
      public/main/inc/lib/SortableTableFromArray.php
  23. 2
      public/main/inc/lib/SortableTableFromArrayConfig.php
  24. 26
      public/main/inc/lib/exercise.lib.php
  25. 4
      public/main/inc/lib/sortable_table.class.php

@ -202,7 +202,7 @@ class Draggable extends Question
public function return_header(Exercise $exercise, $counter = null, $score = [])
{
$header = parent::return_header($exercise, $counter, $score);
$header .= '<table class="'.$this->question_table_class.'"><tr>';
$header .= '<table class="'.$this->questionTableClass.'"><tr>';
if ($exercise->showExpectedChoice()) {
$header .= '<th>'.get_lang('Your choice').'</th>';

@ -252,7 +252,7 @@ class MatchingDraggable extends Question
public function return_header(Exercise $exercise, $counter = null, $score = [])
{
$header = parent::return_header($exercise, $counter, $score);
$header .= '<table class="matching '.$this->question_table_class.'"><tr>';
$header .= '<table class="matching '.$this->questionTableClass.'"><tr>';
$header .= '<th>'.get_lang('Elements list').'</th>';
if (!in_array($exercise->results_disabled, [
RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER,

@ -300,7 +300,7 @@ class MultipleAnswerTrueFalseDegreeCertainty extends Question
public function return_header(Exercise $exercise, $counter = null, $score = [])
{
$header = parent::return_header($exercise, $counter, $score);
$header .= '<table class="'.$this->question_table_class.'"><tr>';
$header .= '<table class="'.$this->questionTableClass.'"><tr>';
$header .= '<th>'.get_lang('Your choice').'</th>';
if ($exercise->showExpectedChoiceColumn()) {

@ -252,7 +252,7 @@ class CalculatedAnswer extends Question
public function return_header(Exercise $exercise, $counter = null, $score = [])
{
$header = parent::return_header($exercise, $counter, $score);
$header .= '<table class="'.$this->question_table_class.'"><tr>';
$header .= '<table class="'.$this->questionTableClass.'"><tr>';
$header .= '<th>'.get_lang('Answer').'</th>';
if ($exercise->showExpectedChoice()) {
$header .= '<th>'.get_lang('Your choice').'</th>';

@ -854,20 +854,20 @@ foreach ($questionList as $questionId) {
$i++;
$contents = ob_get_clean();
$question_content = '<div class="question-answer-result">';
$questionContent = '<div class="question-answer-result">';
if ($show_results && $objQuestionTmp) {
$objQuestionTmp->export = 'export' === $action;
// Shows question title an description
$question_content .= $objQuestionTmp->return_header(
$questionContent .= $objQuestionTmp->return_header(
$objExercise,
$counter,
$score
);
}
$counter++;
$question_content .= $contents;
$question_content .= '</div>';
$exercise_content .= Display::panel($question_content);
$questionContent .= $contents;
$questionContent .= '</div>';
$exercise_content .= Display::panel($questionContent);
} // end of large foreach on questions
$totalScoreText = '';

@ -488,7 +488,7 @@ class FillBlanks extends Question
public function return_header(Exercise $exercise, $counter = null, $score = [])
{
$header = parent::return_header($exercise, $counter, $score);
$header .= '<table class="'.$this->question_table_class.'">
$header .= '<table class="'.$this->questionTableClass.'">
<tr>
<th>'.get_lang('Answer').'</th>
</tr>';

@ -46,7 +46,7 @@ class FreeAnswer extends Question
{
$score['revised'] = $this->isQuestionWaitingReview($score);
$header = parent::return_header($exercise, $counter, $score);
$header .= '<table class="'.$this->question_table_class.'" >
$header .= '<table class="'.$this->questionTableClass.'" >
<tr>
<th>'.get_lang('Answer').'</th>
</tr>';

@ -244,7 +244,7 @@ class GlobalMultipleAnswer extends Question
public function return_header(Exercise $exercise, $counter = null, $score = [])
{
$header = parent::return_header($exercise, $counter, $score);
$header .= '<table class="'.$this->question_table_class.'"><tr>';
$header .= '<table class="'.$this->questionTableClass.'"><tr>';
if (!in_array($exercise->results_disabled, [RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER])) {
$header .= '<th>'.get_lang('Your choice').'</th>';

@ -271,7 +271,7 @@ class Matching extends Question
public function return_header(Exercise $exercise, $counter = null, $score = [])
{
$header = parent::return_header($exercise, $counter, $score);
$header .= '<table class="'.$this->question_table_class.'">';
$header .= '<table class="'.$this->questionTableClass.'">';
$header .= '<tr>';
$header .= '<th>'.get_lang('Elements list').'</th>';
if (!in_array($exercise->results_disabled, [

@ -212,7 +212,7 @@ class MultipleAnswer extends Question
public function return_header(Exercise $exercise, $counter = null, $score = [])
{
$header = parent::return_header($exercise, $counter, $score);
$header .= '<table class="'.$this->question_table_class.'"><tr>';
$header .= '<table class="'.$this->questionTableClass.'"><tr>';
$header .= '<th>'.get_lang('Your choice').'</th>';

@ -210,7 +210,7 @@ class MultipleAnswerCombination extends Question
public function return_header(Exercise $exercise, $counter = null, $score = [])
{
$header = parent::return_header($exercise, $counter, $score);
$header .= '<table class="'.$this->question_table_class.'"><tr>';
$header .= '<table class="'.$this->questionTableClass.'"><tr>';
if (!in_array($exercise->results_disabled, [
RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER,

@ -302,7 +302,7 @@ class MultipleAnswerTrueFalse extends Question
public function return_header(Exercise $exercise, $counter = null, $score = [])
{
$header = parent::return_header($exercise, $counter, $score);
$header .= '<table class="'.$this->question_table_class.'"><tr>';
$header .= '<table class="'.$this->questionTableClass.'"><tr>';
if (!in_array($exercise->results_disabled, [
RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER,

@ -57,7 +57,7 @@ class OralExpression extends Question
{
$score['revised'] = $this->isQuestionWaitingReview($score);
$header = parent::return_header($exercise, $counter, $score);
$header .= '<table class="'.$this->question_table_class.'">
$header .= '<table class="'.$this->questionTableClass.'">
<tr>
<th>'.get_lang('Answer').'</th>
</tr>';

@ -38,7 +38,7 @@ abstract class Question
public $feedback;
public $typePicture = 'new_question.png';
public $explanationLangVar = '';
public $question_table_class = 'table table-striped question-answer-result__detail';
public $questionTableClass = 'table table-striped question-answer-result__detail';
public $questionTypeWithFeedback;
public $extra;
public $export = false;

@ -436,7 +436,7 @@ class UniqueAnswer extends Question
public function return_header(Exercise $exercise, $counter = null, $score = [])
{
$header = parent::return_header($exercise, $counter, $score);
$header .= '<table class="'.$this->question_table_class.'"><tr>';
$header .= '<table class="'.$this->questionTableClass.'"><tr>';
$header .= '<th>'.get_lang('Your choice').'</th>';
if ($exercise->showExpectedChoiceColumn()) {

@ -391,7 +391,7 @@ class UniqueAnswerNoOption extends Question
public function return_header(Exercise $exercise, $counter = null, $score = [])
{
$header = parent::return_header($exercise, $counter, $score);
$header .= '<table class="'.$this->question_table_class.'"><tr>';
$header .= '<table class="'.$this->questionTableClass.'"><tr>';
if (!in_array($exercise->results_disabled, [
RESULT_DISABLE_SHOW_ONLY_IN_CORRECT_ANSWER,

@ -1114,15 +1114,15 @@ class GradebookUtils
}
/**
* @param string[] $list_values
* @param string[] $listValues
*
* @return string
*/
public static function score_badges($list_values)
public static function scoreBadges($listValues)
{
$counter = 1;
$badges = [];
foreach ($list_values as $value) {
foreach ($listValues as $value) {
$class = 'warning';
if (1 == $counter) {
$class = 'success';

@ -330,7 +330,7 @@ class FlatViewTable extends SortableTable
*/
public function get_table_data(
$from = 1,
$per_page = null,
$perPage = null,
$column = null,
$direction = null,
$sort = null

@ -287,14 +287,14 @@ class GradebookTable extends SortableTable
* Function used by SortableTable to generate the data to display.
*
* @param int $from
* @param int $per_page
* @param int $perPage
* @param int $column
* @param string $direction
* @param int $sort
*
* @return array|mixed
*/
public function get_table_data($from = 1, $per_page = null, $column = null, $direction = null, $sort = null)
public function get_table_data($from = 1, $perPage = null, $column = null, $direction = null, $sort = null)
{
//variables load in index.php
global $certificate_min_score;
@ -377,7 +377,7 @@ class GradebookTable extends SortableTable
'ORDER BY id'
);
$total_categories_weight = 0;
$totalCategoriesWeight = 0;
$scoredisplay = ScoreDisplay::instance();
$totalBest = [0, 0];
$totalAverage = [0, 0];
@ -433,7 +433,7 @@ class GradebookTable extends SortableTable
$this->dataForGraph['categories'][] = $item->get_name();
$main_categories[$item->get_id()]['weight'] = $item->get_weight();
$total_categories_weight += $item->get_weight();
$totalCategoriesWeight += $item->get_weight();
// Description.
if (false == $this->exportToPdf) {
@ -461,7 +461,7 @@ class GradebookTable extends SortableTable
}
}
$category_weight = $item->get_weight();
$categoryWeight = $item->get_weight();
if ($this->teacherView) {
$weight_total_links += $data[3];
}
@ -598,7 +598,7 @@ class GradebookTable extends SortableTable
false,
$this->studentList
);
$total_weight = 0;
$totalWeight = 0;
// Links.
foreach ($data_array2 as $data) {
@ -631,7 +631,7 @@ class GradebookTable extends SortableTable
}
$weight = $data[3];
$total_weight += $weight;
$totalWeight += $weight;
// Weight
if ($showWeight) {
@ -696,20 +696,20 @@ class GradebookTable extends SortableTable
if (!empty($data_array)) {
if ($this->teacherView) {
// Compare the category weight to the sum of all weights inside the category
if (intval($total_weight) == $category_weight) {
if (intval($totalWeight) == $categoryWeight) {
$label = null;
$total = GradebookUtils::score_badges(
$total = GradebookUtils::scoreBadges(
[
$total_weight.' / '.$category_weight,
$totalWeight.' / '.$categoryWeight,
'100',
]
);
} else {
$label = Display::return_icon(
'warning.png',
sprintf(get_lang('The sum of all weights of activities must be %s'), $category_weight)
sprintf(get_lang('The sum of all weights of activities must be %s'), $categoryWeight)
);
$total = Display::label($total_weight.' / '.$category_weight, 'warning');
$total = Display::label($totalWeight.' / '.$categoryWeight, 'warning');
}
$row = [
null,
@ -727,13 +727,13 @@ class GradebookTable extends SortableTable
}
} //end looping categories
$main_weight = 0;
$mainWeight = 0;
if (count($main_cat) > 1) {
/** @var Category $myCat */
foreach ($main_cat as $myCat) {
$myParentId = $myCat->get_parent_id();
if (0 == $myParentId) {
$main_weight = (int) $myCat->get_weight();
$mainWeight = (int) $myCat->get_weight();
}
}
}
@ -741,15 +741,15 @@ class GradebookTable extends SortableTable
if ($this->teacherView) {
// Total for teacher.
if (count($main_cat) > 1) {
if (intval($total_categories_weight) == $main_weight) {
$total = GradebookUtils::score_badges(
if (intval($totalCategoriesWeight) == $mainWeight) {
$total = GradebookUtils::scoreBadges(
[
$total_categories_weight.' / '.$main_weight,
$totalCategoriesWeight.' / '.$mainWeight,
'100',
]
);
} else {
$total = Display::label($total_categories_weight.' / '.$main_weight, 'warning');
$total = Display::label($totalCategoriesWeight.' / '.$mainWeight, 'warning');
}
$row = [
null,
@ -764,7 +764,7 @@ class GradebookTable extends SortableTable
$showPercentage = false === $this->datagen->hidePercentage;
// Total for student.
if (count($main_cat) > 1) {
$main_weight = (int) $main_cat[0]->get_weight();
$mainWeight = (int) $main_cat[0]->get_weight();
$global = null;
$average = null;
$myTotal = 0;
@ -777,7 +777,7 @@ class GradebookTable extends SortableTable
$totalResult[0] = $myTotal;
// Overwrite main weight
$totalResult[1] = $main_weight;
$totalResult[1] = $mainWeight;
if (!empty($model)) {
$totalResult = ExerciseLib::show_score($totalResult[0], $totalResult[1], false);
@ -792,7 +792,7 @@ class GradebookTable extends SortableTable
);
if ($useExerciseScoreInTotal) {
$totalResult = ExerciseLib::show_score($myTotal, $main_weight, false);
$totalResult = ExerciseLib::show_score($myTotal, $mainWeight, false);
}
}
@ -806,7 +806,7 @@ class GradebookTable extends SortableTable
}
if ($showWeight) {
$row[] = $main_weight;
$row[] = $mainWeight;
}
$row[] = $totalResult;
@ -865,7 +865,7 @@ class GradebookTable extends SortableTable
$totalBest = $defaultData[$categoryId]['best'];
} else {
// Overwrite main weight
$totalBest[1] = $main_weight;
$totalBest[1] = $mainWeight;
$defaultData[$categoryId]['best'] = $totalBest;
}

@ -89,7 +89,7 @@ class ResultTable extends SortableTable
*/
public function get_table_data(
$from = 1,
$per_page = null,
$perPage = null,
$column = null,
$direction = null,
$sort = null

@ -49,7 +49,7 @@ class UserTable extends SortableTable
/**
* Function used by SortableTable to generate the data to display.
*/
public function get_table_data($from = 1, $per_page = null, $column = null, $direction = null, $sort = null)
public function get_table_data($from = 1, $perPage = null, $column = null, $direction = null, $sort = null)
{
$scoredisplay = ScoreDisplay::instance();

@ -52,7 +52,7 @@ class SortableTableFromArray extends SortableTable
*/
public function get_table_data(
$from = 1,
$per_page = null,
$perPage = null,
$column = null,
$direction = null,
$sort = true

@ -71,7 +71,7 @@ class SortableTableFromArrayConfig extends SortableTable
*/
public function get_table_data(
$from = 1,
$per_page = null,
$perPage = null,
$column = null,
$direction = null,
$sort = true

@ -4195,7 +4195,7 @@ EOT;
$counter = 1;
$total_score = $total_weight = 0;
$exercise_content = null;
$exerciseContent = null;
// Hide results
$show_results = false;
@ -4539,36 +4539,36 @@ EOT;
}
$contents = ob_get_clean();
$question_content = '';
$questionContent = '';
if ($show_results) {
$question_content = '<div class="question-answer-result">';
$questionContent = '<div class="question-answer-result">';
if (false === $showQuestionScore) {
$score = [];
}
// Shows question title an description
$question_content .= $objQuestionTmp->return_header(
$questionContent .= $objQuestionTmp->return_header(
$objExercise,
$counter,
$score
);
}
$counter++;
$question_content .= $contents;
$questionContent .= $contents;
if ($show_results) {
$question_content .= '</div>';
$questionContent .= '</div>';
}
$calculatedScore['question_content'] = $question_content;
$calculatedScore['question_content'] = $questionContent;
$attemptResult[] = $calculatedScore;
if ($objExercise->showExpectedChoice()) {
$exercise_content .= Display::panel($question_content);
$exerciseContent .= Display::panel($questionContent);
} else {
// $show_all_but_expected_answer should not happen at
// the same time as $show_results
if ($show_results && !$show_only_score) {
$exercise_content .= Display::panel($question_content);
$exerciseContent .= Display::panel($questionContent);
}
}
}
@ -4641,14 +4641,14 @@ EOT;
}
if ($show_all_but_expected_answer) {
$exercise_content .= Display::return_message(get_lang('Note: This test has been setup to hide the expected answers.'));
$exerciseContent .= Display::return_message(get_lang('Note: This test has been setup to hide the expected answers.'));
}
// Remove audio auto play from questions on results page - refs BT#7939
$exercise_content = preg_replace(
$exerciseContent = preg_replace(
['/autoplay[\=\".+\"]+/', '/autostart[\=\".+\"]+/'],
'',
$exercise_content
$exerciseContent
);
echo $totalScoreText;
@ -4661,7 +4661,7 @@ EOT;
echo Display::div($objExercise->description, ['class' => 'exercise_description']);
}
echo $exercise_content;
echo $exerciseContent;
if (!$show_only_score) {
echo $totalScoreText;
}

@ -1098,7 +1098,7 @@ class SortableTable extends HTML_Table
* function has the same parameters as defined here.
*
* @param int $from index of the first item to return
* @param int $per_page The number of items to return
* @param int $perPage The number of items to return
* @param int $column The number of the column on which the data should be
* @param bool $sort Whether to sort or not
* sorted
@ -1109,7 +1109,7 @@ class SortableTable extends HTML_Table
*/
public function get_table_data(
$from = null,
$per_page = null,
$perPage = null,
$column = null,
$direction = null,
$sort = null

Loading…
Cancel
Save