diff --git a/main/gradebook/lib/GradebookUtils.php b/main/gradebook/lib/GradebookUtils.php index 1263071417..e936c61fdd 100644 --- a/main/gradebook/lib/GradebookUtils.php +++ b/main/gradebook/lib/GradebookUtils.php @@ -121,12 +121,18 @@ class GradebookUtils */ public static function build_type_icon_tag($kind, $attributes = array()) { - return Display::return_icon(self::get_icon_file_name($kind), ' ', $attributes, ICON_SIZE_SMALL); + return Display::return_icon( + self::get_icon_file_name($kind), + ' ', + $attributes, + ICON_SIZE_SMALL + ); } /** * Returns the icon filename for a gradebook item * @param string $type value returned by a gradebookitem's get_icon_name() + * @return string */ public static function get_icon_file_name($type) { @@ -183,6 +189,7 @@ class GradebookUtils * Builds the course or platform admin icons to edit a category * @param Category $cat category * @param Category $selectcat id of selected category + * @return string */ public static function build_edit_icons_cat($cat, $selectcat) { @@ -289,6 +296,7 @@ class GradebookUtils * Builds the course or platform admin icons to edit an evaluation * @param Evaluation $eval evaluation object * @param int $selectcat id of selected category + * @return string */ public static function build_edit_icons_eval($eval, $selectcat) { @@ -302,7 +310,12 @@ class GradebookUtils $visibility_icon = ($eval->is_visible() == 0) ? 'invisible' : 'visible'; $visibility_command = ($eval->is_visible() == 0) ? 'set_visible' : 'set_invisible'; if ($is_locked && !api_is_platform_admin()) { - $modify_icons = Display::return_icon('edit_na.png', get_lang('Modify'), '', ICON_SIZE_SMALL); + $modify_icons = Display::return_icon( + 'edit_na.png', + get_lang('Modify'), + '', + ICON_SIZE_SMALL + ); } else { $modify_icons = ''. Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL).''; @@ -329,6 +342,8 @@ class GradebookUtils * Builds the course or platform admin icons to edit a link * @param AbstractLink $link * @param int $selectcat id of selected category + * + * @return string */ public static function build_edit_icons_link($link, $selectcat) { @@ -349,7 +364,12 @@ class GradebookUtils $visibility_command = ($link->is_visible() == 0) ? 'set_visible' : 'set_invisible'; if ($is_locked && !api_is_platform_admin()) { - $modify_icons = Display::return_icon('edit_na.png', get_lang('Modify'), '', ICON_SIZE_SMALL); + $modify_icons = Display::return_icon( + 'edit_na.png', + get_lang('Modify'), + '', + ICON_SIZE_SMALL + ); } else { $modify_icons = ''. Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL).''; @@ -381,8 +401,12 @@ class GradebookUtils * * @return array false on error or array of resource */ - public static function isResourceInCourseGradebook($course_code, $resource_type, $resource_id, $session_id = 0) - { + public static function isResourceInCourseGradebook( + $course_code, + $resource_type, + $resource_id, + $session_id = 0 + ) { $table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK); $course_code = Database::escape_string($course_code); $sql = "SELECT * FROM $table l @@ -663,8 +687,14 @@ class GradebookUtils public static function get_list_gradebook_certificates_by_user_id($user_id, $cat_id = null) { $table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE); - $sql = 'SELECT gc.score_certificate, gc.created_at, gc.path_certificate, gc.cat_id, gc.user_id, gc.id - FROM ' . $table_certificate.' gc + $sql = 'SELECT + gc.score_certificate, + gc.created_at, + gc.path_certificate, + gc.cat_id, + gc.user_id, + gc.id + FROM '.$table_certificate.' gc WHERE gc.user_id="' . intval($user_id).'" '; if (!is_null($cat_id) && $cat_id > 0) { $sql .= ' AND cat_id='.intval($cat_id); @@ -781,7 +811,6 @@ class GradebookUtils $default_weight_setting = api_get_setting('gradebook_default_weight'); $default_weight = isset($default_weight_setting) && !empty($default_weight_setting) ? $default_weight_setting : 100; $cat->set_weight($default_weight); - $cat->set_grade_model_id($gradebook_model_id); $cat->set_certificate_min_score(75); @@ -994,12 +1023,14 @@ class GradebookUtils $counter++; $badges[] = Display::badge($value, $class); } + return Display::badge_group($badges); } /** * returns users within a course given by param * @param string $courseCode + * @return array */ public static function get_users_in_course($courseCode) { @@ -1251,7 +1282,6 @@ class GradebookUtils { $userId = intval($userId); $courseList = []; - $courses = CourseManager::get_courses_list_by_user_id($userId); foreach ($courses as $course) { @@ -1293,7 +1323,7 @@ class GradebookUtils /** * Get the achieved certificates for a user in course sessions * @param int $userId The user id - * @param bool $includeNonPublicCertificates Whether include the non-plublic certificates + * @param bool $includeNonPublicCertificates Whether include the non-public certificates * @return array */ public static function getUserCertificatesInSessions($userId, $includeNonPublicCertificates = true) @@ -1332,7 +1362,6 @@ class GradebookUtils } $courseGradebookId = $courseGradebookCategory[0]->get_id(); - $certificateInfo = self::get_certificate_by_user_id( $courseGradebookId, $userId diff --git a/main/gradebook/lib/gradebook_result.class.php b/main/gradebook/lib/gradebook_result.class.php index af04cbac80..7f5fb6452b 100644 --- a/main/gradebook/lib/gradebook_result.class.php +++ b/main/gradebook/lib/gradebook_result.class.php @@ -20,10 +20,8 @@ class GradeBookResult /** * Exports the complete report as a CSV file - * @param string Document path inside the document tool - * @param integer Optional user ID - * @param boolean Whether to include user fields or not - * @return boolean False on error + * @param string $dato Document path inside the document tool + * @return boolean False on error */ public function exportCompleteReportCSV($dato) { @@ -75,6 +73,7 @@ class GradeBookResult /** * Exports the complete report as an XLS file + * @param array $data * @return boolean|null False on error */ public function exportCompleteReportXLS($data) @@ -119,7 +118,7 @@ class GradeBookResult /** * Exports the complete report as a DOCX file - * @param $data The table data + * @param array $data The table data * @return bool */ public function exportCompleteReportDOC($data) diff --git a/main/gradebook/lib/user_data_generator.class.php b/main/gradebook/lib/user_data_generator.class.php index 62e99376a2..22d4ef51a8 100755 --- a/main/gradebook/lib/user_data_generator.class.php +++ b/main/gradebook/lib/user_data_generator.class.php @@ -30,6 +30,12 @@ class UserDataGenerator private $scorecache; private $avgcache; + /** + * UserDataGenerator constructor. + * @param int $userid + * @param array $evals + * @param array $links + */ public function __construct($userid, $evals = array(), $links = array()) { $this->userid = $userid; @@ -95,7 +101,7 @@ class UserDataGenerator // sort users array if ($sorting & self::UDG_SORT_TYPE) { usort($allitems, array('UserDataGenerator', 'sort_by_type')); - }elseif ($sorting & self::UDG_SORT_NAME) { + } elseif ($sorting & self::UDG_SORT_NAME) { usort($allitems, array('UserDataGenerator', 'sort_by_name')); } elseif ($sorting & self::UDG_SORT_COURSE) { usort($allitems, array('UserDataGenerator', 'sort_by_course')); @@ -130,7 +136,7 @@ class UserDataGenerator $visibleitems = array_slice($allitems, $start, $count); // fill score cache if not done yet - if (!isset ($this->scorecache)) { + if (!isset($this->scorecache)) { foreach ($visibleitems as $item) { $this->scorecache[$item->get_item_type().$item->get_id()] = $item->calc_score($this->userid); @@ -148,8 +154,9 @@ class UserDataGenerator $row[] = $this->build_category_name($item); $row[] = $this->build_average_column($item, $ignore_score_color); $row[] = $this->build_result_column($item, $ignore_score_color); - if ($scoredisplay->is_custom()) + if ($scoredisplay->is_custom()) { $row[] = $this->build_mask_column($item, $ignore_score_color); + } $data[] = $row; } return $data; @@ -343,7 +350,7 @@ class UserDataGenerator */ private function get_course_name_from_code_cached($coursecode) { - if (isset ($this->coursecodecache) && isset ($this->coursecodecache[$coursecode])) { + if (isset($this->coursecodecache) && isset($this->coursecodecache[$coursecode])) { return $this->coursecodecache[$coursecode]; } else { $name = CourseManager::getCourseNameFromCode($coursecode); @@ -358,7 +365,7 @@ class UserDataGenerator */ private function get_category_cached($category_id) { - if (isset ($this->categorycache) && isset ($this->categorycache[$category_id])) { + if (isset($this->categorycache) && isset ($this->categorycache[$category_id])) { return $this->categorycache[$category_id]; } else { $cat = Category::load($category_id);