Julio Montoya 15 tahun lalu
induk
melakukan
5d11e0eb60

+ 1 - 1
main/admin/add_many_session_to_category.php

@@ -50,7 +50,7 @@ if(isset($_GET['add_type']) && $_GET['add_type']!=''){
 	$add_type = Security::remove_XSS($_REQUEST['add_type']);
 }
 
-if (!api_is_platform_admin()) {
+if (!api_is_platform_admin() && !api_is_session_admin()) {
 	$sql = 'SELECT session_admin_id FROM '.Database :: get_main_table(TABLE_MAIN_SESSION).' WHERE id='.$id_session;
 	$rs = Database::query($sql);
 	if (Database::result($rs,0,0)!=$_user['user_id']) {

+ 2 - 1
main/admin/session_category_edit.php

@@ -45,9 +45,10 @@ if (!$infos=Database::fetch_array($result)) {
 list($year_start,$month_start,$day_start)=explode('-',$infos['date_start']);
 list($year_end,$month_end,$day_end)=explode('-',$infos['date_end']);
 
-if (!api_is_platform_admin() && $infos['session_admin_id']!=$_user['user_id']) {
+if (!api_is_platform_admin() && $infos['session_admin_id']!=$_user['user_id'] && !api_is_session_admin()) {
 	api_not_allowed(true);
 }
+
 if ($_POST['formSent']) {
 	$formSent=1;
 	$name= $_POST['name'];

+ 2 - 2
main/admin/session_course_edit.php

@@ -12,9 +12,9 @@ $cidReset=true;
 require '../inc/global.inc.php';
 require_once '../inc/lib/sessionmanager.lib.php';
 // setting the section (for the tabs)
-$this_section=SECTION_PLATFORM_ADMIN;
+/*$this_section=SECTION_PLATFORM_ADMIN;
 
-api_protect_admin_script();
+api_protect_admin_script();*/
 
 $id_session=intval($_GET['id_session']);
 $course_code=trim(stripslashes($_GET['course_code']));

+ 1 - 1
main/admin/session_course_list.php

@@ -15,7 +15,7 @@ include('../inc/global.inc.php');
 // setting the section (for the tabs)
 $this_section=SECTION_PLATFORM_ADMIN;
 
-api_protect_admin_script();
+api_protect_admin_script(true);
 
 // Database Table Definitions
 $tbl_course							= Database::get_main_table(TABLE_MAIN_COURSE);

+ 2 - 2
main/admin/session_course_user_list.php

@@ -9,7 +9,7 @@
 $language_file='admin';
 $cidReset=true;
 include('../inc/global.inc.php');
-api_protect_admin_script();
+api_protect_admin_script(true);
 $tbl_user=Database::get_main_table(TABLE_MAIN_USER);
 $tbl_course=Database::get_main_table(TABLE_MAIN_COURSE);
 $tbl_session=Database::get_main_table(TABLE_MAIN_SESSION);
@@ -57,7 +57,7 @@ $limit=20;
 $from=$page * $limit;
 $is_western_name_order = api_is_western_name_order();
 
-$result=Database::query("SELECT user_id,".($is_western_name_order ? 'firstname,lastname' : 'lastname,firstname').",username FROM $tbl_session_rel_course_rel_user,$tbl_user WHERE user_id=id_user AND id_session='$id_session' AND course_code='".addslashes($course_code)."' ORDER BY $sort LIMIT $from,".($limit+1));
+$result=Database::query("SELECT u.user_id,".($is_western_name_order ? 'u.firstname, u.lastname' : 'u.lastname, u.firstname').", u.username FROM $tbl_session_rel_course_rel_user scru, $tbl_user u WHERE u.user_id=scru.id_user AND scru.id_session='$id_session' AND scru.status<>2 AND scru.course_code='".addslashes($course_code)."' ORDER BY $sort LIMIT $from,".($limit+1));
 $Users=Database::store_result($result);
 
 $nbr_results=sizeof($Users);

+ 10 - 4
main/admin/session_list.php

@@ -136,22 +136,27 @@ if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
 		$where.= ' session_category_id = "'.$id_category.'" ';
 		$cond_url.= '&amp;id_category='.$id_category;
 	}
-
+	
+	$user_id= $_user['user_id'];
+	if (api_is_session_admin()==true) {
+		$where.=" AND s.session_admin_id = $user_id ";
+	}
+	
 	//Get list sessions
 	$sort = ($sort != "name_category")?  's.'.$sort : 'category_name';
 	$query = "SELECT s.id, s.name, s.nbr_courses, s.date_start, s.date_end, u.firstname, u.lastname , sc.name as category_name, s.visibility
 			 FROM $tbl_session s
 			 	LEFT JOIN  $tbl_session_category sc ON s.session_category_id = sc.id
-			 	INNER JOIN $tbl_user u ON s.id_coach = u.user_id
+			 	INNER JOIN $tbl_user u ON s.id_coach = u.user_id 
 			 $where
 			 ORDER BY $sort ";
 	//query which allows me to get a record without taking into account the page
 	$query_rows = "SELECT count(*) as total_rows
 			 FROM $tbl_session s
 			 	LEFT JOIN  $tbl_session_category sc ON s.session_category_id = sc.id
-			 	INNER JOIN $tbl_user u ON s.id_coach = u.user_id
+			 	INNER JOIN $tbl_user u ON s.id_coach = u.user_id 
 			 $where ";
-
+			 
 //filtering the session list by access_url
 	if ($_configuration['multiple_access_urls'] == true){
 		$table_access_url_rel_session= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
@@ -174,6 +179,7 @@ if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
 			 $where ";
 		}
 	}
+	
 
 	$result_rows = Database::query($query_rows);
 	$recorset = Database::fetch_array($result_rows);

+ 1 - 1
main/coursecopy/copy_course_session.php

@@ -26,7 +26,7 @@ require_once '../inc/lib/xajax/xajax.inc.php';
 $xajax = new xajax();
 $xajax -> registerFunction('search_courses');
 
-if (!api_is_allowed_to_edit()) {
+if (!api_is_allowed_to_edit() && !api_is_session_admin()) {
 	api_not_allowed(true);
 }
 

+ 1 - 1
main/inc/lib/add_course.lib.inc.php

@@ -2115,7 +2115,7 @@ function fill_Db_course($courseDbName, $courseRepository, $language,$default_doc
     Database::query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_GRADEBOOK."','gradebook/index.php','gradebook.gif','".string2binary(api_get_setting('course_create_active_tools', 'gradebook')). "','0','squaregrey.gif','NO','_self','authoring','0')");
 	Database::query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_GLOSSARY."','glossary/index.php','glossary.gif','".string2binary(api_get_setting('course_create_active_tools', 'glossary')). "','0','squaregrey.gif','NO','_self','authoring','0')");
 	Database::query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_NOTEBOOK."','notebook/index.php','notebook.gif','".string2binary(api_get_setting('course_create_active_tools', 'notebook'))."','0','squaregrey.gif','NO','_self','interaction','0')");
-	Database::query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_ATTENDANCE."','attendance/index.php','attendance.gif','".string2binary(api_get_setting('course_create_active_tools', 'attendances'))."','0','squaregrey.gif','NO','_self','interaction','0')");
+	Database::query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_ATTENDANCE."','attendance/index.php','attendance.gif','".string2binary(api_get_setting('course_create_active_tools', 'attendances'))."','0','squaregrey.gif','NO','_self','authoring','0')");
 	if(api_get_setting('service_visio','active')=='true')
 	{
 		$mycheck = api_get_setting('service_visio','visio_host');

+ 27 - 5
main/mySpace/course.php

@@ -61,12 +61,34 @@ Display :: display_header($nameTools);
 
 $a_courses = array();
 if (api_is_drh()) {
-	
-	$a_courses = array_keys(CourseManager::get_courses_followed_by_drh($_user['user_id']));
+
+	$title = '';
+	if (empty($id_session)) {		
+		if (isset($_GET['user_id'])) {
+			$user_id = intval($_GET['user_id']);
+			$user_info = api_get_user_info($user_id);
+			$title = get_lang('AssignedCoursesTo').' '.api_get_person_name($user_info['firstname'], $user_info['lastname']);			
+			$courses  = CourseManager::get_course_list_of_user_as_course_admin($user_id);		
+		} else {
+			$title = get_lang('YourCourseList');
+			$courses = CourseManager::get_courses_followed_by_drh($_user['user_id']);	
+		}
+	} else {
+		$session_name = api_get_session_name($id_session);		
+		$title = api_htmlentities($session_name,ENT_QUOTES,$charset).' : '.get_lang('CourseListInSession');		
+		$courses = Tracking::get_courses_list_from_session($id_session);
+	}
+			
+	$a_courses = array_keys($courses);
 
 	$menu_items[] = '<a href="index.php?view=drh_students">'.get_lang('Students').'</a>';
 	$menu_items[] = '<a href="teachers.php">'.get_lang('Teachers').'</a>';
-	$menu_items[] = get_lang('Courses');
+	
+	if (empty($_GET['user_id']) && empty($id_session)) {
+		$menu_items[] = get_lang('Courses');
+	} else {
+		$menu_items[] = '<a href="course.php">'.get_lang('Courses').'</a>';
+	}
 	$menu_items[] = '<a href="session.php">'.get_lang('Sessions').'</a>';
 		
 	echo '<div class="actions-title" style ="font-size:10pt;">';
@@ -83,7 +105,7 @@ if (api_is_drh()) {
 		echo '&nbsp;&nbsp;<a href="javascript: void(0);" onclick="javascript: window.print()"><img align="absbottom" src="../img/printmgr.gif">&nbsp;'.get_lang('Print').'</a> ';		
 	}
 	echo '</div>';
-	echo '<br />';
+	echo '<h4>'.$title.'</h4>';
 }
 
 // Database Table Definitions
@@ -156,7 +178,7 @@ if (is_array($a_courses)) {
 		$avg_assignments_in_course = $avg_messages_in_course = $avg_progress_in_course = $avg_score_in_course = $avg_time_spent_in_course = 0;
 
 		// students directly subscribed to the course			
-		if (empty($session_id)) {
+		if (empty($id_session)) {
 			$sql = "SELECT user_id FROM $tbl_user_course as course_rel_user WHERE course_rel_user.status='5' AND course_rel_user.course_code='$course_code'";
 		} else {
 			$sql = "SELECT id_user as user_id FROM $tbl_session_course_user srcu WHERE  srcu. course_code='$course_code' AND id_session = '$id_session' AND srcu.status<>2";			

+ 3 - 3
main/mySpace/myStudents.php

@@ -7,7 +7,7 @@
  */
 
 // name of the language file that needs to be included
-$language_file = array('registration', 'index', 'tracking', 'exercice', 'admin');
+$language_file = array('registration', 'index', 'tracking', 'exercice', 'admin', 'gradebook');
 
 
 require '../inc/global.inc.php';
@@ -892,7 +892,7 @@ if ($timezone !== null) {
 			get_lang('Time', ''),						
 			get_lang('Progress', ''),
 			get_lang('Score', ''),
-			get_lang('AttendanceFaults', ''),
+			get_lang('AttendancesFaults', ''),
 			get_lang('Evaluations')
 		);
 
@@ -933,7 +933,7 @@ if ($timezone !== null) {
 					<th>'.get_lang('Time').'</th>	
 					<th>'.get_lang('Progress').'</th>
 					<th>'.get_lang('Score').'</th>
-					<th>'.get_lang('AttendanceFaults').'</th>
+					<th>'.get_lang('AttendancesFaults').'</th>
 					<th>'.get_lang('Evaluations').'</th>
 					<th>'.get_lang('Details').'</th>
 				  </tr>';

+ 3 - 2
main/mySpace/session.php

@@ -7,7 +7,7 @@
 ob_start();
 $nameTools= 'Sessions';
 // name of the language file that needs to be included
-$language_file = array ('registration', 'index', 'trad4all', 'tracking');
+$language_file = array ('registration', 'index', 'trad4all', 'tracking', 'admin');
 $cidReset = true;
 
 require '../inc/global.inc.php';
@@ -102,7 +102,8 @@ if (api_is_drh()) {
 		echo '<a href="'.api_get_self().'?export=csv"><img align="absbottom" src="../img/excel.gif">&nbsp;'.get_lang('ExportAsCSV').'</a>';	
 	}
 	echo '</div>';
-		
+	echo '<h4>'.get_lang('YourSessionsList').'</h4>';
+
 } else {		
 	if (api_is_platform_admin()) {
 		$a_sessions = SessionManager::get_sessions_list();

+ 31 - 6
main/mySpace/student.php

@@ -5,7 +5,7 @@
  */
 
  // name of the language file that needs to be included
-$language_file = array ('registration', 'index', 'tracking');
+$language_file = array ('registration', 'index', 'tracking', 'admin');
 $cidReset = true;
 
 require '../inc/global.inc.php';
@@ -106,12 +106,34 @@ if ($isCoach || api_is_platform_admin() || api_is_drh()) {
 	
 	if (api_is_drh()) {
 		
-		if (!isset($_GET['id_session'])) {			
-			$students = array_keys(UserManager::get_users_followed_by_drh($_user['user_id'], STUDENT));			
-			$courses_of_the_platform = CourseManager :: get_real_course_list();
+		$title = get_lang('YourStudents');
+		if (!isset($_GET['id_session'])) {
+			
+			if (isset($_GET['user_id'])) {
+				$user_id = intval($_GET['user_id']);
+				$user_info = api_get_user_info($user_id);				
+				$title = api_get_person_name($user_info['firstname'], $user_info['lastname']).' : '.get_lang('Students');
+				$courses_by_teacher  = CourseManager::get_course_list_of_user_as_course_admin($user_id);								
+				$students_by_course = array();
+				if (!empty($courses_by_teacher)) {
+					foreach ($courses_by_teacher as $course) {
+						$students_by_course = array_keys(CourseManager::get_student_list_from_course_code($course['course_code']));
+						if (count($students_by_course) > 0) {
+							foreach ($students_by_course as $student_by_course) {
+								$students[] = $student_by_course;
+							}
+						}
+					}
+				}
+				$students = array_unique($students);				
+			} else {
+				$students = array_keys(UserManager::get_users_followed_by_drh($_user['user_id'], STUDENT));									
+			}
+			
+			$courses_of_the_platform = CourseManager :: get_real_course_list();			
 			foreach ($courses_of_the_platform as $course) {
 				$courses[$course['code']] = $course['code'];
-			}			
+			}
 		}
 		
 		$menu_items[] = '<a href="index.php?view=drh_students">'.get_lang('Students').'</a>';
@@ -134,7 +156,10 @@ if ($isCoach || api_is_platform_admin() || api_is_drh()) {
 			echo '<a href="'.api_get_self().'?export=csv"><img align="absbottom" src="../img/excel.gif">&nbsp;'.get_lang('ExportAsCSV').'</a>';	
 		}
 		echo '</div>';
-		echo '<h4>'.get_lang('YourStudentsList').'</h4>';
+		
+		echo '<h4>'.$title.'</h4>';
+		
+		
 	} else {
 		echo '<div align="left" style="float:left"><h4>'.$title.'</h4></div>
 			  <div align="right">

+ 1 - 0
main/mySpace/teachers.php

@@ -49,6 +49,7 @@ if (api_is_drh()) {
 		echo '<a href="'.api_get_self().'?export=xls"><img align="absbottom" src="../img/excel.gif">&nbsp;'.get_lang('ExportAsXLS').'</a>';	
 	}
 	echo '</div>';
+	echo '<h4>'.get_lang('YourTeachers').'</h4>';
 	echo '<br />';
 }
 

+ 1 - 1
main/tracking/courseLog.php

@@ -37,7 +37,7 @@ if (isset($_GET['from']) && $_GET['from'] == 'myspace') {
 // access restrictions
 $is_allowedToTrack = $is_courseAdmin || $is_platformAdmin || $is_courseCoach || $is_sessionAdmin || api_is_drh();
 
-if (!$is_allowedToTrack) {
+if (!$is_allowedToTrack && !api_is_session_admin()) {
 	Display :: display_header(null);
 	api_not_allowed();
 	Display :: display_footer();