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


PHP ExerciseLib::get_all_exercises方法代码示例

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


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

示例1: get_user_data

 /**
  * Get data for users list in sortable with pagination
  * @param $from
  * @param $number_of_items
  * @param $column
  * @param $direction
  * @param $includeInvitedUsers boolean Whether include the invited users
  * @return array
  */
 public static function get_user_data($from, $number_of_items, $column, $direction, $includeInvitedUsers = false)
 {
     global $user_ids, $course_code, $additional_user_profile_info, $export_csv, $is_western_name_order, $csv_content, $session_id;
     $course_code = Database::escape_string($course_code);
     $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
     $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
     $access_url_id = api_get_current_access_url_id();
     // get all users data from a course for sortable with limit
     if (is_array($user_ids)) {
         $user_ids = array_map('intval', $user_ids);
         $condition_user = " WHERE user.user_id IN (" . implode(',', $user_ids) . ") ";
     } else {
         $user_ids = intval($user_ids);
         $condition_user = " WHERE user.user_id = {$user_ids} ";
     }
     if (!empty($_GET['user_keyword'])) {
         $keyword = trim(Database::escape_string($_GET['user_keyword']));
         $condition_user .= " AND (\n                user.firstname LIKE '%" . $keyword . "%' OR\n                user.lastname LIKE '%" . $keyword . "%'  OR\n                user.username LIKE '%" . $keyword . "%'  OR\n                user.email LIKE '%" . $keyword . "%'\n             ) ";
     }
     $url_table = null;
     $url_condition = null;
     if (api_is_multiple_url_enabled()) {
         $url_table = ", " . $tbl_url_rel_user . "as url_users";
         $url_condition = " AND user.user_id = url_users.user_id AND access_url_id='{$access_url_id}'";
     }
     $invitedUsersCondition = '';
     if (!$includeInvitedUsers) {
         $invitedUsersCondition = " AND user.status != " . INVITEE;
     }
     $sql = "SELECT  user.user_id as user_id,\n                    user.official_code  as col0,\n                    user.lastname       as col1,\n                    user.firstname      as col2,\n                    user.username       as col3\n                FROM {$tbl_user} as user {$url_table}\n    \t        {$condition_user} {$url_condition} {$invitedUsersCondition}";
     if (!in_array($direction, array('ASC', 'DESC'))) {
         $direction = 'ASC';
     }
     $column = intval($column);
     $from = intval($from);
     $number_of_items = intval($number_of_items);
     $sql .= " ORDER BY col{$column} {$direction} ";
     $sql .= " LIMIT {$from},{$number_of_items}";
     $res = Database::query($sql);
     $users = array();
     $course_info = api_get_course_info($course_code);
     $total_surveys = 0;
     $total_exercises = ExerciseLib::get_all_exercises($course_info, $session_id, false, null, false, 3);
     if (empty($session_id)) {
         $survey_user_list = array();
         $survey_list = SurveyManager::get_surveys($course_code, $session_id);
         $total_surveys = count($survey_list);
         if (!empty($survey_list)) {
             foreach ($survey_list as $survey) {
                 $user_list = SurveyManager::get_people_who_filled_survey($survey['survey_id'], false, $course_info['real_id']);
                 foreach ($user_list as $user_id) {
                     isset($survey_user_list[$user_id]) ? $survey_user_list[$user_id]++ : ($survey_user_list[$user_id] = 1);
                 }
             }
         }
     }
     while ($user = Database::fetch_array($res, 'ASSOC')) {
         $courseInfo = api_get_course_info($course_code);
         $courseId = $courseInfo['real_id'];
         $user['official_code'] = $user['col0'];
         $user['lastname'] = $user['col1'];
         $user['firstname'] = $user['col2'];
         $user['username'] = $user['col3'];
         $user['time'] = api_time_to_hms(Tracking::get_time_spent_on_the_course($user['user_id'], $courseId, $session_id));
         $avg_student_score = Tracking::get_avg_student_score($user['user_id'], $course_code, array(), $session_id);
         $avg_student_progress = Tracking::get_avg_student_progress($user['user_id'], $course_code, array(), $session_id);
         if (empty($avg_student_progress)) {
             $avg_student_progress = 0;
         }
         $user['average_progress'] = $avg_student_progress . '%';
         $total_user_exercise = Tracking::get_exercise_student_progress($total_exercises, $user['user_id'], $courseId, $session_id);
         $user['exercise_progress'] = $total_user_exercise;
         $total_user_exercise = Tracking::get_exercise_student_average_best_attempt($total_exercises, $user['user_id'], $courseId, $session_id);
         $user['exercise_average_best_attempt'] = $total_user_exercise;
         if (is_numeric($avg_student_score)) {
             $user['student_score'] = $avg_student_score . '%';
         } else {
             $user['student_score'] = $avg_student_score;
         }
         $user['count_assignments'] = Tracking::count_student_assignments($user['user_id'], $course_code, $session_id);
         $user['count_messages'] = Tracking::count_student_messages($user['user_id'], $course_code, $session_id);
         $user['first_connection'] = Tracking::get_first_connection_date_on_the_course($user['user_id'], $courseId, $session_id);
         $user['last_connection'] = Tracking::get_last_connection_date_on_the_course($user['user_id'], $courseInfo, $session_id);
         // we need to display an additional profile field
         $user['additional'] = '';
         if (isset($_GET['additional_profile_field']) && is_numeric($_GET['additional_profile_field'])) {
             if (isset($additional_user_profile_info[$user['user_id']]) && is_array($additional_user_profile_info[$user['user_id']])) {
                 $user['additional'] = implode(', ', $additional_user_profile_info[$user['user_id']]);
             }
         }
         if (empty($session_id)) {
//.........这里部分代码省略.........
开发者ID:feroli1000,项目名称:chamilo-lms,代码行数:101,代码来源:tracking.lib.php

示例2: array

 if (isset($exerciseLevel) && $exerciseLevel != -1) {
     $filter .= ' AND level=' . $exerciseLevel . ' ';
 }
 if (isset($answerType) && $answerType > 0) {
     $filter .= ' AND qu.type=' . $answerType . ' ';
 }
 if (!empty($session_id) && $session_id != '-1') {
     $main_question_list = array();
     if (!empty($course_list)) {
         foreach ($course_list as $course_item) {
             if (!empty($selected_course) && $selected_course != '-1') {
                 if ($selected_course != $course_item['id']) {
                     continue;
                 }
             }
             $exercise_list = ExerciseLib::get_all_exercises($course_item, $session_id);
             if (!empty($exercise_list)) {
                 foreach ($exercise_list as $exercise) {
                     $my_exercise = new Exercise($course_item['id']);
                     $my_exercise->read($exercise['id']);
                     if (!empty($my_exercise)) {
                         if (!empty($my_exercise->questionList)) {
                             foreach ($my_exercise->questionList as $question_id) {
                                 $question_obj = Question::read($question_id, $course_item['id']);
                                 if ($exerciseLevel != '-1') {
                                     if ($exerciseLevel != $question_obj->level) {
                                         continue;
                                     }
                                 }
                                 if ($answerType > 0) {
                                     if ($answerType != $question_obj->type) {
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:31,代码来源:question_pool.php

示例3: get_session_progress

 /**
  * Gets the progress of the given session
  * @param int   session id
  * @param array options order and limit keys
  * @return array table with user name, lp name, progress
  */
 public static function get_session_progress($sessionId, $courseId, $date_from, $date_to, $options)
 {
     $sessionId = intval($sessionId);
     $getAllSessions = false;
     if (empty($sessionId)) {
         $sessionId = 0;
         $getAllSessions = true;
     }
     //tables
     $session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
     $user = Database::get_main_table(TABLE_MAIN_USER);
     $workTable = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
     $workTableAssignment = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
     $forum = Database::get_course_table(TABLE_FORUM);
     $forum_post = Database::get_course_table(TABLE_FORUM_POST);
     $tbl_course_lp = Database::get_course_table(TABLE_LP_MAIN);
     $wiki = Database::get_course_table(TABLE_WIKI);
     $table_stats_default = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DEFAULT);
     $table_stats_access = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
     $course = api_get_course_info_by_id($courseId);
     $where = " WHERE c_id = '%s' AND s.status <> 2 ";
     $limit = null;
     if (!empty($options['limit'])) {
         $limit = " LIMIT " . $options['limit'];
     }
     if (!empty($options['where'])) {
         $where .= ' ' . $options['where'];
     }
     $order = null;
     if (!empty($options['order'])) {
         $order = " ORDER BY " . $options['order'];
     }
     //TODO, fix create report without session
     $queryVariables = array($course['real_id']);
     if (!empty($sessionId)) {
         $where .= ' AND session_id = %s';
         $queryVariables[] = $sessionId;
         $sql = "SELECT\n                        u.user_id, u.lastname, u.firstname, u.username,\n                        u.email, s.c_id, s.session_id\n                    FROM {$session_course_user} s\n                    INNER JOIN {$user} u\n                    ON u.user_id = s.user_id\n                    {$where} {$order} {$limit}";
     } else {
         $sql = "SELECT\n                        u.user_id, u.lastname, u.firstname, u.username,\n                        u.email, s.c_id, s.session_id\n                    FROM {$session_course_user} s\n                    INNER JOIN {$user} u ON u.user_id = s.user_id\n                    {$where} {$order} {$limit}";
     }
     $sql_query = vsprintf($sql, $queryVariables);
     $rs = Database::query($sql_query);
     while ($user = Database::fetch_array($rs)) {
         $users[$user['user_id']] = $user;
     }
     /**
      *  Lessons
      */
     $sql = "SELECT * FROM {$tbl_course_lp} WHERE c_id = %s ";
     //AND session_id = %s
     $sql_query = sprintf($sql, $course['real_id']);
     $result = Database::query($sql_query);
     $arrLesson = array(array());
     while ($row = Database::fetch_array($result)) {
         if (empty($arrLesson[$row['session_id']]['lessons_total'])) {
             $arrLesson[$row['session_id']]['lessons_total'] = 1;
         } else {
             $arrLesson[$row['session_id']]['lessons_total']++;
         }
     }
     /**
      *  Exercises
      */
     $exercises = ExerciseLib::get_all_exercises($course, $sessionId, false, '', $getAllSessions);
     $exercises_total = count($exercises);
     /**
      *  Assignments
      */
     //total
     if ($getAllSessions) {
         $sql = "SELECT count(w.id) as count\n                    FROM {$workTable} w\n                    LEFT JOIN {$workTableAssignment} a\n                    ON (a.publication_id = w.id AND a.c_id = w.c_id)\n                    WHERE w.c_id = %s\n                    AND parent_id = 0\n                    AND active IN (1, 0)";
     } else {
         $sql = "SELECT count(w.id) as count\n                    FROM {$workTable} w\n                    LEFT JOIN {$workTableAssignment} a\n                    ON (a.publication_id = w.id AND a.c_id = w.c_id)\n                    WHERE w.c_id = %s\n                    AND parent_id = 0\n                    AND active IN (1, 0)\n                    AND  session_id = %s";
     }
     $sql_query = sprintf($sql, $course['real_id'], $sessionId);
     $result = Database::query($sql_query);
     $row = Database::fetch_array($result);
     $assignments_total = $row['count'];
     /**
      * Wiki
      */
     if ($getAllSessions) {
         $sql = "SELECT count(distinct page_id)  as count FROM {$wiki}\n                    WHERE c_id = %s";
     } else {
         $sql = "SELECT count(distinct page_id)  as count FROM {$wiki}\n                    WHERE c_id = %s and session_id = %s";
     }
     $sql_query = sprintf($sql, $course['real_id'], $sessionId);
     $result = Database::query($sql_query);
     $row = Database::fetch_array($result);
     $wiki_total = $row['count'];
     /**
      * Surveys
      */
//.........这里部分代码省略.........
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:101,代码来源:sessionmanager.lib.php

示例4: AND

         $sql = "SELECT u.user_id as id, u.username, u.lastname, u.firstname\n                    FROM {$user} u\n                    INNER JOIN {$session_course_user} r ON u.user_id = r.user_id\n                    WHERE session_id = %d AND c_id =  '%s'\n                    AND (u.firstname LIKE '%s' OR u.username LIKE '%s' OR u.lastname LIKE '%s')";
         $needle = '%' . $_GET['q'] . '%';
         $sql_query = sprintf($sql, $_GET['session_id'], $course['real_id'], $needle, $needle, $needle);
         $result = Database::query($sql_query);
         while ($user = Database::fetch_assoc($result)) {
             $userCompleteName = api_get_person_name($user['firstname'], $user['lastname']);
             $json['items'][] = ['id' => $user['id'], 'text' => "{$user['username']} ({$userCompleteName})"];
         }
         echo json_encode($json);
     }
     break;
 case 'search_exercise_by_course':
     if (api_is_platform_admin()) {
         $course = api_get_course_info_by_id($_GET['course_id']);
         $session_id = !empty($_GET['session_id']) ? intval($_GET['session_id']) : 0;
         $exercises = ExerciseLib::get_all_exercises($course, $session_id, false, $_GET['q'], true, 3);
         foreach ($exercises as $exercise) {
             $data[] = array('id' => $exercise['id'], 'text' => html_entity_decode($exercise['title']));
         }
         if (!empty($data)) {
             $data[] = array('id' => 'T', 'text' => 'TODOS');
             echo json_encode($data);
         } else {
             echo json_encode(array(array('id' => 'T', 'text' => 'TODOS')));
         }
     }
     break;
 case 'search_survey_by_course':
     if (api_is_platform_admin()) {
         $survey = Database::get_course_table(TABLE_SURVEY);
         $sql = "SELECT survey_id as id, title, anonymous\n                    FROM {$survey}\n                    WHERE\n                      c_id = %d AND\n                      session_id = %d AND\n                      title LIKE '%s'";
开发者ID:feroli1000,项目名称:chamilo-lms,代码行数:31,代码来源:course.ajax.php

示例5: api_get_course_url

     $course_data['title'] = Display::url($course_data['title'], api_get_course_url($course_data['code'], $session_id));
 } else {
     continue;
 }
 $list = new LearnpathList(api_get_user_id(), $course_data['code'], $session_id, 'publicated_on ASC', true);
 $lp_list = $list->get_flat_list();
 $lp_count = 0;
 if (!empty($lp_list)) {
     foreach ($lp_list as $valLp) {
         if ($valLp['lp_visibility']) {
             $lp_count++;
         }
     }
 }
 $course_info = api_get_course_info($course_data['code']);
 $exercise_count = count(ExerciseLib::get_all_exercises($course_info, $session_id, true, null, false, 1));
 $max_mutation_date = '';
 $last_date = Tracking::get_last_connection_date_on_the_course(api_get_user_id(), $course_info, $session_id, false);
 $icons = '';
 foreach ($lp_list as $item) {
     if ($item['modified_on'] == '0000-00-00 00:00:00' || empty($item['modified_on'])) {
         $lp_date_original = $item['created_on'];
         $image = 'new.gif';
         $label = get_lang('LearnpathAdded');
     } else {
         $lp_date_original = $item['modified_on'];
         $image = 'moderator_star.png';
         $label = get_lang('LearnpathUpdated');
     }
     $mutation_date = api_strtotime($item['publicated_on']) > api_strtotime($lp_date_original) ? $item['publicated_on'] : $lp_date_original;
     if (api_strtotime($mutation_date) > api_strtotime($max_mutation_date)) {
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:31,代码来源:index.php

示例6: foreach

    }
}
if (!empty($course_list)) {
    foreach ($course_list as $course_data) {
        if (in_array($course_data['code'], $user_course_list)) {
            $course_data['only_title'] = $course_data['title'];
            $course_data['link'] = api_get_course_url($course_data['code'], $session_id);
            $course_data['title'] = Display::url($course_data['title'], api_get_course_url($course_data['code'], $session_id));
        } else {
            continue;
        }
        $list = new LearnpathList(api_get_user_id(), $course_data['code'], $session_id, 'publicated_on ASC', true);
        $lp_list = $list->get_flat_list();
        $lp_count = count($lp_list);
        $course_info = api_get_course_info($course_data['code']);
        $exercise_count = count(ExerciseLib::get_all_exercises($course_info, $session_id, true));
        $max_mutation_date = '';
        $last_date = Tracking::get_last_connection_date_on_the_course(api_get_user_id(), $course_data['id'], $session_id, false);
        $icons = '';
        foreach ($lp_list as $item) {
            if ($item['modified_on'] == '0000-00-00 00:00:00' || empty($item['modified_on'])) {
                $lp_date_original = $item['created_on'];
                $image = 'new.gif';
                $label = get_lang('LearnpathAdded');
            } else {
                $lp_date_original = $item['modified_on'];
                $image = 'moderator_star.png';
                $label = get_lang('LearnpathUpdated');
            }
            $mutation_date = api_strtotime($item['publicated_on']) > api_strtotime($lp_date_original) ? $item['publicated_on'] : $lp_date_original;
            if (api_strtotime($mutation_date) > api_strtotime($max_mutation_date)) {
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:31,代码来源:index.php


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