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


PHP CourseManager::getTeacherListFromCourse方法代码示例

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


在下文中一共展示了CourseManager::getTeacherListFromCourse方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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::getTeacherListFromCourse($courseInfo['real_id']);
     $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:jloguercio,项目名称:chamilo-lms,代码行数:33,代码来源:AnnouncementManager.php

示例2: 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::getTeacherListFromCourse($course_info['real_id']);
         }
         if (!empty($teachers)) {
             foreach ($teachers as $user_id => $teacher_data) {
                 MessageManager::send_message_simple($user_id, $subject, $mail_content);
             }
         }
     }
 }
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:46,代码来源:exercise.class.php

示例3: 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::getTeacherListFromCourse(api_get_course_int_id());
     $teacher_id_list = array();
     if (!empty($teacher_list)) {
         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)) {
//.........这里部分代码省略.........
开发者ID:feroli1000,项目名称:chamilo-lms,代码行数:101,代码来源:exercise.lib.php

示例4: 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, $teacherBackup = array())
 {
     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::getTeacherListFromCourse($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" AND relation_type = 0 ' . $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 {
                 $userCourseCategory = '0';
                 if (isset($teacherBackup[$userId]) && isset($teacherBackup[$userId][$course_code])) {
                     $courseUserData = $teacherBackup[$userId][$course_code];
                     $userCourseCategory = $courseUserData['user_course_cat'];
                 }
                 $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                            relation_type = '0',\n                            user_course_cat = '{$userCourseCategory}'\n                    ";
             }
             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:feroli1000,项目名称:chamilo-lms,代码行数:83,代码来源:course.lib.php

示例5: 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']);
     $groupId = isset($_REQUEST['group_id']) ? $_REQUEST['group_id'] : null;
     $data_array = array();
     $data_array['attendance_id'] = $attendance_id;
     $data_array['users_in_course'] = $attendance->get_users_rel_course($attendance_id, $groupId);
     $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, $groupId);
     if (api_is_allowed_to_edit(null, true) || api_is_drh()) {
         $data_array['users_presence'] = $attendance->get_users_attendance_sheet($attendance_id, 0, $groupId);
     } 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, $groupId);
         $data_array['faults'] = $attendance->get_faults_of_user($user_id, $attendance_id, $groupId);
         $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::getTeacherListFromCourse($courseInfo['real_id']);
     $teacherName = null;
     foreach ($teacherInfo as $teacherData) {
         if ($teacherName != null) {
             $teacherName = $teacherName . " / ";
         }
         $teacherName .= api_get_person_name($teacherData['firstname'], $teacherData['lastname']);
     }
     // Get data table
     $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_NUMBER_NO_YEAR) . ' ' . api_format_date($class_day['date_time'], TIME_NO_SEC_FORMAT);
     }
     $data_table[] = $head_table;
     $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']] = '<span style="color:red">' . get_lang('UserNotAttendedSymbol') . '</span>';
                     }
                 } 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 = isset($data_table[$i]) ? $data_table[$i] : null;
             $key = 1;
             $max_dates_per_page = 10;
             $item = isset($data_table[$i]) ? $data_table[$i] : null;
             $count_j = 0;
             if (!empty($item)) {
                 foreach ($item as $value) {
                     if ($count_j >= $max_dates_per_page) {
                         $key++;
//.........这里部分代码省略.........
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:101,代码来源:attendance_controller.php

示例6: api_get_course_info

/**
 * Returns the current course info array see api_format_course_array()
 * If the course_code is given, the returned array gives info about that
 * particular course, if none given it gets the course info from the session.
 *
 * @param string $course_code
 * @param bool $strict
 *
 * @return array
 */
function api_get_course_info($course_code = null, $strict = false)
{
    if (!empty($course_code)) {
        $course_code = Database::escape_string($course_code);
        $courseId = api_get_course_int_id($course_code);
        if (empty($courseId)) {
            return array();
        }
        $course_table = Database::get_main_table(TABLE_MAIN_COURSE);
        $course_cat_table = Database::get_main_table(TABLE_MAIN_CATEGORY);
        $sql = "SELECT\n                    course.*,\n                    course_category.code faCode,\n                    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.id = {$courseId}";
        $result = Database::query($sql);
        $courseInfo = array();
        if (Database::num_rows($result) > 0) {
            $data = Database::fetch_array($result);
            $data['teacher_list'] = CourseManager::getTeacherListFromCourse($courseId);
            $data['teacher_list_formatted'] = CourseManager::formatUserListToString($data['teacher_list'], null, true);
            $courseInfo = api_format_course_array($data);
        }
        return $courseInfo;
    }
    $_course = Session::read('_course');
    if ($_course == '-1') {
        $_course = array();
    }
    return $_course;
}
开发者ID:feroli1000,项目名称:chamilo-lms,代码行数:37,代码来源:api.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::getTeacherListFromCourse($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:daffef,项目名称:chamilo-lms,代码行数:67,代码来源:sessionmanager.lib.php

示例8: 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::getTeacherListFromCourse($course['real_id']);
    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:omaoibrahim,项目名称:chamilo-lms,代码行数:31,代码来源:teacher_time_report.php

示例9: 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::getTeacherListFromCourse($course_id);
        $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:omaoibrahim,项目名称:chamilo-lms,代码行数:31,代码来源:current_courses.php

示例10: restore

 /**
  * Restore a course.
  *
  * @param string    $destination_course_code code of the Chamilo-course in
  * @param int	    $session_id
  * @param bool	    $update_course_settings Course settings are going to be restore?
  * @param bool      $respect_base_content
  * @return bool
  */
 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::getTeacherListFromCourse($this->destination_course_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);
     foreach ($this->course->resources as $type => $resources) {
         if (is_array($resources)) {
             foreach ($resources as $id => $resource) {
                 if (isset($resource->item_properties)) {
                     foreach ($resource->item_properties as $property) {
                         // First check if there isn't already a record for this resource
                         $sql = "SELECT * FROM {$table}\n                                    WHERE\n                                        c_id = " . $this->destination_course_id . " AND\n                                        tool = '" . $property['tool'] . "' AND\n                                        ref = '" . $resource->destination_id . "'";
                         $params = [];
                         if (!empty($session_id)) {
                             $params['session_id'] = intval($session_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*/
                             $params['c_id'] = $this->destination_course_id;
                             $params['tool'] = self::DBUTF8($property['tool']);
                             $params['insert_user_id'] = self::DBUTF8($property['insert_user_id']);
                             $params['insert_date'] = self::DBUTF8($property['insert_date']);
                             $params['lastedit_date'] = self::DBUTF8($property['lastedit_date']);
                             $params['ref'] = $resource->destination_id;
                             $params['lastedit_type'] = self::DBUTF8($property['lastedit_type']);
                             $params['lastedit_user_id'] = self::DBUTF8($property['lastedit_user_id']);
                             $params['visibility'] = self::DBUTF8($property['visibility']);
                             $params['start_visible'] = self::DBUTF8($property['start_visible']);
                             $params['end_visible'] = self::DBUTF8($property['end_visible']);
                             $params['to_user_id'] = self::DBUTF8($property['to_user_id']);
                             //$params['to_group_id'] = 'NULL';
                             $id = Database::insert($table, $params);
                             if ($id) {
                                 $sql = "UPDATE {$table} SET id = iid WHERE iid = {$id}";
                                 Database::query($sql);
                             }
                         }
                     }
                 }
             }
         }
     }
//.........这里部分代码省略.........
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:101,代码来源:CourseRestorer.class.php

示例11: 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::getTeacherListFromCourse($course_data['real_id']);
         $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:jloguercio,项目名称:chamilo-lms,代码行数:35,代码来源:pdf.lib.php

示例12: 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.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(), null, null, 0);
        }
        $complete_user_list2 = CourseManager::get_coach_list_from_course_code($course_info['code'], api_get_session_id());
        $generalCoachList = array();
        $courseCoachList = array();
        foreach ($complete_user_list2 as $coach) {
            if ($coach['type'] == 'general_coach') {
                $generalCoachList[] = $coach;
            } else {
                $courseCoachList[] = $coach;
            }
        }
        $hideCourseCoach = api_get_setting('dropbox_hide_course_coach');
        if ($hideCourseCoach == 'false') {
            $complete_user_list_for_dropbox = array_merge($complete_user_list_for_dropbox, $courseCoachList);
        }
        $hideGeneralCoach = api_get_setting('dropbox_hide_general_coach');
        if ($hideGeneralCoach == 'false') {
            $complete_user_list_for_dropbox = array_merge($complete_user_list_for_dropbox, $generalCoachList);
        }
    } else {
        if (api_get_setting('dropbox.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::getTeacherListFromCourse($course_info['real_id'], 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();
    $userGroup = new UserGroup();
    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['is_tutor'] == 1) && $current_user['user_id'] != $_user['user_id']) {
            // Don't include yourself.
            if ($current_user['user_id'] == $current_user_id) {
                continue;
            }
            $userId = $current_user['user_id'];
            $userInfo = api_get_user_info($userId);
            $groupNameListToString = '';
            if (!empty($groups)) {
                $groupNameList = array_column($groups, 'name');
                $groupNameListToString = ' - [' . implode(', ', $groupNameList) . ']';
            }
            $groups = $userGroup->getUserGroupListByUser($userId);
            $full_name = $userInfo['complete_name'] . $groupNameListToString;
            $current_user_id = $current_user['user_id'];
            $options['user_' . $current_user_id] = $full_name;
        }
    }
    /*
     * 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) {
                    $options['group_' . $current_group['id']] = 'G: ' . $current_group['name'] . ' - ' . $current_group['number_of_members'] . ' ' . get_lang('Users');
                }
            }
        }
//.........这里部分代码省略.........
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:101,代码来源:dropbox_functions.inc.php

示例13: 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)
{
    $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);
    if ($commentId) {
        $sql = "UPDATE {$commentTable} SET id = iid WHERE iid = {$commentId}";
        Database::query($sql);
    }
    $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::getTeacherListFromCourse($courseInfo['real_id']);
            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(api_replace_dangerous_char($fileData['name']));
            $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:omaoibrahim,项目名称:chamilo-lms,代码行数:60,代码来源:work.lib.php


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