From b4a159f6d4f7524bb2517b9a4b16622f63c604c9 Mon Sep 17 00:00:00 2001 From: Isaac Flores Date: Sat, 11 Apr 2009 19:47:51 +0200 Subject: [PATCH] [svn r19711] logic changes - allow search by category in gradebook tool - (partial FS#4020) --- main/gradebook/gradebook.php | 16 +++++++++++++--- main/gradebook/lib/be/category.class.php | 15 +++++++++++++++ main/gradebook/lib/fe/displaygradebook.php | 9 +++++---- 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/main/gradebook/gradebook.php b/main/gradebook/gradebook.php index 78cf043c81..d8223faa75 100644 --- a/main/gradebook/gradebook.php +++ b/main/gradebook/gradebook.php @@ -490,8 +490,14 @@ if ($simple_search_form->validate() && (empty($keyword))) { if (!empty($keyword)) { $cats= Category :: load($category); $allcat= array (); - $alleval= Evaluation :: find_evaluations($keyword, $cats[0]->get_id()); - $alllink= LinkFactory :: find_links($keyword, $cats[0]->get_id()); + if ((isset($_GET['selectcat']) && $_GET['selectcat']==0) && isset($_GET['search'])) { + $allcat= $cats[0]->get_subcategories(null); + $allcat_info = Category :: find_category($keyword,$allcat); + } else { + $alleval = Evaluation :: find_evaluations($keyword, $cats[0]->get_id()); + $alllink = LinkFactory :: find_links($keyword, $cats[0]->get_id()); + } + } elseif (isset ($_GET['studentoverview'])) { $cats= Category :: load($category); $stud_id= (api_is_allowed_to_create_course() ? null : api_get_user_id()); @@ -577,7 +583,11 @@ if (isset($_GET['search'])) { if (isset ($_GET['studentoverview'])) { $addparams['studentoverview'] = ''; } - +if (count($allcat_info)>0 && (isset($_GET['selectcat']) && $_GET['selectcat']==0) && isset($_GET['search'])) { + $allcat=$allcat_info; +} else { + $allcat=$allcat; +} $gradebooktable= new GradebookTable($cats[0], $allcat, $alleval, $alllink, $addparams); if (((empty ($allcat)) && (empty ($alleval)) && (empty ($alllink)) && (!$is_platform_admin) && ($is_course_admin) && (!isset ($_GET['selectcat']))) && api_is_course_tutor()) { Display :: display_normal_message(get_lang('GradebookWelcomeMessage') . '

',false); diff --git a/main/gradebook/lib/be/category.class.php b/main/gradebook/lib/be/category.class.php index a17c30027b..dbd2d01c94 100644 --- a/main/gradebook/lib/be/category.class.php +++ b/main/gradebook/lib/be/category.class.php @@ -25,6 +25,7 @@ /** * Defines a gradebook Category object * @author Bert Stepp�, Stijn Konings + * @author Isaac flores, * @package dokeos.gradebook */ class Category implements GradebookItem @@ -1087,4 +1088,18 @@ class Category implements GradebookItem public function get_icon_name() { return 'cat'; } + /** + * Find category by name + * @param string $name_mask search string + * @return array category objects matching the search criterium + */ + public function find_category ($name_mask,$allcat) { + $foundcats = array(); + foreach ($allcat as $search_cat) { + if (!(strpos(strtolower($search_cat->get_name()), strtolower($name_mask)) === false)) { + $foundcats[] = $search_cat; + } + } + return $foundcats; + } } \ No newline at end of file diff --git a/main/gradebook/lib/fe/displaygradebook.php b/main/gradebook/lib/fe/displaygradebook.php index 63405f9c56..b969ae2178 100644 --- a/main/gradebook/lib/fe/displaygradebook.php +++ b/main/gradebook/lib/fe/displaygradebook.php @@ -234,10 +234,11 @@ class DisplayGradebook } // show navigation tree and buttons? $header=''; - $header .= ''; + $header .= '
'; if (($showtree == '1') || (isset ($_GET['studentoverview']))) { - $header .= '' . + ''; if (!$selectcat == '0') { - $header .= ''; + $header .= ''; } if (!empty($simple_search_form) && $message_resource===false) { $header .= ''; @@ -277,7 +278,7 @@ class DisplayGradebook } $header .= ''; } - $header.='
' . get_lang('CurrentCategory') . '
' . get_lang('CurrentCategory') . ''.$simple_search_form->toHtml().'
'; + $header.=''; // for course admin & platform admin add item buttons are added to the header $header .= '
';