function Report_User($id_report, $report_name = false)
 {
     parent::Report($id_report, $report_name);
     $this->lang =& DoceboLanguage::createInstance('report', 'framework');
     $this->usestandardtitle_rows = false;
     $this->_set_columns_category(_RU_CATEGORY_COURSES, $this->lang->def('_RU_CAT_COURSES'), 'get_courses_filter', 'show_report_courses', '_get_courses_query');
     //$this->_set_columns_category(_RU_CATEGORY_GENERAL, $this->lang->def('_RU_CAT_GENERAL'), 'get_general_filter', 'show_report_general');
     //$this->_set_columns_category(_RU_CATEGORY_COMPETENCES, $this->lang->def('_RU_CAT_COMPETENCES'), 'get_competences_filter', 'show_report_competences', '_get_competences_query');
     $this->_set_columns_category(_RU_CATEGORY_DELAY, $this->lang->def('_RU_CAT_DELAY'), 'get_delay_filter', 'show_report_delay', '_get_delay_query');
     $this->_set_columns_category(_RU_CATEGORY_LO, $this->lang->def('_RU_CAT_LO'), 'get_LO_filter', 'show_report_LO', '_get_LO_query');
     $this->_set_columns_category(_RU_CATEGORY_COMMUNICATIONS, $this->lang->def('_RU_CAT_COMMUNICATIONS'), 'get_communications_filter', 'show_report_communications', '_get_communications_query');
     $this->_set_columns_category(_RU_CATEGORY_GAMES, $this->lang->def('_RU_CAT_GAMES'), 'get_games_filter', 'show_report_games', '_get_games_query');
     $this->status_c = array(CST_PREPARATION => Lang::t('_CST_PREPARATION', 'course'), CST_AVAILABLE => Lang::t('_CST_AVAILABLE', 'course'), CST_EFFECTIVE => Lang::t('_CST_CONFIRMED', 'course'), CST_CONCLUDED => Lang::t('_CST_CONCLUDED', 'course'), CST_CANCELLED => Lang::t('_CST_CANCELLED', 'course'));
     $csub = new CourseSubscribe_Manager();
     $this->status_u = $csub->getUserStatus();
     $this->courses_filter_definition = array(array('key' => _COURSES_FILTER_SESSION_NUMBER, 'label' => $this->lang->def('_COURSES_FILTER_SESSION_NUMBER'), 'type' => _FILTER_INTEGER), array('key' => _COURSES_FILTER_SCORE_INIT, 'label' => $this->lang->def('_COURSES_FILTER_SCORE_INIT'), 'type' => _FILTER_INTEGER), array('key' => _COURSES_FILTER_SCORE_END, 'label' => $this->lang->def('_FINAL_SCORE'), 'type' => _FILTER_INTEGER), array('key' => _COURSES_FILTER_SCORE_COURSE, 'label' => $this->lang->def('_COURSES_FILTER_SCORE_COURSE'), 'type' => _FILTER_INTEGER), array('key' => _COURSES_FILTER_INSCRIPTION_DATE, 'label' => $this->lang->def('_COURSES_FILTER_INSCRIPTION_DATE'), 'type' => _FILTER_DATE), array('key' => _COURSES_FILTER_FIRSTACCESS_DATE, 'label' => $this->lang->def('_DATE_FIRST_ACCESS'), 'type' => _FILTER_DATE), array('key' => _COURSES_FILTER_END_DATE, 'label' => $this->lang->def('_COURSES_FILTER_END_DATE'), 'type' => _FILTER_DATE), array('key' => _COURSES_FILTER_LASTACCESS_DATE, 'label' => $this->lang->def('_DATE_LAST_ACCESS'), 'type' => _FILTER_DATE));
     $this->LO_columns = array(array('key' => 'userid', 'select' => false, 'group' => 'user', 'label' => Lang::t('_USERID', 'standard')), array('key' => 'user_name', 'select' => true, 'group' => 'user', 'label' => Lang::t('_FULLNAME', 'standard')), array('key' => 'email', 'select' => true, 'group' => 'user', 'label' => Lang::t('_EMAIL', 'standard')), array('key' => 'suspended', 'select' => true, 'group' => 'user', 'label' => Lang::t('_SUSPENDED', 'standard')), array('key' => '_CUSTOM_FIELDS_', 'select' => false, 'group' => 'user', 'label' => false), array('key' => 'course_code', 'select' => false, 'group' => 'course', 'label' => $this->lang->def('_CODE')), array('key' => 'course_name', 'select' => true, 'group' => 'course', 'label' => $this->lang->def('_COURSE_NAME')), array('key' => 'course_status', 'select' => true, 'group' => 'course', 'label' => $this->lang->def('_STATUS')), array('key' => 'lo_type', 'select' => true, 'group' => 'lo', 'label' => $this->lang->def('_LO_COL_TYPE')), array('key' => 'lo_name', 'select' => true, 'group' => 'lo', 'label' => $this->lang->def('_TITLE')), array('key' => 'lo_milestone', 'select' => true, 'group' => 'lo', 'label' => $this->lang->def('_LO_COL_MILESTONE')), array('key' => 'firstAttempt', 'select' => true, 'group' => 'lo', 'label' => $this->lang->def('_LO_COL_FIRSTATT')), array('key' => 'lastAttempt', 'select' => true, 'group' => 'lo', 'label' => $this->lang->def('_LO_COL_LASTATT')), array('key' => 'lo_status', 'select' => true, 'group' => 'lo', 'label' => $this->lang->def('_STATUS')), array('key' => 'lo_score', 'select' => true, 'group' => 'lo', 'label' => $this->lang->def('_SCORE')));
     $this->delay_columns = array(array('key' => 'userid', 'label' => Lang::t('_USERNAME', 'standard'), 'select' => false), array('key' => 'lastname', 'label' => Lang::t('_LASTNAME', 'standard'), 'select' => true), array('key' => 'firstname', 'label' => Lang::t('_FIRSTNAME', 'standard'), 'select' => true), array('key' => 'email', 'label' => Lang::t('_EMAIL', 'standard'), 'select' => true), array('key' => 'level', 'label' => Lang::t('_LEVEL', 'standard'), 'select' => true), array('key' => 'status', 'label' => Lang::t('_STATUS', 'standard'), 'select' => true), array('key' => 'date_subscription', 'label' => Lang::t('_DATE_INSCR', 'report'), 'select' => true), array('key' => 'date_first_access', 'label' => Lang::t('_DATE_FIRST_ACCESS', 'standard'), 'select' => true), array('key' => 'date_last_access', 'label' => Lang::t('_DATE_LAST_ACCESS', 'standard'), 'select' => true), array('key' => 'date_complete', 'label' => Lang::t('_DATE_END', 'standard'), 'select' => true));
 }
Example #2
0
 public function delUserFromEdition($id_user, $id_course, $id_edition)
 {
     $level = $this->subscribe_man->getUserLeveInCourse($id_user, $id_course);
     $this->removeUserFromEdition($id_user, $id_edition, $id_course);
     if (!$this->controlUserSubscriptions($id_user, $id_course)) {
         require_once _lms_ . '/lib/lib.subscribe.php';
         require_once _lms_ . '/lib/lib.course.php';
         $subscribe_man = new CourseSubscribe_Manager();
         $subscribe_man->delUserFromCourse($id_user, $id_course);
         $docebo_course = new DoceboCourse($id_course);
         $level_idst =& $docebo_course->getCourseLevel($id_course);
         $this->acl_man->removeFromGroup($level_idst[$level], $id_user);
     }
     return true;
 }
Example #3
0
function duplicateCourse()
{
    $id_dupcourse = Get::req('id_course', DOTY_INT, 0);
    // read the old course info
    $query_sel = "SELECT *\n\tFROM " . $GLOBALS['prefix_lms'] . "_course\n\tWHERE idCourse = '" . $id_dupcourse . "' ";
    $result_sel = sql_query($query_sel);
    $list_sel = sql_fetch_array($result_sel);
    foreach ($list_sel as $k => $v) {
        $list_sel[$k] = mysql_escape_string($v);
    }
    $new_course_dup = 0;
    $new_file_array = array();
    if ($list_sel['imgSponsor'] !== '') {
        $new_name_array = explode('_', str_replace('course_sponsor_logo_', '', $list_sel['imgSponsor']));
        $filename = 'course_sponsor_logo_' . mt_rand(0, 100) . '_' . time() . '_' . str_replace('course_sponsor_logo_' . $new_name_array[0] . '_' . $new_name_array[1] . '_', '', $list_sel['imgSponsor']);
        $new_file_array[0]['old'] = $list_sel['imgSponsor'];
        $new_file_array[0]['new'] = $filename;
        $list_sel['imgSponsor'] = $filename;
    }
    if ($list_sel['img_course'] !== '') {
        $new_name_array = explode('_', str_replace('course_logo_', '', $list_sel['img_course']));
        $filename = 'course_logo_' . mt_rand(0, 100) . '_' . time() . '_' . str_replace('course_logo_' . $new_name_array[0] . '_' . $new_name_array[1] . '_', '', $list_sel['img_course']);
        $new_file_array[1]['old'] = $list_sel['img_course'];
        $new_file_array[1]['new'] = $filename;
        $list_sel['img_course'] = $filename;
    }
    if ($list_sel['img_material'] !== '') {
        $new_name_array = explode('_', str_replace('course_user_material_', '', $list_sel['img_material']));
        $filename = 'course_user_material_' . mt_rand(0, 100) . '_' . time() . '_' . str_replace('course_user_material_' . $new_name_array[0] . '_' . $new_name_array[1] . '_', '', $list_sel['img_material']);
        $new_file_array[2]['old'] = $list_sel['img_material'];
        $new_file_array[2]['new'] = $filename;
        $list_sel['img_material'] = $filename;
    }
    if ($list_sel['img_othermaterial'] !== '') {
        $new_name_array = explode('_', str_replace('course_otheruser_material_', '', $list_sel['img_othermaterial']));
        $filename = 'course_otheruser_material_' . mt_rand(0, 100) . '_' . time() . '_' . str_replace('course_otheruser_material_' . $new_name_array[0] . '_' . $new_name_array[1] . '_', '', $list_sel['img_othermaterial']);
        $new_file_array[3]['old'] = $list_sel['img_othermaterial'];
        $new_file_array[3]['new'] = $filename;
        $list_sel['img_othermaterial'] = $filename;
    }
    if ($list_sel['course_demo'] !== '') {
        $new_name_array = explode('_', str_replace('course_demo_', '', $list_sel['course_demo']));
        $filename = 'course_demo_' . mt_rand(0, 100) . '_' . time() . '_' . str_replace('course_demo_' . $new_name_array[0] . '_' . $new_name_array[1] . '_', '', $list_sel['course_demo']);
        $new_file_array[4]['old'] = $list_sel['course_demo'];
        $new_file_array[4]['new'] = $filename;
        $list_sel['course_demo'] = $filename;
    }
    // duplicate the entry of learning_course
    $query_ins = "INSERT INTO " . $GLOBALS['prefix_lms'] . "_course\n\t\t( idCategory, code, name, description, lang_code, status, level_show_user,\n\t\tsubscribe_method, linkSponsor, imgSponsor, img_course, img_material, img_othermaterial,\n\t\tcourse_demo, mediumTime, permCloseLO, userStatusOp, difficult, show_progress, show_time, show_extra_info,\n\t\tshow_rules, valid_time, max_num_subscribe, min_num_subscribe,\n\t\tmax_sms_budget, selling, prize, course_type, policy_point, point_to_all, course_edition, classrooms, certificates,\n\t\tcreate_date, security_code, imported_from_connection, course_quota, used_space, course_vote, allow_overbooking, can_subscribe,\n\t\tsub_start_date, sub_end_date, advance, show_who_online, direct_play, autoregistration_code, use_logo_in_courselist )\n\tVALUES\n\t\t( '" . $list_sel['idCategory'] . "', '" . $list_sel['code'] . "', '" . "Copia di " . $list_sel['name'] . "', '" . $list_sel['description'] . "', '" . $list_sel['lang_code'] . "', '" . $list_sel['status'] . "', '" . $list_sel['level_show_user'] . "',\n\t\t'" . $list_sel['subscribe_method'] . "', '" . $list_sel['linkSponsor'] . "', '" . $list_sel['imgSponsor'] . "', '" . $list_sel['img_course'] . "', '" . $list_sel['img_material'] . "', '" . $list_sel['img_othermaterial'] . "',\n\t\t'" . $list_sel['course_demo'] . "', '" . $list_sel['mediumTime'] . "', '" . $list_sel['permCloseLO'] . "', '" . $list_sel['userStatusOp'] . "', '" . $list_sel['difficult'] . "', '" . $list_sel['show_progress'] . "', '" . $list_sel['show_time'] . "', '" . $list_sel['show_extra_info'] . "',\n\t\t'" . $list_sel['show_rules'] . "', '" . $list_sel['valid_time'] . "', '" . $list_sel['max_num_subscribe'] . "', '" . $list_sel['min_num_subscribe'] . "',\n\t\t'" . $list_sel['max_sms_budget'] . "', '" . $list_sel['selling'] . "', '" . $list_sel['prize'] . "', '" . $list_sel['course_type'] . "', '" . $list_sel['policy_point'] . "', '" . $list_sel['point_to_all'] . "', '" . $list_sel['course_edition'] . "', '" . $list_sel['classrooms'] . "', '" . $list_sel['certificates'] . "',\n\t\t'" . $list_sel['create_date'] . "', '" . $list_sel['security_code'] . "', '" . $list_sel['imported_from_connection'] . "', '" . $list_sel['course_quota'] . "', '" . $list_sel['used_space'] . "', '" . $list_sel['course_vote'] . "', '" . $list_sel['allow_overbooking'] . "', '" . $list_sel['can_subscribe'] . "',\n\t\t'" . $list_sel['sub_start_date'] . "', '" . $list_sel['sub_end_date'] . "', '" . $list_sel['advance'] . "', '" . $list_sel['show_who_online'] . "', '" . $list_sel['direct_play'] . "', '" . $list_sel['autoregistration_code'] . "', '" . $list_sel['use_logo_in_courselist'] . "' )";
    $result_ins = sql_query($query_ins);
    if (!$result_ins) {
        //Util::jump_to('index.php?modname=course&op=course_list&result=err_course');
        return false;
    }
    // the id of the new course created
    $new_course_dup = sql_insert_id();
    //Create the new course file
    $path = Get::sett('pathcourse');
    $path = '/appLms/' . Get::sett('pathcourse') . (substr($path, -1) != '/' && substr($path, -1) != '\\' ? '/' : '');
    require_once _base_ . '/lib/lib.upload.php';
    sl_open_fileoperations();
    foreach ($new_file_array as $file_info) {
        sl_copy($path . $file_info['old'], $path . $file_info['new']);
    }
    sl_close_fileoperations();
    // copy the old course menu into the new one
    $query_selmen = "SELECT *\n\tFROM " . $GLOBALS['prefix_lms'] . "_menucourse_main\n\tWHERE idCourse = '" . $id_dupcourse . "' ";
    $result_selmen = sql_query($query_selmen);
    while ($list_selmen = sql_fetch_array($result_selmen)) {
        $query_dupmen = "INSERT INTO " . $GLOBALS['prefix_lms'] . "_menucourse_main " . " (idCourse, sequence, name, image) " . " VALUES " . " ( '" . $new_course_dup . "', '" . $list_selmen['sequence'] . "', '" . $list_selmen['name'] . "', '" . $list_selmen['image'] . "' )";
        $result_dupmen = sql_query($query_dupmen);
        $array_seq[$list_selmen['idMain']] = sql_insert_id();
    }
    $query_selmenun = "SELECT *\n\tFROM " . $GLOBALS['prefix_lms'] . "_menucourse_under\n\tWHERE idCourse = '" . $id_dupcourse . "' ";
    $result_selmenun = sql_query($query_selmenun);
    while ($list_selmenun = sql_fetch_array($result_selmenun)) {
        $valore_idn = $list_selmenun['idMain'];
        $_idMain = $array_seq[$valore_idn];
        $query_dupmen = "INSERT INTO " . $GLOBALS['prefix_lms'] . "_menucourse_under\n\t\t(idMain, idCourse, sequence, idModule, my_name)\n\t\tVALUES\n\t\t('" . $_idMain . "', '" . $new_course_dup . "', '" . $list_selmenun['sequence'] . "', '" . $list_selmenun['idModule'] . "', '" . $list_selmenun['my_name'] . "')";
        $result_dupmen = sql_query($query_dupmen);
    }
    function &getCourseLevelSt($id_course)
    {
        $map = array();
        $levels = CourseLevel::getLevels();
        $acl_man =& $GLOBALS['current_user']->getAclManager();
        // find all the group created for this menu custom for permission management
        foreach ($levels as $lv => $name_level) {
            $group_info = $acl_man->getGroup(FALSE, '/lms/course/' . $id_course . '/subscribed/' . $lv);
            $map[$lv] = $group_info[ACL_INFO_IDST];
        }
        return $map;
    }
    function funAccess($functionname, $mode, $returnValue = false, $custom_mod_name = false)
    {
        return true;
    }
    require_once $GLOBALS['where_lms'] . '/lib/lib.course.php';
    require_once $GLOBALS['where_lms'] . '/lib/lib.manmenu.php';
    require_once $GLOBALS['where_lms'] . '/lib/lib.subscribe.php';
    $docebo_course = new DoceboCourse($id_dupcourse);
    $subscribe_man = new CourseSubscribe_Manager();
    $group_idst =& $docebo_course->createCourseLevel($new_course_dup);
    $group_of_from =& $docebo_course->getCourseLevel($id_dupcourse);
    $perm_form =& createPermForCoursebis($group_of_from, $new_course_dup, $id_dupcourse);
    $levels = $subscribe_man->getUserLevel();
    foreach ($levels as $lv => $name_level) {
        foreach ($perm_form[$lv] as $idrole => $v) {
            if ($group_idst[$lv] != 0 && $idrole != 0) {
                $acl_man =& $GLOBALS['current_user']->getAclManager();
                $acl_man->addToRole($idrole, $group_idst[$lv]);
            }
        }
    }
    // duplicate the certificate assigned
    $query_selmenun = "SELECT *\n\tFROM " . $GLOBALS['prefix_lms'] . "_certificate_course\n\tWHERE id_course = '" . $id_dupcourse . "' ";
    $result_selmenun = sql_query($query_selmenun);
    while ($list_selmenun = sql_fetch_array($result_selmenun)) {
        $query_dupmen = "INSERT INTO " . $GLOBALS['prefix_lms'] . "_certificate_course\n\t\t\t(id_certificate, id_course, available_for_status)\n\t\t\tVALUES\n\t\t\t('" . $list_selmenun['id_certificate'] . "', '" . $new_course_dup . "', '" . $list_selmenun['available_for_status'] . "' )";
        $result_dupmen = sql_query($query_dupmen);
    }
    require_once $GLOBALS['where_lms'] . '/modules/organization/orglib.php';
    require_once $GLOBALS['where_lms'] . '/lib/lib.param.php';
    require_once $GLOBALS['where_lms'] . '/class.module/track.object.php';
    require_once $GLOBALS['where_lms'] . '/class.module/learning.object.php';
    function createLO($objectType, $idResource = NULL)
    {
        $query = "SELECT className, fileName FROM " . $GLOBALS['prefix_lms'] . "_lo_types WHERE objectType='" . $objectType . "'";
        $rs = sql_query($query);
        list($className, $fileName) = sql_fetch_row($rs);
        require_once $GLOBALS['where_lms'] . '/class.module/' . $fileName;
        $lo = new $className($idResource);
        return $lo;
    }
    $nullVal = NULL;
    $array_cor = array();
    $map_org = array();
    $tree_course = new OrgDirDb($id_dupcourse);
    $coll = $tree_course->getFoldersCollection($nullVal);
    while ($folder = $coll->getNext()) {
        //if($folder->otherValues[REPOFIELDIDRESOURCE] != 0 ) {
        if (!empty($folder->otherValues[REPOFIELDOBJECTTYPE])) {
            $lo = createLO($folder->otherValues[REPOFIELDOBJECTTYPE]);
            $id_nuovo_lo = $lo->copy($folder->otherValues[REPOFIELDIDRESOURCE]);
            $id_vecchio = $folder->otherValues[REPOFIELDIDRESOURCE];
            $query_selmenun = "SELECT * FROM\n\t\t\t" . $GLOBALS['prefix_lms'] . "_organization\n\t\t\tWHERE idCourse = '" . $id_dupcourse . "'\n\t\t\tAND idResource = '" . $id_vecchio . "' ";
            $result_selmenun = sql_query($query_selmenun);
            while ($list_selmenun = mysql_fetch_array($result_selmenun)) {
                $query_dupmen = "INSERT INTO " . $GLOBALS['prefix_lms'] . "_organization\n\t\t\t\t(idParent, path, lev, title,\n\t\t\t\tobjectType, idResource, idCategory, idUser, idAuthor,\n\t\t\t\tversion, difficult, description, language, resource,\n\t\t\t\tobjective, dateInsert, idCourse, prerequisites, isTerminator,\n\t\t\t\tidParam, visible, milestone)\n\t\t\t\tVALUES\n\t\t\t\t('" . (isset($map_org[$list_selmenun['idParent']]) ? $map_org[$list_selmenun['idParent']] : 0) . "', '" . $list_selmenun['path'] . "', '" . $list_selmenun['lev'] . "', '" . $list_selmenun['title'] . "',\n\t\t\t\t'" . $list_selmenun['objectType'] . "', '" . $id_nuovo_lo . "', '" . $list_selmenun['idCategory'] . "', '" . $list_selmenun['idUser'] . "', '" . $list_selmenun['idAuthor'] . "',\n\t\t\t\t'" . $list_selmenun['version'] . "', '" . $list_selmenun['difficult'] . "', '" . $list_selmenun['description'] . "', '" . $list_selmenun['language'] . "', '" . $list_selmenun['resource'] . "',\n\t\t\t\t'" . $list_selmenun['objective'] . "', '" . $list_selmenun['dateInsert'] . "', '" . $new_course_dup . "', '" . $list_selmenun['prerequisites'] . "', '" . $list_selmenun['isTerminator'] . "',\n\t\t\t\t'" . $list_selmenun['idParam'] . "', '" . $list_selmenun['visible'] . "', '" . $list_selmenun['milestone'] . "')";
                $result_dupmen = sql_query($query_dupmen);
                $id_org = $list_selmenun['idOrg'];
                $id_last = sql_insert_id();
                $array_cor[$id_org] = $id_last;
                $query_lo_par = "INSERT INTO " . $GLOBALS['prefix_lms'] . "_lo_param\n\t\t\t\t(param_name, param_value)\n\t\t\t\tVALUES\n\t\t\t\t('idReference', '" . $id_last . "') ";
                $result_lo_par = sql_query($query_lo_par);
                $id_lo_par = sql_insert_id();
                $query_up_lo = "UPDATE " . $GLOBALS['prefix_lms'] . "_lo_param\n\t\t\t\tSET idParam = '" . $id_lo_par . "'\n\t\t\t\tWHERE id = '" . $id_lo_par . "' ";
                $result_up_lo = sql_query($query_up_lo);
                $query_up_or = "UPDATE " . $GLOBALS['prefix_lms'] . "_organization\n\t\t\t\tSET\tidParam = '" . $id_lo_par . "'\n\t\t\t\tWHERE idOrg = '" . $id_last . "' ";
                $result_up_or = sql_query($query_up_or);
            }
        } else {
            // copy folder
            echo $id_vecchio = $folder->id;
            $query_selmenun = "SELECT * FROM\n\t\t\t" . $GLOBALS['prefix_lms'] . "_organization\n\t\t\tWHERE idCourse = '" . $id_dupcourse . "'\n\t\t\tAND idOrg = '" . $id_vecchio . "' ";
            $result_selmenun = sql_query($query_selmenun);
            $list_selmenun = mysql_fetch_array($result_selmenun);
            $query_dupmen = " INSERT INTO " . $GLOBALS['prefix_lms'] . "_organization\n\t\t\t(idParent, path, lev, title,\n\t\t\tobjectType, idResource, idCategory, idUser, idAuthor,\n\t\t\tversion, difficult, description, language, resource,\n\t\t\tobjective, dateInsert, idCourse, prerequisites, isTerminator,\n\t\t\tidParam, visible, milestone)\n\t\t\tVALUES\n\t\t\t('" . (isset($map_org[$list_selmenun['idParent']]) ? $map_org[$list_selmenun['idParent']] : 0) . "', '" . $list_selmenun['path'] . "', '" . $list_selmenun['lev'] . "', '" . $list_selmenun['title'] . "',\n\t\t\t'" . $list_selmenun['objectType'] . "', '" . $id_nuovo_lo . "', '" . $list_selmenun['idCategory'] . "', '" . $list_selmenun['idUser'] . "', '" . $list_selmenun['idAuthor'] . "',\n\t\t\t'" . $list_selmenun['version'] . "', '" . $list_selmenun['difficult'] . "', '" . $list_selmenun['description'] . "', '" . $list_selmenun['language'] . "', '" . $list_selmenun['resource'] . "',\n\t\t\t'" . $list_selmenun['objective'] . "', '" . $list_selmenun['dateInsert'] . "', '" . $new_course_dup . "', '" . $list_selmenun['prerequisites'] . "', '" . $list_selmenun['isTerminator'] . "',\n\t\t\t'" . $list_selmenun['idParam'] . "', '" . $list_selmenun['visible'] . "', '" . $list_selmenun['milestone'] . "')";
            $result_dupmen = sql_query($query_dupmen);
            $map_org[$id_vecchio] = sql_insert_id();
        }
    }
    $query_cor = "SELECT *\n\tFROM " . $GLOBALS['prefix_lms'] . "_organization\n\tWHERE\n\tidCourse = '" . $new_course_dup . "'\n\tAND prerequisites !='' ";
    $result_cor = sql_query($query_cor);
    while ($list_cor = sql_fetch_array($result_cor)) {
        $id_orgup = $list_cor['prerequisites'];
        $arr_pre = explode(",", $id_orgup);
        for ($i = 0; $i < sizeof($arr_pre); $i++) {
            $arr_pre[$i] = str_replace(intval($arr_pre[$i]), $array_cor[intval($arr_pre[$i])], $arr_pre[$i]);
        }
        $query_updcor = "UPDATE " . $GLOBALS['prefix_lms'] . "_organization\n\t\t\tSET prerequisites = '";
        for ($i = 0; $i < sizeof($arr_pre); $i++) {
            if ($i != 0) {
                $query_updcor .= ",";
            }
            $query_updcor .= $arr_pre[$i];
        }
        $query_updcor .= "' WHERE idOrg = '" . $list_cor['idOrg'] . "' ";
        $result_upcor = sql_query($query_updcor);
    }
    $query_selmenun = "SELECT * FROM\n\t" . $GLOBALS['prefix_lms'] . "_forum\n\tWHERE idCourse = '" . $id_dupcourse . "' ";
    $result_selmenun = sql_query($query_selmenun);
    while ($list_selmenun = sql_fetch_array($result_selmenun)) {
        $query_dupmen = "INSERT INTO\n\t\t" . $GLOBALS['prefix_lms'] . "_forum\n\t\t(idCourse, title, description, locked, sequence, emoticons)\n\t\tVALUES\n\t\t('" . $new_course_dup . "', '" . $list_selmenun['title'] . "', '" . $list_selmenun['description'] . "',\n\t\t'" . $list_selmenun['locked'] . "', '" . $list_selmenun['sequence'] . "', '" . $list_selmenun['emoticons'] . "')";
        $result_dupmen = sql_query($query_dupmen);
    }
    $query_selmenun = "SELECT * FROM\n\t" . $GLOBALS['prefix_lms'] . "_coursereport\n\tWHERE id_course = '" . $id_dupcourse . "' ";
    $sql2 = $query_selmenun;
    $result_selmenun = sql_query($query_selmenun);
    while ($list_selmenun = sql_fetch_array($result_selmenun)) {
        if (!isset($array_organization[$list_selmenun['id_source']]) or $array_organization[$list_selmenun['id_source']] == "") {
            $array_organization[$list_selmenun['id_source']] = 0;
        }
        $query_dupmen = "INSERT INTO\n\t\t" . $GLOBALS['prefix_lms'] . "_coursereport\n\t\t(id_course,title,max_score,required_score,weight,show_to_user,use_for_final,sequence,source_of,id_source)\n\t\tVALUES\n\t\t('" . $new_course_dup . "', '" . $list_selmenun['title'] . "', '" . $list_selmenun['max_score'] . "',\n\t\t'" . $list_selmenun['required_score'] . "', '" . $list_selmenun['weight'] . "', '" . $list_selmenun['show_to_user'] . "', '" . $list_selmenun['use_for_final'] . "', '" . $list_selmenun['sequence'] . "', '" . $list_selmenun['source_of'] . "', '" . $array_organization[$list_selmenun['id_source']] . "')";
        $sql2 = $query_dupmen;
        $result_dupmen = sql_query($query_dupmen);
    }
    $query_selmenun = "SELECT *\n\tFROM " . $GLOBALS['prefix_lms'] . "_htmlfront\n\tWHERE id_course = '" . $id_dupcourse . "' ";
    $result_selmenun = sql_query($query_selmenun);
    while ($list_selmenun = sql_fetch_array($result_selmenun)) {
        $query_dupmen = "INSERT INTO " . $GLOBALS['prefix_lms'] . "_htmlfront\n\t\t(id_course, textof)\n\t\tVALUES\n\t\t('" . $new_course_dup . "', '" . mysql_escape_string($list_selmenun['textof']) . "')";
        $result_dupmen = sql_query($query_dupmen);
    }
    //Util::jump_to('index.php?modname=course&amp;op=course_list&result=ok_course');
    return true;
}
 /**
  * retrive the user statistic in the lms
  */
 function getUserCourseStat($id_user)
 {
     require_once $GLOBALS['where_lms'] . '/lib/lib.course.php';
     $stats = array();
     $c_lang =& DoceboLanguage::CreateInstance('course', 'lms');
     $lang =& DoceboLanguage::createInstance('course', 'lms');
     $id_courses = array();
     $query_course_user = "******" . $GLOBALS['prefix_lms'] . "_courseuser AS cu\r\n\t\t\tJOIN " . $GLOBALS['prefix_lms'] . "_course AS c\r\n\t\tWHERE cu.idCourse = c.idCourse\r\n\t\t\tAND cu.idUser = '******'";
     $re_course_user = sql_query($query_course_user);
     while (list($id_c, $code, $name, $status, $status_user, $date_inscr, $date_first_access, $date_complete) = sql_fetch_row($re_course_user)) {
         $id_courses[] = $id_c;
         $stats[$id_c]['course_name'] = $name;
         $stats[$id_c]['course_code'] = $code;
         $course_status = array(CST_PREPARATION => $c_lang->def('_CST_PREPARATION', 'course', 'lms'), CST_AVAILABLE => $c_lang->def('_CST_AVAILABLE', 'course', 'lms'), CST_EFFECTIVE => $c_lang->def('_CST_CONFIRMED', 'course', 'lms'), CST_CONCLUDED => $c_lang->def('_CST_CONCLUDED', 'course', 'lms'), CST_CANCELLED => $c_lang->def('_CST_CANCELLED', 'course', 'lms'));
         $stats[$id_c]['course_status'] = $course_status[$status];
         $cman = new CourseSubscribe_Manager();
         $arr_status = $cman->getUserStatus();
         $stats[$id_c]['user_status'] = isset($arr_status[$status_user]) ? $arr_status[$status_user] : "";
         $stats[$id_c]['date_inscr'] = $date_inscr;
         $stats[$id_c]['date_first_access'] = $date_first_access;
         $stats[$id_c]['date_complete'] = $date_complete;
         $stats[$id_c]['score_init'] = '';
         $stats[$id_c]['score_final'] = '';
         $stats[$id_c]['access_count'] = '';
         $stats[$id_c]['access_time'] = '';
         $stats[$id_c]['access_last'] = '';
         $stats[$id_c]['point_do'] = '';
     }
     //recover start and final score
     require_once $GLOBALS['where_lms'] . '/lib/lib.orgchart.php';
     $org_man = new OrganizationManagement(false);
     require_once $GLOBALS['where_lms'] . '/lib/lib.coursereport.php';
     $rep_man = new CourseReportManager();
     $score_course = $rep_man->getUserFinalScore(array($id_user));
     $score_start = $org_man->getStartObjectScore(array($id_user), $id_courses);
     $score_final = $org_man->getFinalObjectScore(array($id_user), $id_courses);
     while (list(, $id_c) = each($id_courses)) {
         if (isset($stats[$id_c])) {
             $stats[$id_c]['score_init'] = isset($score_start[$id_c][$id_user]) && $score_start[$id_c][$id_user]['max_score'] ? $score_start[$id_c][$id_user]['score'] . ' / ' . $score_start[$id_c][$id_user]['max_score'] : '';
             $stats[$id_c]['score_final'] = isset($score_final[$id_c][$id_user]) && $score_final[$id_c][$id_user]['max_score'] ? $score_final[$id_c][$id_user]['score'] . ' / ' . $score_final[$id_c][$id_user]['max_score'] : '';
         }
         $point_do = isset($score_course[$id_user][$id_c]) ? $score_course[$id_user][$id_c]['score'] : '';
         $point_max = isset($score_course[$id_user][$id_c]) ? $score_course[$id_user][$id_c]['max_score'] : '';
         $stats[$id_c]['point_do'] = $point_do !== '' ? number_format($point_do, 2) . ' / ' . number_format($point_max, 2) : '';
     }
     $query = "\r\n\t\tSELECT idCourse, COUNT(*), SUM(UNIX_TIMESTAMP(lastTime) - UNIX_TIMESTAMP(enterTime)), MAX(lastTime)\r\n\t\tFROM " . $GLOBALS['prefix_lms'] . "_tracksession\r\n\t\tWHERE idUser = '******'\r\n\t\tGROUP BY idCourse ";
     $re_time = sql_query($query);
     while (list($id_c, $session_num, $time_num, $last_num) = sql_fetch_row($re_time)) {
         if (isset($stats[$id_c])) {
             $stats[$id_c]['access_count'] = $session_num;
             $stats[$id_c]['access_time'] = $time_num;
             $stats[$id_c]['access_last'] = $last_num;
         }
     }
     return $stats;
 }
Example #5
0
 /**
  * Find the idst of the group of a course that represent the level
  * @param 	int 	$id_course 	the id of the course
  *
  * @return 	array	[lv] => idst, [lv] => idst
  */
 function getCourseLevel($id_course, $also_waiting = false)
 {
     require_once _lms_ . '/lib/lib.subscribe.php';
     $subscribe_man = new CourseSubscribe_Manager();
     $map = array();
     $levels = $subscribe_man->getUserLevel();
     //CourseLevel::getLevels();
     $acl_man =& Docebo::user()->getAclManager();
     // find all the group created for this menu custom for permission management
     $arr_groupid = array();
     foreach ($levels as $lv => $name_level) {
         $arr_groupid[$lv] = '/lms/course/' . $id_course . '/subscribed/' . $lv;
     }
     $arr_idst = Docebo::aclm()->getArrGroupST($arr_groupid);
     $map = array();
     $flip = array_flip($arr_groupid);
     foreach ($arr_idst as $groupid => $idst) {
         $lv = $flip[$groupid];
         $map[$lv] = (int) $idst;
     }
     return $map;
 }
Example #6
0
function modstatus()
{
    funAccess('statuser', 'OP');
    require_once _base_ . '/lib/lib.form.php';
    require_once _lms_ . '/lib/lib.subscribe.php';
    $lang =& DoceboLanguage::createInstance('stats', 'lms');
    $out =& $GLOBALS['page'];
    $form = new Form();
    $aclManager =& Docebo::user()->getACLManager();
    $idUser = (int) $_GET['idUser'];
    //$idItem = (int)$_GET['idItem'];
    $user_info = $aclManager->getUser($idUser, FALSE);
    $out->setWorkingZone('content');
    $out->add(getTitleArea($lang->def('_STATUS') . $user_info[ACL_INFO_FIRSTNAME] . ' ' . $user_info[ACL_INFO_LASTNAME], 'stats'));
    $out->add('<div class="std_block">' . getBackUi('index.php?modname=stats&amp;op=statuser&amp;idUser='******'_BACK')));
    $query = "\r\n\tSELECT status\r\n\tFROM " . $GLOBALS['prefix_lms'] . "_courseuser\r\n\tWHERE idUser = '******'\r\n\t\tAND idCourse = '" . (int) $_SESSION['idCourse'] . "'";
    list($status) = sql_fetch_row(sql_query($query));
    $out->add($form->openForm('modstatus', 'index.php?modname=stats&amp;op=upstatus'));
    $out->add($form->getHidden('idUser', 'idUser', $idUser));
    $cs = new CourseSubscribe_Manager();
    $arr_status = $cs->getUserStatus();
    $out->add($form->getDropdown($lang->def('_STATUS'), 'status', 'status', $arr_status, $status));
    $out->add($form->getButton('gofilter', 'gofilter', $lang->def('_SAVE')));
    $out->add($form->closeForm());
    $out->add('</div>');
}
Example #7
0
 public function delUserFromDate($id_user, $id_course, $id_date)
 {
     $this->removeUserFromDate($id_user, $id_date, $id_course);
     if (!$this->controlUserSubscriptions($id_user, $id_course)) {
         require_once _lms_ . '/lib/lib.course.php';
         require_once _lms_ . '/lib/lib.subscribe.php';
         $subscribe_man = new CourseSubscribe_Manager();
         $level = $this->subscribe_man->getUserLeveInCourse($id_user, $id_course);
         $subscribe_man->delUserFromCourse($id_user, $id_course);
         $docebo_course = new DoceboCourse($id_course);
         $level_idst =& $docebo_course->getCourseLevel($id_course);
         $this->acl_man->removeFromGroup($level_idst[$level], $id_user);
         //check if there are overbooked users
         $cinfo = $this->getDateInfo($id_date);
         $overbooking_users = $this->getDateOverbookingUsers($id_date);
         if ($cinfo['overbooking'] > 0 && !empty($overbooking_users)) {
             if ($cinfo['user_subscribed'] - count($overbooking_users) < $cinfo['max_par']) {
                 $this->setFirstOverbookingUser($id_date);
             }
         }
     }
     return true;
 }
 public function isUserSubscribed($id_user, $id_course = false)
 {
     if ($id_course == false) {
         $id_course = $this->id_course;
     }
     $subscribe_man = new CourseSubscribe_Manager();
     return $subscribe_man->controlSubscription($id_user, $id_course);
 }
 public function dupcourse()
 {
     if (!$this->permissions['add']) {
         $output = array('success' => false, 'message' => $this->_getMessage("no permission"));
         echo $this->json->encode($output);
         return;
     }
     //TO DO: make it a sqltransaction if possible
     if (isset($_POST['confirm'])) {
         $id_dupcourse = Get::req('id_course', DOTY_INT, 0);
         $id_orgs = array();
         $array_new_testobject = array();
         // read the old course info
         $query_sel = "SELECT * FROM %lms_course WHERE idCourse = '" . $id_dupcourse . "' ";
         $result_sel = sql_query($query_sel);
         $list_sel = sql_fetch_array($result_sel);
         foreach ($list_sel as $k => $v) {
             $list_sel[$k] = sql_escape_string($v);
         }
         $new_course_dup = 0;
         $new_file_array = array();
         if ($list_sel['imgSponsor'] != '') {
             $new_name_array = explode('_', str_replace('course_sponsor_logo_', '', $list_sel['imgSponsor']));
             $filename = 'course_sponsor_logo_' . mt_rand(0, 100) . '_' . time() . '_' . str_replace('course_sponsor_logo_' . $new_name_array[0] . '_' . $new_name_array[1] . '_', '', $list_sel['imgSponsor']);
             $new_file_array[0]['old'] = $list_sel['imgSponsor'];
             $new_file_array[0]['new'] = $filename;
             $list_sel['imgSponsor'] = $filename;
         }
         if ($list_sel['img_course'] != '') {
             $new_name_array = explode('_', str_replace('course_logo_', '', $list_sel['img_course']));
             $filename = 'course_logo_' . mt_rand(0, 100) . '_' . time() . '_' . str_replace('course_logo_' . $new_name_array[0] . '_' . $new_name_array[1] . '_', '', $list_sel['img_course']);
             $new_file_array[1]['old'] = $list_sel['img_course'];
             $new_file_array[1]['new'] = $filename;
             $list_sel['img_course'] = $filename;
         }
         if ($list_sel['img_material'] != '') {
             $new_name_array = explode('_', str_replace('course_user_material_', '', $list_sel['img_material']));
             $filename = 'course_user_material_' . mt_rand(0, 100) . '_' . time() . '_' . str_replace('course_user_material_' . $new_name_array[0] . '_' . $new_name_array[1] . '_', '', $list_sel['img_material']);
             $new_file_array[2]['old'] = $list_sel['img_material'];
             $new_file_array[2]['new'] = $filename;
             $list_sel['img_material'] = $filename;
         }
         if ($list_sel['img_othermaterial'] != '') {
             $new_name_array = explode('_', str_replace('course_otheruser_material_', '', $list_sel['img_othermaterial']));
             $filename = 'course_otheruser_material_' . mt_rand(0, 100) . '_' . time() . '_' . str_replace('course_otheruser_material_' . $new_name_array[0] . '_' . $new_name_array[1] . '_', '', $list_sel['img_othermaterial']);
             $new_file_array[3]['old'] = $list_sel['img_othermaterial'];
             $new_file_array[3]['new'] = $filename;
             $list_sel['img_othermaterial'] = $filename;
         }
         if ($list_sel['course_demo'] != '') {
             $new_name_array = explode('_', str_replace('course_demo_', '', $list_sel['course_demo']));
             $filename = 'course_demo_' . mt_rand(0, 100) . '_' . time() . '_' . str_replace('course_demo_' . $new_name_array[0] . '_' . $new_name_array[1] . '_', '', $list_sel['course_demo']);
             $new_file_array[4]['old'] = $list_sel['course_demo'];
             $new_file_array[4]['new'] = $filename;
             $list_sel['course_demo'] = $filename;
         }
         // duplicate the entry of learning_course
         $query_ins = "INSERT INTO %lms_course\n\t\t\t\t( idCategory, code, name, description, lang_code, status, level_show_user,\n\t\t\t\tsubscribe_method, linkSponsor, imgSponsor, img_course, img_material, img_othermaterial,\n\t\t\t\tcourse_demo, mediumTime, permCloseLO, userStatusOp, difficult, show_progress, show_time, show_extra_info,\n\t\t\t\tshow_rules, valid_time, max_num_subscribe, min_num_subscribe,\n\t\t\t\tmax_sms_budget, selling, prize, course_type, policy_point, point_to_all, course_edition, classrooms, certificates,\n\t\t\t\tcreate_date, security_code, imported_from_connection, course_quota, used_space, course_vote, allow_overbooking, can_subscribe,\n\t\t\t\tsub_start_date, sub_end_date, advance, show_who_online, direct_play, autoregistration_code, use_logo_in_courselist )\n\t\t\t\tVALUES\n\t\t\t\t( '" . $list_sel['idCategory'] . "', '" . $list_sel['code'] . "', '" . "Copia di " . $list_sel['name'] . "', '" . $list_sel['description'] . "', '" . $list_sel['lang_code'] . "', '" . $list_sel['status'] . "', '" . $list_sel['level_show_user'] . "',\n\t\t\t\t'" . $list_sel['subscribe_method'] . "', '" . $list_sel['linkSponsor'] . "', '" . $list_sel['imgSponsor'] . "', '" . $list_sel['img_course'] . "', '" . $list_sel['img_material'] . "', '" . $list_sel['img_othermaterial'] . "',\n\t\t\t\t'" . $list_sel['course_demo'] . "', '" . $list_sel['mediumTime'] . "', '" . $list_sel['permCloseLO'] . "', '" . $list_sel['userStatusOp'] . "', '" . $list_sel['difficult'] . "', '" . $list_sel['show_progress'] . "', '" . $list_sel['show_time'] . "', '" . $list_sel['show_extra_info'] . "',\n\t\t\t\t'" . $list_sel['show_rules'] . "', '" . $list_sel['valid_time'] . "', '" . $list_sel['max_num_subscribe'] . "', '" . $list_sel['min_num_subscribe'] . "',\n\t\t\t\t'" . $list_sel['max_sms_budget'] . "', '" . $list_sel['selling'] . "', '" . $list_sel['prize'] . "', '" . $list_sel['course_type'] . "', '" . $list_sel['policy_point'] . "', '" . $list_sel['point_to_all'] . "', '" . $list_sel['course_edition'] . "', '" . $list_sel['classrooms'] . "', '" . $list_sel['certificates'] . "',\n\t\t\t\t'" . date('Y-m-d H:i:s') . "', '" . $list_sel['security_code'] . "', '" . $list_sel['imported_from_connection'] . "', '" . $list_sel['course_quota'] . "', '" . $list_sel['used_space'] . "', '" . $list_sel['course_vote'] . "', '" . $list_sel['allow_overbooking'] . "', '" . $list_sel['can_subscribe'] . "',\n\t\t\t\t'" . $list_sel['sub_start_date'] . "', '" . $list_sel['sub_end_date'] . "', '" . $list_sel['advance'] . "', '" . $list_sel['show_who_online'] . "', '" . $list_sel['direct_play'] . "', '" . $list_sel['autoregistration_code'] . "', '" . $list_sel['use_logo_in_courselist'] . "' )";
         $result_ins = sql_query($query_ins);
         if (!$result_ins) {
             ob_clean();
             ob_start();
             echo $this->json->encode(array('success' => false));
             die;
         }
         // the id of the new course created
         $new_id_course = $new_course_dup = sql_insert_id();
         //Create the new course file
         if (isset($_POST['image'])) {
             $path = Get::sett('pathcourse');
             $path = '/appLms/' . Get::sett('pathcourse') . (substr($path, -1) != '/' && substr($path, -1) != '\\' ? '/' : '');
             require_once _base_ . '/lib/lib.upload.php';
             sl_open_fileoperations();
             foreach ($new_file_array as $file_info) {
                 sl_copy($path . $file_info['old'], $path . $file_info['new']);
             }
             sl_close_fileoperations();
         }
         //--- copy menu data -----------------------------------------------------
         // copy the old course menu into the new one
         $query_selmen = "SELECT * FROM %lms_menucourse_main WHERE idCourse = '" . $id_dupcourse . "' ";
         $result_selmen = sql_query($query_selmen);
         while ($list_selmen = sql_fetch_array($result_selmen)) {
             $query_dupmen = "INSERT INTO %lms_menucourse_main " . " (idCourse, sequence, name, image) " . " VALUES " . " ( '" . $new_course_dup . "', '" . $list_selmen['sequence'] . "', '" . $list_selmen['name'] . "', '" . $list_selmen['image'] . "' )";
             $result_dupmen = sql_query($query_dupmen);
             $array_seq[$list_selmen['idMain']] = sql_insert_id();
         }
         $query_insert_list = array();
         $query_selmenun = "SELECT * FROM %lms_menucourse_under WHERE idCourse = '" . $id_dupcourse . "' ";
         $result_selmenun = sql_query($query_selmenun);
         while ($new_org = sql_fetch_array($result_selmenun)) {
             $valore_idn = $new_org['idMain'];
             $_idMain = $array_seq[$valore_idn];
             $query_insert_list[] = "('" . $_idMain . "', '" . $new_course_dup . "', '" . $new_org['sequence'] . "', '" . $new_org['idModule'] . "', '" . $new_org['my_name'] . "')";
         }
         $result_dupmen = true;
         if (!empty($query_insert_list)) {
             $query_dupmen = "INSERT INTO %lms_menucourse_under\n\t\t\t\t\t(idMain, idCourse, sequence, idModule, my_name)\n\t\t\t\t\tVALUES " . implode(",", $query_insert_list);
             $result_dupmen = sql_query($query_dupmen);
         }
         //--- end menu -----------------------------------------------------------
         function &getCourseLevelSt($id_course)
         {
             $map = array();
             $levels = CourseLevel::getLevels();
             // find all the group created for this menu custom for permission management
             foreach ($levels as $lv => $name_level) {
                 $group_info = Docebo::aclm()->getGroup(FALSE, '/lms/course/' . $id_course . '/subscribed/' . $lv);
                 $map[$lv] = $group_info[ACL_INFO_IDST];
             }
             return $map;
         }
         function funAccess($functionname, $mode, $returnValue = false, $custom_mod_name = false)
         {
             return true;
         }
         require_once _lms_ . '/lib/lib.course.php';
         require_once _lms_ . '/lib/lib.manmenu.php';
         require_once _lms_ . '/lib/lib.subscribe.php';
         $docebo_course = new DoceboCourse($id_dupcourse);
         $subscribe_man = new CourseSubscribe_Manager();
         $group_idst =& $docebo_course->createCourseLevel($new_course_dup);
         $group_of_from =& $docebo_course->getCourseLevel($id_dupcourse);
         $perm_form =& createPermForCoursebis($group_of_from, $new_course_dup, $id_dupcourse);
         $levels = $subscribe_man->getUserLevel();
         foreach ($levels as $lv => $name_level) {
             foreach ($perm_form[$lv] as $idrole => $v) {
                 if ($group_idst[$lv] != 0 && $idrole != 0) {
                     Docebo::aclm()->addToRole($idrole, $group_idst[$lv]);
                 }
             }
         }
         if (isset($_POST['certificate'])) {
             // duplicate the certificate assigned
             $query_insert_list = array();
             $query_selmenun = "SELECT * FROM %lms_certificate_course WHERE id_course = '" . $id_dupcourse . "' ";
             $result_selmenun = sql_query($query_selmenun);
             while ($new_org = sql_fetch_assoc($result_selmenun)) {
                 $query_insert_list[] = "('" . $new_org['id_certificate'] . "', '" . $new_course_dup . "', \n\t\t\t\t\t\t'" . $new_org['available_for_status'] . "', '" . $new_org['point_required'] . "' )";
             }
             $result_dupmen = true;
             if (!empty($query_insert_list)) {
                 $query_dupmen = "INSERT INTO %lms_certificate_course\n\t\t\t\t\t\t(id_certificate, id_course, available_for_status, point_required)\n\t\t\t\t\t\tVALUES " . implode(",", $query_insert_list);
                 $result_dupmen = sql_query($query_dupmen);
             }
         }
         require_once _lms_ . '/modules/organization/orglib.php';
         require_once _lms_ . '/lib/lib.param.php';
         require_once _lms_ . '/class.module/track.object.php';
         require_once _lms_ . '/class.module/learning.object.php';
         $nullVal = NULL;
         $id_orgs = array();
         $map_org = array();
         if (isset($_POST['lo'])) {
             $org_map = array();
             $id_orgs = array();
             $prereq_map = array();
             // retrive all the folders and object, the order by grant that folder are created before the elements contained in them
             $query = "SELECT * FROM %lms_organization WHERE idCourse = " . (int) $id_dupcourse . " ORDER BY path ASC";
             $source_res = sql_query($query);
             // Go trough all the entry of learning_organization
             while ($source = sql_fetch_object($source_res)) {
                 // check if LO id is checked
                 if (in_array($source->idOrg, $_POST['lo_list'])) {
                     // if it's an object we must make a copy, if it's a folder we can create a row
                     // inside learning_orgation and save the id for later use
                     if ($source->objectType == '') {
                         // is a folder
                         // create a new row in learning_organization
                         $query_new_org = "INSERT INTO %lms_organization (\n\t\t\t\t\t\t\t\tidParent,\n\t\t\t\t\t\t\t\tpath, lev, title,\n\t\t\t\t\t\t\t\tobjectType, idResource, idCategory, idUser,\n\t\t\t\t\t\t\t\tidAuthor, version, difficult, description,\n\t\t\t\t\t\t\t\tlanguage, resource, objective, dateInsert,\n\t\t\t\t\t\t\t\tidCourse, prerequisites, isTerminator, idParam,\n\t\t\t\t\t\t\t\tvisible, milestone)\n\t\t\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t\t('" . (isset($id_orgs[$source->idParent]) ? $id_orgs[$source->idParent] : 0) . "',\n\t\t\t\t\t\t\t\t'" . $source->path . "', '" . $source->lev . "', '" . sql_escape_string($source->title) . "',\n\t\t\t\t\t\t\t\t'" . $source->objectType . "', '" . $source->idResource . "', '" . $source->idCategory . "', '" . $source->idUser . "',\n\t\t\t\t\t\t\t\t'" . $source->idAuthor . "', '" . $source->version . "', '" . $source->difficult . "', '" . sql_escape_string($source->description) . "',\n\t\t\t\t\t\t\t\t'" . $source->language . "', '" . $source->resource . "', '" . $source->objective . "', '" . $source->dateInsert . "',\n\t\t\t\t\t\t\t\t'" . $new_id_course . "', '" . $source->prerequisites . "', '" . $source->isTerminator . "', '" . $source->idParam . "',\n\t\t\t\t\t\t\t\t'" . $source->visible . "', '" . $source->milestone . "')";
                         $re_new_org = sql_query($query_new_org);
                         $new_id_reference = sql_insert_id();
                         // map for later use
                         $org_map['folder'][$source->idOrg] = $new_id_reference;
                     } else {
                         // is an object
                         // make a copy
                         $lo = $this->_createLO($source->objectType);
                         $new_id_resource = $lo->copy($source->idResource);
                         // create a new row in learning_organization
                         $query_new_org = "INSERT INTO %lms_organization (\n\t\t\t\t\t\t\t\tidParent, path, lev, title,\n\t\t\t\t\t\t\t\tobjectType, idResource, idCategory, idUser,\n\t\t\t\t\t\t\t\tidAuthor, version, difficult, description,\n\t\t\t\t\t\t\t\tlanguage, resource, objective, dateInsert,\n\t\t\t\t\t\t\t\tidCourse, prerequisites, isTerminator, idParam,\n\t\t\t\t\t\t\t\tvisible, milestone)\n\t\t\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t\t('" . (isset($id_orgs[$source->idParent]) ? $id_orgs[$source->idParent] : 0) . "',\n\t\t\t\t\t\t\t\t'" . $source->path . "', '" . $source->lev . "', '" . sql_escape_string($source->title) . "',\n\t\t\t\t\t\t\t\t'" . $source->objectType . "', '" . $new_id_resource . "', '" . $source->idCategory . "', '" . $source->idUser . "',\n\t\t\t\t\t\t\t\t'" . $source->idAuthor . "', '" . $source->version . "', '" . $source->difficult . "', '" . sql_escape_string($source->description) . "',\n\t\t\t\t\t\t\t\t'" . $source->language . "', '" . $source->resource . "', '" . $source->objective . "', '" . $source->dateInsert . "',\n\t\t\t\t\t\t\t\t'" . $new_id_course . "', '" . $source->prerequisites . "', '" . $source->isTerminator . "', '0',\n\t\t\t\t\t\t\t\t'" . $source->visible . "', '" . $source->milestone . "')";
                         $re_new_org = sql_query($query_new_org);
                         $new_id_reference = sql_insert_id();
                         // for a learning_object we have to create a row in lo_param as well
                         // with 4.1 or 4.2 we plan to remove this table, but until then we need this
                         $query_lo_par = "INSERT INTO %lms_lo_param (param_name, param_value) VALUES ('idReference', '" . $new_id_reference . "') ";
                         $result_lo_par = sql_query($query_lo_par);
                         $id_lo_par = sql_insert_id();
                         $query_up_lo = "UPDATE %lms_lo_param SET idParam = '" . $id_lo_par . "' WHERE id = '" . $id_lo_par . "' ";
                         $result_up_lo = sql_query($query_up_lo);
                         $query_up_or = "UPDATE %lms_organization SET idParam = '" . $id_lo_par . "' WHERE idOrg = '" . $new_id_reference . "' ";
                         $result_up_or = sql_query($query_up_or);
                         // map for later use
                         $org_map[$source->objectType][$source->idResource] = $new_id_resource;
                     }
                     // create a map for the olds and new idReferences
                     $id_orgs[$source->idOrg] = $new_id_reference;
                     if ($source->prerequisites != '') {
                         $prereq_map[$new_id_reference] = $source->prerequisites;
                     }
                 }
             }
             // updates prerequisites
             foreach ($prereq_map as $new_id_reference => $old_prerequisites) {
                 $new_prerequisites = array();
                 $old_prerequisites = explode(",", $old_prerequisites);
                 foreach ($old_prerequisites as $old_p) {
                     //a prerequisite can be a pure number or something like 7=NULL, or 7=incomplete
                     $old_id = intval($old_p);
                     if (isset($id_orgs[$old_id])) {
                         $new_prerequisites[] = str_replace($old_id, $id_orgs[$old_id], $old_p);
                     }
                 }
                 if (!empty($new_prerequisites)) {
                     $query_updcor = "UPDATE %lms_organization " . "SET prerequisites = '" . implode(",", $new_prerequisites) . "' " . "WHERE idOrg = " . $new_id_reference . " ";
                     $result_upcor = sql_query($query_updcor);
                 }
             }
             //--- copy forum data --------------------------------------------------
             $query_insert_list = array();
             $query_selmenun = "SELECT * FROM %lms_forum WHERE idCourse = '" . $id_dupcourse . "' ";
             $result_selmenun = sql_query($query_selmenun);
             while ($new_org = sql_fetch_assoc($result_selmenun)) {
                 $query_insert_list[] = "('" . $new_course_dup . "', '" . sql_escape_string($new_org['title']) . "', '" . sql_escape_string($new_org['description']) . "',\n\t\t\t\t\t\t'" . $new_org['locked'] . "', '" . $new_org['sequence'] . "', '" . $new_org['emoticons'] . "')";
             }
             $result_dupmen = true;
             if (!empty($query_insert_list)) {
                 $query_dupmen = "INSERT INTO %lms_forum\n\t\t\t\t\t\t(idCourse, title, description, locked, sequence, emoticons)\n\t\t\t\t\t\tVALUES " . implode(",", $query_insert_list);
                 $result_dupmen = sql_query($query_dupmen);
             }
             //--- end forum --------------------------------------------------------
             //--- copy coursereports data ------------------------------------------
             //create a conversion table for tests and scoitems coursereports
             $array_organization = array('test' => array(), 'scoitem' => array());
             $arr_items_flat = array('test' => array(), 'scoitem' => array());
             $query_org = "SELECT source_of, id_source\n\t\t\t\t\tFROM %lms_coursereport WHERE id_course = '" . $id_dupcourse . "'\n\t\t\t\t\tAND source_of IN ('test', 'scoitem')";
             $res_org = sql_query($query_org);
             while (list($source_of, $id_source) = sql_fetch_row($res_org)) {
                 switch ($source_of) {
                     case 'scoitem':
                         $arr_items_flat['scoitem'][] = $id_source;
                         break;
                 }
             }
             if (!empty($arr_items_flat['scoitem'])) {
                 //retrieve idOrgs of scoitems' scormorgs
                 $arr_old_idorg = array();
                 $arr_old_ident = array();
                 $query = "SELECT o.idOrg, o.idResource, s.idscorm_item, s.item_identifier\n\t\t\t\t\t\tFROM %lms_organization AS o\n\t\t\t\t\t\tJOIN %lms_scorm_items AS s\n\t\t\t\t\t\tON (o.idResource = s.idscorm_organization)\n\t\t\t\t\t\tWHERE s.idscorm_item IN (" . implode(",", $arr_items_flat['scoitem']) . ")\n\t\t\t\t\t\tAND o.objectType = 'scormorg'";
                 $res = sql_query($query);
                 while (list($idOrg, $idResource, $idscorm_item, $item_identifier) = sql_fetch_row($res)) {
                     $arr_old_idorg[] = $idOrg;
                     $arr_old_ident[$idOrg . '/' . $item_identifier] = $idscorm_item;
                 }
                 if (!empty($arr_old_idorg)) {
                     $arr_new_idorg = array();
                     foreach ($arr_old_idorg as $idOrg) {
                         $arr_new_idorg[] = $id_orgs[$idOrg];
                     }
                     $query = "SELECT o.idOrg, o.idResource, s.idscorm_item, s.item_identifier\n\t\t\t\t\t\t\tFROM %lms_organization AS o\n\t\t\t\t\t\t\tJOIN %lms_scorm_items AS s\n\t\t\t\t\t\t\tON (o.idResource = s.idscorm_organization)\n\t\t\t\t\t\t\tWHERE o.idOrg IN (" . implode(",", $arr_new_idorg) . ")\n\t\t\t\t\t\t\tAND o.objectType = 'scormorg'";
                     $res = sql_query($query);
                     $new_to_old = array_flip($id_orgs);
                     while (list($idOrg, $idResource, $idscorm_item, $item_identifier) = sql_fetch_row($res)) {
                         $_key = $new_to_old[$idOrg] . '/' . $item_identifier;
                         if (array_key_exists($_key, $arr_old_ident)) {
                             $_index = $arr_old_ident[$_key];
                             $array_organization['scoitem'][$_index] = $idscorm_item;
                         }
                     }
                 }
             }
             $query_insert_list = array();
             $query_selmenun = "SELECT * FROM %lms_coursereport WHERE id_course = '" . $id_dupcourse . "' ";
             $result_selmenun = sql_query($query_selmenun);
             while ($new_org = sql_fetch_array($result_selmenun)) {
                 $id_source_val = 0;
                 switch ($new_org['source_of']) {
                     case 'test':
                         $id_source_val = !isset($org_map['test'][$new_org['id_source']]) ? 0 : $org_map['test'][$new_org['id_source']];
                         break;
                     case 'scoitem':
                         $id_source_val = !isset($array_organization['scoitem'][$new_org['id_source']]) || $array_organization['scoitem'][$new_org['id_source']] == "" ? 0 : $array_organization['scoitem'][$new_org['id_source']];
                         break;
                 }
                 $query_insert_list[] = "('" . $new_course_dup . "', '" . sql_escape_string($new_org['title']) . "', '" . $new_org['max_score'] . "',\n\t\t\t\t\t\t'" . $new_org['required_score'] . "', '" . $new_org['weight'] . "', '" . $new_org['show_to_user'] . "',\n\t\t\t\t\t\t'" . $new_org['use_for_final'] . "', '" . $new_org['sequence'] . "', '" . $new_org['source_of'] . "',\n\t\t\t\t\t\t'" . $id_source_val . "')";
             }
             $result_dupman = true;
             if (!empty($query_insert_list)) {
                 $query_dupmen = "INSERT INTO %lms_coursereport\n\t\t\t\t\t\t(id_course,title,max_score,required_score,weight,show_to_user,use_for_final,sequence,source_of,id_source)\n\t\t\t\t\t\tVALUES " . implode(",", $query_insert_list);
                 $result_dupmen = sql_query($query_dupmen);
             }
             //--- end coursereports ------------------------------------------------
             //--- copy htmlfront data ----------------------------------------------
             $query_insert_list = array();
             $query_selmenun = "SELECT * FROM %lms_htmlfront WHERE id_course = '" . $id_dupcourse . "' ";
             $result_selmenun = sql_query($query_selmenun);
             while ($new_org = sql_fetch_array($result_selmenun)) {
                 $query_insert_list[] = "('" . $new_course_dup . "', '" . sql_escape_string($new_org['textof']) . "')";
             }
             $result_dupmen = true;
             if (!empty($query_insert_list)) {
                 $query_dupmen = "INSERT INTO %lms_htmlfront\n\t\t\t\t\t\t(id_course, textof)\n\t\t\t\t\t\tVALUES " . implode(",", $query_insert_list);
                 $result_dupmen = sql_query($query_dupmen);
             }
             //--- end htmlfront ----------------------------------------------------
         }
         if (isset($_POST['advice'])) {
             $query = "SELECT * FROM %lms_advice WHERE idCourse = " . (int) $id_dupcourse;
             $result = sql_query($query);
             if (sql_num_rows($result) > 0) {
                 $query_insert_list = array();
                 $array_sub = array();
                 $array_replace = array();
                 foreach ($id_orgs as $id_old_obj => $id_new_obj) {
                     $array_sub[] = 'id_org=' . $id_old_obj;
                     $array_replace[] = 'id_org=' . $id_new_obj;
                     //convert direct links to LOs. TO DO: make sure you are changing only the correct link urls
                     $array_sub[] = 'id_item=' . $id_old_obj;
                     $array_replace[] = 'id_item=' . $id_new_obj;
                 }
                 while ($row = sql_fetch_assoc($result)) {
                     $new_description = !empty($id_orgs) ? str_replace($array_sub, $array_replace, $row['description']) : $row['description'];
                     $query_insert_list[] = "(NULL, " . (int) $new_course_dup . ", '" . $row['posted'] . "', " . (int) $row['author'] . ", '" . $row['title'] . "', '" . $new_description . "', " . (int) $row['important'] . ")";
                 }
                 if (!empty($query_insert_list)) {
                     $query = "INSERT INTO %lms_advice\n\t\t\t\t\t\t\t(idAdvice, idCourse, posted, author, title, description, important)\n\t\t\t\t\t\t\tVALUES " . implode(",", $query_insert_list);
                     sql_query($query);
                 }
             }
         }
         ob_clean();
         echo $this->json->encode(array('success' => true));
     }
 }
 public function fast_subscribe_dialog()
 {
     require_once _lms_ . '/lib/lib.subscribe.php';
     $subscribe_man = new CourseSubscribe_Manager();
     $this->render('fast_subscribe_dialog', array('title' => Lang::t('_SUBSCRIBE', 'subscribe'), 'levels' => $subscribe_man->getUserLevel(), 'selected_level' => 3, 'json' => $this->json));
 }
 public function export_csvTask()
 {
     //check permissions
     if (!$this->permissions['view']) {
         Util::jump_to('index.php?r=coursestats/show');
     }
     require_once _base_ . '/lib/lib.download.php';
     $id_course = isset($_SESSION['idCourse']) && $_SESSION['idCourse'] > 0 ? $_SESSION['idCourse'] : false;
     if ((int) $id_course <= 0) {
         //...
         return;
     }
     $separator = ',';
     $delimiter = '"';
     $line_end = "\r\n";
     $output = "";
     $lo_list = $this->model->getCourseLOs($id_course);
     $lo_total = count($lo_list);
     $head = array();
     $head[] = $this->_formatCsvValue(Lang::t('_USERNAME', 'standard'), $delimiter);
     $head[] = $this->_formatCsvValue(Lang::t('_FULLNAME', 'standard'), $delimiter);
     $head[] = $this->_formatCsvValue(Lang::t('_LEVEL', 'standard'), $delimiter);
     $head[] = $this->_formatCsvValue(Lang::t('_STATUS', 'standard'), $delimiter);
     foreach ($lo_list as $id_lo => $lo_info) {
         $head[] = $this->_formatCsvValue($lo_info->title, $delimiter);
     }
     $head[] = $this->_formatCsvValue(Lang::t('_COMPLETED', 'course'), $delimiter);
     $output .= implode($separator, $head) . $line_end;
     $records = $this->model->getCourseStatsList(false, $id_course, false);
     if (!empty($records)) {
         $acl_man = Docebo::user()->getAclManager();
         require_once _lms_ . '/lib/lib.subscribe.php';
         $cman = new CourseSubscribe_Manager();
         $arr_status = $cman->getUserStatus();
         $arr_level = $cman->getUserLevel();
         if (is_array($records)) {
             foreach ($records as $record) {
                 $row = array();
                 $row[] = $acl_man->relativeId($record->userid);
                 $row[] = $record->firstname . ' ' . $record->lastname;
                 $row[] = isset($arr_level[$record->level]) ? $arr_level[$record->level] : "";
                 $row[] = isset($arr_status[$record->status]) ? $arr_status[$record->status] : "";
                 $num_completed = 0;
                 foreach ($lo_list as $id_lo => $lo_info) {
                     $_lo_status = isset($record->lo_status[$id_lo]) ? $record->lo_status[$id_lo] : "";
                     $row[] = $_lo_status;
                     if ($_lo_status == 'completed' || $_lo_status == 'passed') {
                         $num_completed++;
                     }
                 }
                 $row[] = $num_completed . ' / ' . $lo_total;
                 //format row and produce a string text to add to CSV file
                 $csv_row = array();
                 foreach ($row as $row_data) {
                     $csv_row[] = $this->_formatCsvValue($row_data, $delimiter);
                 }
                 $output .= implode($separator, $csv_row) . $line_end;
             }
         }
     }
     sendStrAsFile($output, 'coursestats_export_' . date("Ymd") . '.csv');
 }