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


PHP ExtraField::parseConditions方法代码示例

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


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

示例1: getQuestions

 /**
  * Get all questions
  * @param Application $app
  * @param int $categoryId
  * @param int $exerciseId
  * @param int $courseId
  * @param array $options
  * @param bool $get_count
  * @return array
  */
 public static function getQuestions($app, $categoryId, $exerciseId, $courseId, $options, $get_count = false)
 {
     $questionTable = Database::get_course_table(TABLE_QUIZ_QUESTION);
     $questionPoolFields = array('question_session_id' => array('innerjoin' => " INNER JOIN " . Database::get_course_table(TABLE_QUIZ_TEST_QUESTION) . " as quiz_rel_question_session ON (quiz_rel_question_session.question_id = s.iid)\n                                 INNER JOIN " . Database::get_course_table(TABLE_QUIZ_TEST) . " as quizsession ON (quizsession.iid = quiz_rel_question_session.exercice_id)\n                                 INNER JOIN " . Database::get_main_table(TABLE_MAIN_SESSION) . " session ON (session.id = quizsession.session_id)", 'where' => 'session_id', 'inject_fields' => 'session.name as question_session_id, '), 'question_category_id' => array('innerjoin' => " INNER JOIN " . Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY) . " as quiz_rel_cat ON (quiz_rel_cat.question_id = s.iid)\n                                 INNER JOIN " . Database::get_course_table(TABLE_QUIZ_CATEGORY) . " as cat ON (cat.iid = quiz_rel_cat.category_id)", 'where' => 'quiz_rel_cat.category_id', 'inject_fields' => 'cat.title as question_category_id, '), 'question_exercise_id' => array('innerjoin' => " INNER JOIN " . Database::get_course_table(TABLE_QUIZ_TEST_QUESTION) . " as quiz_rel_question ON (quiz_rel_question.question_id = s.iid)\n                                 INNER JOIN " . Database::get_course_table(TABLE_QUIZ_TEST) . " as quizexercise ON (quizexercise.iid = quiz_rel_question.exercice_id) ", 'where' => 'quiz_rel_question.exercice_id', 'inject_fields' => 'quizexercise.title as question_exercise_id, '), 'question_c_id' => array('where' => 's.c_id', 'innerjoin' => " INNER JOIN " . Database::get_main_table(TABLE_MAIN_COURSE) . " as course ON (course.id = s.c_id) ", 'inject_fields' => 'course.title as question_c_id, '), 'question_question_type' => array('where' => 's.type ', 'inject_fields' => 's.type as question_question_type,'), 'question_difficulty' => array('where' => 's.level', 'inject_fields' => 's.level as question_difficulty, '));
     // Checking if you're looking for orphan questions.
     $isOrphanQuestion = false;
     if (isset($options['question'])) {
         foreach ($options['question'] as $option) {
             if (isset($option['field']) && $option['field'] == 'question_exercise_id') {
                 if ($option['data'] == 0) {
                     $isOrphanQuestion = true;
                     break;
                 }
             }
         }
     }
     // Special case for orphan questions.
     if ($isOrphanQuestion) {
         $questionPoolFields['question_exercise_id'] = array('innerjoin' => " LEFT JOIN " . Database::get_course_table(TABLE_QUIZ_TEST_QUESTION) . " as quiz_rel_question ON (quiz_rel_question.question_id = s.iid)\n                                 LEFT JOIN " . Database::get_course_table(TABLE_QUIZ_TEST) . " as quizexercise ON (quizexercise.iid = quiz_rel_question.exercice_id) ", 'where' => 'quiz_rel_question.exercice_id', 'inject_fields' => 'quizexercise.title as question_exercise_id, ');
     }
     $inject_extra_fields = null;
     $inject_joins = null;
     $where = $options['where'];
     $newQuestionPoolField = array();
     if (isset($options['question'])) {
         foreach ($options['question'] as $question) {
             if (isset($questionPoolFields[$question['field']])) {
                 $newQuestionPoolField[$question['field']] = $questionPoolFields[$question['field']];
             }
         }
     }
     $inject_question_fields = null;
     $questionPoolFields = $newQuestionPoolField;
     // Injecting inner joins.
     foreach ($questionPoolFields as $field => $option) {
         $where = str_replace($field, $option['where'], $where);
         if (isset($option['innerjoin']) && !empty($option['innerjoin'])) {
             $inject_joins .= $option['innerjoin'];
         }
         if (isset($option['inject_fields']) && !empty($option['inject_fields'])) {
             $inject_question_fields .= $option['inject_fields'];
         }
     }
     $options['where'] = $where;
     $extra_field = new ExtraField('question');
     $conditions = $extra_field->parseConditions($options);
     $inject_joins .= $conditions['inject_joins'];
     $where = $conditions['where'];
     $inject_where = $conditions['inject_where'];
     $inject_extra_fields = $conditions['inject_extra_fields'];
     $order = $conditions['order'];
     $limit = $conditions['limit'];
     if ($get_count == true) {
         $select = " SELECT count(*) as total_rows";
     } else {
         $select = " SELECT s.*, {$inject_extra_fields} {$inject_question_fields} 1 ";
     }
     $extraCondition = null;
     // Used by the question manager
     if (!empty($categoryId)) {
         $categoryRelQuestionTable = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY);
         $extraCondition = " INNER JOIN {$categoryRelQuestionTable} c ON (s.iid = c.question_id)";
         $categoryId = intval($categoryId);
         $where .= " AND category_id = {$categoryId} ";
     }
     /*if (!empty($exerciseId)) {
           $exerciseRelQuestionTable = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
           $extraCondition .= " INNER JOIN $exerciseRelQuestionTable e ON (s.iid = e.question_id)";
           $exerciseId = intval($exerciseId);
           $where .= " AND exercice_id = $exerciseId ";
       }*/
     // Orphan questions
     if ($isOrphanQuestion) {
         //$exerciseRelQuestionTable = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
         //$extraCondition .= " INNER JOIN $exerciseRelQuestionTable e ON (s.iid = e.question_id)";
         $where .= " OR quizexercise.active = -1 OR quiz_rel_question.exercice_id IS NULL";
     }
     if (!empty($courseId)) {
         $courseId = intval($courseId);
         $where .= " AND s.c_id = {$courseId} ";
     }
     if (isset($options['question'])) {
         $courseList = CourseManager::get_course_list_of_user_as_course_admin(api_get_user_id());
         foreach ($options['question'] as $questionOption) {
             if ($questionOption['field'] == 'question_c_id') {
                 if (isset($questionOption['data'])) {
                     if (!isset($courseList[$questionOption['data']])) {
                         return array();
                     }
                 }
//.........这里部分代码省略.........
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:101,代码来源:question.class.php

示例2: get_sessions_admin

 /**
  * Gets the admin session list callback of the session/session_list.php page
  * @param array order and limit keys
  * @param boolean Whether to get all the results or only the count
  * @return mixed Integer for number of rows, or array of results
  * @assert (array(),true) !== false
  */
 public static function get_sessions_admin($options = array(), $get_count = false)
 {
     $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
     $where = 'WHERE 1 = 1 ';
     $user_id = api_get_user_id();
     if (!api_is_platform_admin()) {
         if (api_is_session_admin() && api_get_setting('allow_session_admins_to_manage_all_sessions') == 'false') {
             $where .= " AND s.session_admin_id = {$user_id} ";
         }
     }
     if (!api_is_platform_admin() && api_is_teacher() && api_get_setting('allow_teachers_to_create_sessions') == 'true') {
         $where .= " AND s.id_coach = {$user_id} ";
     }
     $extra_field = new ExtraField('session');
     $conditions = $extra_field->parseConditions($options);
     $inject_joins = $conditions['inject_joins'];
     $where .= $conditions['where'];
     $inject_where = $conditions['inject_where'];
     $inject_extra_fields = $conditions['inject_extra_fields'];
     $order = $conditions['order'];
     $limit = $conditions['limit'];
     if ($get_count == true) {
         $select = " SELECT count(*) as total_rows";
     } else {
         $select = "SELECT DISTINCT " . " s.name, " . " s.display_start_date, " . " s.display_end_date, " . " access_start_date, " . " access_end_date, " . " s.visibility, " . " {$inject_extra_fields} " . " s.id ";
     }
     $query = "{$select} FROM {$tbl_session} s {$inject_joins} {$where} {$inject_where}";
     if (api_is_multiple_url_enabled()) {
         $table_access_url_rel_session = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
         $access_url_id = api_get_current_access_url_id();
         if ($access_url_id != -1) {
             $where .= " AND ar.access_url_id = {$access_url_id} ";
             $query = "{$select} FROM {$tbl_session} s {$inject_joins} INNER JOIN {$table_access_url_rel_session} ar ON (ar.session_id = s.id) {$where}";
         }
     }
     $query .= $order;
     $query .= $limit;
     $result = Database::query($query);
     $formatted_sessions = array();
     if (Database::num_rows($result)) {
         $sessions = Database::store_result($result, 'ASSOC');
         if ($get_count) {
             return $sessions[0]['total_rows'];
         }
         foreach ($sessions as $session) {
             $session_id = $session['id'];
             $session['name'] = Display::url($session['name'], "resume_session.php?id_session=" . $session['id']);
             if (isset($session['session_active']) && $session['session_active'] == 1) {
                 $session['session_active'] = Display::return_icon('accept.png', get_lang('Active'), array(), ICON_SIZE_SMALL);
             } else {
                 $session['session_active'] = Display::return_icon('error.png', get_lang('Inactive'), array(), ICON_SIZE_SMALL);
             }
             $session = self::convert_dates_to_local($session);
             switch ($session['visibility']) {
                 case SESSION_VISIBLE_READ_ONLY:
                     //1
                     $session['visibility'] = get_lang('ReadOnly');
                     break;
                 case SESSION_VISIBLE:
                     //2
                 //2
                 case SESSION_AVAILABLE:
                     //4
                     $session['visibility'] = get_lang('Visible');
                     break;
                 case SESSION_INVISIBLE:
                     //3
                     $session['visibility'] = api_ucfirst(get_lang('Invisible'));
                     break;
             }
             // Cleaning double selects.
             foreach ($session as $key => &$value) {
                 if (isset($options_by_double[$key]) || isset($options_by_double[$key . '_second'])) {
                     $options = explode('::', $value);
                 }
                 $original_key = $key;
                 if (strpos($key, '_second') === false) {
                 } else {
                     $key = str_replace('_second', '', $key);
                 }
                 if (isset($options_by_double[$key])) {
                     if (isset($options[0])) {
                         if (isset($options_by_double[$key][$options[0]])) {
                             if (strpos($original_key, '_second') === false) {
                                 $value = $options_by_double[$key][$options[0]]['option_display_text'];
                             } else {
                                 $value = $options_by_double[$key][$options[1]]['option_display_text'];
                             }
                         }
                     }
                 }
             }
             $formatted_sessions[$session_id] = $session;
//.........这里部分代码省略.........
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:101,代码来源:sessionmanager.lib.php


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