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

[svn r20454] FS#306 - The Assessments (Gradebook) tool: Improvements for better encoding support.

Ivan Tcholakov пре 16 година
родитељ
комит
10053fcdae

+ 19 - 19
main/gradebook/gradebook.php

@@ -303,22 +303,22 @@ if (isset ($_POST['action'])) {
 				$number_of_deleted_evaluations= 0;
 				$number_of_deleted_links= 0;
 				foreach ($_POST['id'] as $indexstr) {
-					if (substr($indexstr, 0, 4) == 'CATE') {
-						$cats= Category :: load(substr($indexstr, 4));
+					if (api_substr($indexstr, 0, 4) == 'CATE') {
+						$cats= Category :: load(api_substr($indexstr, 4));
 						if ($cats[0] != null) {
 							$cats[0]->delete_all();
 						}
 						$number_of_deleted_categories++;
 					}
-					if (substr($indexstr, 0, 4) == 'EVAL') {
-						$eval= Evaluation :: load(substr($indexstr, 4));
+					if (api_substr($indexstr, 0, 4) == 'EVAL') {
+						$eval= Evaluation :: load(api_substr($indexstr, 4));
 						if ($eval[0] != null) {
 						$eval[0]->delete_with_results();						
 						}
 						$number_of_deleted_evaluations++;
 					}
-					if (substr($indexstr, 0, 4) == 'LINK') {
-						$link= LinkFactory :: load(substr($indexstr, 4));
+					if (api_substr($indexstr, 0, 4) == 'LINK') {
+						$link= LinkFactory :: load(api_substr($indexstr, 4));
 						if ($link[0] != null) {
 							$link[0]->delete();							
 						}
@@ -331,22 +331,22 @@ if (isset ($_POST['action'])) {
 			case 'setvisible' :
 				foreach ($_POST['id'] as $indexstr)
 				{
-					if (substr($indexstr, 0, 4) == 'CATE')
+					if (api_substr($indexstr, 0, 4) == 'CATE')
 					{
-						$cats= Category :: load(substr($indexstr, 4));
+						$cats= Category :: load(api_substr($indexstr, 4));
 						$cats[0]->set_visible(1);
 						$cats[0]->save();
 						$cats[0]->apply_visibility_to_children();
 					}
-					if (substr($indexstr, 0, 4) == 'EVAL')
+					if (api_substr($indexstr, 0, 4) == 'EVAL')
 					{
-						$eval= Evaluation :: load(substr($indexstr, 4));
+						$eval= Evaluation :: load(api_substr($indexstr, 4));
 						$eval[0]->set_visible(1);
 						$eval[0]->save();
 					}
-					if (substr($indexstr, 0, 4) == 'LINK')
+					if (api_substr($indexstr, 0, 4) == 'LINK')
 					{
-						$link= LinkFactory :: load(substr($indexstr, 4));
+						$link= LinkFactory :: load(api_substr($indexstr, 4));
 						$link[0]->set_visible(1);
 						$link[0]->save();
 					}
@@ -357,22 +357,22 @@ if (isset ($_POST['action'])) {
 			case 'setinvisible' :
 				foreach ($_POST['id'] as $indexstr)
 				{
-					if (substr($indexstr, 0, 4) == 'CATE')
+					if (api_substr($indexstr, 0, 4) == 'CATE')
 					{
-						$cats= Category :: load(substr($indexstr, 4));
+						$cats= Category :: load(api_substr($indexstr, 4));
 						$cats[0]->set_visible(0);
 						$cats[0]->save();
 						$cats[0]->apply_visibility_to_children();
 					}
-					if (substr($indexstr, 0, 4) == 'EVAL')
+					if (api_substr($indexstr, 0, 4) == 'EVAL')
 					{
-						$eval= Evaluation :: load(substr($indexstr, 4));
+						$eval= Evaluation :: load(api_substr($indexstr, 4));
 						$eval[0]->set_visible(0);
 						$eval[0]->save();
 					}
-					if (substr($indexstr, 0, 4) == 'LINK')
+					if (api_substr($indexstr, 0, 4) == 'LINK')
 					{
-						$link= LinkFactory :: load(substr($indexstr, 4));
+						$link= LinkFactory :: load(api_substr($indexstr, 4));
 						$link[0]->set_visible(0);
 						$link[0]->save();
 					}
@@ -602,4 +602,4 @@ if ($category != '0') {
 	DisplayGradebook :: display_header_gradebook($cats[0], (((count($allcat) == '0') && (!isset ($_GET['search']))) ? 0 : 1), 0, $is_course_admin, $is_platform_admin, $simple_search_form);
 }
 $gradebooktable->display();
-Display :: display_footer();
+Display :: display_footer();

+ 1 - 1
main/gradebook/gradebook_view_result.php

@@ -508,4 +508,4 @@ if ($file_type == null) { //show the result header
 	}
 	$resulttable->display();
 	Display :: display_footer();
-}
+}

+ 2 - 2
main/gradebook/lib/be/abstractlink.class.php

@@ -365,7 +365,7 @@ abstract class AbstractLink implements GradebookItem
 		$links = $rootcat[0]->get_links((api_is_allowed_to_create_course() ? null : api_get_user_id()), true);
 		$foundlinks = array();
 		foreach ($links as $link) {
-			if (!(strpos(strtolower($link->get_name()), strtolower($name_mask)) === false)) {
+			if (!(api_strpos(api_strtolower($link->get_name()), api_strtolower($name_mask)) === false)) {
 				$foundlinks[] = $link;				
 			}
 		}
@@ -428,4 +428,4 @@ abstract class AbstractLink implements GradebookItem
 	public function get_view_url ($stud_id) {
 		return null;
 	}
-}
+}

+ 2 - 2
main/gradebook/lib/be/evaluation.class.php

@@ -573,7 +573,7 @@ class Evaluation implements GradebookItem
 		$evals = $rootcat[0]->get_evaluations((api_is_allowed_to_create_course() ? null : api_get_user_id()), true);
 		$foundevals = array();
 		foreach ($evals as $eval) {
-			if (!(strpos(strtolower($eval->get_name()), strtolower($name_mask)) === false)) {
+			if (!(api_strpos(api_strtolower($eval->get_name()), api_strtolower($name_mask)) === false)) {
 				$foundevals[] = $eval;				
 			}
 		}
@@ -592,4 +592,4 @@ class Evaluation implements GradebookItem
 		return $this->has_results() ? 'evalnotempty' : 'evalempty';
 	}
     
-}
+}

+ 2 - 2
main/gradebook/lib/fe/evalform.class.php

@@ -111,7 +111,7 @@ class EvalForm extends FormValidator
 			'style' => 'width:250px'
 		));
 		foreach ($this->evaluation_object->get_not_subscribed_students() as $user) {
-			if ( (!isset($this->extra)) || empty($this->extra) || strtoupper(substr($user[1],0,1)) == $this->extra ) {
+			if ( (!isset($this->extra)) || empty($this->extra) || api_strtoupper(api_substr($user[1],0,1)) == $this->extra ) {
 				$select->addoption($user[1] . ' ' . $user[2] . ' (' . $user[3] . ')', $user[0]);
 			}	
 		}
@@ -385,4 +385,4 @@ class EvalForm extends FormValidator
 			return ($user1['lastname'] < $user2['lastname'] ? -1 : 1);
 		}	
 	}
-}
+}

+ 5 - 5
main/gradebook/lib/flatview_data_generator.class.php

@@ -252,19 +252,19 @@ class FlatViewDataGenerator
 	// Sort functions - used internally
 
 	function sort_by_last_name($item1, $item2) {
-		if (strtolower($item1[1]) == strtolower($item2[1])) {
+		if (api_strtolower($item1[1]) == api_strtolower($item2[1])) {
 			return 0;			
 		} else {
-			return (strtolower($item1[1]) < strtolower($item2[1]) ? -1 : 1);			
+			return (api_strtolower($item1[1]) < api_strtolower($item2[1]) ? -1 : 1);			
 		}
 	}
 
 	function sort_by_first_name($item1, $item2)
 	{
-		if (strtolower($item1[2]) == strtolower($item2[2])) {
+		if (api_strtolower($item1[2]) == api_strtolower($item2[2])) {
 			return $this->sort_by_last_name($item1, $item2);			
 		} else {
-			return (strtolower($item1[2]) < strtolower($item2[2]) ? -1 : 1);			
+			return (api_strtolower($item1[2]) < api_strtolower($item2[2]) ? -1 : 1);			
 		}
 	}
-}
+}

+ 5 - 5
main/gradebook/lib/gradebook_data_generator.class.php

@@ -146,10 +146,10 @@ class GradebookDataGenerator
 // Make sure to only use functions as defined in the GradebookItem interface !
 
 	function sort_by_name($item1, $item2) {
-		if (strtolower($item1->get_name()) == strtolower($item2->get_name())) {
+		if (api_strtolower($item1->get_name()) == api_strtolower($item2->get_name())) {
 			return 0;			
 		} else {
-			return (strtolower($item1->get_name()) < strtolower($item2->get_name()) ? -1 : 1);			
+			return (api_strtolower($item1->get_name()) < api_strtolower($item2->get_name()) ? -1 : 1);			
 		}
 	}
 
@@ -163,10 +163,10 @@ class GradebookDataGenerator
 	}
 	
 	function sort_by_description($item1, $item2) {
-		if (strtolower($item1->get_description()) == strtolower($item2->get_description())) {
+		if (api_strtolower($item1->get_description()) == api_strtolower($item2->get_description())) {
 			return $this->sort_by_name($item1,$item2);			
 		} else {
-			return (strtolower($item1->get_description()) < strtolower($item2->get_description()) ? -1 : 1);			
+			return (api_strtolower($item1->get_description()) < api_strtolower($item2->get_description()) ? -1 : 1);			
 		}
 
 	}
@@ -226,4 +226,4 @@ class GradebookDataGenerator
 			return date("j/n/Y g:i", $date);			
 		}
 	}
-}
+}

+ 5 - 5
main/gradebook/lib/results_data_generator.class.php

@@ -137,19 +137,19 @@ class ResultsDataGenerator
 
 	// Sort functions - used internally
 	function sort_by_last_name($item1, $item2) {
-		if (strtolower($item1['lastname']) == strtolower($item2['lastname'])) {
+		if (api_strtolower($item1['lastname']) == api_strtolower($item2['lastname'])) {
 			return 0;
 		} else {
-			return (strtolower($item1['lastname']) < strtolower($item2['lastname']) ? -1 : 1);			
+			return (api_strtolower($item1['lastname']) < api_strtolower($item2['lastname']) ? -1 : 1);			
 		}
 	}
 
 	function sort_by_first_name($item1, $item2) {
-		if (strtolower($item1['firstname']) == strtolower($item2['firstname'])) {
+		if (api_strtolower($item1['firstname']) == api_strtolower($item2['firstname'])) {
 			return 0;
 		}
 		else {
-			return (strtolower($item1['firstname']) < strtolower($item2['firstname']) ? -1 : 1);			
+			return (api_strtolower($item1['firstname']) < api_strtolower($item2['firstname']) ? -1 : 1);			
 		}
 
 	}
@@ -167,4 +167,4 @@ class ResultsDataGenerator
 		$score2 = (isset($item2['score']) ? array($item2['score'],$this->evaluation->get_max()) : null);
 		return ScoreDisplay :: compare_scores_by_custom_display($score1, $score2);
 	}
-}
+}

+ 7 - 7
main/gradebook/lib/user_data_generator.class.php

@@ -171,8 +171,8 @@ class UserDataGenerator
 	}
 
 	function sort_by_course($item1, $item2) {
-		$name1 = strtolower($this->get_course_name_from_code_cached($item1->get_course_code()));
-		$name2 = strtolower($this->get_course_name_from_code_cached($item2->get_course_code()));
+		$name1 = api_strtolower($this->get_course_name_from_code_cached($item1->get_course_code()));
+		$name2 = api_strtolower($this->get_course_name_from_code_cached($item2->get_course_code()));
 		if ($name1 == $name2) {
 			return 0;
 		} else {
@@ -184,8 +184,8 @@ class UserDataGenerator
 		$cat1 = $this->get_category_cached($item1->get_category_id());
 		$cat2 = $this->get_category_cached($item2->get_category_id());
 
-		$name1 = strtolower($this->get_category_name_to_display($cat1));
-		$name2 = strtolower($this->get_category_name_to_display($cat2));
+		$name1 = api_strtolower($this->get_category_name_to_display($cat1));
+		$name2 = api_strtolower($this->get_category_name_to_display($cat2));
 		if ($name1 == $name2) {
 			return 0;
 		} else {
@@ -195,10 +195,10 @@ class UserDataGenerator
 
 
 	function sort_by_name($item1, $item2) {
-		if (strtolower($item1->get_name()) == strtolower($item2->get_name())) {
+		if (api_strtolower($item1->get_name()) == api_strtolower($item2->get_name())) {
 			return 0;
 		} else {
-			return (strtolower($item1->get_name()) < strtolower($item2->get_name()) ? -1 : 1);
+			return (api_strtolower($item1->get_name()) < api_strtolower($item2->get_name()) ? -1 : 1);
 		}		
 	}
 
@@ -318,4 +318,4 @@ class UserDataGenerator
 					return '';
 			}
 	}
-}
+}