Merge pull request #4037 from AngelFQC/master-css

Fix CSS in exercises page results
pull/4042/head
Angel Fernando Quiroz Campos 4 years ago committed by GitHub
commit dd8cf8498a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 32
      assets/css/app.scss
  2. 58
      assets/css/scss/_exercise.scss
  3. 4
      public/main/exercise/Draggable.php
  4. 12
      public/main/exercise/MatchingDraggable.php
  5. 10
      public/main/exercise/MultipleAnswerTrueFalseDegreeCertainty.php
  6. 22
      public/main/exercise/UniqueAnswerImage.php
  7. 4
      public/main/exercise/calculated_answer.class.php
  8. 67
      public/main/exercise/exercise.class.php
  9. 10
      public/main/exercise/exercise_show.php
  10. 2
      public/main/exercise/fill_blanks.class.php
  11. 2
      public/main/exercise/freeanswer.class.php
  12. 4
      public/main/exercise/global_multiple_answer.class.php
  13. 14
      public/main/exercise/matching.class.php
  14. 4
      public/main/exercise/multiple_answer.class.php
  15. 4
      public/main/exercise/multiple_answer_combination.class.php
  16. 8
      public/main/exercise/multiple_answer_true_false.class.php
  17. 2
      public/main/exercise/oral_expression.class.php
  18. 9
      public/main/exercise/question.class.php
  19. 4
      public/main/exercise/unique_answer.class.php
  20. 4
      public/main/exercise/unique_answer_no_option.class.php
  21. 8
      public/main/gradebook/lib/GradebookUtils.php
  22. 2
      public/main/gradebook/lib/fe/flatviewtable.class.php
  23. 46
      public/main/gradebook/lib/fe/gradebooktable.class.php
  24. 2
      public/main/gradebook/lib/fe/resulttable.class.php
  25. 2
      public/main/gradebook/lib/fe/usertable.class.php
  26. 2
      public/main/inc/lib/SortableTableFromArray.php
  27. 2
      public/main/inc/lib/SortableTableFromArrayConfig.php
  28. 39
      public/main/inc/lib/display.lib.php
  29. 32
      public/main/inc/lib/exercise.lib.php
  30. 6
      public/main/inc/lib/exercise_show_functions.lib.php
  31. 4
      public/main/inc/lib/sortable_table.class.php
  32. 6
      public/main/survey/survey_invitation.php
  33. 2
      public/main/template/default/exercise/oral_expression.html.twig
  34. 2
      public/plugin/advanced_subscription/views/admin_view.tpl
  35. 2
      src/CoreBundle/Resources/views/LearnPath/record_voice.html.twig

@ -129,14 +129,12 @@
@apply bg-gray-50;
}
table thead th {
@apply py-2;
}
table tbody {
@apply bg-white divide-y divide-gray-200;
}
table thead th,
table tbody th,
table tbody td {
@apply px-2 py-1;
}
@ -233,7 +231,31 @@
// Special
.badge {
@apply border-ch-text rounded-sm p-1;
@apply rounded-sm p-1 font-medium;
&--error {
@apply bg-ch-error text-ch-text-error;
}
&--success {
@apply bg-ch-success text-ch-text-success;
}
&--warning {
@apply bg-ch-warning text-ch-text-warning;
}
&--info {
@apply bg-ch-info text-ch-text-info;
}
&--primary {
@apply bg-ch-primary text-ch-text-primary;
}
&--secondary {
@apply bg-ch-secondary text-ch-text-secondary;
}
}
// Progress bars

@ -66,6 +66,7 @@
@apply p-4 flex flex-row gap-1;
}
/* Quuestion types */
.question_options {
/** Question unique answer image */
&.type-17 {
@ -175,3 +176,60 @@
}
}
}
/* Answer results */
.question-answer-result {
@apply p-4;
&__header {
@apply mb-4;
&-ribbon {
@apply mb-4 flex border bg-gray-100 rounded-md;
&-title {
@apply font-bold p-3 rounded-l-md;
&--error {
@apply bg-ch-error text-ch-text-error;
}
&--warning {
@apply bg-ch-warning text-ch-text-warning;
}
&--success {
@apply bg-ch-success text-ch-text-success;
}
&--info {
@apply bg-ch-info text-ch-text-info;
}
}
&-detail {
@apply font-bold p-3;
}
&-description {
@apply mb-4;
}
&--no-ribbon {
@apply border-l-8;
img {
@apply inline;
}
}
}
}
&__detail {
@apply mb-4;
th {
@apply text-left;
}
}
}

@ -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>';
@ -212,7 +212,7 @@ class Draggable extends Question
} else {
$header .= '<th>'.get_lang('Elements list').'</th>';
}
$header .= '<th>'.get_lang('Status').'</th>';
$header .= '<th class="text-center">'.get_lang('Status').'</th>';
$header .= '</tr>';
return $header;

@ -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,
@ -260,15 +260,13 @@ class MatchingDraggable extends Question
])
) {
$header .= '<th>'.get_lang('Your choice').'</th>';
}
if ($exercise->showExpectedChoice()) {
if ($exercise->showExpectedChoiceColumn()) {
$header .= '<th>'.get_lang('Expected choice').'</th>';
}
$header .= '<th>'.get_lang('Status').'</th>';
} else {
$header .= '<th>'.get_lang('Corresponds to').'</th>';
}
if ($exercise->showExpectedChoice()) {
$header .= '<th class="text-center">'.get_lang('Status').'</th>';
}
$header .= '</tr>';

@ -155,7 +155,7 @@ class MultipleAnswerTrueFalseDegreeCertainty extends Question
$form->addElement('radio', 'correct['.$i.']', null, null, 2);
}
$txtAnswer = $form->addHtmlEditor(
$form->addHtmlEditor(
'answer['.$i.']',
null,
true,
@ -166,11 +166,11 @@ class MultipleAnswerTrueFalseDegreeCertainty extends Question
$form->addRule('answer['.$i.']', get_lang('Required field'), 'required');
if (isset($_POST['answer']) && isset($_POST['answer'][$i])) {
$txtAnswer->setValue(Security::remove_XSS($_POST['answer'][$i]));
$form->getElement("answer[$i]")->setValue(Security::remove_XSS($_POST['answer'][$i]));
}
// show comment when feedback is enable
if (EXERCISE_FEEDBACK_TYPE_EXAM != $objEx->getFeedbackType()) {
$txtComment = $form->addHtmlEditor(
$form->addHtmlEditor(
'comment['.$i.']',
null,
false,
@ -179,7 +179,7 @@ class MultipleAnswerTrueFalseDegreeCertainty extends Question
['style' => 'vertical-align:middle;'],
);
if (isset($_POST['comment']) && isset($_POST['comment'][$i])) {
$txtComment->setValue(Security::remove_XSS($_POST['comment'][$i]));
$form->getElement("comment[$i]")->setValue(Security::remove_XSS($_POST['comment'][$i]));
}
}
$form->addElement('html', '</tr>');
@ -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()) {

@ -417,26 +417,4 @@ class UniqueAnswerImage extends UniqueAnswer
$this->updateWeighting($questionWeighting);
$this->save($exercise);
}
public function return_header(Exercise $exercise, $counter = null, $score = [])
{
if ($exercise->showExpectedChoice()) {
$header = '<table class="'.$this->question_table_class.'">
<tr>
<th>'.get_lang('Your choice').'</th>';
if ($exercise->showExpectedChoiceColumn()) {
$header .= '<th>'.get_lang('Expected choice').'</th>';
}
$header .= '<th>'.get_lang('Answer').'</th>';
$header .= '<th>'.get_lang('Status').'</th>';
if (false === $exercise->hideComment) {
$header .= '<th>'.get_lang('Comment').'</th>';
}
$header .= '</tr>';
} else {
$header = parent::return_header($exercise, $counter, $score);
}
return $header;
}
}

@ -252,14 +252,14 @@ 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>';
if ($exercise->showExpectedChoiceColumn()) {
$header .= '<th>'.get_lang('Expected choice').'</th>';
}
$header .= '<th>'.get_lang('Status').'</th>';
$header .= '<th class="text-center">'.get_lang('Status').'</th>';
}
$header .= '</tr>';

@ -4561,7 +4561,7 @@ class Exercise
}
echo '</td>';
}
echo '<td>'.$status.'</td>';
echo '<td class="text-center">'.$status.'</td>';
} else {
if (in_array($answerType, [MATCHING, MATCHING_DRAGGABLE])) {
if (isset($real_list[$i_answer_correct_answer]) &&
@ -4605,7 +4605,7 @@ class Exercise
$status = Display::label(get_lang('Correct'), 'success');
}
echo '<td>'.$s_answer_label.'</td>';
echo '<td>'.$status.'</td>';
echo '<td class="text-center">'.$status.'</td>';
} else {
echo '<td>'.$s_answer_label.'</td>';
echo '<td>'.$user_answer.'</td>';
@ -8431,64 +8431,45 @@ class Exercise
return false;
}
/**
* @param string $class
* @param string $scoreLabel
* @param string $result
* @param array
*
* @return string
*/
public function getQuestionRibbon($class, $scoreLabel, $result, $array)
public function getQuestionRibbon(string $class, string $scoreLabel, ?string $result, array $array): string
{
$hide = (int) $this->getPageConfigurationAttribute('hide_question_score');
if (1 === $hide) {
return '';
}
$ribbon = '<div class="question-answer-result__header-ribbon-title question-answer-result__header-ribbon-title--'.$class.'">'.$scoreLabel.'</div>';
if (!empty($result)) {
$ribbon .= '<div class="question-answer-result__header-ribbon-detail">'
.get_lang('Score').': '.$result
.'</div>';
}
$ribbonClassModifier = '';
if ($this->showExpectedChoice()) {
$html = null;
$hideLabel = api_get_configuration_value('exercise_hide_label');
$label = '<div class="rib rib-'.$class.'">
<h3>'.$scoreLabel.'</h3>
</div>';
if (!empty($result)) {
$label .= '<h4>'.get_lang('Score').': '.$result.'</h4>';
}
if (true === $hideLabel) {
$ribbonClassModifier = 'question-answer-result__header-ribbon--no-ribbon';
$html = '';
$answerUsed = (int) $array['used'];
$answerMissing = (int) $array['missing'] - $answerUsed;
for ($i = 1; $i <= $answerUsed; $i++) {
$html .= '<span class="score-img">'.
Display::return_icon('attempt-check.png').
'</span>';
$html .= Display::return_icon('attempt-check.png');
}
for ($i = 1; $i <= $answerMissing; $i++) {
$html .= '<span class="score-img">'.
Display::return_icon('attempt-nocheck.png').
'</span>';
$html .= Display::return_icon('attempt-nocheck.png');
}
$label = '<div class="score-title">'.get_lang('Correct answers').': '.$result.'</div>';
$label .= '<div class="score-limits">';
$label .= $html;
$label .= '</div>';
$ribbon = '<div class="question-answer-result__header-ribbon-title">'
.get_lang('Correct answers').': '.$result.'</div>'
.'<div class="question-answer-result__header-ribbon-detail">'.$html.'</div>';
}
return '<div class="ribbon">
'.$label.'
</div>';
} else {
$html = '<div class="ribbon">
<div class="rib rib-'.$class.'">
<h3>'.$scoreLabel.'</h3>
</div>';
if (!empty($result)) {
$html .= '<h4>'.get_lang('Score').': '.$result.'</h4>';
}
$html .= '</div>';
return $html;
}
return Display::div(
$ribbon,
['class' => "question-answer-result__header-ribbon $ribbonClassModifier"]
);
}
/**

@ -854,20 +854,20 @@ foreach ($questionList as $questionId) {
$i++;
$contents = ob_get_clean();
$question_content = '<div class="question_row">';
$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>';
@ -255,7 +255,7 @@ class GlobalMultipleAnswer extends Question
$header .= '<th>'.get_lang('Answer').'</th>';
if ($exercise->showExpectedChoice()) {
$header .= '<th>'.get_lang('Status').'</th>';
$header .= '<thclass="text-center">'.get_lang('Status').'</th>';
}
$header .= '<th>'.get_lang('Comment').'</th>';
$header .= '</tr>';

@ -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, [
@ -279,17 +279,13 @@ class Matching extends Question
])
) {
$header .= '<th>'.get_lang('Your choice').'</th>';
//if ($exercise->showExpectedYour choiceColumn()) {
//$header .= '<th>'.get_lang('ExpectedYour choice').'</th>';
//}
if ($exercise->showExpectedChoiceColumn()) {
$header .= '<th>'.get_lang('Expected choice').'</th>';
}
}
if ($exercise->showExpectedChoice()) {
$header .= '<th>'.get_lang('Status').'</th>';
} else {
if ($exercise->showExpectedChoiceColumn()) {
$header .= '<th>'.get_lang('Corresponds to').'</th>';
}
$header .= '<th class="text-center">'.get_lang('Status').'</th>';
}
$header .= '</tr>';

@ -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>';
@ -222,7 +222,7 @@ class MultipleAnswer extends Question
$header .= '<th>'.get_lang('Answer').'</th>';
if ($exercise->showExpectedChoice()) {
$header .= '<th>'.get_lang('Status').'</th>';
$header .= '<th class="text-center">'.get_lang('Status').'</th>';
}
if (false === $exercise->hideComment) {

@ -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,
@ -224,7 +224,7 @@ class MultipleAnswerCombination extends Question
$header .= '<th>'.get_lang('Answer').'</th>';
if ($exercise->showExpectedChoice()) {
$header .= '<th>'.get_lang('Status').'</th>';
$header .= '<th class="text-center">'.get_lang('Status').'</th>';
}
if (false === $exercise->hideComment) {
$header .= '<th>'.get_lang('Comment').'</th>';

@ -149,7 +149,7 @@ class MultipleAnswerTrueFalse extends Question
}
// show comment when feedback is enable
if (EXERCISE_FEEDBACK_TYPE_EXAM != $obj_ex->getFeedbackType()) {
$txtComment = $form->addHtmlEditor(
$form->addHtmlEditor(
'comment['.$i.']',
null,
true,
@ -161,7 +161,7 @@ class MultipleAnswerTrueFalse extends Question
]
);
if (isset($_POST['comment']) && isset($_POST['comment'][$i])) {
$txtComment->setValue(Security::remove_XSS($_POST['comment'][$i]));
$form->getElement("comment[$i]")->setValue(Security::remove_XSS($_POST['comment'][$i]));
}
}
@ -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,
@ -317,7 +317,7 @@ class MultipleAnswerTrueFalse extends Question
$header .= '<th>'.get_lang('Answer').'</th>';
if ($exercise->showExpectedChoice()) {
$header .= '<th>'.get_lang('Status').'</th>';
$header .= '<th class="text-center">'.get_lang('Status').'</th>';
}
if (EXERCISE_FEEDBACK_TYPE_EXAM != $exercise->getFeedbackType() ||
in_array(

@ -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';
public $questionTableClass = 'table table-striped question-answer-result__detail';
public $questionTypeWithFeedback;
public $extra;
public $export = false;
@ -1730,7 +1730,7 @@ abstract class Question
// Do not show the description (the text to read) if the question is of type READING_COMPREHENSION
$header .= Display::div(
$this->description,
['class' => 'question_description']
['class' => 'question-answer-result__header-description']
);
} else {
/** @var ReadingComprehension $this */
@ -1770,7 +1770,10 @@ abstract class Question
}
}
return $header;
return Display::div(
$header,
['class' => 'question-answer-result__header']
);
}
/**

@ -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()) {
@ -445,7 +445,7 @@ class UniqueAnswer extends Question
$header .= '<th>'.get_lang('Answer').'</th>';
if ($exercise->showExpectedChoice()) {
$header .= '<th>'.get_lang('Status').'</th>';
$header .= '<th class="text-center">'.get_lang('Status').'</th>';
}
if (false === $exercise->hideComment) {
$header .= '<th>'.get_lang('Comment').'</th>';

@ -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,
@ -404,7 +404,7 @@ class UniqueAnswerNoOption extends Question
}
$header .= '<th>'.get_lang('Answer').'</th>';
if ($exercise->showExpectedChoice()) {
$header .= '<th>'.get_lang('Status').'</th>';
$header .= '<th class="text-center">'.get_lang('Status').'</th>';
}
if (false === $exercise->hideComment) {
$header .= '<th>'.get_lang('Comment').'</th>';

@ -1114,21 +1114,21 @@ 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';
}
$counter++;
$badges[] = Display::badge($value, $class);
$badges[] = Display::label($value, $class);
}
return Display::badgeGroup($badges);

@ -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::badge($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::badge($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

@ -1635,41 +1635,6 @@ class Display
return $div;
}
/**
* @param string $count
* @param string $type
*
* @return string|null
*/
public static function badge($count, $type = 'warning')
{
$class = '';
switch ($type) {
case 'success':
$class = 'bg-success';
break;
case 'warning':
$class = 'bg-warning text-dark';
break;
case 'important':
$class = 'bg-important';
break;
case 'info':
$class = 'bg-info';
break;
case 'inverse':
$class = 'bg-inverse';
break;
}
if (!empty($count)) {
return ' <span class="badge '.$class.'">'.$count.'</span>';
}
return null;
}
/**
* @param array $badge_list
*
@ -1696,13 +1661,13 @@ class Display
$class = match ($type) {
'success' => 'success',
'warning' => 'warning',
'important', 'danger' => 'danger',
'important', 'danger', 'error' => 'error',
'info' => 'info',
'primary' => 'primary',
default => 'secondary',
};
$html = '<span class="badge bg-ch-'.$class.'">';
$html = '<span class="badge badge--'.$class.'">';
$html .= $content;
$html .= '</span>';
}

@ -4195,7 +4195,7 @@ EOT;
$counter = 1;
$total_score = $total_weight = 0;
$exercise_content = null;
$exerciseContent = null;
// Hide results
$show_results = false;
@ -4539,42 +4539,36 @@ EOT;
}
$contents = ob_get_clean();
$question_content = '';
$questionContent = '';
if ($show_results) {
$question_content = '<div class="question_row_answer">';
$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::div(
Display::panel($question_content),
['class' => 'question-panel']
);
$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::div(
Display::panel($question_content),
['class' => 'question-panel']
);
$exerciseContent .= Display::panel($questionContent);
}
}
}
@ -4647,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;
@ -4667,7 +4661,7 @@ EOT;
echo Display::div($objExercise->description, ['class' => 'exercise_description']);
}
echo $exercise_content;
echo $exerciseContent;
if (!$show_only_score) {
echo $totalScoreText;
}

@ -423,7 +423,7 @@ class ExerciseShowFunctions
if ($answerCorrect || ($answerCorrect && $studentChoiceInt === $answerCorrectChoice)) {
$status = Display::label(get_lang('Correct'), 'success');
}
echo '<td width="20%">';
echo '<td class="text-center">';
// Show only status for the selected student answer BT#16256
if ($studentChoice) {
echo $status;
@ -551,7 +551,7 @@ class ExerciseShowFunctions
$status = Display::label(get_lang('Correct'), 'success');
}
}
$content .= '<td width="20%">';
$content .= '<td class="text-center">';
$content .= $status;
$content .= '</td>';
}
@ -779,7 +779,7 @@ class ExerciseShowFunctions
$status = Display::label(get_lang('Correct'), 'success');
}
}
echo '<td width="20%">';
echo '<td class="text-center">';
echo $status;
echo '</td>';
}

@ -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

@ -81,7 +81,7 @@ if ('invited' === $view) {
echo '<li role="presentation"><a href="'.$url.'&view=invited">'.
get_lang('View invited');
}
echo Display::badge($invitationsCount);
echo Display::label($invitationsCount, 'warning');
echo '</a></li>';
if ('answered' === $view) {
echo '<li role="presentation" class="active"><a href="#">'.get_lang('View people who answered');
@ -90,7 +90,7 @@ if ('answered' === $view) {
<a href="'.$url.'&view=answered">'.
get_lang('View people who answered');
}
echo Display::badge($answeredCount);
echo Display::label($answeredCount, 'warning');
echo '</a></li>';
if ('unanswered' === $view) {
@ -101,7 +101,7 @@ if ('unanswered' === $view) {
<a href="'.$url.'&view=unanswered">'.
get_lang('View people who didn\'t answer');
}
echo Display::badge($unAnsweredCount);
echo Display::label($unAnsweredCount, 'warning');
echo '</a></li>';
echo '</ul>';
echo '<table class="table table-hover table-striped data_table" style="margin-top: 5px;">';

@ -9,7 +9,7 @@
<div class="form-group text-center">
<div id="timer" style="display: none">
<h2>
<div class="badge badge-danger">
<div class="badge badge--error">
<span id="hour">00</span>
<span class="divider">:</span>
<span id="minute">00</span>

@ -24,7 +24,7 @@
<span class="badge badge-dis">{{ session.vacancies }}</span>
{{ "Vacancies" | get_plugin_lang('AdvancedSubscriptionPlugin') }}</p>
<p class="separate-badge">
<span class="badge badge-info">{{ session.nbr_users }}</span>
<span class="badge badge--info">{{ session.nbr_users }}</span>
{{ 'CountOfSubscribedUsers'|get_lang }}
</p>
<p class="separate-badge">

@ -4,7 +4,7 @@
<span class="sr-only">{{ 'Record audio'|trans }}</span>
<div id="timer" style="display: none">
<h2>
<div class="badge badge-danger">
<div class="badge badge--error">
<span id="hour">00</span>
<span class="divider">:</span>
<span id="minute">00</span>

Loading…
Cancel
Save