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


PHP Database::result方法代码示例

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


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

示例1: logout

 /**
  * @return void  Directly redirects the user or leaves him where he is, but doesn't return anything
  * @param int $userId
  * @param bool $logout_redirect
  * @author Fernando P. García <fernando@develcuy.com>
  */
 public static function logout($user_id = null, $logout_redirect = false)
 {
     global $extAuthSource;
     // Database table definition
     $tbl_track_login = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
     if (empty($user_id)) {
         $user_id = api_get_user_id();
     }
     $user_id = intval($user_id);
     // Changing global chat status to offline
     if (api_is_global_chat_enabled()) {
         $chat = new Chat();
         $chat->set_user_status(0);
     }
     // selecting the last login of the user
     $sql_last_connection = "SELECT login_id, login_date FROM {$tbl_track_login}\n                              WHERE login_user_id='{$user_id}' ORDER BY login_date DESC LIMIT 0,1";
     $q_last_connection = Database::query($sql_last_connection);
     $i_id_last_connection = null;
     if (Database::num_rows($q_last_connection) > 0) {
         $i_id_last_connection = Database::result($q_last_connection, 0, "login_id");
     }
     if (!isset($_SESSION['login_as']) && !empty($i_id_last_connection)) {
         $current_date = api_get_utc_datetime();
         $s_sql_update_logout_date = "UPDATE {$tbl_track_login} SET logout_date='" . $current_date . "' WHERE login_id = '{$i_id_last_connection}'";
         Database::query($s_sql_update_logout_date);
     }
     Online::loginDelete($user_id);
     //from inc/lib/online.inc.php - removes the "online" status
     //the following code enables the use of an external logout function.
     //example: define a $extAuthSource['ldap']['logout']="file.php" in configuration.php
     // then a function called ldap_logout() inside that file
     // (using *authent_name*_logout as the function name) and the following code
     // will find and execute it
     $uinfo = api_get_user_info($user_id);
     if (isset($uinfo['auth_source']) && $uinfo['auth_source'] != PLATFORM_AUTH_SOURCE && is_array($extAuthSource)) {
         if (is_array($extAuthSource[$uinfo['auth_source']])) {
             $subarray = $extAuthSource[$uinfo['auth_source']];
             if (!empty($subarray['logout']) && file_exists($subarray['logout'])) {
                 require_once $subarray['logout'];
                 $logout_function = $uinfo['auth_source'] . '_logout';
                 if (function_exists($logout_function)) {
                     $logout_function($uinfo);
                 }
             }
         }
     }
     require_once api_get_path(SYS_PATH) . 'main/chat/chat_functions.lib.php';
     exit_of_chat($user_id);
     if ($logout_redirect) {
         header("Location: index.php");
         exit;
     }
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:59,代码来源:online.inc.php

示例2: loadSettings

 static function loadSettings($var = null)
 {
     Database::DB()->select('settings');
     if ($var) {
         Database::DB()->where('var', $var, 'IN');
     }
     Database::DB()->exec();
     if (Database::result()->num_rows == 0) {
         throw new Exception('Ошибка при загрузке настроек');
     }
     $arg = array();
     while ($row = Database::result()->fetch_assoc()) {
         $arg[$row['var']] = $row['val'];
     }
     if (is_string($var)) {
         return $arg[$var];
     }
     return $arg;
 }
开发者ID:pdanver,项目名称:mir-ndv,代码行数:19,代码来源:Engine.php

示例3: count

 $total_students = count($a_students);
 $sqlExercices = "SELECT count(id) as count FROM " . $t_quiz . " AS quiz WHERE active='1' AND c_id = {$course_id} ";
 $resultExercices = Database::query($sqlExercices);
 $data_exercises = Database::store_result($resultExercices);
 $exercise_count = $data_exercises[0]['count'];
 if ($global) {
     if ($exercise_count == 0) {
         $exercise_count = 2;
     }
     $html_result .= "<tr class='{$s_css_class}'>\n                                <td rowspan={$exercise_count}>";
     $html_result .= $current_course['title'];
     $html_result .= "</td>";
 }
 $sql = "SELECT visibility FROM {$table} WHERE c_id = {$course_id} AND name='quiz'";
 $resultVisibilityQuizz = Database::query($sql);
 if (Database::result($resultVisibilityQuizz, 0, 'visibility') == 1) {
     $sqlExercices = "    SELECT quiz.title,id FROM " . $t_quiz . " AS quiz WHERE c_id = {$course_id}  AND active='1' ORDER BY quiz.title ASC";
     //Getting the exam list
     if (!$global) {
         if (!empty($exercise_id)) {
             $sqlExercices = "    SELECT quiz.title,id FROM " . $t_quiz . " AS quiz WHERE c_id = {$course_id}  AND active='1' AND id = {$exercise_id} ORDER BY quiz.title ASC";
         }
     }
     $resultExercices = Database::query($sqlExercices);
     $i = 0;
     if (Database::num_rows($resultExercices) > 0) {
         while ($a_exercices = Database::fetch_array($resultExercices)) {
             $global_row[] = $current_course['title'];
             if (!$global) {
                 $html_result .= "<tr class='{$s_css_class}'>";
             }
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:31,代码来源:exams.php

示例4: unset_document_as_template

 /**
  * Unset a document as template
  *
  * @param int $document_id
  * @param string $couse_code
  * @param int $user_id
  */
 public static function unset_document_as_template($document_id, $course_code, $user_id)
 {
     $table_template = Database::get_main_table(TABLE_MAIN_TEMPLATES);
     $course_code = Database::escape_string($course_code);
     $user_id = Database::escape_string($user_id);
     $document_id = Database::escape_string($document_id);
     $sql = 'SELECT id FROM ' . $table_template . ' WHERE course_code="' . $course_code . '" AND user_id="' . $user_id . '" AND ref_doc="' . $document_id . '"';
     $result = Database::query($sql);
     $template_id = Database::result($result, 0, 0);
     FileManager::my_delete(api_get_path(SYS_CODE_PATH) . 'upload/template_thumbnails/' . $template_id . '.jpg');
     $sql = 'DELETE FROM ' . $table_template . ' WHERE course_code="' . $course_code . '" AND user_id="' . $user_id . '" AND ref_doc="' . $document_id . '"';
     Database::query($sql);
 }
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:20,代码来源:document.lib.php

示例5: delete_inactive_student

 /**
  *
  * @param int   student id
  * @param int   years
  * @param bool  show warning_message
  * @param bool  return_timestamp
  */
 public static function delete_inactive_student($student_id, $years = 2, $warning_message = false, $return_timestamp = false)
 {
     $tbl_track_login = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
     $sql = 'SELECT login_date FROM ' . $tbl_track_login . '
             WHERE login_user_id = ' . intval($student_id) . '
             ORDER BY login_date DESC LIMIT 0,1';
     if (empty($years)) {
         $years = 1;
     }
     $inactive_time = $years * 31536000;
     //1 year
     $rs = Database::query($sql);
     if (Database::num_rows($rs) > 0) {
         if ($last_login_date = Database::result($rs, 0, 0)) {
             $last_login_date = api_get_local_time($last_login_date, null, date_default_timezone_get());
             if ($return_timestamp) {
                 return api_strtotime($last_login_date);
             } else {
                 if (!$warning_message) {
                     return api_format_date($last_login_date, DATE_FORMAT_SHORT);
                 } else {
                     $timestamp = api_strtotime($last_login_date);
                     $currentTimestamp = time();
                     //If the last connection is > than 7 days, the text is red
                     //345600 = 7 days in seconds 63072000= 2 ans
                     // if ($currentTimestamp - $timestamp > 184590 )
                     if ($currentTimestamp - $timestamp > $inactive_time && UserManager::delete_user($student_id)) {
                         Display::display_normal_message(get_lang('UserDeleted'));
                         echo '<p>', 'id', $student_id, ':', $last_login_date, '</p>';
                     }
                 }
             }
         }
     }
     return false;
 }
开发者ID:secuencia24,项目名称:chamilo-lms,代码行数:43,代码来源:usermanager.lib.php

示例6: array

}
if (isset($_GET["user_id"]) && $_GET["user_id"] != "" && !isset($_GET["type"])) {
    $interbreadcrumb[] = array("url" => "teachers.php", "name" => get_lang('Teachers'));
}
function count_courses()
{
    global $nb_courses;
    return $nb_courses;
}
//checking if the current coach is the admin coach
$show_import_icon = false;
if (api_get_setting('add_users_by_coach') == 'true') {
    if (!api_is_platform_admin()) {
        $sql = 'SELECT id_coach FROM ' . Database::get_main_table(TABLE_MAIN_SESSION) . ' WHERE id=' . $id_session;
        $rs = Database::query($sql);
        if (Database::result($rs, 0, 0) != $_user['user_id']) {
            api_not_allowed(true);
        } else {
            $show_import_icon = true;
        }
    }
}
Display::display_header($nameTools);
$a_courses = array();
if (api_is_drh() || api_is_session_admin() || api_is_platform_admin()) {
    $title = '';
    if (empty($id_session)) {
        if (isset($_GET['user_id'])) {
            $user_id = intval($_GET['user_id']);
            $user_info = api_get_user_info($user_id);
            $title = get_lang('AssignedCoursesTo') . ' ' . api_get_person_name($user_info['firstname'], $user_info['lastname']);
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:31,代码来源:course.php

示例7: display_document_form

 /**
  * Returns the form to update or create a document
  *
  * @param	string	Action (add/edit)
  * @param	integer	ID of the lp_item (if already exists)
  * @param	mixed	Integer if document ID, string if info ('new')
  * @return	string	HTML form
  */
 function display_document_form($action = 'add', $id = 0, $extra_info = 'new')
 {
     global $charset, $_course;
     require_once api_get_path(LIBRARY_PATH) . 'fileUpload.lib.php';
     require_once api_get_path(LIBRARY_PATH) . 'document.lib.php';
     $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
     $tbl_doc = Database::get_course_table(TABLE_DOCUMENT);
     $path_parts = pathinfo($extra_info['dir']);
     $no_display_edit_textarea = false;
     //If action==edit document
     //We don't display the document form if it's not an editable document (html or txt file)
     if ($action == "edit") {
         if (is_array($extra_info)) {
             if ($path_parts['extension'] != "txt" && $path_parts['extension'] != "html") {
                 $no_display_edit_textarea = true;
             }
         }
     }
     $no_display_add = false;
     //If action==add an existing document
     //We don't display the document form if it's not an editable document (html or txt file)
     if ($action == "add") {
         if (is_numeric($extra_info)) {
             $sql_doc = "SELECT path FROM " . $tbl_doc . "WHERE id = " . Database::escape_string($extra_info);
             $result = Database::query($sql_doc, __FILE__, __LINE__);
             $path_file = Database::result($result, 0, 0);
             $path_parts = pathinfo($path_file);
             if ($path_parts['extension'] != "txt" && $path_parts['extension'] != "html") {
                 $no_display_add = true;
             }
         }
     }
     // create css folder
     $css_name = api_get_setting('stylesheets');
     $perm = api_get_setting('permissions_for_new_directories');
     $perm = octdec(!empty($perm) ? $perm : '0770');
     $css_folder = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document/css';
     if (!is_dir($css_folder)) {
         mkdir($css_folder);
         chmod($css_folder, $perm);
         $doc_id = add_document($_course, '/css', 'folder', 0, 'css');
         api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'FolderCreated', $_user['user_id']);
         api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'invisible', $_user['user_id']);
     }
     if (!file_exists($css_folder . '/templates.css')) {
         if (file_exists(api_get_path(SYS_PATH) . 'main/css/' . $css_name . '/templates.css')) {
             $template_content = str_replace('../../img/', api_get_path(REL_CODE_PATH) . 'img/', file_get_contents(api_get_path(SYS_PATH) . 'main/css/' . $css_name . '/templates.css'));
             $template_content = str_replace('images/', api_get_path(REL_CODE_PATH) . 'css/' . $css_name . '/images/', $template_content);
             file_put_contents($css_folder . '/templates.css', $template_content);
         }
     }
     if ($action == 'add' && (isset($_GET['tplid']) && $_GET['tplid'] >= 0)) {
         $table_sys_template = Database::get_main_table(TABLE_MAIN_SYSTEM_TEMPLATE);
         $user_id = api_get_user_id();
         // Session used by the ajax request when we are using php 5.3
         $_SESSION['dbName'] = $_course['dbName'];
         // setting some paths
         $img_dir = api_get_path(REL_CODE_PATH) . 'img/';
         $default_course_dir = api_get_path(REL_CODE_PATH) . 'default_course_document/';
         if (!isset($_GET['resource'])) {
             // Load a template into a document
             $query = 'SELECT content, title FROM ' . $table_sys_template . ' WHERE id=' . Database::escape_string(Security::remove_XSS($_GET['tplid']));
             $result = Database::query($query, __FILE__, __LINE__);
             $obj = Database::fetch_object($result);
             $valcontent = $obj->content;
             $valtitle = $obj->title != '' ? get_lang($obj->title) : get_lang('Empty');
             if (isset($_GET['tplid']) && $_GET['tplid'] == 0) {
                 $valcontent = '<head>{CSS}<style type="text/css">.text{font-weight: normal;}</style></head><body></body>';
             }
             $template_css = '';
             if (strpos($valcontent, '/css/templates.css') === false) {
                 $template_css = '<link rel="stylesheet" href="' . api_get_path(WEB_COURSE_PATH) . $_course['path'] . '/document/css/templates.css" type="text/css" />';
             }
             $js = '';
             if (strpos($valcontent, 'javascript/jquery.highlight.js') === false) {
                 $js .= '<script type="text/javascript" src="' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/jquery-1.4.2.min.js" language="javascript"></script>';
                 $js .= '<script type="text/javascript" src="' . api_get_path(WEB_LIBRARY_PATH) . 'jwplayer/jwplayer.js" language="javascript"></script>' . PHP_EOL;
                 if (api_get_setting('show_glossary_in_documents') != 'none') {
                     $js .= '<script language="javascript" src="' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/jquery.highlight.js"></script>';
                     if (api_get_setting('show_glossary_in_documents') == 'ismanual') {
                         $js .= '<script language="javascript" src="' . api_get_path(WEB_LIBRARY_PATH) . 'fckeditor/editor/plugins/glossary/fck_glossary_manual.js"></script>';
                     } else {
                         $js .= '<script language="javascript" src="' . api_get_path(WEB_LIBRARY_PATH) . 'fckeditor/editor/plugins/glossary/fck_glossary_automatic.js"></script>';
                     }
                 }
             }
             $valcontent = str_replace('{CSS}', $template_css . $js, $valcontent);
             if (strpos($valcontent, '/css/templates.css') === false) {
                 $valcontent = str_replace('</head>', $template_css . '</head>', $valcontent);
             }
             if (strpos($valcontent, 'javascript/jquery.highlight.js') === false) {
                 $valcontent = str_replace('</head>', $js . '</head>', $valcontent);
//.........这里部分代码省略.........
开发者ID:Eidn,项目名称:shanghai,代码行数:101,代码来源:learnpath.class.php

示例8: get_last_connection_time_in_lp

 /**
  * This function gets last connection time to one learning path
  * @param     int|array    Student id(s)
  * @param     string         Course code
  * @param     int         Learning path id
  * @return     int         Total time
  */
 public static function get_last_connection_time_in_lp($student_id, $course_code, $lp_id, $session_id = 0)
 {
     $course = CourseManager::get_course_information($course_code);
     $student_id = intval($student_id);
     $lp_id = intval($lp_id);
     $last_time = 0;
     $session_id = intval($session_id);
     if (!empty($course)) {
         $course_id = $course['real_id'];
         $lp_table = Database::get_course_table(TABLE_LP_MAIN);
         $t_lpv = Database::get_course_table(TABLE_LP_VIEW);
         $t_lpiv = Database::get_course_table(TABLE_LP_ITEM_VIEW);
         // Check the real number of LPs corresponding to the filter in the
         // database (and if no list was given, get them all)
         $res_row_lp = Database::query("SELECT id FROM {$lp_table} WHERE c_id = {$course_id} AND id = {$lp_id} ");
         $count_row_lp = Database::num_rows($res_row_lp);
         // calculates last connection time
         if ($count_row_lp > 0) {
             $sql = 'SELECT MAX(start_time)
                     FROM ' . $t_lpiv . ' AS item_view
                     INNER JOIN ' . $t_lpv . ' AS view
                         ON item_view.lp_view_id = view.id
                     WHERE
                         item_view.c_id 		= ' . $course_id . ' AND
                         view.c_id 			= ' . $course_id . ' AND
                         view.lp_id 			= ' . $lp_id . '
                         AND view.user_id 	= ' . $student_id . '
                         AND view.session_id = ' . $session_id;
             $rs = Database::query($sql);
             if (Database::num_rows($rs) > 0) {
                 $last_time = Database::result($rs, 0, 0);
             }
         }
     }
     return $last_time;
 }
开发者ID:feroli1000,项目名称:chamilo-lms,代码行数:43,代码来源:tracking.lib.php

示例9: load

    /**
     * Retrieve results and return them as an array of Result objects
     * @param $id result id
     * @param $user_id user id (student)
     * @param $evaluation_id evaluation where this is a result for
     */
    public static function load($id = null, $user_id = null, $evaluation_id = null)
    {
        $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
        $tbl_grade_results = Database::get_main_table(TABLE_MAIN_GRADEBOOK_RESULT);
        $tbl_course_rel_course = Database::get_main_table(TABLE_MAIN_COURSE_USER);
        $tbl_session_rel_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
        if (is_null($id) && is_null($user_id) && !is_null($evaluation_id)) {
            $sql_verified_if_exist_evaluation = 'SELECT COUNT(*) AS count FROM ' . $tbl_grade_results . ' WHERE evaluation_id="' . Database::escape_string($evaluation_id) . '";';
            $res_verified_if_exist_evaluation = Database::query($sql_verified_if_exist_evaluation);
            $info_verified_if_exist_evaluation = Database::result($res_verified_if_exist_evaluation, 0, 0);
            if ($info_verified_if_exist_evaluation != 0) {
                $sql_course_rel_user = '';
                if (api_get_session_id()) {
                    $sql_course_rel_user = 'SELECT course_code, id_user as user_id, status
					                        FROM ' . $tbl_session_rel_course_user . '
											WHERE status=0 AND c_id="' . api_get_course_int_id() . '" AND id_session=' . api_get_session_id();
                } else {
                    $sql_course_rel_user = 'SELECT course_code, user_id, status
					                        FROM ' . $tbl_course_rel_course . '
					                        WHERE status ="' . STUDENT . '" AND c_id ="' . api_get_course_int_id() . '" ';
                }
                $res_course_rel_user = Database::query($sql_course_rel_user);
                $list_user_course_list = array();
                while ($row_course_rel_user = Database::fetch_array($res_course_rel_user, 'ASSOC')) {
                    $list_user_course_list[] = $row_course_rel_user;
                }
                $current_date = api_get_utc_datetime();
                for ($i = 0; $i < count($list_user_course_list); $i++) {
                    $sql_verified = 'SELECT COUNT(*) AS count FROM ' . $tbl_grade_results . ' WHERE user_id="' . intval($list_user_course_list[$i]['user_id']) . '" AND evaluation_id="' . intval($evaluation_id) . '";';
                    $res_verified = Database::query($sql_verified);
                    $info_verified = Database::result($res_verified, 0, 0);
                    if ($info_verified == 0) {
                        $sql_insert = 'INSERT INTO ' . $tbl_grade_results . '(user_id,evaluation_id,created_at,score)
									 VALUES ("' . intval($list_user_course_list[$i]['user_id']) . '","' . intval($evaluation_id) . '","' . $current_date . '",0);';
                        $res_insert = Database::query($sql_insert);
                    }
                }
                $list_user_course_list = array();
            }
        }
        $sql = "SELECT gr.id, gr.user_id, gr.evaluation_id, gr.created_at, gr.score \n                FROM {$tbl_grade_results} gr\n                LEFT JOIN {$tbl_user} u ON gr.user_id = u.user_id ";
        $paramcount = 0;
        if (!empty($id)) {
            $sql .= ' WHERE gr.id = ' . Database::escape_string($id);
            $paramcount++;
        }
        if (!empty($user_id)) {
            if ($paramcount != 0) {
                $sql .= ' AND';
            } else {
                $sql .= ' WHERE';
            }
            $sql .= ' user_id = ' . Database::escape_string($user_id);
            $paramcount++;
        }
        if (!empty($evaluation_id)) {
            if ($paramcount != 0) {
                $sql .= ' AND';
            } else {
                $sql .= ' WHERE';
            }
            $sql .= ' evaluation_id = ' . Database::escape_string($evaluation_id);
            $paramcount++;
        }
        $result = Database::query($sql);
        $allres = array();
        while ($data = Database::fetch_array($result)) {
            $res = new Result();
            $res->set_id($data['id']);
            $res->set_user_id($data['user_id']);
            $res->set_evaluation_id($data['evaluation_id']);
            $res->set_date(api_get_local_time($data['created_at']));
            $res->set_score($data['score']);
            $allres[] = $res;
        }
        return $allres;
    }
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:83,代码来源:result.class.php

示例10: get_comments

 /**
  * This function gets the comments of an exercise
  *
  * @param int $exe_id
  * @param int $question_id
  *
  * @return string the comment
  */
 public static function get_comments($exe_id, $question_id)
 {
     $table_track_attempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
     $sql = "SELECT teacher_comment FROM " . $table_track_attempt . "\n                WHERE\n                    exe_id='" . Database::escape_string($exe_id) . "' AND\n                    question_id = '" . Database::escape_string($question_id) . "'\n                ORDER by question_id";
     $sqlres = Database::query($sql);
     $comm = Database::result($sqlres, 0, "teacher_comment");
     return $comm;
 }
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:16,代码来源:events.lib.php

示例11: init_course

 /**
  *
  * @global bool $is_platformAdmin
  * @global bool $is_allowedCreateCourse
  * @global object $_user
  * @global int $_cid
  * @global array $_course
  * @global int $_real_cid
  * @global type $_courseUser
  * @global type $is_courseAdmin
  * @global type $is_courseTutor
  * @global type $is_courseCoach
  * @global type $is_courseMember
  * @global type $is_sessionAdmin
  * @global type $is_allowed_in_course
  *
  * @param type $course_id
  * @param type $reset
  */
 static function init_course($course_id, $reset)
 {
     global $_configuration;
     global $is_platformAdmin;
     global $is_allowedCreateCourse;
     global $_user;
     global $_cid;
     global $_course;
     global $_real_cid;
     global $is_courseAdmin;
     //course teacher
     global $is_courseTutor;
     //course teacher - some rights
     global $is_courseCoach;
     //course coach
     global $is_courseMember;
     //course student
     global $is_sessionAdmin;
     global $is_allowed_in_course;
     if ($reset) {
         // Course session data refresh requested or empty data
         if ($course_id) {
             $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_id}'";
             $result = Database::query($sql);
             if (Database::num_rows($result) > 0) {
                 $course_data = Database::fetch_array($result);
                 //@TODO real_cid should be cid, for working with numeric course id
                 $_real_cid = $course_data['id'];
                 $_cid = $course_data['code'];
                 $_course = array();
                 $_course['real_id'] = $course_data['id'];
                 $_course['id'] = $course_data['code'];
                 //auto-assigned integer
                 $_course['code'] = $course_data['code'];
                 $_course['name'] = $course_data['title'];
                 $_course['title'] = $course_data['title'];
                 $_course['official_code'] = $course_data['visual_code'];
                 // use in echo
                 $_course['sysCode'] = $course_data['code'];
                 // use as key in db
                 $_course['path'] = $course_data['directory'];
                 // use as key in path
                 $_course['titular'] = $course_data['tutor_name'];
                 // this should be deprecated and use the table course_rel_user
                 $_course['language'] = $course_data['course_language'];
                 $_course['extLink']['url'] = $course_data['department_url'];
                 $_course['extLink']['name'] = $course_data['department_name'];
                 $_course['categoryCode'] = $course_data['faCode'];
                 $_course['categoryName'] = $course_data['faName'];
                 $_course['visibility'] = $course_data['visibility'];
                 $_course['subscribe_allowed'] = $course_data['subscribe'];
                 $_course['unsubscribe'] = $course_data['unsubscribe'];
                 $_course['activate_legal'] = $course_data['activate_legal'];
                 $_course['show_score'] = $course_data['show_score'];
                 //used in the work tool
                 Session::write('_cid', $_cid);
                 Session::write('_course', $_course);
                 //@TODO real_cid should be cid, for working with numeric course id
                 Session::write('_real_cid', $_real_cid);
                 // if a session id has been given in url, we store the session
                 // Database Table Definitions
                 $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
                 if (!empty($_GET['id_session'])) {
                     $_SESSION['id_session'] = intval($_GET['id_session']);
                     $sql = 'SELECT name FROM ' . $tbl_session . ' WHERE id="' . intval($_SESSION['id_session']) . '"';
                     $rs = Database::query($sql);
                     list($_SESSION['session_name']) = Database::fetch_array($rs);
                 } else {
                     Session::erase('session_name');
                     Session::erase('id_session');
                 }
                 if (!isset($_SESSION['login_as'])) {
                     //Course login
                     if (isset($_user['user_id'])) {
                         Event::event_course_login(api_get_course_int_id(), $_user['user_id'], api_get_session_id());
                     }
                 }
             } else {
                 //exit("WARNING UNDEFINED CID !! ");
//.........这里部分代码省略.........
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:101,代码来源:login.lib.php

示例12: get_num_subscriptions

 /**
  *  Get number of subscriptions of the user
  *
  *  @return -   int     The amount of itemrights
  */
 function get_num_subscriptions()
 {
     $sql = "SELECT COUNT(*) FROM " . Rsys::getTable("subscription") . " s\n\t\t\t            INNER JOIN " . Rsys::getTable("reservation") . " r ON r.id = s.reservation_id\n\t\t\t            INNER JOIN " . Rsys::getTable("item") . " i ON i.id=r.item_id\n\t\t\t            WHERE s.user_id = '" . api_get_user_id() . "'";
     return @Database::result(Database::query($sql), 0, 0);
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:10,代码来源:rsys.php

示例13: save

 /**
  * updates the question in the data base
  * if an exercise ID is provided, we add that exercise ID into the exercise list
  *
  * @author Olivier Brouckaert
  * @param integer $exerciseId - exercise ID if saving in an exercise
  */
 public function save($exerciseId = 0)
 {
     $TBL_EXERCISE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
     $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
     $id = $this->id;
     $question = $this->question;
     $description = $this->description;
     $weighting = $this->weighting;
     $position = $this->position;
     $type = $this->type;
     $picture = $this->picture;
     $level = $this->level;
     $extra = $this->extra;
     $c_id = $this->course['real_id'];
     $category = $this->category;
     // question already exists
     if (!empty($id)) {
         $params = ['question' => $question, 'description' => $description, 'ponderation' => $weighting, 'position' => $position, 'type' => $type, 'picture' => $picture, 'extra' => $extra, 'level' => $level];
         Database::update($TBL_QUESTIONS, $params, ['c_id = ? AND id = ?' => [$c_id, $id]]);
         $this->saveCategory($category);
         if (!empty($exerciseId)) {
             api_item_property_update($this->course, TOOL_QUIZ, $id, 'QuizQuestionUpdated', api_get_user_id());
         }
         if (api_get_setting('search.search_enabled') == 'true') {
             if ($exerciseId != 0) {
                 $this->search_engine_edit($exerciseId);
             } else {
                 /**
                  * actually there is *not* an user interface for
                  * creating questions without a relation with an exercise
                  */
             }
         }
     } else {
         // creates a new question
         $sql = "SELECT max(position)\n                    FROM {$TBL_QUESTIONS} as question,\n                    {$TBL_EXERCISE_QUESTION} as test_question\n                    WHERE\n                        question.id = test_question.question_id AND\n                        test_question.exercice_id = " . intval($exerciseId) . " AND\n                        question.c_id = {$c_id} AND\n                        test_question.c_id = {$c_id} ";
         $result = Database::query($sql);
         $current_position = Database::result($result, 0, 0);
         $this->updatePosition($current_position + 1);
         $position = $this->position;
         $params = ['c_id' => $c_id, 'question' => $question, 'description' => $description, 'ponderation' => $weighting, 'position' => $position, 'type' => $type, 'picture' => $picture, 'extra' => $extra, 'level' => $level];
         $this->id = Database::insert($TBL_QUESTIONS, $params);
         if ($this->id) {
             $sql = "UPDATE {$TBL_QUESTIONS} SET id = iid WHERE iid = {$this->id}";
             Database::query($sql);
             api_item_property_update($this->course, TOOL_QUIZ, $this->id, 'QuizQuestionAdded', api_get_user_id());
             // If hotspot, create first answer
             if ($type == HOT_SPOT || $type == HOT_SPOT_ORDER) {
                 $TBL_ANSWERS = Database::get_course_table(TABLE_QUIZ_ANSWER);
                 $params = ['c_id' => $c_id, 'question_id' => $this->id, 'answer' => '', 'correct' => '', 'comment' => '', 'ponderation' => 10, 'position' => 1, 'hotspot_coordinates' => '0;0|0|0', 'hotspot_type' => 'square'];
                 $id = Database::insert($TBL_ANSWERS, $params);
                 if ($id) {
                     $sql = "UPDATE {$TBL_ANSWERS} SET id = iid, id_auto = iid WHERE iid = {$id}";
                     Database::query($sql);
                 }
             }
             if ($type == HOT_SPOT_DELINEATION) {
                 $TBL_ANSWERS = Database::get_course_table(TABLE_QUIZ_ANSWER);
                 $params = ['c_id' => $c_id, 'question_id' => $this->id, 'answer' => '', 'correct' => '', 'comment' => '', 'ponderation' => 10, 'position' => 1, 'hotspot_coordinates' => '0;0|0|0', 'hotspot_type' => 'delineation'];
                 $id = Database::insert($TBL_ANSWERS, $params);
                 if ($id) {
                     $sql = "UPDATE {$TBL_ANSWERS} SET id = iid, id_auto = iid WHERE iid = {$id}";
                     Database::query($sql);
                 }
             }
             if (api_get_setting('search.search_enabled') == 'true') {
                 if ($exerciseId != 0) {
                     $this->search_engine_edit($exerciseId, true);
                 } else {
                     /**
                      * actually there is *not* an user interface for
                      * creating questions without a relation with an exercise
                      */
                 }
             }
         }
     }
     // if the question is created in an exercise
     if ($exerciseId) {
         // adds the exercise into the exercise list of this question
         $this->addToList($exerciseId, TRUE);
     }
 }
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:90,代码来源:question.class.php

示例14: get_lang

if (api_is_western_name_order(PERSON_NAME_DATA_EXPORT)) {
    $header[] = get_lang('FirstName', '');
    $header[] = get_lang('LastName', '');
} else {
    $header[] = get_lang('LastName', '');
    $header[] = get_lang('FirstName', '');
}
$header[] = get_lang('ConnectionTime', '');
if (Database::num_rows($result_coachs) > 0) {
    while ($coachs = Database::fetch_array($result_coachs)) {
        $id_coach = $coachs["id_coach"];
        if (isset($_GET["id_student"])) {
            $sql_infos_coach = "SELECT lastname, firstname FROM {$tbl_user} WHERE user_id='{$id_coach}'";
            $result_coachs_infos = Database::query($sql_infos_coach);
            $lastname = Database::result($result_coachs_infos, 0, "lastname");
            $firstname = Database::result($result_coachs_infos, 0, "firstname");
        } else {
            $lastname = $coachs["lastname"];
            $firstname = $coachs["firstname"];
        }
        $sql_connection_time = "SELECT login_date, logout_date FROM {$tbl_track_login} WHERE login_user_id ='{$id_coach}' AND logout_date <> 'null'";
        $result_connection_time = Database::query($sql_connection_time);
        $nb_seconds = 0;
        while ($connections = Database::fetch_array($result_connection_time)) {
            $login_date = $connections["login_date"];
            $logout_date = $connections["logout_date"];
            $timestamp_login_date = strtotime($login_date);
            $timestamp_logout_date = strtotime($logout_date);
            $nb_seconds += $timestamp_logout_date - $timestamp_login_date;
        }
        if ($nb_seconds == 0) {
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:31,代码来源:coaches.php

示例15: write_to_db


//.........这里部分代码省略.........
                                    $my_status = " status = '" . $this->get_status(false) . "' ,";
                                } elseif (in_array($row_verified['status'], $case_completed) && $my_type_lp == 2 && $this->type != 'sco') {
                                    //&& $this->type!='dir'
                                    $total_time = " total_time = total_time +" . $this->get_total_time() . ", ";
                                    $my_status = " status = '" . $this->get_status(false) . "' ,";
                                } else {
                                    //&& !in_array($row_verified['status'], $case_completed)
                                    //is lp dokeos
                                    if ($my_type_lp == 1 && $this->type != 'chapter') {
                                        $total_time = " total_time = total_time + " . $this->get_total_time() . ", ";
                                        $my_status = " status = '" . $this->get_status(false) . "' ,";
                                    }
                                }
                            }
                        } else {
                            // Multiple attempts are allowed.
                            if (in_array($this->get_status(false), $case_completed) && $my_type_lp == 2) {
                                // Reset zero new attempt ?
                                $my_status = " status = '" . $this->get_status(false) . "' ,";
                            } elseif (!in_array($this->get_status(false), $case_completed) && $my_type_lp == 2) {
                                $total_time = " total_time = " . $this->get_total_time() . ", ";
                                $my_status = " status = '" . $this->get_status(false) . "' ,";
                            } else {
                                // It is dokeos LP.
                                $total_time = " total_time = total_time +" . $this->get_total_time() . ", ";
                                $my_status = " status = '" . $this->get_status(false) . "' ,";
                            }
                            // Code added by Isaac Flores.
                            // This code line fixes the problem of wrong status.
                            if ($my_type_lp == 2) {
                                // Verify current status in multiples attempts.
                                $sql_status = 'SELECT status FROM ' . $item_view_table . '
                                               WHERE c_id = ' . $course_id . ' AND lp_item_id="' . $this->db_id . '" AND lp_view_id="' . $this->view_id . '" AND view_count="' . $this->get_attempt_id() . '" ';
                                $rs_status = Database::query($sql_status);
                                $current_status = Database::result($rs_status, 0, 'status');
                                if (in_array($current_status, $case_completed)) {
                                    $my_status = '';
                                    $total_time = '';
                                } else {
                                    $total_time = " total_time = total_time +" . $this->get_total_time() . ", ";
                                }
                            }
                        }
                    }
                    if ($this->type == 'sco') {
                        //IF scorm scorm_update_time has already updated total_tim in db
                        $sql = "UPDATE {$item_view_table} " . " SET " . " score = " . $this->get_score() . ", " . $my_status . " max_score = '" . $this->get_max() . "'," . " suspend_data = '" . Database::escape_string($this->current_data) . "'," . " lesson_location = '" . $this->lesson_location . "' " . "WHERE c_id = {$course_id} AND lp_item_id = " . $this->db_id . " " . "AND lp_view_id = " . $this->view_id . " " . "AND view_count = " . $this->get_attempt_id();
                    } else {
                        $sql = "UPDATE {$item_view_table} " . "SET " . $total_time . " start_time = " . $this->get_current_start_time() . ", " . " score = " . $this->get_score() . ", " . $my_status . " max_score = '" . $this->get_max() . "'," . " suspend_data = '" . Database::escape_string($this->current_data) . "'," . " lesson_location = '" . $this->lesson_location . "' " . "WHERE c_id = {$course_id} AND lp_item_id = " . $this->db_id . " " . "AND lp_view_id = " . $this->view_id . " " . "AND view_count = " . $this->get_attempt_id();
                    }
                    $this->current_start_time = time();
                }
                if (self::debug > 2) {
                    error_log('learnpathItem::write_to_db() - Updating item_view: ' . $sql, 0);
                }
                $res = Database::query($sql);
            }
            if (is_array($this->interactions) && count($this->interactions) > 0) {
                // Save interactions.
                $tbl = Database::get_course_table(TABLE_LP_ITEM_VIEW);
                $sql = "SELECT id FROM {$tbl} " . "WHERE c_id = {$course_id} AND lp_item_id = " . $this->db_id . " " . "AND   lp_view_id = " . $this->view_id . " " . "AND   view_count = " . $this->get_attempt_id();
                $res = Database::query($sql);
                if (Database::num_rows($res) > 0) {
                    $row = Database::fetch_array($res);
                    $lp_iv_id = $row[0];
                    if (self::debug > 2) {
                        error_log('learnpathItem::write_to_db() - Got item_view_id ' . $lp_iv_id . ', now checking interactions ', 0);
                    }
                    foreach ($this->interactions as $index => $interaction) {
                        $correct_resp = '';
                        if (is_array($interaction[4]) && !empty($interaction[4][0])) {
                            foreach ($interaction[4] as $resp) {
                                $correct_resp .= $resp . ',';
                            }
                            $correct_resp = substr($correct_resp, 0, strlen($correct_resp) - 1);
                        }
                        $iva_table = Database::get_course_table(TABLE_LP_IV_INTERACTION);
                        $iva_sql = "SELECT id FROM {$iva_table} " . "WHERE c_id = {$course_id} AND lp_iv_id = {$lp_iv_id} " . "AND (order_id = {$index} " . "OR interaction_id = '" . Database::escape_string($interaction[0]) . "')";
                        $iva_res = Database::query($iva_sql);
                        // id(0), type(1), time(2), weighting(3), correct_responses(4), student_response(5), result(6), latency(7)
                        if (Database::num_rows($iva_res) > 0) {
                            // Update (or don't).
                            $iva_row = Database::fetch_array($iva_res);
                            $iva_id = $iva_row[0];
                            $ivau_sql = "UPDATE {$iva_table} " . "SET interaction_id = '" . Database::escape_string($interaction[0]) . "'," . "interaction_type = '" . Database::escape_string($interaction[1]) . "'," . "weighting = '" . Database::escape_string($interaction[3]) . "'," . "completion_time = '" . Database::escape_string($interaction[2]) . "'," . "correct_responses = '" . Database::escape_string($correct_resp) . "'," . "student_response = '" . Database::escape_string($interaction[5]) . "'," . "result = '" . Database::escape_string($interaction[6]) . "'," . "latency = '" . Database::escape_string($interaction[7]) . "'" . "WHERE c_id = {$course_id} AND id = {$iva_id}";
                            Database::query($ivau_sql);
                        } else {
                            // Insert new one.
                            $ivai_sql = "INSERT INTO {$iva_table} (c_id, order_id, lp_iv_id, interaction_id, interaction_type, " . "weighting, completion_time, correct_responses, " . "student_response, result, latency)" . "VALUES" . "({$course_id}, " . $index . "," . $lp_iv_id . ",'" . Database::escape_string($interaction[0]) . "','" . Database::escape_string($interaction[1]) . "'," . "'" . Database::escape_string($interaction[3]) . "','" . Database::escape_string($interaction[2]) . "','" . Database::escape_string($correct_resp) . "'," . "'" . Database::escape_string($interaction[5]) . "','" . Database::escape_string($interaction[6]) . "','" . Database::escape_string($interaction[7]) . "'" . ")";
                            Database::query($ivai_sql);
                        }
                    }
                }
            }
        }
        if (self::debug > 2) {
            error_log('End of learnpathItem::write_to_db()', 0);
        }
        return true;
    }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:101,代码来源:learnpathItem.class.php


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