From 321095f186e9ccc53d129b2394dcffb91ab4e8de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Arag=C3=B3n?= Date: Mon, 23 Jul 2018 17:45:36 -0500 Subject: [PATCH] Change of colors and improvement of presentation of results - refs #2600 --- app/Resources/public/css/base.css | 175 +++++++++++ ...MultipleAnswerTrueFalseDegreeCertainty.php | 287 ++++++++++++------ main/exercise/TestCategory.php | 2 +- main/inc/lib/exercise_show_functions.lib.php | 6 +- 4 files changed, 365 insertions(+), 105 deletions(-) diff --git a/app/Resources/public/css/base.css b/app/Resources/public/css/base.css index b01677019a..672def3dd4 100644 --- a/app/Resources/public/css/base.css +++ b/app/Resources/public/css/base.css @@ -2531,6 +2531,181 @@ div.admin_section h4 { margin-top: 20px; margin-bottom: 25px; } +/* EXERCISE MATFDC */ + +.certaintyQuizBox { + border : 1px solid black; + margin : auto; +} + +.certaintyQuizColumn { + float : left; +} + +/* text at the top of the column */ +.certaint-score { + height : 20px; + margin-bottom: 10px; + padding : 0; + text-align: center; + font-size: 22px; + font-weight: bold; +} +.chart-grid{ + display: grid; + grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); + grid-gap: 30px; + width: 100%; + margin: 0 auto; +} +.chart-title{ + text-align: center; + font-weight: bold; + font-size: 16px; + margin-bottom: 20px; + padding-bottom: 10px; + border-bottom: 1px solid #b3b3b3; + text-transform: uppercase; + background: #ecf0f1; + padding-top: 10px; +} +.certaint-list-two, .certaint-list{ + margin: 0; + padding: 0; + list-style: none; + text-align: center; + position: absolute; + bottom: 0; + display: inline-block; + width: 100%; +} +.certaint-list-two li{ + display: inline-block; + margin-right: 10px; + width: 40%; +} +.certaint-list li{ + width: 50%; + margin: auto; +} +.certaint-list-two li:last-child{ + margin-right: 0; +} +.answers-title{ + text-align: center; + margin-bottom: 20px; + font-weight: bold; +} +.panel-certaint{ + margin-bottom: 20px; + background-color: #FFF; + border: 1px solid #e4e4e4;; + box-shadow: 0 2px 2px rgba(204, 197, 185, 0.5); + padding: 10px; + border-radius: 6px; +} + +.certaint-text{ + text-align: center; + padding: 10px 5px; +} +.certaintyVerticalLine { + float: left; + border-left : 1px solid black; + font-size: 0; +} + +.certaintyQuizClearer { + clear : both; + font-size: 0; + height:0 +} +.chart-legend{ + list-style: none; + margin: 0; + padding: 0; + text-align: center; +} +.chart-legend li{ + display: inline-block; + padding-left: 10px; + padding-right: 10px; + margin-right: 10px; + margin-bottom: 10px; +} +.square_color4{ + color: #1e9c55; +} +.square_color3{ + color: #b1e183; +} +.square_color2{ + color: #f6ba2a; +} +.square_color1{ + color: #f79b88; +} +.square_color0{ + color: #ed4040; +} +.levelbar_1 { + background-color: #1e9c55; + border: 1px solid #1e9c55; +} + +.levelbar_2 { + background-color: #b1e183; + border: 1px solid #b1e183; +} + +.levelbar_3 { + background-color: #f6ba2a; + border: 1px solid #f6ba2a; +} + +.levelbar_4 { + background-color: #f79b88; + border: 1px solid #f79b88; +} + +.levelbar_5 { + background-color: #ed4040; + border: 1px solid #ed4040; +} + +table.certaintyTable { + margin : auto; + border: 1px solid #7FC5FF; +} + +table.certaintyTable th { + text-align: center; + border-bottom: 1px solid #7FC5FF; + background-color: #c9e0ff; +} + +table.certaintyTable td { + padding : 10px; +} + +table.certaintyTable td.borderRight { + border-right: 1px dotted #7FC5FF; +} + +table.certaintyTable td.firstLine { + vertical-align: top; + text-align: center; +} + +table.certaintyTable th.globalChart { + font-size : 18pt; + line-height : 120%; + padding : 20px; +} + +table.certaintyTable td.globalChart { + font-weight : bold; +} /* Exercise clock*/ .count_down { diff --git a/main/exercise/MultipleAnswerTrueFalseDegreeCertainty.php b/main/exercise/MultipleAnswerTrueFalseDegreeCertainty.php index 2d969603f5..c80a8fbf43 100644 --- a/main/exercise/MultipleAnswerTrueFalseDegreeCertainty.php +++ b/main/exercise/MultipleAnswerTrueFalseDegreeCertainty.php @@ -335,7 +335,7 @@ class MultipleAnswerTrueFalseDegreeCertainty extends Question if ($studentDegreeChoicePosition == 3) { $result = [ 'color' => '#000000', - 'background-color' => '#FFFFFF', + 'background-color' => '#F6BA2A', 'status' => self::LEVEL_WHITE, 'label' => get_lang('DegreeOfCertaintyDeclaredIgnorance'), 'description' => get_lang('DegreeOfCertaintyDeclaredIgnoranceDescription'), @@ -346,7 +346,7 @@ class MultipleAnswerTrueFalseDegreeCertainty extends Question if ($studentDegreeChoicePosition >= 6) { $result = [ 'color' => '#FFFFFF', - 'background-color' => '#088A08', + 'background-color' => '#1E9C55', 'status' => self::LEVEL_DARKGREEN, 'label' => get_lang('DegreeOfCertaintyVerySure'), 'description' => get_lang('DegreeOfCertaintyVerySureDescription'), @@ -354,7 +354,7 @@ class MultipleAnswerTrueFalseDegreeCertainty extends Question } elseif ($studentDegreeChoicePosition >= 4 && $studentDegreeChoicePosition <= 5) { $result = [ 'color' => '#000000', - 'background-color' => '#A9F5A9', + 'background-color' => '#B1E183', 'status' => self::LEVEL_LIGHTGREEN, 'label' => get_lang('DegreeOfCertaintyPrettySure'), 'description' => get_lang('DegreeOfCertaintyPrettySureDescription'), @@ -364,7 +364,7 @@ class MultipleAnswerTrueFalseDegreeCertainty extends Question if ($studentDegreeChoicePosition >= 6) { $result = [ 'color' => '#FFFFFF', - 'background-color' => '#FE2E2E', + 'background-color' => '#ED4040', 'status' => self::LEVEL_DARKRED, 'label' => get_lang('DegreeOfCertaintyVeryUnsure'), 'description' => get_lang('DegreeOfCertaintyVeryUnsureDescription'), @@ -372,7 +372,7 @@ class MultipleAnswerTrueFalseDegreeCertainty extends Question } elseif ($studentDegreeChoicePosition >= 4 && $studentDegreeChoicePosition <= 5) { $result = [ 'color' => '#000000', - 'background-color' => '#F6CECE', + 'background-color' => '#F79B88', 'status' => self::LEVEL_LIGHTRED, 'label' => get_lang('DegreeOfCertaintyUnsure'), 'description' => get_lang('DegreeOfCertaintyUnsureDescription'), @@ -498,7 +498,7 @@ class MultipleAnswerTrueFalseDegreeCertainty extends Question if ($category) { $categoryQuestionName = $category->name; } - list($noValue, $height) = self::displayDegreeChart( + list($noValue, $height) = self::displayDegreeChartChildren( $scoreListForCategory, 300, '', @@ -519,8 +519,21 @@ class MultipleAnswerTrueFalseDegreeCertainty extends Question $boxWidth = $sizeRatio * 300 + 54; } - $html = '
'; - $html .= '

'.$title.'

'; + $html = '
'; + $html .= '

'.$title.'

'; + + $legendTitle = [ + 'DegreeOfCertaintyVeryUnsure', + 'DegreeOfCertaintyUnsure', + 'DegreeOfCertaintyDeclaredIgnorance', + 'DegreeOfCertaintyPrettySure', + 'DegreeOfCertaintyVerySure', + ]; + $html .= '
    '; + foreach ($legendTitle as $i => $item){ + $html .= '
  • '.get_lang($item).'
  • '; + } + $html .= '
'; // get the html of items $i = 0; @@ -538,8 +551,8 @@ class MultipleAnswerTrueFalseDegreeCertainty extends Question $categoryName = $categoryQuestionName; } - $html .= '
'; - $html .= self::displayDegreeChart( + $html .= '
'; + $html .= self::displayDegreeChartChildren( $scoreListForCategory, 300, $categoryName, @@ -551,15 +564,16 @@ class MultipleAnswerTrueFalseDegreeCertainty extends Question ); $html .= '
'; - if ($i == 1) { - $html .= '
 
'; + if ($i == 2) { + $html .= '
 
'; $i = 0; } else { $i++; } } + $html .= '
'; - return $html.'
 
'; + return $html.'
 
'; } /** @@ -587,7 +601,8 @@ class MultipleAnswerTrueFalseDegreeCertainty extends Question $returnHeight = false, $groupCategoriesByBracket = false, $numberOfQuestions = 0 - ) { + ) + { $topAndBottomMargin = 10; $colorList = [ self::LEVEL_DARKRED, @@ -613,96 +628,166 @@ class MultipleAnswerTrueFalseDegreeCertainty extends Question } // draw chart - $html = ''; + + $html .= '
'; + + $explainHistoList = null; + if ($displayExplanationText) { + // Display of histogram text + $explainHistoList = [ + 'DegreeOfCertaintyVeryUnsure', + 'DegreeOfCertaintyUnsure', + 'DegreeOfCertaintyDeclaredIgnorance', + 'DegreeOfCertaintyPrettySure', + 'DegreeOfCertaintyVerySure', + ]; + } + + foreach ($colorList as $i => $color) { + if (array_key_exists($color, $scoreList)) { + $scoreOnBottom = $scoreList[$color]; // height of the colored area on the bottom + } else { + $scoreOnBottom = 0; + } + $sizeBar = ($scoreOnBottom * $sizeRatio * 2).'px;'; + + if ($i == 0 ) { + $html .= '
'; + $html .= '
'; + $html .= '
'.$IncorrectAnswers.'
'; + $html .= '
    '; + } else if($i == 3){ + $html .= '
    '; + $html .= '
    '; + $html .= '
    '.$CorrectAnswers.'
    '; + $html .= '
      '; + } else if($i==2){ + $html .= '
      '; + $html .= '
      '; + $html .= '
      '.$IgnoranceAnswers.'
      '; + $html .= '
        '; + } + $html .= '
      • '; + $html .= '
        '; + $html .= $scoreOnBottom; + $html .= '
        '; + $html .= '
         
        '; + $html .= '
        '.get_lang($explainHistoList[$i]).'
        '; + $html .= '
      • '; + + if ($i == 1 || $i == 2 || $i == 4) { + $html .= '
      '; + $html .= '
      '; + $html .= '
      '; + } + } + + $html .= '
    '; + $html .= '
    '; + + + if ($returnHeight) { + return [$html, $verticalLineHeight]; + } else { + return $html; + } + } + + /** + * Return HTML code for the $scoreList of MultipleAnswerTrueFalseDegreeCertainty questions. + * + * @param $scoreList + * @param $widthTable + * @param string $title + * @param int $sizeRatio + * @param int $minHeight + * @param bool $displayExplanationText + * @param bool $returnHeight + * @param bool $groupCategoriesByBracket + * @param int $numberOfQuestions + * + * @return array|string + */ + public static function displayDegreeChartChildren( + $scoreList, + $widthTable, + $title = '', + $sizeRatio = 1, + $minHeight = 0, + $displayExplanationText = true, + $returnHeight = false, + $groupCategoriesByBracket = false, + $numberOfQuestions = 0 + ) + { + $topAndBottomMargin = 10; + $colorList = [ + self::LEVEL_DARKRED, + self::LEVEL_LIGHTRED, + self::LEVEL_WHITE, + self::LEVEL_LIGHTGREEN, + self::LEVEL_DARKGREEN, + ]; + + // get total attempt number + $highterColorHeight = 0; + foreach ($scoreList as $color => $number) { + if ($number > $highterColorHeight) { + $highterColorHeight = $number; + } + } + + $totalAttemptNumber = $numberOfQuestions; + $verticalLineHeight = $highterColorHeight * $sizeRatio * 2 + 122 + $topAndBottomMargin * 2; + if ($verticalLineHeight < $minHeight) { + $minHeightCorrection = $minHeight - $verticalLineHeight; + $verticalLineHeight += $minHeightCorrection; + } + + // draw chart + $html = ''; if ($groupCategoriesByBracket) { $title = api_preg_replace("/[^]]*$/", '', $title); @@ -723,7 +808,7 @@ class MultipleAnswerTrueFalseDegreeCertainty extends Question $classGlobalChart = 'globalChart'; } - $html .= ''; + $html .= '
    '; $html .= ''; @@ -779,7 +864,7 @@ class MultipleAnswerTrueFalseDegreeCertainty extends Question if ($i == 1 || $i == 2) { $html .= '
    ' @@ -754,16 +839,16 @@ class MultipleAnswerTrueFalseDegreeCertainty extends Question $html .= '
    '. + style="width:'.($colWidth * 2).'px; line-height: 15px; font-size:'.$textSize.'%;">'. sprintf(get_lang('IncorrectAnswersX'), $nbResponsesInc).' '. + style="width:'.$colWidth.'px; line-height: 15px; font-size :'.$textSize.'%;">'. sprintf(get_lang('IgnoranceAnswersX'), $nbResponsesIng).' '. + style="width:'.($colWidth * 2).'px; line-height: 15px; font-size:'.$textSize.'%;">'. sprintf(get_lang('CorrectAnswersX'), $nbResponsesCor).'
    ' ; @@ -791,9 +876,9 @@ class MultipleAnswerTrueFalseDegreeCertainty extends Question .'%;">' ; } - $html .= '
    ' + $html .= '
    ' .$scoreOnBottom - .'
    '; + echo '
    '; echo $answer; echo ''; echo $newOptions[$studentChoiceDegree]['name']; @@ -562,9 +562,9 @@ class ExerciseShowFunctions ); echo ' - +
    '. nl2br($degreeInfo['label']).