Sfoglia il codice sorgente

Use exercise platform score settings in the gradebook graph

See BT#14972

$_configuration['gradebook_use_exercise_score_settings_in_categories'] = true;
Julio 6 anni fa
parent
commit
77b8287979

+ 26 - 10
main/gradebook/lib/fe/gradebooktable.class.php

@@ -286,7 +286,9 @@ class GradebookTable extends SortableTable
         }
 
         $model = ExerciseLib::getCourseScoreModel();
-
+        $userExerciseScoreInCategory = api_get_configuration_value(
+            'gradebook_use_exercise_score_settings_in_categories'
+        );
         // Categories.
         if (!empty($data_array)) {
             foreach ($data_array as $data) {
@@ -321,7 +323,6 @@ 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();
 
@@ -412,17 +413,32 @@ class GradebookTable extends SortableTable
                                 $data['result_score'][1]
                             );
                         }
-                        $totalResultAverageValue = strip_tags(
-                            $scoredisplay->display_score(
-                                $totalResult,
-                                SCORE_AVERAGE
-                            )
-                        );
+
+                        $mode = SCORE_AVERAGE;
+                        if ($userExerciseScoreInCategory) {
+                            $mode = SCORE_SIMPLE;
+
+                            $result = ExerciseLib::convertScoreToPlatformSetting($totalAverage[0], $totalAverage[1]);
+                            $totalAverage[0] = $result['score'];
+                            $totalAverage[1] = $result['weight'];
+
+                            $result = ExerciseLib::convertScoreToPlatformSetting($totalResult[0], $totalResult[1]);
+                            $totalResult[0] = $result['score'];
+                            $totalResult[1] = $result['weight'];
+
+                            $result = ExerciseLib::convertScoreToPlatformSetting(
+                                $data['result_score'][0],
+                                $data['result_score'][1]
+                            );
+                            $data['my_result_no_float'][0] = $result['score'];
+                        }
+
+                        $totalResultAverageValue = strip_tags($scoredisplay->display_score($totalResult, $mode));
+                        $totalAverageValue = strip_tags($scoredisplay->display_score($totalAverage, $mode));
 
                         $this->dataForGraph['my_result'][] = floatval($totalResultAverageValue);
-                        $this->dataForGraph['my_result_no_float'][] = $data['result_score'][0];
-                        $totalAverageValue = strip_tags($scoredisplay->display_score($totalAverage, SCORE_AVERAGE));
                         $this->dataForGraph['average'][] = floatval($totalAverageValue);
+                        $this->dataForGraph['my_result_no_float'][] = $data['result_score'][0];
 
                         if (empty($model)) {
                             // Ranking

+ 3 - 0
main/install/configuration.dist.php

@@ -1012,6 +1012,9 @@ VALUES (2, 13, 'session_courses_read_only_mode', 'Lock Course In Session', 1, 1,
 // Hide percentage in best/average gradebook results
 //$_configuration['hide_gradebook_percentage_user_result'] = true;
 
+// Use exercise platform score settings in the gradebook graph
+// $_configuration['gradebook_use_exercise_score_settings_in_categories'] = true;
+
 // ------ Custom DB changes (keep this at the end)
 // Add user activation by confirmation email
 // This option prevents the new user to login in the platform if your account is not confirmed via email