[svn r11842] update the list of students in a course : if we fill the param $session_id, only the students of this session will be listed

skala
Eric Marguin 19 years ago
parent e7b6b0271a
commit afeaa7e264
  1. 23
      main/inc/lib/course.lib.php

@ -1047,25 +1047,32 @@ class CourseManager
* @param boolean $full list to true if we want sessions students too
* @return array with user id
*/
function get_student_list_from_course_code($course_code, $full_list=false)
function get_student_list_from_course_code($course_code, $with_session=false, $session_id=0)
{
$a_students = array();
// students directly subscribed to the course
$table = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
$sql_query = "SELECT user_id FROM $table WHERE `course_code` = '$course_code' AND `status` = 5";
$rs = api_sql_query($sql_query, __FILE__, __LINE__);
while($student = mysql_fetch_array($rs))
$session_id = intval($session_id);
if($session_id == 0)
{
$a_students[$student['user_id']] = $student['user_id'];
// students directly subscribed to the course
$table = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
$sql_query = "SELECT user_id FROM $table WHERE `course_code` = '$course_code' AND `status` = 5";
$rs = api_sql_query($sql_query, __FILE__, __LINE__);
while($student = mysql_fetch_array($rs))
{
$a_students[$student['user_id']] = $student['user_id'];
}
}
// students subscribed to the course through a session
if(api_get_setting('use_session_mode')=='true' && $full_list)
if(api_get_setting('use_session_mode')=='true' && $with_session)
{
$table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$sql_query = "SELECT DISTINCT id_user as user_id FROM $table WHERE `course_code` = '$course_code'";
if($session_id!=0)
$sql_query .= ' AND id_session = '.$session_id;
$rs = api_sql_query($sql_query, __FILE__, __LINE__);
while($student = mysql_fetch_array($rs))
{

Loading…
Cancel
Save