Преглед изворни кода

Serve the course tools for student view in course info request - refs #7402

Angel Fernando Quiroz Campos пре 8 година
родитељ
комит
9a09260bd0
2 измењених фајлова са 18 додато и 5 уклоњено
  1. 6 4
      main/inc/lib/course_home.lib.php
  2. 12 1
      main/inc/lib/webservices/Rest.php

+ 6 - 4
main/inc/lib/course_home.lib.php

@@ -441,19 +441,21 @@ class CourseHome
     /**
      * Gets the tools of a certain category. Returns an array expected
      * by show_tools_category()
-     * @param string $course_tool_category	contains the category of tools to
+     * @param string $course_tool_category contains the category of tools to
      * display: "toolauthoring", "toolinteraction", "tooladmin", "tooladminplatform", "toolplugin"
+     * @param int $courseId Optional
+     * @param int $sessionId Optional
      * @return array
      */
-    public static function get_tools_category($course_tool_category)
+    public static function get_tools_category($course_tool_category, $courseId = 0, $sessionId = 0)
     {
         $course_tool_table = Database::get_course_table(TABLE_TOOL_LIST);
         $is_platform_admin = api_is_platform_admin();
         $all_tools_list = array();
 
         // Condition for the session
-        $session_id = api_get_session_id();
-        $course_id = api_get_course_int_id();
+        $session_id = $sessionId ?: api_get_session_id();
+        $course_id = $courseId ?: api_get_course_int_id();
         $condition_session = api_get_session_condition($session_id, true, true, 't.session_id');
 
         switch ($course_tool_category) {

+ 12 - 1
main/inc/lib/webservices/Rest.php

@@ -224,6 +224,11 @@ class Rest extends WebService
     public function getCourseInfo()
     {
         $teachers = CourseManager::get_teacher_list_from_course_code_to_string($this->course->getCode());
+        $tools = CourseHome::get_tools_category(
+            'TOOL_STUDENT_VIEW',
+            $this->course->getId(),
+            $this->session ? $this->session->getId() : 0
+        );
 
         return [
             'id' => $this->course->getId(),
@@ -231,7 +236,13 @@ class Rest extends WebService
             'code' => $this->course->getCode(),
             'directory' => $this->course->getDirectory(),
             'urlPicture' => $this->course->getPicturePath(true),
-            'teachers' => $teachers
+            'teachers' => $teachers,
+            'tools' => array_map(
+                function ($tool) {
+                    return ['type' => $tool['name']];
+                },
+                $tools
+            )
         ];
     }