From 9fdd76de37fb842d4e37ba56dd5770f0bfceb8dc Mon Sep 17 00:00:00 2001 From: Isaac Flores Date: Wed, 25 Mar 2009 01:01:09 +0100 Subject: [PATCH] [svn r19259] logic changes - allow to see the results about students notes - (partial FS#3909) --- main/gradebook/lib/be/category.class.php | 27 +++++++++---------- .../lib/user_data_generator.class.php | 11 +++++--- main/gradebook/user_stats.php | 26 ++++++++++-------- 3 files changed, 35 insertions(+), 29 deletions(-) diff --git a/main/gradebook/lib/be/category.class.php b/main/gradebook/lib/be/category.class.php index 22e8b1d9a6..a17c30027b 100644 --- a/main/gradebook/lib/be/category.class.php +++ b/main/gradebook/lib/be/category.class.php @@ -998,12 +998,12 @@ class Category implements GradebookItem if (isset($stud_id)) { // special case: this is the root if ($this->id == 0) { - $evals = Evaluation::get_evaluations_with_result_for_student(0,$stud_id); + $evals = Evaluation::get_evaluations_with_result_for_student(0,$stud_id); } else { - $evals = Evaluation::load(null,null,null,$this->id, + //added api_get_course_id() + $evals = Evaluation::load(null,null,api_get_course_id(),$this->id, api_is_allowed_to_create_course() ? null : 1); } - } else {// all students // course admin if (api_is_allowed_to_create_course() && !api_is_platform_admin()) { @@ -1013,20 +1013,21 @@ class Category implements GradebookItem } // inside a course elseif (isset($this->course_code) && !empty($this->course_code)) { - $evals = Evaluation::load(null, null, $this->course_code, $this->id, null); + $evals = Evaluation::load(null, null, api_get_course_id(), $this->id, null); + }else { // course independent $evals = Evaluation::load(null, api_get_user_id(), null, $this->id, null); } } - - // platform admin + + //platform admin elseif (api_is_platform_admin()) { - $evals = Evaluation::load(null, null, null, $this->id, null); + $evals = Evaluation::load(null, null, api_get_course_id(), $this->id, null); } } - + if ($recursive) { $subcats = $this->get_subcategories($stud_id); foreach ($subcats as $subcat) { @@ -1035,7 +1036,6 @@ class Category implements GradebookItem $evals = array_merge($evals, $subevals); } } - return $evals; } @@ -1050,11 +1050,11 @@ class Category implements GradebookItem // no links in root or course independent categories if ($this->id == 0) { - ; + ; } - // 1 student + // 1 student $stud_id elseif (isset($stud_id)) { - $links = LinkFactory::load(null,null,null,null,empty($this->course_code)?null:$this->course_code,$this->id, + $links = LinkFactory::load(null,null,null,null,empty($this->course_code)?null:api_get_course_id(),$this->id, api_is_allowed_to_create_course() ? null : 1); } // all students -> only for course/platform admin @@ -1065,11 +1065,10 @@ class Category implements GradebookItem if ($recursive) { $subcats = $this->get_subcategories($stud_id); foreach ($subcats as $subcat) { - $sublinks = $subcat->get_links($stud_id, true); + $sublinks = $subcat->get_links($stud_id, false); $links = array_merge($links, $sublinks); } } - return $links; } diff --git a/main/gradebook/lib/user_data_generator.class.php b/main/gradebook/lib/user_data_generator.class.php index 692d15749b..569d3e6786 100644 --- a/main/gradebook/lib/user_data_generator.class.php +++ b/main/gradebook/lib/user_data_generator.class.php @@ -3,7 +3,7 @@ /** * Class to select, sort and transform object data into array data, * used for a student's general view - * @author Bert Steppé + * @author Bert Stepp� */ class UserDataGenerator { @@ -32,7 +32,6 @@ class UserDataGenerator function UserDataGenerator($userid, $evals = array(), $links = array()) { $this->userid = $userid; - $evals_filtered = array(); foreach ($evals as $eval) { $toadd = true; @@ -44,11 +43,15 @@ class UserDataGenerator } } if ($toadd) { - $evals_filtered[] = $eval; + $evals_filtered_copy = $evals; } + }//isset($coursecode) && strcmp($coursecode,api_get_course_id())===0 + if (count($result) == 0) { + $evals_filtered=$evals; + } else { + $evals_filtered=$evals_filtered_copy; } - $this->items = array_merge ($evals_filtered, $links); diff --git a/main/gradebook/user_stats.php b/main/gradebook/user_stats.php index 16ef3ac6ae..d7e9d85e09 100644 --- a/main/gradebook/user_stats.php +++ b/main/gradebook/user_stats.php @@ -41,26 +41,28 @@ $interbreadcrumb[]= array ( 'name' => get_lang('Gradebook' )); $category= Category :: load(0); -$allevals= $category[0]->get_evaluations($_GET['userid'], true); -$alllinks= $category[0]->get_links($_GET['userid'], true); +$my_user_id=Security::remove_XSS($_GET['userid']); +$allevals= $category[0]->get_evaluations($my_user_id, true); +$alllinks= $category[0]->get_links($my_user_id, true); if ($_GET['selectcat'] != null) { $addparams= array ( - 'userid' => $_GET['userid'], - 'selectcat' => $_GET['selectcat'] + 'userid' => $my_user_id, + 'selectcat' => Security::remove_XSS($_GET['selectcat']) ); } else { $addparams= array ( - 'userid' => $_GET['userid'], - 'selecteval' => $_GET['selecteval'] + 'userid' => $my_user_id, + 'selecteval' => Security::remove_XSS($_GET['selecteval']) ); } -$user_table= new UserTable($_GET['userid'], $allevals, $alllinks, $addparams); + +$user_table= new UserTable($my_user_id, $allevals, $alllinks, $addparams); if (isset ($_GET['exportpdf'])) { $pdf= new Cezpdf(); $pdf->selectFont(api_get_path(LIBRARY_PATH).'ezpdf/fonts/Courier.afm'); $pdf->ezSetMargins(30, 30, 50, 30); $pdf->ezSetY(800); - $datagen= new UserDataGenerator($_GET['userid'], $allevals,$alllinks); + $datagen= new UserDataGenerator($my_user_id, $allevals,$alllinks); $data_array= $datagen->get_data(UserDataGenerator :: UDG_SORT_NAME, 0, null, true); $newarray= array (); $displayscore= Scoredisplay :: instance(); @@ -68,8 +70,9 @@ if (isset ($_GET['exportpdf'])) { foreach ($data_array as $data) { $newarray[] = array_slice($data, 1); } + $pdf->ezSetY(810); - $userinfo = get_user_info_from_id($_GET['userid']); + $userinfo = get_user_info_from_id($my_user_id); $pdf->ezText(get_lang('Results').' : '.$userinfo['lastname']. ' '. $userinfo['firstname'].' ('. date('j/n/Y g:i') .')',12,array('justification'=>'center')); $pdf->line(50,790,550,790); $pdf->line(50,40,550,40); @@ -112,6 +115,7 @@ $actions.= '