浏览代码

Minor - fix course/session score BT#15694

Julio Montoya 5 年之前
父节点
当前提交
90529d5db6
共有 1 个文件被更改,包括 9 次插入5 次删除
  1. 9 5
      main/webservices/gradebook.php

+ 9 - 5
main/webservices/gradebook.php

@@ -256,7 +256,7 @@ function WSGetGradebookCategoryUserScore($params)
     if (!empty($sessionId)) {
         $sessionInfo = api_get_session_info($sessionId);
         if (empty($sessionInfo)) {
-            return 'Session not found';
+            return new soap_fault('Server', '', 'Session not found');
         }
     }
 
@@ -289,12 +289,15 @@ function WSGetGradebookCategoryUserScore($params)
         $category = isset($categoryCourse[0]) ? $categoryCourse[0] : null;
         $allevals = $category->get_evaluations($userId, true);
         $alllinks = $category->get_links($userId, true);
+
         $allEvalsLinks = array_merge($allevals, $alllinks);
         $main_weight = $category->get_weight();
         $scoredisplay = ScoreDisplay::instance();
         $item_value_total = 0;
-        for ($count = 0; $count < count($allEvalsLinks); $count++) {
-            $item = $allEvalsLinks[$count];
+        /** @var AbstractLink $item */
+        foreach ($allEvalsLinks as $item) {
+            $item->set_session_id($sessionId);
+            $item->set_course_code($courseCode);
             $score = $item->calc_score($userId);
             if (!empty($score)) {
                 $divide = $score[1] == 0 ? 1 : $score[1];
@@ -305,9 +308,10 @@ function WSGetGradebookCategoryUserScore($params)
 
         $item_total = $main_weight;
         $total_score = [$item_value_total, $item_total];
-        $scorecourse_display = $scoredisplay->display_score($total_score, SCORE_DIV_PERCENT);
+        $score = $scoredisplay->display_score($total_score, SCORE_DIV_PERCENT);
+        $score = strip_tags($score);
 
-        return $scorecourse_display;
+        return $score;
     }
 
     if (empty($category)) {