当前位置: 首页>>代码示例>>PHP>>正文


PHP CourseManager::get_teacher_list_from_course_code方法代码示例

本文整理汇总了PHP中CourseManager::get_teacher_list_from_course_code方法的典型用法代码示例。如果您正苦于以下问题:PHP CourseManager::get_teacher_list_from_course_code方法的具体用法?PHP CourseManager::get_teacher_list_from_course_code怎么用?PHP CourseManager::get_teacher_list_from_course_code使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CourseManager的用法示例。


在下文中一共展示了CourseManager::get_teacher_list_from_course_code方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: parse_content

 /**
  * @param int       $userId
  * @param string    $content
  * @param string    $course_code
  * @param int       $session_id
  *
  * @return mixed
  */
 public static function parse_content($userId, $content, $course_code, $session_id = 0)
 {
     $readerInfo = api_get_user_info($userId);
     $courseInfo = api_get_course_info($course_code);
     $teacher_list = CourseManager::get_teacher_list_from_course_code($courseInfo['code']);
     $teacher_name = '';
     if (!empty($teacher_list)) {
         foreach ($teacher_list as $teacher_data) {
             $teacher_name = api_get_person_name($teacher_data['firstname'], $teacher_data['lastname']);
             $teacher_email = $teacher_data['email'];
             break;
         }
     }
     $courseLink = api_get_course_url($course_code, $session_id);
     $data['user_name'] = $readerInfo['username'];
     $data['user_firstname'] = $readerInfo['firstname'];
     $data['user_lastname'] = $readerInfo['lastname'];
     $data['teacher_name'] = $teacher_name;
     $data['teacher_email'] = $teacher_email;
     $data['course_title'] = $courseInfo['name'];
     $data['course_link'] = Display::url($courseLink, $courseLink);
     $data['official_code'] = $readerInfo['official_code'];
     $content = str_replace(self::get_tags(), $data, $content);
     return $content;
 }
开发者ID:secuencia24,项目名称:chamilo-lms,代码行数:33,代码来源:AnnouncementManager.php

示例2: attendance_sheet_export_to_pdf

 /**
  * It's used to print attendance sheet
  * @param string action
  * @param int    attendance id
  */
 public function attendance_sheet_export_to_pdf($action, $attendance_id, $student_id = 0, $course_id = '')
 {
     $attendance = new Attendance();
     $courseInfo = CourseManager::get_course_information($course_id);
     $attendance->set_course_id($courseInfo['code']);
     $data_array = array();
     $data_array['attendance_id'] = $attendance_id;
     $data_array['users_in_course'] = $attendance->get_users_rel_course($attendance_id);
     $filter_type = 'today';
     if (!empty($_REQUEST['filter'])) {
         $filter_type = $_REQUEST['filter'];
     }
     $my_calendar_id = null;
     if (is_numeric($filter_type)) {
         $my_calendar_id = $filter_type;
         $filter_type = 'calendar_id';
     }
     $data_array['attendant_calendar'] = $attendance->get_attendance_calendar($attendance_id, $filter_type, $my_calendar_id);
     if (api_is_allowed_to_edit(null, true) || api_is_drh()) {
         $data_array['users_presence'] = $attendance->get_users_attendance_sheet($attendance_id);
     } else {
         if (!empty($student_id)) {
             $user_id = intval($student_id);
         } else {
             $user_id = api_get_user_id();
         }
         $data_array['users_presence'] = $attendance->get_users_attendance_sheet($attendance_id, $user_id);
         $data_array['faults'] = $attendance->get_faults_of_user($user_id, $attendance_id);
         $data_array['user_id'] = $user_id;
     }
     $data_array['next_attendance_calendar_id'] = $attendance->get_next_attendance_calendar_id($attendance_id);
     //Set headers pdf
     $courseCategory = CourseManager::get_course_category($courseInfo['category_code']);
     $teacherInfo = CourseManager::get_teacher_list_from_course_code($courseInfo['real_id']);
     $teacherName = null;
     foreach ($teacherInfo as $dados) {
         if ($teacherName != null) {
             $teacherName = $teacherName . " / ";
         }
         $teacherName .= $dados['firstname'] . " " . $dados['lastname'];
     }
     // Get data table - Marco - ordenacao fixa - just fullname
     $data_table = array();
     $head_table = array('#', get_lang('Name'));
     foreach ($data_array['attendant_calendar'] as $class_day) {
         //$head_table[] = api_format_date($class_day['date_time'], DATE_FORMAT_SHORT).' <br />'.api_format_date($class_day['date_time'], TIME_NO_SEC_FORMAT);
         $head_table[] = api_format_date($class_day['date_time'], DATE_FORMAT_NUMBER_NO_YEAR);
     }
     $data_table[] = $head_table;
     $dataClass = array();
     $max_dates_per_page = 10;
     $data_attendant_calendar = $data_array['attendant_calendar'];
     $data_users_presence = $data_array['users_presence'];
     $count = 1;
     if (!empty($data_array['users_in_course'])) {
         foreach ($data_array['users_in_course'] as $user) {
             $cols = 1;
             $result = array();
             $result['count'] = $count;
             $result['full_name'] = api_get_person_name($user['firstname'], $user['lastname']);
             foreach ($data_array['attendant_calendar'] as $class_day) {
                 if ($class_day['done_attendance'] == 1) {
                     if ($data_users_presence[$user['user_id']][$class_day['id']]['presence'] == 1) {
                         $result[$class_day['id']] = get_lang('UserAttendedSymbol');
                     } else {
                         $result[$class_day['id']] = get_lang('UserNotAttendedSymbol');
                     }
                 } else {
                     $result[$class_day['id']] = " ";
                 }
                 $cols++;
             }
             $count++;
             $data_table[] = $result;
         }
     }
     $max_cols_per_page = 12;
     //10 dates + 2 name and number
     $max_dates_per_page = $max_dates_per_page_original = $max_cols_per_page - 2;
     //10
     $rows = count($data_table);
     if ($cols > $max_cols_per_page) {
         $number_tables = round(($cols - 2) / $max_dates_per_page);
         $headers = $data_table[0];
         $all = array();
         $tables = array();
         $changed = 1;
         for ($i = 0; $i <= $rows; $i++) {
             $row = $data_table[$i];
             $key = 1;
             $max_dates_per_page = 10;
             $item = $data_table[$i];
             $count_j = 0;
             if (!empty($item)) {
                 foreach ($item as $value) {
//.........这里部分代码省略.........
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:101,代码来源:attendance_controller.php

示例3: restore

 /**
  * Restore a course.
  * @param 	string 	The code of the Chamilo-course in
  * @param	int		The session id
  * @param	bool	Course settings are going to be restore?
  */
 public function restore($destination_course_code = '', $session_id = 0, $update_course_settings = false, $respect_base_content = false)
 {
     if ($destination_course_code == '') {
         $course_info = api_get_course_info();
         $this->destination_course_info = $course_info;
         $this->course->destination_path = $course_info['path'];
     } else {
         $course_info = api_get_course_info($destination_course_code);
         $this->destination_course_info = $course_info;
         $this->course->destination_path = $course_info['path'];
     }
     $this->destination_course_id = $course_info['real_id'];
     //Getting first teacher (for the forums)
     $teacher_list = CourseManager::get_teacher_list_from_course_code($course_info['real_id']);
     $this->first_teacher_id = api_get_user_id();
     if (!empty($teacher_list)) {
         foreach ($teacher_list as $teacher) {
             $this->first_teacher_id = $teacher['user_id'];
             break;
         }
     }
     if (empty($this->course)) {
         return false;
     }
     // Source platform encoding - reading/detection
     // The correspondent data field has been added as of version 1.8.6.1
     if (empty($this->course->encoding)) {
         // The archive has been created by a system which is prior to 1.8.6.1 version.
         // In this case we have to detect the encoding.
         $sample_text = $this->course->get_sample_text() . "\n";
         // Let us exclude ASCII lines, probably they are English texts.
         $sample_text = explode("\n", $sample_text);
         foreach ($sample_text as $key => &$line) {
             if (api_is_valid_ascii($line)) {
                 unset($sample_text[$key]);
             }
         }
         $sample_text = join("\n", $sample_text);
         $this->course->encoding = api_detect_encoding($sample_text, $course_info['language']);
     }
     // Encoding conversion of the course, if it is needed.
     $this->course->to_system_encoding();
     foreach ($this->tools_to_restore as $tool) {
         $function_build = 'restore_' . $tool;
         $this->{$function_build}($session_id, $respect_base_content, $destination_course_code);
     }
     if ($update_course_settings) {
         $this->restore_course_settings($destination_course_code);
     }
     // Restore the item properties
     $table = Database::get_course_table(TABLE_ITEM_PROPERTY);
     $condition_session = "";
     if (!empty($session_id)) {
         $condition_session = " , id_session='" . intval($session_id) . "'";
     }
     foreach ($this->course->resources as $type => $resources) {
         if (is_array($resources)) {
             foreach ($resources as $id => $resource) {
                 foreach ($resource->item_properties as $property) {
                     // First check if there isn't allready a record for this resource
                     $sql = "SELECT * FROM {$table} WHERE c_id = " . $this->destination_course_id . " AND tool = '" . $property['tool'] . "' AND ref = '" . $resource->destination_id . "'";
                     $res = Database::query($sql);
                     if (Database::num_rows($res) == 0) {
                         // The to_group_id and to_user_id are set to default values as users/groups possibly not exist in the target course
                         $sql = "INSERT INTO {$table} SET\n\t\t\t\t\t\t\t\t\tc_id \t\t\t\t= '" . $this->destination_course_id . "',\n\t\t\t\t\t\t\t\t\ttool \t\t\t\t= '" . self::DBUTF8escapestring($property['tool']) . "',\n\t\t\t\t\t\t\t\t\tinsert_user_id \t\t= '" . self::DBUTF8escapestring($property['insert_user_id']) . "',\n\t\t\t\t\t\t\t\t\tinsert_date \t\t= '" . self::DBUTF8escapestring($property['insert_date']) . "',\n\t\t\t\t\t\t\t\t\tlastedit_date \t\t= '" . self::DBUTF8escapestring($property['lastedit_date']) . "',\n\t\t\t\t\t\t\t\t\tref \t\t\t\t= '" . self::DBUTF8escapestring($resource->destination_id) . "',\n\t\t\t\t\t\t\t\t\tlastedit_type \t\t= '" . self::DBUTF8escapestring($property['lastedit_type']) . "',\n\t\t\t\t\t\t\t\t\tlastedit_user_id \t= '" . self::DBUTF8escapestring($property['lastedit_user_id']) . "',\n\t\t\t\t\t\t\t\t\tvisibility \t\t\t= '" . self::DBUTF8escapestring($property['visibility']) . "',\n\t\t\t\t\t\t\t\t\tstart_visible \t\t= '" . self::DBUTF8escapestring($property['start_visible']) . "',\n\t\t\t\t\t\t\t\t\tend_visible \t\t= '" . self::DBUTF8escapestring($property['end_visible']) . "',\n\t\t\t\t\t\t\t\t\tto_user_id  \t\t= '" . self::DBUTF8escapestring($property['to_user_id']) . "',\n\t\t\t\t\t\t\t\t\tto_group_id \t\t= '0' {$condition_session}";
                         Database::query($sql);
                     }
                 }
             }
         }
     }
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:78,代码来源:CourseRestorer.class.php

示例4: switch

     }
 }
 switch ($_GET['type']) {
     case 'csv':
         Export::export_table_csv_utf8($a_users);
         exit;
     case 'xls':
         Export::export_table_xls($a_users);
         exit;
     case 'pdf':
         $description = '<table class="data_table_no_border">';
         if (api_get_session_id()) {
             $description .= '<tr><td>' . get_lang('Session') . ': </td><td class="highlight">' . api_get_session_name(api_get_session_id()) . '</td>';
         }
         $description .= '<tr><td>' . get_lang('Course') . ': </td><td class="highlight">' . $course_info['name'] . '</td>';
         $teachers = CourseManager::get_teacher_list_from_course_code($course_info['real_id']);
         //If I'm a teacher in this course show just my name
         if (isset($teachers[$user_id])) {
             if (!empty($teachers)) {
                 $teacher_info = $teachers[$user_id];
                 $description .= '<tr><td>' . get_lang('Teacher') . ': </td><td class="highlight">' . api_get_person_name($teacher_info['firstname'], $teacher_info['lastname']) . '</td>';
             }
         } else {
             //If not show all teachers
             $teachers = CourseManager::get_teacher_list_from_course_code_to_string($course_info['real_id']);
             if (!empty($teachers)) {
                 $description .= '<tr><td>' . get_lang('Teachers') . ': </td><td class="highlight">' . $teachers . '</td>';
             }
         }
         if (!empty($session_id)) {
             //If I'm a coach
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:31,代码来源:user.php

示例5: get_exam_results_data

 /**
  * Gets the exam'data results
  * @todo this function should be moved in a library  + no global calls
  * @param int $from
  * @param int $number_of_items
  * @param int $column
  * @param string $direction
  * @param int $exercise_id
  * @param null $extra_where_conditions
  * @param bool $get_count
  * @return array
  */
 public static function get_exam_results_data($from, $number_of_items, $column, $direction, $exercise_id, $extra_where_conditions = null, $get_count = false)
 {
     //@todo replace all this globals
     global $documentPath, $filter;
     $course_id = api_get_course_int_id();
     $sessionId = api_get_session_id();
     $is_allowedToEdit = api_is_allowed_to_edit(null, true) || api_is_allowed_to_edit(true) || api_is_drh() || api_is_student_boss();
     $TBL_USER = Database::get_main_table(TABLE_MAIN_USER);
     $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
     $TBL_GROUP_REL_USER = Database::get_course_table(TABLE_GROUP_USER);
     $TBL_GROUP = Database::get_course_table(TABLE_GROUP);
     $TBL_TRACK_EXERCICES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
     $TBL_TRACK_HOTPOTATOES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES);
     $TBL_TRACK_ATTEMPT_RECORDING = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);
     $session_id_and = ' AND te.session_id = ' . $sessionId . ' ';
     $exercise_id = intval($exercise_id);
     $exercise_where = '';
     if (!empty($exercise_id)) {
         $exercise_where .= ' AND te.exe_exo_id = ' . $exercise_id . '  ';
     }
     $hotpotatoe_where = '';
     if (!empty($_GET['path'])) {
         $hotpotatoe_path = Database::escape_string($_GET['path']);
         $hotpotatoe_where .= ' AND exe_name = "' . $hotpotatoe_path . '"  ';
     }
     // sql for chamilo-type tests for teacher / tutor view
     $sql_inner_join_tbl_track_exercices = "\n        (\n            SELECT DISTINCT ttte.*, if(tr.exe_id,1, 0) as revised\n            FROM {$TBL_TRACK_EXERCICES} ttte LEFT JOIN {$TBL_TRACK_ATTEMPT_RECORDING} tr\n            ON (ttte.exe_id = tr.exe_id)\n            WHERE\n                c_id = {$course_id} AND\n                exe_exo_id = {$exercise_id} AND\n                ttte.session_id = " . $sessionId . "\n        )";
     if ($is_allowedToEdit) {
         //@todo fix to work with COURSE_RELATION_TYPE_RRHH in both queries
         // Hack in order to filter groups
         $sql_inner_join_tbl_user = '';
         if (strpos($extra_where_conditions, 'group_id')) {
             $sql_inner_join_tbl_user = "\n                (\n                    SELECT\n                        u.user_id,\n                        firstname,\n                        lastname,\n                        official_code,\n                        email,\n                        username,\n                        g.name as group_name,\n                        g.id as group_id\n                    FROM {$TBL_USER} u\n                    INNER JOIN {$TBL_GROUP_REL_USER} gru\n                    ON (gru.user_id = u.user_id AND gru.c_id=" . $course_id . ")\n                    INNER JOIN {$TBL_GROUP} g\n                    ON (gru.group_id = g.id AND g.c_id=" . $course_id . ")\n                )";
         }
         if (strpos($extra_where_conditions, 'group_all')) {
             $extra_where_conditions = str_replace("AND (  group_id = 'group_all'  )", '', $extra_where_conditions);
             $extra_where_conditions = str_replace("AND group_id = 'group_all'", '', $extra_where_conditions);
             $extra_where_conditions = str_replace("group_id = 'group_all' AND", '', $extra_where_conditions);
             $sql_inner_join_tbl_user = "\n                (\n                    SELECT\n                        u.user_id,\n                        firstname,\n                        lastname,\n                        official_code,\n                        email,\n                        username,\n                        '' as group_name,\n                        '' as group_id\n                    FROM {$TBL_USER} u\n                )";
             $sql_inner_join_tbl_user = null;
         }
         if (strpos($extra_where_conditions, 'group_none')) {
             $extra_where_conditions = str_replace("AND (  group_id = 'group_none'  )", "AND (  group_id is null  )", $extra_where_conditions);
             $extra_where_conditions = str_replace("AND group_id = 'group_none'", "AND (  group_id is null  )", $extra_where_conditions);
             $sql_inner_join_tbl_user = "\n            (\n                SELECT\n                    u.user_id,\n                    firstname,\n                    lastname,\n                    official_code,\n                    email,\n                    username,\n                    g.name as group_name,\n                    g.id as group_id\n                FROM {$TBL_USER} u\n                LEFT OUTER JOIN {$TBL_GROUP_REL_USER} gru\n                ON ( gru.user_id = u.user_id AND gru.c_id=" . $course_id . " )\n                LEFT OUTER JOIN {$TBL_GROUP} g\n                ON (gru.group_id = g.id AND g.c_id = " . $course_id . ")\n            )";
         }
         // All
         $is_empty_sql_inner_join_tbl_user = false;
         if (empty($sql_inner_join_tbl_user)) {
             $is_empty_sql_inner_join_tbl_user = true;
             $sql_inner_join_tbl_user = "\n            (\n                SELECT u.user_id, firstname, lastname, email, username, ' ' as group_name, '' as group_id, official_code\n                FROM {$TBL_USER} u\n                WHERE u.status NOT IN(" . api_get_users_status_ignored_in_reports('string') . ")\n            )";
         }
         $sqlFromOption = " , {$TBL_GROUP_REL_USER} AS gru ";
         $sqlWhereOption = "  AND gru.c_id = " . $course_id . " AND gru.user_id = user.user_id ";
         $first_and_last_name = api_is_western_name_order() ? "firstname, lastname" : "lastname, firstname";
         if ($get_count) {
             $sql_select = "SELECT count(te.exe_id) ";
         } else {
             $sql_select = "SELECT DISTINCT\n                    user_id,\n                    {$first_and_last_name},\n                    official_code,\n                    ce.title,\n                    username,\n                    te.exe_result,\n                    te.exe_weighting,\n                    te.exe_date,\n                    te.exe_id,\n                    email as exemail,\n                    te.start_date,\n                    steps_counter,\n                    exe_user_id,\n                    te.exe_duration,\n                    propagate_neg,\n                    revised,\n                    group_name,\n                    group_id,\n                    orig_lp_id,\n                    te.user_ip";
         }
         $sql = " {$sql_select}\n                FROM {$TBL_EXERCICES} AS ce\n                INNER JOIN {$sql_inner_join_tbl_track_exercices} AS te\n                ON (te.exe_exo_id = ce.id)\n                INNER JOIN {$sql_inner_join_tbl_user} AS user\n                ON (user.user_id = exe_user_id)\n                WHERE\n                    te.status != 'incomplete' AND\n                    te.c_id = " . $course_id . " {$session_id_and} AND\n                    ce.active <>-1 AND ce.c_id = " . $course_id . "\n                    {$exercise_where}\n                    {$extra_where_conditions}\n                ";
         // sql for hotpotatoes tests for teacher / tutor view
         if ($get_count) {
             $hpsql_select = "SELECT count(username)";
         } else {
             $hpsql_select = "SELECT\n                    {$first_and_last_name} ,\n                    username,\n                    official_code,\n                    tth.exe_name,\n                    tth.exe_result ,\n                    tth.exe_weighting,\n                    tth.exe_date";
         }
         $hpsql = " {$hpsql_select}\n                FROM\n                    {$TBL_TRACK_HOTPOTATOES} tth,\n                    {$TBL_USER} user\n                    {$sqlFromOption}\n                WHERE\n                    user.user_id=tth.exe_user_id\n                    AND tth.c_id = " . $course_id . "\n                    {$hotpotatoe_where}\n                    {$sqlWhereOption}\n                    AND user.status NOT IN(" . api_get_users_status_ignored_in_reports('string') . ")\n                ORDER BY\n                    tth.c_id ASC,\n                    tth.exe_date DESC";
     }
     if ($get_count) {
         $resx = Database::query($sql);
         $rowx = Database::fetch_row($resx, 'ASSOC');
         return $rowx[0];
     }
     $teacher_list = CourseManager::get_teacher_list_from_course_code(api_get_course_id());
     $teacher_id_list = array();
     foreach ($teacher_list as $teacher) {
         $teacher_id_list[] = $teacher['user_id'];
     }
     $list_info = array();
     // Simple exercises
     if (empty($hotpotatoe_where)) {
         $column = !empty($column) ? Database::escape_string($column) : null;
         $from = intval($from);
         $number_of_items = intval($number_of_items);
         if (!empty($column)) {
             $sql .= " ORDER BY {$column} {$direction} ";
         }
//.........这里部分代码省略.........
开发者ID:secuencia24,项目名称:chamilo-lms,代码行数:101,代码来源:exercise.lib.php

示例6: set_header

    /**
     * @param array $course_data
     */
    public function set_header($course_data)
    {
        $this->pdf->defaultheaderfontsize   = 10;   // in pts
        $this->pdf->defaultheaderfontstyle  = 'BI';   // blank, B, I, or BI
        $this->pdf->defaultheaderline       = 1;    // 1 to include line below header/above footer

        if (!empty($course_data['code'])) {
            $teacher_list = CourseManager::get_teacher_list_from_course_code($course_data['code']);

            $teachers = '';
            if (!empty($teacher_list)) {

                foreach ($teacher_list as $teacher) {
                    $teachers[]= $teacher['firstname'].' '.$teacher['lastname'];
                }
                if (count($teachers) > 1) {
                    $teachers = get_lang('Teachers').': '.implode(', ', $teachers);
                } else {
                    $teachers = get_lang('Teacher').': '.implode('', $teachers);
                }

                // Do not show the teacher list see BT#4080 only the current teacher name
                $user_info = api_get_user_info();
                $teachers = $user_info['complete_name'];
            }

            $left_content    = '';
            $center_content  = '';
            $right_content   = $teachers;

            $header = array(
                'odd' => array(
                    'L' => array(
                        'content' => $left_content,
                        'font-size' => 10,
                        'font-style' => 'B',
                        'font-family' => 'serif',
                        'color'=>'#000000'
                    ),
                    'C' => array(
                        'content' => $center_content,
                        'font-size' => 10,
                        'font-style' => 'B',
                        'font-family' => 'serif',
                        'color'=>'#000000'
                    ),
                    'R' => array(
                        'content' => $right_content,
                        'font-size' => 10,
                        'font-style' => 'B',
                        'font-family' => 'serif',
                        'color'=>'#000000'
                    ),
                    'line' => 1,
                ),
                'even' => array(
                    'L' => array(
                        'content' => $left_content,
                        'font-size' => 10,
                        'font-style' => 'B',
                        'font-family' => 'serif',
                        'color'=>'#000000'
                    ),
                    'C' => array(
                        'content' => $center_content,
                        'font-size' => 10,
                        'font-style' => 'B',
                        'font-family' => 'serif',
                        'color'=>'#000000'
                    ),
                    'R' => array(
                        'content' => $right_content,
                        'font-size' => 10,
                        'font-style' => 'B',
                        'font-family' => 'serif',
                        'color'=>'#000000'
                    ),
                    'line' => 1,
                ),
            );
            $this->pdf->SetHeader($header);// ('{DATE j-m-Y}|{PAGENO}/{nb}|'.$title);
        }
    }
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:86,代码来源:pdf.lib.php

示例7: importCSV


//.........这里部分代码省略.........
                     $sql = "INSERT IGNORE INTO {$tbl_session_course}\n                                SET c_id = '{$courseId}', session_id='{$session_id}'";
                     Database::query($sql);
                     SessionManager::installCourse($session_id, $courseInfo['real_id']);
                     if ($debug) {
                         $logger->addInfo("Sessions - Adding course '{$course_code}' to session #{$session_id}");
                     }
                     $course_counter++;
                     $course_coaches = isset($courseArray[1]) ? $courseArray[1] : null;
                     $course_users = isset($courseArray[2]) ? $courseArray[2] : null;
                     $course_users = explode(',', $course_users);
                     $course_coaches = explode(',', $course_coaches);
                     // Checking if the flag is set TeachersWillBeAddedAsCoachInAllCourseSessions (course_edit.php)
                     $addTeachersToSession = true;
                     if (array_key_exists('add_teachers_to_sessions_courses', $courseInfo)) {
                         $addTeachersToSession = $courseInfo['add_teachers_to_sessions_courses'];
                     }
                     // If any user provided for a course, use the users array.
                     if (empty($course_users)) {
                         if (!empty($userList)) {
                             SessionManager::subscribe_users_to_session_course($userList, $session_id, $course_code);
                             if ($debug) {
                                 $msg = "Sessions - Adding student list " . implode(', #', $userList) . " to course: '{$course_code}' and session #{$session_id}";
                                 $logger->addInfo($msg);
                             }
                         }
                     }
                     // Adding coaches to session course user.
                     if (!empty($course_coaches)) {
                         $savedCoaches = array();
                         // only edit if add_teachers_to_sessions_courses is set.
                         if ($addTeachersToSession) {
                             if ($addOriginalCourseTeachersAsCourseSessionCoaches) {
                                 // Adding course teachers as course session teachers.
                                 $alreadyAddedTeachers = CourseManager::get_teacher_list_from_course_code($course_code);
                                 if (!empty($alreadyAddedTeachers)) {
                                     $teachersToAdd = array();
                                     foreach ($alreadyAddedTeachers as $user) {
                                         $teachersToAdd[] = $user['username'];
                                     }
                                     $course_coaches = array_merge($course_coaches, $teachersToAdd);
                                 }
                             }
                             foreach ($course_coaches as $course_coach) {
                                 $coach_id = UserManager::get_user_id_from_username($course_coach);
                                 if ($coach_id !== false) {
                                     // Just insert new coaches
                                     SessionManager::updateCoaches($session_id, $courseId, array($coach_id), false);
                                     if ($debug) {
                                         $logger->addInfo("Sessions - Adding course coach: user #{$coach_id} ({$course_coach}) to course: '{$course_code}' and session #{$session_id}");
                                     }
                                     $savedCoaches[] = $coach_id;
                                 } else {
                                     $error_message .= get_lang('UserDoesNotExist') . ' : ' . $course_coach . $eol;
                                 }
                             }
                         }
                         // Custom courses/session coaches
                         $teacherToAdd = null;
                         // Only one coach is added.
                         if ($onlyAddFirstCoachOrTeacher == true) {
                             foreach ($course_coaches as $course_coach) {
                                 $coach_id = UserManager::get_user_id_from_username($course_coach);
                                 if ($coach_id !== false) {
                                     $teacherToAdd = $coach_id;
                                     break;
                                 }
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:67,代码来源:sessionmanager.lib.php

示例8: addWorkComment

/**
 * Adds a comments to the work document
 * @param array $courseInfo
 * @param int $userId
 * @param array $work
 * @param array $data
 * @return int
 */
function addWorkComment($courseInfo, $userId, $parentWork, $work, $data)
{
    if (ADD_DOCUMENT_TO_WORK == false) {
        return null;
    }

    $commentTable = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT_COMMENT);

    $params = array(
        'work_id' => $work['id'],
        'c_id' => $work['c_id'],
        'user_id' => $userId,
        'comment' => $data['comment'],
        'sent_at' => api_get_utc_datetime()
    );

    $commentId = Database::insert($commentTable, $params);

    $userIdListToSend = array();

    if (api_is_allowed_to_edit()) {
        if (isset($data['send_mail']) && $data['send_mail']) {
            // Teacher sends a feedback
            $userIdListToSend = array($work['user_id']);
        }
    } else {
        $sessionId = api_get_session_id();
        if (empty($sessionId)) {
            $teachers = CourseManager::get_teacher_list_from_course_code(
                $courseInfo['code']
            );
            if (!empty($teachers)) {
                $userIdListToSend = array_keys($teachers);
            }
        } else {
            $teachers = SessionManager::getCoachesByCourseSession(
                $sessionId,
                $courseInfo['code']
            );

            if (!empty($teachers)) {
                $userIdListToSend = array_values($teachers);
            }
        }
    }

    $url = api_get_path(WEB_CODE_PATH).'work/view.php?'.api_get_cidreq().'&id='.$work['id'];
    $subject = sprintf(get_lang('ThereIsANewWorkFeedback'), $parentWork['title']);
    $content = sprintf(get_lang('ThereIsANewWorkFeedbackInWorkXHere'), $work['title'], $url);

    if (!empty($userIdListToSend)) {
        foreach ($userIdListToSend as $userId) {
            MessageManager::send_message_simple(
                $userId,
                $subject,
                $content
            );
        }
    }

    $fileData = isset($data['file']) ? $data['file'] : null;
    if (!empty($commentId) && !empty($fileData)) {
        $workParent = get_work_data_by_id($work['parent_id']);
        if (!empty($workParent)) {
            $uploadDir = api_get_path(SYS_COURSE_PATH).$courseInfo['path'].'/work'.$workParent['url'];
            $newFileName = 'comment_'.$commentId.'_'.php2phps(
                replace_dangerous_char($fileData['name'], 'strict')
            );
            $newFilePath = $uploadDir.'/'.$newFileName;
            $result = move_uploaded_file($fileData['tmp_name'], $newFilePath);
            if ($result) {
                $params = array('file' => $newFileName);
                Database::update(
                    $commentTable,
                    $params,
                    array('id = ? AND c_id = ? ' => array($commentId, $work['c_id']))
                );
            }
        }
    }
}
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:89,代码来源:work.lib.php

示例9: display_add_form

/**
* this function displays the form to upload a new item to the dropbox.
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version march 2006
*/
function display_add_form($dropbox_unid, $viewReceivedCategory, $viewSentCategory, $view)
{
    $course_info = api_get_course_info();
    $_user = api_get_user_info();
    $is_courseAdmin = api_is_course_admin();
    $is_courseTutor = api_is_course_tutor();
    $origin = isset($_GET['origin']) ? $_GET['origin'] : null;
    $token = Security::get_token();
    $dropbox_person = new Dropbox_Person(api_get_user_id(), $is_courseAdmin, $is_courseTutor);
    $form = new FormValidator('sent_form', 'post', api_get_self() . '?view_received_category=' . $viewReceivedCategory . '&view_sent_category=' . $viewSentCategory . '&view=' . $view . '&' . api_get_cidreq(), null, array('enctype' => 'multipart/form-data', 'onsubmit' => 'javascript: return checkForm(this);'));
    $form->addElement('header', get_lang('UploadNewFile'));
    $form->addElement('hidden', 'MAX_FILE_SIZE', dropbox_cnf('maxFilesize'));
    $form->addElement('hidden', 'dropbox_unid', $dropbox_unid);
    $form->addElement('hidden', 'sec_token', $token);
    $form->addElement('hidden', 'origin', $origin);
    $form->addElement('file', 'file', get_lang('UploadFile'), array('onChange' => 'javascript: checkfile(this.value);'));
    if (dropbox_cnf('allowOverwrite')) {
        $form->addElement('checkbox', 'cb_overwrite', null, get_lang('OverwriteFile'), array('id' => 'cb_overwrite'));
    }
    // List of all users in this course and all virtual courses combined with it
    if (api_get_session_id()) {
        $complete_user_list_for_dropbox = array();
        if (api_get_setting('dropbox_allow_student_to_student') == 'true' || $_user['status'] != STUDENT) {
            $complete_user_list_for_dropbox = CourseManager::get_user_list_from_course_code($course_info['code'], api_get_session_id());
        }
        $complete_user_list2 = CourseManager::get_coach_list_from_course_code($course_info['code'], api_get_session_id());
        $complete_user_list_for_dropbox = array_merge($complete_user_list_for_dropbox, $complete_user_list2);
    } else {
        if (api_get_setting('dropbox_allow_student_to_student') == 'true' || $_user['status'] != STUDENT) {
            $complete_user_list_for_dropbox = CourseManager::get_user_list_from_course_code($course_info['code'], api_get_session_id());
        } else {
            $complete_user_list_for_dropbox = CourseManager::get_teacher_list_from_course_code($course_info['code'], false);
        }
    }
    if (!empty($complete_user_list_for_dropbox)) {
        foreach ($complete_user_list_for_dropbox as $k => $e) {
            $complete_user_list_for_dropbox[$k] = $e + array('lastcommafirst' => api_get_person_name($e['firstname'], $e['lastname']));
        }
        $complete_user_list_for_dropbox = TableSort::sort_table($complete_user_list_for_dropbox, 'lastcommafirst');
    }
    /*
        Create the options inside the select box:
        List all selected users their user id as value and a name string as display
    */
    $current_user_id = '';
    $options = array();
    foreach ($complete_user_list_for_dropbox as $current_user) {
        if (($dropbox_person->isCourseTutor || $dropbox_person->isCourseAdmin || dropbox_cnf('allowStudentToStudent') || $current_user['status'] != 5 || $current_user['tutor_id'] == 1) && $current_user['user_id'] != $_user['user_id']) {
            // Don't include yourself.
            if ($current_user['user_id'] == $current_user_id) {
                continue;
            }
            $full_name = $current_user['lastcommafirst'];
            $current_user_id = $current_user['user_id'];
            $options['user_' . $current_user_id] = $full_name;
            //echo '<option value="user_' . $current_user_id . '">' . $full_name . '</option>';
        }
    }
    /*
     * Show groups
     */
    if (($dropbox_person->isCourseTutor || $dropbox_person->isCourseAdmin) && dropbox_cnf('allowGroup') || dropbox_cnf('allowStudentToStudent')) {
        $complete_group_list_for_dropbox = GroupManager::get_group_list(null, dropbox_cnf('courseId'));
        if (count($complete_group_list_for_dropbox) > 0) {
            foreach ($complete_group_list_for_dropbox as $current_group) {
                if ($current_group['number_of_members'] > 0) {
                    //echo '<option value="group_'.$current_group['id'].'">G: '.$current_group['name'].' - '.$current_group['number_of_members'].' '.get_lang('Users').'</option>';
                    $options['group_' . $current_group['id']] = 'G: ' . $current_group['name'] . ' - ' . $current_group['number_of_members'] . ' ' . get_lang('Users');
                }
            }
        }
    }
    if (dropbox_cnf('allowJustUpload')) {
        //echo '<option value="upload">'.get_lang('JustUploadInSelect').'</option>';
        //echo '<option value="user_'.$_user['user_id'].'">'.get_lang('JustUploadInSelect').'</option>';
        $options['user_' . $_user['user_id']] = get_lang('JustUploadInSelect');
    }
    $form->addElement('select', 'recipients', get_lang('SendTo'), $options, array('multiple' => 'multiple', 'size' => '10', 'class' => 'span4'));
    $form->addElement('button', 'submitWork', get_lang('Upload'));
    $form->display();
}
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:87,代码来源:dropbox_functions.inc.php

示例10: send_notification_for_oral_questions

 function send_notification_for_oral_questions($question_list_answers, $origin, $exe_id)
 {
     if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1) {
         return null;
     }
     // Email configuration settings
     $courseCode = api_get_course_id();
     $course_info = api_get_course_info($courseCode);
     $url_email = api_get_path(WEB_CODE_PATH) . 'exercice/exercise_show.php?' . api_get_cidreq() . '&id_session=' . api_get_session_id() . '&id=' . $exe_id . '&action=qualify';
     $user_info = api_get_user_info(api_get_user_id());
     $oral_question_list = null;
     foreach ($question_list_answers as $item) {
         $question = $item['question'];
         $answer = $item['answer'];
         $answer_type = $item['answer_type'];
         if (!empty($question) && !empty($answer) && $answer_type == ORAL_EXPRESSION) {
             $oral_question_list .= '<br /><table width="730" height="136" border="0" cellpadding="3" cellspacing="3">' . '<tr>' . '<td width="220" valign="top" bgcolor="#E5EDF8">&nbsp;&nbsp;' . get_lang('Question') . '</td>' . '<td width="473" valign="top" bgcolor="#F3F3F3">' . $question . '</td>' . '</tr>' . '<tr>' . '<td width="220" valign="top" bgcolor="#E5EDF8">&nbsp;&nbsp;' . get_lang('Answer') . '</td>' . '<td valign="top" bgcolor="#F3F3F3">' . $answer . '</td>' . '</tr></table>';
         }
     }
     if (!empty($oral_question_list)) {
         $msg = get_lang('OralQuestionsAttempted') . '<br /><br />
                 ' . get_lang('AttemptDetails') . ' : <br /><br />' . '<table>' . '<tr>' . '<td><em>' . get_lang('CourseName') . '</em></td>' . '<td>&nbsp;<b>#course#</b></td>' . '</tr>' . '<tr>' . '<td>' . get_lang('TestAttempted') . '</td>' . '<td>&nbsp;#exercise#</td>' . '</tr>' . '<tr>' . '<td>' . get_lang('StudentName') . '</td>' . '<td>&nbsp;#firstName# #lastName#</td>' . '</tr>' . '<tr>' . '<td>' . get_lang('StudentEmail') . '</td>' . '<td>&nbsp;#mail#</td>' . '</tr>' . '</table>';
         $msg .= '<br />' . sprintf(get_lang('OralQuestionsAttemptedAreX'), $oral_question_list) . '<br />';
         $msg1 = str_replace("#exercise#", $this->exercise, $msg);
         $msg = str_replace("#firstName#", $user_info['firstname'], $msg1);
         $msg1 = str_replace("#lastName#", $user_info['lastname'], $msg);
         $msg = str_replace("#mail#", $user_info['email'], $msg1);
         $msg = str_replace("#course#", $course_info['name'], $msg1);
         if ($origin != 'learnpath') {
             $msg .= '<br /><a href="#url#">' . get_lang('ClickToCommentAndGiveFeedback') . '</a>';
         }
         $msg1 = str_replace("#url#", $url_email, $msg);
         $mail_content = $msg1;
         $subject = get_lang('OralQuestionsAttempted');
         if (api_get_session_id()) {
             $teachers = CourseManager::get_coach_list_from_course_code($courseCode, api_get_session_id());
         } else {
             $teachers = CourseManager::get_teacher_list_from_course_code($courseCode);
         }
         if (!empty($teachers)) {
             foreach ($teachers as $user_id => $teacher_data) {
                 MessageManager::send_message_simple($user_id, $subject, $mail_content);
             }
         }
     }
 }
开发者ID:secuencia24,项目名称:chamilo-lms,代码行数:46,代码来源:exercise.class.php

示例11: api_get_user_id

}
$user_id = api_get_user_id();
$my_courses = CourseManager::get_course_list_of_user_as_course_admin($user_id);
$array = array();
$i = 0;
$session_id = 0;
if (!empty($my_courses)) {
    foreach ($my_courses as $course) {
        $course_code = $course['code'];
        $course_id = $course['real_id'];
        $course_info = api_get_course_info($course_code);
        //Only show open courses
        if ($course_info['visibility'] == 0) {
            continue;
        }
        $teachers = CourseManager::get_teacher_list_from_course_code($course_code);
        $teacher_list = array();
        if (!empty($teachers)) {
            foreach ($teachers as $teacher) {
                $teacher_list[] = $teacher['firstname'] . ' ' . $teacher['lastname'];
            }
        }
        $tmp_students = CourseManager::get_student_list_from_course_code($course_code, false);
        //Cleaning students only REAL students
        $students = array();
        foreach ($tmp_students as $student) {
            $user_info = api_get_user_info($student['user_id']);
            if ($user_info['status'] != STUDENT) {
                continue;
            }
            $students[] = $student['user_id'];
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:31,代码来源:current_courses.php

示例12: api_get_course_info

/**
 * Returns the current course info array.
 * Note: this array is only defined if the user is inside a course.
 * Array elements:
 * ['name']
 * ['official_code']
 * ['sysCode']
 * ['path']
 * ['dbName']
 * ['dbNameGlu']
 * ['titular']
 * ['language']
 * ['extLink']['url' ]
 * ['extLink']['name']
 * ['categoryCode']
 * ['categoryName']
 *
 * Now if the course_code is given, the returned array gives info about that
 * particular course, not specially the current one.
 * @todo    Same behaviour as api_get_user_info so that api_get_course_id becomes absolete too.
 */
function api_get_course_info($course_code = null, $add_extra_values = false, $addCourseSettings = false)
{
    if (!empty($course_code)) {
        $course_code = Database::escape_string($course_code);
        $course_table = Database::get_main_table(TABLE_MAIN_COURSE);
        $course_cat_table = Database::get_main_table(TABLE_MAIN_CATEGORY);
        $sql = "SELECT course.*, course_category.code faCode, course_category.name faName\n                 FROM {$course_table}\n                 LEFT JOIN {$course_cat_table}\n                 ON course.category_code =  course_category.code\n                 WHERE course.code = '{$course_code}'";
        $result = Database::query($sql);
        $_course = array();
        if (Database::num_rows($result) > 0) {
            $course_data = Database::fetch_array($result);
            if ($add_extra_values) {
                $extra_field_values = new ExtraField('course');
                $course_data['extra_fields'] = $extra_field_values->get_handler_extra_data($course_code);
            }
            if ($addCourseSettings) {
                $course_data['settings'] = CourseManager::getCourseSettings($course_data['id']);
            }
            $course_data['teacher_list'] = CourseManager::get_teacher_list_from_course_code($course_data['id']);
            $course_data['teacher_list_formatted'] = CourseManager::formatUserListToString($course_data['teacher_list'], null, true);
            $_course = api_format_course_array($course_data);
        }
        return $_course;
    }
    $_course = Session::read('_course');
    if ($_course == '-1') {
        $_course = array();
    }
    return $_course;
}
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:51,代码来源:api.lib.php

示例13: foreach

}
foreach ($sessionsList as $sessionItem) {
    $optionsSessions[$sessionItem['id']] = $sessionItem['name'];
}
foreach ($teacherList as $teacherItem) {
    $optionsTeachers[$teacherItem['user_id']] = $teacherItem['completeName'];
}
$withFilter = false;
$reportTitle = get_lang('TimeReportIncludingAllCoursesAndSessionsByTeacher');
$reportSubTitle = sprintf(get_lang('TimeSpentBetweenXAndY'), $selectedFrom, $selectedUntil);
$timeReport = new TeacherTimeReport();
if (!empty($selectedCourse)) {
    $withFilter = true;
    $course = api_get_course_info($selectedCourse);
    $reportTitle = sprintf(get_lang('TimeReportForCourseX'), $course['title']);
    $teachers = CourseManager::get_teacher_list_from_course_code($selectedCourse);
    foreach ($teachers as $teacher) {
        $totalTime = UserManager::getTimeSpentInCourses($teacher['user_id'], $course['real_id'], 0, $selectedFrom, $selectedUntil);
        $formattedTime = api_format_time($totalTime);
        $timeReport->data[] = array('session' => null, 'course' => array('id' => $course['real_id'], 'name' => $course['title']), 'coach' => array('userId' => $teacher['user_id'], 'lastname' => $teacher['lastname'], 'firstname' => $teacher['firstname'], 'username' => $teacher['username'], 'completeName' => api_get_person_name($teacher['firstname'], $teacher['lastname'])), 'totalTime' => $formattedTime);
    }
    $sessionsByCourse = SessionManager::get_session_by_course($course['real_id']);
    foreach ($sessionsByCourse as $session) {
        $coaches = CourseManager::get_coachs_from_course($session['id'], $course['real_id']);
        if ($coaches) {
            foreach ($coaches as $coach) {
                $totalTime = UserManager::getTimeSpentInCourses($coach['user_id'], $course['real_id'], $session['id'], $selectedFrom, $selectedUntil);
                $formattedTime = api_format_time($totalTime);
                $timeReport->data[] = array('session' => array('id' => $session['id'], 'name' => $session['name']), 'course' => array('id' => $course['real_id'], 'name' => $course['title']), 'coach' => array('userId' => $coach['user_id'], 'lastname' => $coach['lastname'], 'firstname' => $coach['firstname'], 'username' => $coach['username'], 'completeName' => api_get_person_name($coach['firstname'], $coach['lastname'])), 'totalTime' => $formattedTime);
            }
        }
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:31,代码来源:teacher_time_report.php

示例14: api_get_person_name

    $course_teachers[$obj->user_id] = api_get_person_name($obj->firstname, $obj->lastname);
}
// Get all possible teachers without the course teachers
/*$sql = "SELECT u.user_id,lastname,firstname
  FROM $table_user as u
  INNER JOIN $access_url_rel_user_table url_rel_user
  ON (u.user_id=url_rel_user.user_id)
  WHERE
      url_rel_user.access_url_id=".api_get_current_access_url_id()." AND
      status = 1 or status = 2 ".$order_clause;*/
/** @var Doctrine\ORM\EntityManager $em */
/*$em = $this->getDoctrine()->getManager();
$userManager = $em->getRepository('ChamiloUserBundle:User');
var_dump($userManager->getTeachers());*/
//$userManager->get
$teachersInPlatform = CourseManager::get_teacher_list_from_course_code($course['real_id']);
$teachers = array();
$platform_teachers[0] = '-- ' . get_lang('NoManager') . ' --';
foreach ($teachersInPlatform as $teacher) {
    $teacherId = $teacher['user_id'];
    if (!array_key_exists($teacherId, $course_teachers)) {
        $teachers[$teacherId] = api_get_person_name($teacher['firstname'], $teacher['lastname']);
    }
    if (isset($course['tutor_name']) && isset($course_teachers[$teacherId]) && $course['tutor_name'] == $course_teachers[$teacherId]) {
        $course['tutor_name'] = $teacherId;
    }
    //We add in the array platform teachers
    $platform_teachers[$teacherId] = api_get_person_name($teacher['firstname'], $teacher['lastname']);
}
//Case where there is no teacher in the course
if (count($course_teachers) == 0) {
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:31,代码来源:course_edit.php

示例15: updateTeachers

 /**
  * @param int $courseId
  * @param array $teachers
  * @param bool $deleteTeachersNotInList
  * @param bool $editTeacherInSessions
  * @param bool $deleteSessionTeacherNotInList
  * @return bool
  */
 public static function updateTeachers($courseId, $teachers, $deleteTeachersNotInList = true, $editTeacherInSessions = false, $deleteSessionTeacherNotInList = false)
 {
     if (empty($teachers)) {
         return false;
     }
     if (!is_array($teachers)) {
         $teachers = array($teachers);
     }
     $courseId = intval($courseId);
     $courseInfo = api_get_course_info_by_id($courseId);
     $course_code = $courseInfo['code'];
     $course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER);
     $alreadyAddedTeachers = CourseManager::get_teacher_list_from_course_code($course_code);
     if ($deleteTeachersNotInList) {
         // Delete only teacher relations that doesn't match the selected teachers
         $cond = null;
         if (count($teachers) > 0) {
             foreach ($teachers as $key) {
                 $key = Database::escape_string($key);
                 $cond .= " AND user_id <> '" . $key . "'";
             }
         }
         $sql = 'DELETE FROM ' . $course_user_table . '
                 WHERE c_id ="' . $courseId . '" AND status="1"' . $cond;
         Database::query($sql);
     }
     if (count($teachers) > 0) {
         foreach ($teachers as $userId) {
             $userId = intval($userId);
             // We check if the teacher is already subscribed in this course
             $sql = 'SELECT 1 FROM ' . $course_user_table . '
                     WHERE user_id = "' . $userId . '" AND c_id = "' . $courseId . '" ';
             $result = Database::query($sql);
             if (Database::num_rows($result)) {
                 $sql = 'UPDATE ' . $course_user_table . ' SET status = "1"
                         WHERE c_id = "' . $courseId . '" AND user_id = "' . $userId . '"  ';
             } else {
                 $sql = "INSERT INTO " . $course_user_table . " SET\n                            c_id = " . $courseId . ",\n                            user_id = " . $userId . ",\n                            status = '1',\n                            is_tutor = '0',\n                            sort = '0',\n                            user_course_cat='0'";
             }
             Database::query($sql);
         }
     }
     if ($editTeacherInSessions) {
         $sessions = SessionManager::get_session_by_course($courseId);
         if (!empty($sessions)) {
             foreach ($sessions as $session) {
                 // Remove old and add new
                 if ($deleteSessionTeacherNotInList) {
                     foreach ($teachers as $userId) {
                         SessionManager::set_coach_to_course_session($userId, $session['id'], $courseId);
                     }
                     $teachersToDelete = array();
                     if (!empty($alreadyAddedTeachers)) {
                         $teachersToDelete = array_diff(array_keys($alreadyAddedTeachers), $teachers);
                     }
                     if (!empty($teachersToDelete)) {
                         foreach ($teachersToDelete as $userId) {
                             SessionManager::set_coach_to_course_session($userId, $session['id'], $courseId, true);
                         }
                     }
                 } else {
                     // Add new teachers only
                     foreach ($teachers as $userId) {
                         SessionManager::set_coach_to_course_session($userId, $session['id'], $courseId);
                     }
                 }
             }
         }
     }
 }
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:78,代码来源:course.lib.php


注:本文中的CourseManager::get_teacher_list_from_course_code方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。