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


PHP AMA_DataHandler::get_tutors_assigned_course_instance方法代码示例

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


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

示例1: parameter_controlFN


//.........这里部分代码省略.........
    /**
     * If in a valid NON PUBLIC course and user is student or tutor
     * and
     *  $_SESSION['sess_id_course'] (that is the course_id the user is going into)
     * 	IS NOT EQUAL TO
     *  $sess_id_course (that is the course_id the user is coming form)
     *  
     *  The user has clicked a cross course link, and is handled by unsetting the
     *  $_SESSION['sess_id_course_instance'] and looking for a course instance
     *  to which the user is subscribed.
     *  
     */
    if ($invalid_course === FALSE && $invalid_node === FALSE && isset($sess_courseObj) && !$sess_courseObj->getIsPublic() && in_array($sess_userObj->getType(), array(AMA_TYPE_STUDENT, AMA_TYPE_TUTOR)) && is_numeric($sess_id_course) && intval($_SESSION['sess_id_course']) !== intval($sess_id_course)) {
        /**
         * unset sess_id_course_instance
         */
        unset($_SESSION['sess_id_course_instance']);
        /**
         * Try to find an instance of target course where used is subscribed
         */
        $getAll = true;
        /**
         * Need to get instance the user is allowed to browse, based on user type
         */
        switch ($sess_userObj->getType()) {
            case AMA_TYPE_STUDENT:
                $instances = $dh->get_course_instance_for_this_student_and_course_model($sess_userObj->getId(), $_SESSION['sess_id_course'], $getAll);
                break;
            case AMA_TYPE_TUTOR:
                $instances = $dh->get_course_instance_for_this_student_and_course_model($sess_userObj->getId(), $_SESSION['sess_id_course'], $getAll);
                if (AMA_DB::isError($instances) || !is_array($instances) || count($instances) <= 0) {
                    $instances = array();
                }
                $tutorInstances = $dh->get_tutors_assigned_course_instance($sess_userObj->getId(), $_SESSION['sess_id_course'], $sess_userObj->isSuper());
                if (!AMA_DB::isError($tutorInstances) && is_array($tutorInstances) && count($tutorInstances) > 0) {
                    /**
                     * the returned array is array[id_tutor]=>array[key]=>array['id_istanza_corso']
                     * and needs to be converted to reflect the structre returned in student case
                     */
                    foreach ($tutorInstances[$sess_userObj->getId()] as $tutorInstance) {
                        $instances[]['id_istanza_corso'] = $tutorInstance['id_istanza_corso'];
                    }
                }
                break;
        }
        if (!AMA_DB::isError($instances) && count($instances) > 0) {
            if (count($instances) == 1) {
                /**
                 * User is subscribed to one instance only, good!
                 * Set the $target_course_instance var and proceed
                 */
                $target_course_instance = $instances[0]['id_istanza_corso'];
            } else {
                if (count($instances) > 1 && !isset($_REQUEST['id_course_instance'])) {
                    /**
                     * If there's more than one instance, must build an array of
                     * found instances to ask the user to select one.
                     * 
                     * This array is returned in the 'course' key of the returned
                     * array and so $invalid_course must be populated accordingly.
                     * 
                     * The node that was requested is returned in the 'node' key of
                     * the returned array and so $invalid_node must be populated. 
                     */
                    foreach ($instances as $instance) {
                        $invalid_course[] = $instance['id_istanza_corso'];
开发者ID:eguicciardi,项目名称:ada,代码行数:67,代码来源:module_init_functions.inc.php


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