diff --git a/main/admin/add_courses_to_session.php b/main/admin/add_courses_to_session.php index cdfd50de5d..b0d66e258a 100755 --- a/main/admin/add_courses_to_session.php +++ b/main/admin/add_courses_to_session.php @@ -102,10 +102,10 @@ $noPHP_SELF=true; if ($_POST['formSent']) { - $formSent=$_POST['formSent']; - $firstLetterCourse=$_POST['firstLetterCourse']; - $firstLetterSession=$_POST['firstLetterSession']; - $CourseList=$_POST['SessionCoursesList']; + $formSent = $_POST['formSent']; + $firstLetterCourse = $_POST['firstLetterCourse']; + $firstLetterSession = $_POST['firstLetterSession']; + $CourseList = $_POST['SessionCoursesList']; if (!is_array($CourseList)) { $CourseList=array(); } @@ -117,12 +117,12 @@ if ($_POST['formSent']) { $rs = Database::query("SELECT course_code FROM $tbl_session_rel_course WHERE id_session=$id_session"); $existingCourses = Database::store_result($rs); - - $sql="SELECT id_user - FROM $tbl_session_rel_user - WHERE id_session = $id_session AND relation_type=".COURSE_RELATION_TYPE_RRHH." "; - $result=Database::query($sql); - $UserList=Database::store_result($result); + + // Updating only the RRHH users?? why? + //$sql="SELECT id_user FROM $tbl_session_rel_user WHERE id_session = $id_session AND relation_type=".COURSE_RELATION_TYPE_RRHH." "; + $sql = "SELECT id_user FROM $tbl_session_rel_user WHERE id_session = $id_session "; + $result = Database::query($sql); + $UserList = Database::store_result($result); foreach($CourseList as $enreg_course) { diff --git a/main/exercice/exercice.php b/main/exercice/exercice.php index fb9fc9a236..5bdc79876b 100755 --- a/main/exercice/exercice.php +++ b/main/exercice/exercice.php @@ -744,9 +744,9 @@ if ($show == 'test') { */ if ($origin != 'learnpath') { //avoid sending empty parameters - $myorigin = (empty ($origin) ? '' : '&origin=' . $origin); - $mylpid = (empty ($learnpath_id) ? '' : '&learnpath_id=' . $learnpath_id); - $mylpitemid = (empty ($learnpath_item_id) ? '' : '&learnpath_item_id=' . $learnpath_item_id); + $myorigin = (empty ($origin) ? '' : '&origin=' . $origin); + $mylpid = (empty ($learnpath_id) ? '' : '&learnpath_id=' . $learnpath_id); + $mylpitemid = (empty ($learnpath_item_id) ? '' : '&learnpath_item_id=' . $learnpath_item_id); $token = Security::get_token(); while ($row = Database :: fetch_array($result,'ASSOC')) { @@ -756,20 +756,18 @@ if ($show == 'test') { $time_limits = false; if ($row['start_time'] != '0000-00-00 00:00:00' && $row['end_time'] != '0000-00-00 00:00:00') { $time_limits = true; - } - + } if ($time_limits) { // check if start time - - $start_time = api_strtotime($row['start_time'],'UTC'); - $end_time = api_strtotime($row['end_time'], 'UTC'); - $now = time(); - - $is_actived_time = false; + $start_time = api_strtotime($row['start_time']); + $end_time = api_strtotime($row['end_time']); + $now = time(); + $is_actived_time = false; if ($now > $start_time && $end_time > $now ) { $is_actived_time = true; } - } + } + if ($i % 2 == 0) $s_class = "row_odd"; diff --git a/main/exercice/exercise.class.php b/main/exercice/exercise.class.php index 0cb8873b44..d1c198c457 100755 --- a/main/exercice/exercise.class.php +++ b/main/exercice/exercise.class.php @@ -16,7 +16,7 @@ define('EXERCISE_FEEDBACK_TYPE_END',0); define('EXERCISE_FEEDBACK_TYPE_DIRECT',1); define('EXERCISE_FEEDBACK_TYPE_EXAM',2); -require_once '../inc/lib/exercise_show_functions.lib.php'; +require_once api_get_path(LIBRARY_PATH).'exercise_show_functions.lib.php'; if(!class_exists('Exercise')): @@ -2421,4 +2421,4 @@ class Exercise { } } endif; -?> \ No newline at end of file +?> diff --git a/main/exercice/exercise_admin.php b/main/exercice/exercise_admin.php index 6b1452881b..742c6c75d6 100755 --- a/main/exercice/exercise_admin.php +++ b/main/exercice/exercise_admin.php @@ -12,11 +12,11 @@ // name of the language file that needs to be included $language_file='exercice'; -include 'exercise.class.php'; -include 'question.class.php'; -include 'answer.class.php'; -include '../inc/global.inc.php'; -include 'exercise.lib.php'; +require_once 'exercise.class.php'; +require_once 'question.class.php'; +require_once 'answer.class.php'; +require_once '../inc/global.inc.php'; +require_once 'exercise.lib.php'; $this_section=SECTION_COURSES; if(!api_is_allowed_to_edit(null,true)) { @@ -133,18 +133,12 @@ $(document).ready(function () { }); '; -/********************* - * INIT EXERCISE - *********************/ +// INIT EXERCISE require_once(api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'); $objExercise = new Exercise(); -/********************* - * INIT FORM - *********************/ - - +//INIT FORM if(isset($_GET['exerciseId'])) { $form = new FormValidator('exercise_admin', 'post', api_get_self().'?'.api_get_cidreq().'&exerciseId='.$_GET['exerciseId']); $objExercise -> read (intval($_GET['exerciseId'])); @@ -156,10 +150,8 @@ if(isset($_GET['exerciseId'])) { $objExercise -> createForm ($form); -/********************* - * VALIDATE FORM - *********************/ -if ($form -> validate()) { +// VALIDATE FORM +if ($form->validate()) { $objExercise -> processCreation($form); if ($form -> getSubmitValue('edit') == 'true') { header('Location:exercice.php?message=ExerciseEdited&'.api_get_cidreq()); @@ -168,10 +160,8 @@ if ($form -> validate()) { header('Location:admin.php?message=ExerciseAdded&exerciseId='.$objExercise->id); exit; } -} else { - /********************* - * DISPLAY FORM - *********************/ +} else { + // DISPLAY FORM if (isset($_SESSION['gradebook'])) { $gradebook= $_SESSION['gradebook']; } diff --git a/main/forum/forumfunction.inc.php b/main/forum/forumfunction.inc.php index 18c0b6777f..1558018ef8 100755 --- a/main/forum/forumfunction.inc.php +++ b/main/forum/forumfunction.inc.php @@ -1563,22 +1563,48 @@ function get_thread_information($thread_id) { * @param string Course DB name (optional) * @return resource array Array of type ([user_id=>w,lastname=>x,firstname=>y,thread_id=>z],[]) * @author Christian Fasanando , +* @todo this function need to be improved * @version octubre 2008, dokeos 1.8 */ function get_thread_users_details($thread_id, $db_name = null) { - $t_posts = Database :: get_course_table(TABLE_FORUM_POST, (empty($db_name)?null:$db_name)); - $t_users = Database :: get_main_table(TABLE_MAIN_USER); - $t_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER); - - $sql = "SELECT DISTINCT user.user_id, user.lastname, user.firstname, thread_id - FROM $t_posts , $t_users user, $t_course_user course_user - WHERE poster_id = user.user_id - AND user.user_id = course_user.user_id - AND course_user.relation_type<>".COURSE_RELATION_TYPE_RRHH." - AND thread_id = '".Database::escape_string($thread_id)."' - AND course_user.status NOT IN('1') - AND course_code = '".api_get_course_id()."'"; + $t_posts = Database :: get_course_table(TABLE_FORUM_POST, (empty($db_name)?null:$db_name)); + $t_users = Database :: get_main_table(TABLE_MAIN_USER); + $t_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER); + $t_session_rel_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER); + + $is_western_name_order = api_is_western_name_order(); + if ($is_western_name_order) { + $orderby = 'ORDER BY user.firstname, user.lastname '; + } else { + $orderby = 'ORDER BY user.lastname, user.firstname'; + } + + + if (api_get_session_id()) { + $session_info = api_get_session_info(api_get_session_id()); + $user_to_avoid = "'".$session_info['id_coach']."', '".$session_info['session_admin_id']."'"; + //not showing coaches + $sql = "SELECT DISTINCT user.user_id, user.lastname, user.firstname, thread_id + FROM $t_posts , $t_users user, $t_session_rel_user session_rel_user_rel_course + WHERE poster_id = user.user_id + AND user.user_id = session_rel_user_rel_course.id_user + AND session_rel_user_rel_course.status<>'2' + AND session_rel_user_rel_course.id_user NOT IN ($user_to_avoid) + AND thread_id = '".Database::escape_string($thread_id)."' + AND id_session = '".api_get_session_id()."' + AND course_code = '".api_get_course_id()."' $orderby "; + + } else { + $sql = "SELECT DISTINCT user.user_id, user.lastname, user.firstname, thread_id + FROM $t_posts , $t_users user, $t_course_user course_user + WHERE poster_id = user.user_id + AND user.user_id = course_user.user_id + AND course_user.relation_type<>".COURSE_RELATION_TYPE_RRHH." + AND thread_id = '".Database::escape_string($thread_id)."' + AND course_user.status NOT IN('1') + AND course_code = '".api_get_course_id()."' $orderby"; + } $result = Database::query($sql); return $result; } @@ -1589,6 +1615,7 @@ function get_thread_users_details($thread_id, $db_name = null) { * @param string Course DB name (optional) * @return array Array of type ([user_id=>w,lastname=>x,firstname=>y,thread_id=>z],[]) * @author Jhon Hinojosa, +* @todo this function need to be improved * @version octubre 2008, dokeos 1.8 */ @@ -1597,21 +1624,48 @@ function get_thread_users_qualify($thread_id, $db_name = null) { $t_qualify = Database :: get_course_table(TABLE_FORUM_THREAD_QUALIFY, (empty($db_name)?null:$db_name)); $t_users = Database :: get_main_table(TABLE_MAIN_USER); $t_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER); - - $sql = "SELECT post.poster_id, user.lastname, user.firstname, post.thread_id,user.user_id,qualify.qualify - FROM $t_posts post, - $t_qualify qualify, - $t_users user, - $t_course_user course_user - WHERE - post.poster_id = user.user_id - AND post.poster_id = qualify.user_id - AND user.user_id = course_user.user_id - AND course_user.relation_type<>".COURSE_RELATION_TYPE_RRHH." - AND qualify.thread_id = '".Database::escape_string($thread_id)."' - AND course_user.status not in('1') - AND course_code = '".api_get_course_id()."' - GROUP BY post.poster_id "; + $t_session_rel_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER); + + $is_western_name_order = api_is_western_name_order(); + if ($is_western_name_order) { + $orderby = 'ORDER BY user.firstname, user.lastname '; + } else { + $orderby = 'ORDER BY user.lastname, user.firstname'; + } + + if (api_get_session_id()) { + $session_info = api_get_session_info(api_get_session_id()); + $user_to_avoid = "'".$session_info['id_coach']."', '".$session_info['session_admin_id']."'"; + //not showing coaches + $sql = "SELECT DISTINCT post.poster_id, user.lastname, user.firstname, post.thread_id,user.user_id,qualify.qualify + FROM $t_posts post , $t_users user, $t_session_rel_user session_rel_user_rel_course, $t_qualify qualify + WHERE poster_id = user.user_id + AND post.poster_id = qualify.user_id + AND user.user_id = session_rel_user_rel_course.id_user + AND session_rel_user_rel_course.status<>'2' + AND session_rel_user_rel_course.id_user NOT IN ($user_to_avoid) + AND qualify.thread_id = '".Database::escape_string($thread_id)." + AND thread_id = '".Database::escape_string($thread_id)."' + AND id_session = '".api_get_session_id()."' + AND course_code = '".api_get_course_id()."' + $orderby "; + } else { + $sql = "SELECT DISTINCT post.poster_id, user.lastname, user.firstname, post.thread_id,user.user_id,qualify.qualify + FROM $t_posts post, + $t_qualify qualify, + $t_users user, + $t_course_user course_user + WHERE + post.poster_id = user.user_id + AND post.poster_id = qualify.user_id + AND user.user_id = course_user.user_id + AND course_user.relation_type<>".COURSE_RELATION_TYPE_RRHH." + AND qualify.thread_id = '".Database::escape_string($thread_id)."' + AND post.thread_id = '".Database::escape_string($thread_id)."' + AND course_user.status not in('1') + AND course_code = '".api_get_course_id()."' + $orderby "; + } $result = Database::query($sql); return $result; } @@ -1621,7 +1675,8 @@ function get_thread_users_qualify($thread_id, $db_name = null) { * @param int Thread ID * @param string Course DB name (optional) * @return array Array of type ([user_id=>w,lastname=>x,firstname=>y,thread_id=>z],[]) -* @author Jhon Hinojosa, +* @author Jhon Hinojosa, +* @todo i'm a horrible function fix me * @version octubre 2008, dokeos 1.8 */ @@ -1630,7 +1685,16 @@ function get_thread_users_not_qualify($thread_id, $db_name = null) { $t_qualify = Database :: get_course_table(TABLE_FORUM_THREAD_QUALIFY, (empty($db_name)?null:$db_name)); $t_users = Database :: get_main_table(TABLE_MAIN_USER); $t_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER); - + $t_session_rel_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER); + + + $is_western_name_order = api_is_western_name_order(); + if ($is_western_name_order) { + $orderby = 'ORDER BY user.firstname, user.lastname '; + } else { + $orderby = 'ORDER BY user.lastname, user.firstname'; + } + $sql1 = "select user_id FROM $t_qualify WHERE thread_id = '".$thread_id."'"; $result1 = Database::query($sql1); $cad=''; @@ -1642,15 +1706,32 @@ function get_thread_users_not_qualify($thread_id, $db_name = null) { } else { $cad=substr($cad,0,strlen($cad)-1); } - $sql = "SELECT DISTINCT user.user_id, user.lastname, user.firstname, post.thread_id - FROM $t_posts post, $t_users user,$t_course_user course_user - WHERE post.poster_id = user.user_id - AND user.user_id NOT IN (".$cad.") - AND user.user_id = course_user.user_id - AND course_user.relation_type<>".COURSE_RELATION_TYPE_RRHH." - AND post.thread_id = '".Database::escape_string($thread_id)."' - AND course_user.status not in('1') - AND course_code = '".api_get_course_id()."'"; + + if (api_get_session_id()) { + $session_info = api_get_session_info(api_get_session_id()); + $user_to_avoid = "'".$session_info['id_coach']."', '".$session_info['session_admin_id']."'"; + //not showing coaches + $sql = "SELECT DISTINCT user.user_id, user.lastname, user.firstname, post.thread_id + FROM $t_posts post , $t_users user, $t_session_rel_user session_rel_user_rel_course + WHERE poster_id = user.user_id + AND user.user_id NOT IN (".$cad.") + AND user.user_id = session_rel_user_rel_course.id_user + AND session_rel_user_rel_course.status<>'2' + AND session_rel_user_rel_course.id_user NOT IN ($user_to_avoid) + AND post.thread_id = '".Database::escape_string($thread_id)."' + AND id_session = '".api_get_session_id()."' + AND course_code = '".api_get_course_id()."' $orderby "; + } else { + $sql = "SELECT DISTINCT user.user_id, user.lastname, user.firstname, post.thread_id + FROM $t_posts post, $t_users user,$t_course_user course_user + WHERE post.poster_id = user.user_id + AND user.user_id NOT IN (".$cad.") + AND user.user_id = course_user.user_id + AND course_user.relation_type<>".COURSE_RELATION_TYPE_RRHH." + AND post.thread_id = '".Database::escape_string($thread_id)."' + AND course_user.status not in('1') + AND course_code = '".api_get_course_id()."' $orderby"; + } $result = Database::query($sql); return $result; } @@ -1947,7 +2028,7 @@ function show_add_post_form($action='', $id='', $form_values='') { // thread qualify $form->addElement('static','Group', '
'.get_lang('AlterQualifyThread').''); $form->applyFilter('numeric_calification', 'html_filter'); - $form->addElement('checkbox', 'thread_qualify_gradebook', '', get_lang('QualifyThreadGradebook'),'onclick="javascript: if(this.checked){document.getElementById(\'options_field\').style.display = \'block\';}else{document.getElementById(\'options_field\').style.display = \'none\';}"'); + $form->addElement('checkbox', 'thread_qualify_gradebook', '', get_lang('QualifyThreadGradebook'),'onclick="javascript:if(this.checked==true){document.getElementById(\'options_field\').style.display = \'block\';}else{document.getElementById(\'options_field\').style.display = \'none\';}"'); $form -> addElement('html','